Add a short description here!
Project description
CIGMA
CIGMA is a Python package for decomposing cell type-shared and cell type-specific genetic effects on gene expression (eQTLs). For a full description of the CIGMA model, please refer to the original paper: https://doi.org/??.??????/??????????.
This repository also contains the Snakemake workflows used for data analyses in our paper, including simulations and real-data applications.
Installation
Option 1: Conda environment (recommended)
The conda environment is defined in environment.yml, which includes Python 3.11.5 and all required dependencies:
conda env create -n cigma -f envs/environment.yaml
conda activate cigma
Option 2: pip install
To install only the CIGMA Python package (should complete within seconds):
pip install cigma
Python dependencies are listed in the install_requires section of setup.cfg.
R dependencies (for CIGMA-REML)
Running CIGMA-REML requires the following R packages:
install.packages(c("optparse", "numDeriv", "Matrix"))
Testing
To verify the installation:
python3 -m cigma.tests.test
Quick start
CIGMA provides helper functions to generate model input from scRNA-seq data that have undergone quality control and normalization:
import scanpy as sc
import pandas as pd
from cigma import preprocess, fit
# Read scRNA-seq data in h5ad format.
# The data contains: a gene expression matrix (cells x genes) and cell metadata
# with columns: 'cell' (cell IDs), 'ind' (individual IDs), 'ct' (cell types).
ann = sc.read_h5ad(scRNA_h5ad_file)
# Compute pseudobulk quantities:
# ctp - cell type-pseudobulk matrix (individual-cell type pairs x genes)
# ctnu - cell-to-cell variation matrix (individual-cell type pairs x genes)
# P - cell type proportion matrix (individuals x cell types)
# n - cell count matrix (individuals x cell types)
ctp, ctnu, P, n = preprocess.pseudobulk(
ann=ann, ind_col='ind', ct_col='ct', cell_col='cell'
)
# or
# ctp, ctnu, P, n = preprocess.pseudobulk(
# X=ann.X, obs=ann.obs, var=ann.var, ind_col='ind', ct_col='ct', cell_col='cell'
# )
# Remove genes or cell types to match the requirement of CIGMA that genes are expressed in all cell types.
# For example, keep cell types CT1 and CT2 that all genes are expressed in, and remove other cell types.
ctp = ctp.loc[ctp.index.get_level_values('ct').isin(['CT1', 'CT2'])]
ctnu = ctnu.loc[ctnu.index.get_level_values('ct').isin(['CT1', 'CT2'])]
P = P[['CT1', 'CT2']]
# n = n.loc[:, ['CT1', 'CT2']]
# Optional: scale so overall-pseudobulk has mean 0 and variance 1 across individuals.
_, _, ctp, ctnu = preprocess.std(ctp, ctnu, P)
# Fit a single gene with CIGMA-HE
gene = 'GENE1'
ctp_gene = ctp[gene].unstack().to_numpy()
ctnu_gene = ctnu[gene].unstack().to_numpy()
# Kinship matrix (individuals in same order as ctp/ctnu).
# Can be computed from genotype data using GCTA or PLINK.
K = pd.read_csv(K_file, index_col=0).to_numpy()
out, pvalues = fit.free_HE(ctp_gene, K, ctnu_gene, P)
Input data
See the test script for complete input data examples and usage.
Note
This project has been set up using PyScaffold 4.4. For details and usage information on PyScaffold see https://pyscaffold.org/.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cigma-1.0.6.tar.gz.
File metadata
- Download URL: cigma-1.0.6.tar.gz
- Upload date:
- Size: 89.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
067ce9946eca4e599fee06c1136f8d27c0aff495742be8447216dc5803da4a55
|
|
| MD5 |
dcdfc32bd6c3dd7605a695d9d51bfc11
|
|
| BLAKE2b-256 |
80249261f300caac91f90a1ab9ae71e87adeb6425b5edb681f0eed3b9c88d5e7
|
File details
Details for the file cigma-1.0.6-py3-none-any.whl.
File metadata
- Download URL: cigma-1.0.6-py3-none-any.whl
- Upload date:
- Size: 83.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8c1d152216dba556a7c9a4082de001eecb914a07666b523a40549868502833d
|
|
| MD5 |
eb7ae2c93943cb62a3cdc55ab93ad74f
|
|
| BLAKE2b-256 |
3e01482a8ff93a5a25954bfe7f43e46d794271cd6e31245bc4d731a29c3785e1
|