Skip to content

Repository files navigation

ssimpy

ssimpy is a Python command-line tool for detecting statistically significant pairwise somatic co-mutations in cancer genomics data. It implements the SelectSim algorithm, testing both co-occurrence (two genes mutated together more frequently than expected by chance) and mutual exclusivity (two genes mutated together less frequently than expected by chance) using a simulation-based FDR framework.

Features

  • rcRAS simulation engine — generates null GAMs that exactly preserve each gene's observed mutation count
  • TMB-aware penalty — down-weights hypermutated samples to avoid signal dominated by outlier tumors
  • Bidirectional FDR — separately calibrated FDR for co-occurrence and mutual exclusivity
  • Sample class covariates — per-subtype expected mutation matrices (e.g. LUAD vs LUSC)
  • Mutation type covariates — element-wise max of per-type E matrices (e.g. missense + truncating)

Installation

Requires Python ≥ 3.9 and numpy + pandas:

pip install numpy pandas

Clone the repository and run from within the ssimpy/ directory:

git clone https://github.com/CSOgroup/ssimpy.git
cd ssimpy
python ssimpy.py --gam <gam.tsv> [options]

Input files

FileRequiredDescription
GAM (TSV)YesBinary matrix: rows = genes, columns = samples
TMB (TSV)NoPer-sample mutation burden; columns: sample, tmb/mutation, optional class
MAF (TSV)NoMutation Annotation Format file (alternative TMB source, single-GAM mode only)

When the TMB file includes a class column, ssimpy automatically computes separate expected mutation matrices per class.

Usage

Minimal run

python ssimpy.py --gam lung_gam.tsv --output results.tsv

With pre-calculated TMB and sample class covariates

python ssimpy.py \
--gam lung_gam_complete.tsv \
--tmb lung_tmb_complete.tsv \
--N 1000 --seed 42 \
--output results.tsv

Multiple mutation types (missense + truncating)

python ssimpy.py \
--gam lung_gam_missense.tsv lung_gam_truncating.tsv \
--tmb lung_tmb_missense.tsv lung_tmb_truncating.tsv \
--N 1000 --seed 42 \
--output results_multitype.tsv

All GAM files must share identical genes and samples. The combined GAM is their element-wise union; the expected matrix E is the element-wise maximum across per-type E matrices.

Key parameters

ArgumentDefaultDescription
--N1000Number of rcRAS simulations
--min-mut5Minimum mutated samples to retain a gene
--fdr0.1FDR threshold for significance calls
--tau1.0TMB fold-change threshold for penalization
--lam0.3Rate of TMB-based penalization
--filter-pct0.10Fraction of worst simulations to discard
--seedNoneRandom seed for reproducibility
--outputselectsim_results.tsvOutput file path

Output

A TSV file with one row per gene pair, sorted by |nES| descending. Key columns:

ColumnDescription
gene1, gene2Gene pair
n_comutSamples mutated in both genes
nESNormalized effect size (+ co-occurrence, − mutual exclusivity)
directionco-occurrence or mutual_exclusivity
FDREstimated false discovery rate
significantTrue if FDR < threshold

Preparing input files from a MAF

The companion script maf_to_ssimpy.py converts a standard MAF file into the GAM and TMB files required by ssimpy.

Basic usage

python maf_to_ssimpy.py --maf input.maf --prefix cohort --output-dir ./data

This produces cohort_gam.tsv and cohort_tmb.tsv ready to pass to ssimpy.

Separate missense and truncating files

python maf_to_ssimpy.py --maf input.maf --split-by-type --prefix cohort

Produces six files: cohort_gam.tsv, cohort_gam_missense.tsv, cohort_gam_truncating.tsv, and the corresponding TMB files. Pass the per-type GAMs and TMBs to ssimpy with --gam and --tmb to enable mutation-type covariates.

Restrict to a gene list and set mutation thresholds

python maf_to_ssimpy.py \
--maf input.maf \
--gene-list cancer_genes.txt \
--min-samples 2 \
--min-mutations 5 \
--split-by-type \
--prefix cohort

cancer_genes.txt is a plain text file with one gene name per line (lines starting with # are ignored).

MAF converter parameters

ArgumentDefaultDescription
--mafrequiredInput MAF TSV file
--output-dir.Directory for output files
--prefixssimpyFilename prefix for all output files
--split-by-typeoffAlso produce separate missense and truncating GAM/TMB files
--metadataNoneTSV with sample and class columns — adds a class column to all TMB files
--gene-listNoneText file (one gene per line) — restricts the GAM to listed genes only
--min-samples2Minimum number of mutated samples for a gene to be retained
--min-mutations1Minimum total non-synonymous mutations across all samples for a gene to be retained

Note on TMB: sample TMB is computed from all non-silent mutations genome-wide (not limited to the genes retained in the GAM), which is the correct measure of overall mutational activity used by ssimpy's penalty vector.

Mutation type classification

CategoryVariant classifications
Silent (excluded from TMB and GAM)Silent, Synonymous_Mutation
MissenseMissense_Mutation, In_Frame_Del, In_Frame_Ins
TruncatingNonsense_Mutation, Frame_Shift_Del, Frame_Shift_Ins, Splice_Site, Splice_Region, Nonstop_Mutation, Translation_Start_Site
Other non-silentall remaining — counted in TMB and combined GAM, excluded from per-type files

Full pipeline example (MAF → ssimpy results)

# Step 1: convert MAF to ssimpy input files
python maf_to_ssimpy.py \
--maf lung.maf \
--metadata sample_classes.tsv \
--split-by-type \
--min-samples 2 --min-mutations 5 \
--prefix lung --output-dir ./data
# Step 2: run ssimpy with mutation-type and class covariates
python ssimpy.py \
--gam data/lung_gam_missense.tsv data/lung_gam_truncating.tsv \
--tmb data/lung_tmb_missense.tsv data/lung_tmb_truncating.tsv \
--N 1000 --seed 42 \
--output results.tsv

Reference

ssimpy is the Python implementation of the SelectSim methodology. See also:

About

Python implementation of SelectSim: significance testing for somatic co-mutations in cancer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages