A collection of handy tools for GWAS SumStats
Project description
GWASLab
- A handy Python toolkit for handling GWAS summary statistics (sumstats).
- Each process is modularized and can be customized to your needs.
- Sumstats-specific manipulations are designed as methods of a Python object,
gwaslab.Sumstats
.
Please check GWASLab documentation at https://cloufield.github.io/gwaslab/
Note: GWASLab is being updated very frequently for now. I will release the first stable version soon! Please stay tuned.
Warning: Known issues of GWASLab are summarized in https://cloufield.github.io/gwaslab/KnownIssues/ .
Install
install via pip
pip install gwaslab==3.4.41
import gwaslab as gl
# load plink2 output
mysumstats = gl.Sumstats("t2d_bbj.txt.gz", fmt="plink2")
# load sumstats with auto mode (auto-detecting common headers)
# assuming ALT/A1 is EA, and frq is EAF
mysumstats = gl.Sumstats("t2d_bbj.txt.gz", fmt="auto")
# or you can specify the columns:
mysumstats = gl.Sumstats("t2d_bbj.txt.gz",
snpid="SNP",
chrom="CHR",
pos="POS",
ea="ALT",
nea="REF",
neaf="Frq",
beta="BETA",
se="SE",
p="P",
direction="Dir",
n="N",
build="19")
# manhattan and qq plot
mysumstats.plot_mqq()
...
install in conda environment
Create a Python 3.9 environment and install gwaslab using pip:
conda env create -n gwaslab_test -c conda-forge python=3.9
conda activate gwaslab
pip install gwaslab==3.4.41
or create a new environment using yml file environment_3.4.40.yml
conda env create -n gwaslab -f environment_3.4.40.yml
install using docker
A docker file is available here for building local images.
Functions
Loading and Formatting
- Loading sumstats by simply specifying the software name or format name, or specifying each column name.
- Converting GWAS sumstats to specific formats:
- LDSC / MAGMA / METAL / PLINK / SAIGE / REGENIE / MR-MEGA / GWAS-SSF / FUMA / GWAS-VCF / BED...
- check available formats
- Optional filtering of variants in commonly used genomic regions: Hapmap3 SNPs / High-LD regions / MHC region
Standardization & Normalization
- Variant ID standardization
- CHR and POS notation standardization
- Variant POS and allele normalization
- Genome build : Inference and Liftover
Quality control, Value conversion & Filtering
- Statistics sanity check
- Extreme value removal
- Equivalent statistics conversion
- BETA/SE , OR/OR_95L/OR_95U
- P, Z, CHISQ, MLOG10P
- Customizable value filtering
Harmonization
- rsID assignment based on CHR, POS, and REF/ALT
- CHR POS assignment based on rsID using a reference text file
- Palindromic SNPs and indels strand inference using a reference VCF
- Check allele frequency discrepancy using a reference VCF
- Reference allele alignment using a reference genome sequence FASTA file
Visualization
- Mqq plot: Manhattan plot, QQ plot or MQQ plot (with a bunch of customizable features including auto-annotate nearest gene names)
- Miami plot: mirrored Manhattan plot
- Brisbane plot: GWAS hits density plot
- Regional plot: GWAS regional plot
- Genetic correlation heatmap: ldsc-rg genetic correlation matrix
- Scatter plot: variant effect size comparison
- Scatter plot: allele frequency comparison
- Scatter plot: trumpet plot (plot of MAF and effect size with power lines)
Visualization Examples
Other Utilities
- Read ldsc h2 or rg outputs directly as DataFrames (auto-parsing).
- Extract lead variants given a sliding window size.
- Extract novel loci given a list of known lead variants / or known loci obtained from GWAS Catalog.
- Logging: keep a complete record of manipulations applied to the sumstats.
- Sumstats summary: give you a quick overview of the sumstats.
- ...
Requirements (deprecated)
environment.yml
name: gwaslab
channels:
- conda-forge
- defaults
dependencies:
- python=3.8.16=h7a1cb2a_3
- jupyter==1.0.0
- pip==23.1.2
- pip:
- adjusttext==0.8
- biopython==1.81
- gwaslab==3.4.16
- liftover==1.1.16
- matplotlib==3.7.1
- numpy==1.24.2
- pandas==1.4.4
- scikit-allel==1.3.5
- scikit-learn==1.2.2
- scipy==1.10.1
- seaborn==0.11.2
- statsmodels==0.13
- adjustText==0.8
- pysam==0.19
- pyensembl==2.2.3
- h5py==3.10.0
How to cite
- GWASLab preprint: He, Y., Koido, M., Shimmori, Y., Kamatani, Y. (2023). GWASLab: a Python package for processing and visualizing GWAS summary statistics. Preprint at Jxiv, 2023-5. https://doi.org/10.51094/jxiv.370
Sample Data
- Sample GWAS data used in GWASLab is obtained from: http://jenger.riken.jp/ (Suzuki, Ken, et al. "Identification of 28 new susceptibility loci for type 2 diabetes in the Japanese population." Nature genetics 51.3 (2019): 379-386.).
Acknowledgement
Thanks to @sup3rgiu, @soumickmj and @gmauro for their contributions to the source codes.
Contacts
- Github: https://github.com/Cloufield/gwaslab
- Blog (in Chinese): https://gwaslab.com/
- Email: gwaslab@gmail.com
- Stats: https://pypistats.org/packages/gwaslab
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gwaslab-3.4.43.tar.gz
.
File metadata
- Download URL: gwaslab-3.4.43.tar.gz
- Upload date:
- Size: 20.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdeb25533a77610bd35ff15ba8221979f72aef43afb31d7f1c3f97c97f810981 |
|
MD5 | b79fe928c09372380d7a3cfa2b8af0ac |
|
BLAKE2b-256 | 1a7aa26df5bf9fd4e460eaf41dd8a1124984c9a0c73d4f513598516a66cd5843 |
File details
Details for the file gwaslab-3.4.43-py3-none-any.whl
.
File metadata
- Download URL: gwaslab-3.4.43-py3-none-any.whl
- Upload date:
- Size: 20.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 050eb3c2b840e3e0a7290a903bae798022dbdd3af33a191054fa16a4e064b37f |
|
MD5 | d3e785cdd2c8c6e9e4ecaf25f5805217 |
|
BLAKE2b-256 | 1dfd128db70801c36f2e5f698502a0fc9a77ac9aac5a24e0f2f96620f6029c6a |