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

Metadata

Release files for CIGMA 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CIGMA 1.1.0
File Size Uploaded Provenance Actions
cigma-1.1.0.tar.gz 92.5 kB Without provenance Details for cigma-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for CIGMA 1.1.0
File Interpreter ABI Platform Actions
cigma-1.1.0-py3-none-any.whl Python 3 none any Details for cigma-1.1.0-py3-none-any.whl

Total release size: 178.5 kB

Release files / cigma-1.1.0.tar.gz

Download URL cigma-1.1.0.tar.gz
Size 92.5 kB
Tags Source
SHA-256 checksum
How to use checksums
543687393628b8eee294f8add5b073e1a5fcd8d28dcb8dfe401ab63a5e89cd82
BLAKE2b-256 checksum
How to use checksums
5eccd8589b5095c20ad07663bed0106f47f165917779e257de699957dcbe8ef8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / cigma-1.1.0-py3-none-any.whl

Download URL cigma-1.1.0-py3-none-any.whl
Size 86.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b2bf3551f6c14b1f3a99193fdbf07baf53197dbb932db44daced2a5602055e5
BLAKE2b-256 checksum
How to use checksums
46556b6806990301fa793efa1289c45373c14edd883818712ac6f07f61204062
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for CIGMA 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

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