Package: gwas-sumstats-tools
GWAS SumStats ToolsA simple toolkit for reading and formatting GWAS sumstats files from the GWAS Catalog.
Built with:PetlPydanticTyperThere are three commands,validate,readandformat.validateis for:Validating a summary statistic file using a dynamically generated schemareadis for:Previewing a data file:no optionsExtracting the field headers:-hExtracting all the metadata:-MExtacting specific field, value pairs from the metada:-m <field name>More functionality is to come...formatis for:Converting a minamally formatted sumstats data file to the standard format. This is not guaranteed to return a valid standard file, because manadatory data fields could be missing in the input. It simply does the following.-sRenamesvariant_id->rsidReorders the fieldsConvertsNAmissing values to#NAIt is memory efficient and will take approx. 30s per 1 million recordsGenerate metadata for a data file:-mRead metadata in from existing file:--meta-in <file>Create metadata from the GWAS Catalog (internal use, requires authenticated API):-gEdit/add the values to the metadata:-ewith--<FIELD>=<VALUE>Requirementspython >= 3.9InstallationLocal installation with pip$pip3installgwas-sumstats-toolsRun with DockerThe following Docker command is the equivalent to runninggwas-ssf.$dockerrun-it-v${PWD}:/applicationebispot/gwas-sumstats-tools:latestJust append any subcommands or arguments e.g.:$dockerrun-it-v${PWD}:/applicationebispot/gwas-sumstats-tools:latestvalidateUsage$gwas-ssf[OPTIONS]COMMAND[ARGS]...Options:--help: Show this message and exit.Commands:validate: Validate a sumstats fileformat: Format a sumstats filegen_meta: generate meta-yaml fileread: Read a sumstats filegwas-ssf validateValidate a sumstats fileUsage:$gwas-ssfvalidate[OPTIONS]FILENAMEArguments:FILENAME: Input sumstats file. Must be TSV (may be gzipped) [required]Options:-e, --errors-out: Output erros to a csv file, .err.csv.gz-z, --p-zero: Force p-values of zero to be allowable. Takes precedence over inferred value (-i)-m, --min-rows:  Minimum rows acceptable for the file [default: 100000]-i, --infer-from-metadata: Infer validation options from the metadata file -meta.yaml. E.g. a populated field for analysis software makes p-values of zero allowable.--help: Show this message and exit.gwas-ssf readRead (preview) a sumstats fileUsage:$gwas-ssfread[OPTIONS]FILENAMEArguments:FILENAME: Input sumstats file  [required]Options:-h, --get-header: Just return the headers of the file  [default: False]--meta-in PATH: Specify a metadata file to read in, defaulting to -meta.yaml-M, --get-all-metadata: Return all metadata  [default: False]-m, --get-metadata TEXT: Get metadata for the specified fields e.g. `-m genomeAssembly -m isHarmonised--help: Show this message and exit.gwas-ssf formatFormat a sumstats file and creating a new one. Add/edit metadata.Usage:$gwas-ssfformat[OPTIONS]FILENAMEArguments:FILENAME: Input sumstats file. Must be TSV or CSV and may be gzipped  [required]Options:-o, --ss-out PATH: Output sumstats file-s, --minimal2standard: Try to convert a valid, minimally formatted file to the standard format.This assumes the file at least hasp_valuecombined with rsid invariant_idfield orchromosomeandbase_pair_location. Validity of the new file is not guaranteed because mandatory data could be missing from the original file.  [default: False]-m, --generate-metadata: Create the metadata file  [default: False]--meta-out PATH: Specify the metadata output file--meta-in PATH: Specify a metadata file to read in-e, --meta-edit: Enable metadata edit mode. Then provide params to edit in the--<FIELD>=<VALUE>format e.g.--GWASID=GCST123456to edit/add that value  [default: False]-g, --meta-gwas: Populate metadata from GWAS Catalog  [default: False]-c, --custom-header-map: Provide a custom header mapping using the--<FROM>:<TO>format e.g.--chr:chromosome[default: False]--help: Show this message and exit.gwas-ssf gen_metaGenerate a meta-yaml file for the existing sumstats file OR edit the existing meta-yaml file.Usage:$gwas-ssfgen_meta[OPTIONS]FILENAMEExample:#Generateameta-yamlfilefromGWASAPI(-g)withcustomisedfields(-e--file_type=pre-gwas-ssf)forGCST90278188.tsvfiles$gwas-ssfgen_meta--meta-outGCST90278188.tsv-meta.yaml-gGCST90278188.tsv-e--file_type=pre-gwas-ssfArguments:FILENAME: Input sumstats file. Must be TSV or CSV and may be gzipped  [required]Options:--meta-out PATH: Specify the metadata output file-g, --meta-gwas: Populate metadata from GWAS Catalog  [default: False]-e, --meta-edit: Enable metadata edit mode. Then provide params to edit in the--<FIELD>=<VALUE>format e.g.--GWASID=GCST123456to edit/add that value  [default: False]--help: Show this message and exit.DevelopmentThis repository usespoetryfor dependency and packaging management.To run the tests:install poetrygit clone https://github.com/EBISPOT/gwas-sumstats-tools.gitcd gwas-sumstats-toolspoetry installpoetry run pytestTo make a change:
branch from master -> PR to master -> poetry version -> git add pyproject.toml -> git commit -> git tag  -> git push origin master --tags
If all the tests pass, this will publish to pypi.