Skip to main content
Project generated with PyScaffold

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.

This repository also contains the Snakemake workflows used for data analyses in our paper, including simulations and real-data applications.

Installation

Option 2: pip install

To install only the CIGMA Python package (should complete within seconds; have tested on Python 3.11 - 3.14):

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, CT2, and CT3 that all genes are expressed in, and remove other cell types.
ctp = ctp.loc[ctp.index.get_level_values('ct').isin(['CT1', 'CT2', 'CT3'])]
ctnu = ctnu.loc[ctnu.index.get_level_values('ct').isin(['CT1', 'CT2', 'CT3'])]
P = P[['CT1', 'CT2', 'CT3']]
# n = n.loc[:, ['CT1', 'CT2', 'CT3']]

# 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/.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cigma-1.1.0.tar.gz (92.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cigma-1.1.0-py3-none-any.whl (86.0 kB view details)

Uploaded Python 3

File details

Details for the file cigma-1.1.0.tar.gz.

File metadata

  • Download URL: cigma-1.1.0.tar.gz
  • Upload date:
  • Size: 92.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for cigma-1.1.0.tar.gz
Algorithm Hash digest
SHA256 543687393628b8eee294f8add5b073e1a5fcd8d28dcb8dfe401ab63a5e89cd82
MD5 287bc06ae345b59fbf5288495323c8fb
BLAKE2b-256 5eccd8589b5095c20ad07663bed0106f47f165917779e257de699957dcbe8ef8

See more details on using hashes here.

File details

Details for the file cigma-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: cigma-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 86.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for cigma-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b2bf3551f6c14b1f3a99193fdbf07baf53197dbb932db44daced2a5602055e5
MD5 d64f7756395d1400f8f35791c99551e0
BLAKE2b-256 46556b6806990301fa793efa1289c45373c14edd883818712ac6f07f61204062

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.6

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page