External tools tl.external#

Wrappers around external genetics tools. Most of these shell out to a command-line tool that has to be installed separately (e.g. PLINK, MAGMA, LDSC, TensorQTL, SAIGE-QTL) — see each tool’s own documentation for installation instructions.

eQTL mapping (jaxQTL / TensorQTL)#

tl.external.run_jaxqtl(dd[, prefix, out, ...])

Run cis- or trans-eQTL mapping using jaxQTL on donor-level genotype and aggregated expression data.

tl.external.read_jaxqtl_results(prefix)

Read jaxQTL output TSV file.

tl.external.run_tensorqtl(dd[, n_pcs, mode, ...])

Run cis- or trans-QTL mapping using TensorQTL on donor-level aggregated expression and genotype data.

tl.external.read_tensorqtl_results([prefix, ...])

Read TensorQTL result files.

SAIGE-QTL#

tl.external.configure_saigeqtl_runner([...])

tl.external.get_saigeqtl_runner()

tl.external.make_group_file([dd, ...])

Create group file for set-based rare variant tests.

tl.external.run_saigeqtl(dd, gene_col[, ...])

Run eQTL mapping using SAIGE-QTL with flexible step execution.

tl.external.read_saigeqtl_results(prefix[, step])

Read SAIGE-QTL results

MixMIL#

tl.external.run_mixmil(dd[, n_pcs, ...])

Train a MixMIL model on donor-level data with flexible covariate encoding.

LD and principal components#

tl.external.calculate_ld(dd, prefix[, out, ...])

Estimate LD patterns using PLINK.

tl.external.calculate_pcs(dd, prefix[, out, ...])

Run PLINK to calculate genetic PCs using the --pca option.

LD score regression (S-LDSC)#

tl.external.configure_ldsc_runner([...])

tl.external.munge_sumstats(sumstats_file[, ...])

Munge (clean and standardize) GWAS summary statistics for LDSC analysis

tl.external.make_annot_from_bimfile(bimfile, ...)

Create a binary or continuous S-LDSC annotation file from a PLINK bimfile.

tl.external.make_annot_from_donor_data(dd, ...)

Create a binary or continuous S-LDSC annotation file from a DonorData object.

tl.external.estimate_ld_scores_from_bimfile(...)

Estimate LD scores from PLINK bfile (works with any bfile, including 1000G)

tl.external.estimate_ld_scores_from_donor_data(dd)

Estimate LD scores from DonorData object

tl.external.compute_ld_scores_with_annotations_from_bimfile(...)

Compute LD scores with cell-type-specific annotations from PLINK bfile

tl.external.compute_ld_scores_with_annotations_from_donor_data(dd, ...)

Compute LD scores with cell-type-specific annotations from DonorData object

tl.external.estimate_heritability(...[, ...])

Estimate SNP heritability using LD Score regression

tl.external.estimate_celltype_specific_heritability(...)

Estimate cell-type-specific heritability using LD Score regression.

tl.external.estimate_genetic_correlation(...)

Estimate genetic correlation using LD Score regression

tl.external.generate_gene_coord_file(out_path, *)

Generate a gene coordinate file for S-LDSC analysis from Ensembl BioMart.

tl.external.generate_sldsc_genesets(...[, ...])

Generate cell-type-specific gene sets for S-LDSC analysis.

tl.external.get_magma_gene_loc([...])

Download and cache a MAGMA-compatible gene location file from Ensembl BioMart.

tl.external.preprocess_for_sldsc(adata, *, ...)

Preprocess single-cell data for S-LDSC cell-type-specific analysis.

MAGMA#

tl.external.run_magma_pipeline(gwas_sumstats)

Complete MAGMA pipeline: prepare inputs, annotate SNPs, and run gene analysis.

tl.external.run_magma_annotate(snp_loc, ...)

Run MAGMA Step I — annotate SNPs to genes.

tl.external.run_magma_gene_analysis(bfile, ...)

Run MAGMA Step II — gene-level association analysis.

tl.external.run_magma_gsa(gene_results, ...)

Run MAGMA Step III — gene-set analysis (GSA).

tl.external.run_magma_gpa(gene_results, ...)

Run MAGMA Step III — gene property analysis (GPA).

tl.external.genesets_dir_to_entrez_gmt(*[, ...])

tl.external.load_ensembl_to_entrez_map(map_tsv)

Load a mapping TSV with columns: ensembl_gene_id, entrez_id.

tl.external.scores_to_gmt(scores, out_file)

Convert a genes × cell-types score DataFrame to MAGMA GMT format.

tl.external.scores_to_covar(scores, out_file)

Convert a genes × cell-types score DataFrame to a MAGMA gene covariate file.

gsMap#

tl.external.format_gsmap_sumstats(sumstats, ...)

Convert GWAS summary statistics into gsMap-compatible format.

tl.external.load_gsmap_results(workdir, ...)

Load gsMap output files into DataFrames.

sc-linker gene programs and heritability#

tl.external.compute_celltype_programs(adata, ...)

Compute cell-type gene programs by differential expression (one vs rest).

tl.external.compute_diseaseprogression_programs(...)

Compute disease-progression gene programs.

tl.external.compute_nmf_programs(adata, *[, ...])

Compute NMF cellular process programs (single healthy tissue).

tl.external.compute_joint_nmf_programs(...)

Compute joint NMF programs across healthy and disease tissue.

tl.external.JointNMFWrapper(Xh, Xd, *[, ...])

Joint NMF decomposition for paired healthy / disease single-cell data.

tl.external.compute_escore(results_df[, ...])

Compute the E-score: enrichment of a program minus the all-coding control.

tl.external.run_sclinker_heritability(...[, ...])

Run S-LDSC --h2 --overlap-annot for every (program, strategy, trait).

tl.external.compute_ld_scores_for_sclinker(...)

Compute LD scores for all sc-linker annotations.

tl.external.load_sclinker_heritability_results(...)

Parse all S-LDSC .log files from a sc-linker run into a DataFrame.

tl.external.download_sclinker_references([...])

Download sc-linker reference files.

tl.external.download_sclinker_enhancer_links([...])

Download the sc-linker enhancer-gene reference files from GCS.

tl.external.load_roadmap_links(roadmap_file)

Load Roadmap enhancer-gene links from the combined all-tissue file.

tl.external.load_abc_links(abc_file[, tissue])

Load ABC model enhancer-gene predictions from the combined all-tissue file.

tl.external.load_gene_annotation([...])

Load gene TSS/TES coordinates for the 100 kb window S2G strategy.

tl.external.genescores_to_abc_road_bedgraph(...)

Convert gene scores to ABC_Road bedgraphs (Roadmap ∪ ABC strategy).

tl.external.genescores_to_100kb_bedgraph(...)

Convert gene scores to 100kb window bedgraphs.

tl.external.genescores_to_annotations(...[, ...])

Full Step 2: gene scores → bedgraphs → per-chromosome SNP annotations.

tl.external.bedgraph_to_snp_annotation(...)

Convert a bedgraph file to an S-LDSC annotation file (.annot.gz).

tl.external.check_and_patch_ldsc_parse_bug(runner)

Check whether the LDSC installation has the pandas column-sort bug and patch it.

scDRS and seismic (GWAS x single-cell disease relevance)#

tl.external.run_scdrs(adata[, gs_file, ...])

Run scDRS (single-cell disease-relevance score) analysis on AnnData.

tl.external.run_seismic(adata, magma_file, ...)

Run seismic analysis to link cell types with GWAS traits using single-cell data.

tl.external.run_seismic_torch(adata, ...[, ...])

Run the sparse-torch Seismic backend end to end.

tl.external.SparseScore(E)

Compute Seismic cell-type specificity scores from a sparse expression matrix.

tl.external.RegressionNLL(z)

Closed-form univariate regression of GWAS z-scores against a gene-level covariate.

scPRS#

tl.external.prepare_scprs_data(adata, ...[, ...])

Prepare scPRS input data from pre-computed PLINK score files.

tl.external.get_plink_commands_per_cell(...)

Generate the PLINK shell commands for all cells without running them.

tl.external.write_slurm_array_job(adata, ...)

Prepare per-cell GWAS files and write a SLURM array job for the PLINK C+T step.

tl.external.get_disease_relevant_cells(...)

Identify disease-relevant cells from scPRS model weights.

tl.external.run_scprs_pipeline(adata, ...[, ...])

End-to-end scPRS pipeline.

LIVI#

Donor-level representation learning on paired genotype/expression data. See the Tutorial: Donor Effect Decomposition with LIVI using cellink tutorial for a full walkthrough.

tl.external.LIVIRunner(livi_root[, ...])

Manages access to the LIVI package.

tl.external.configure_livi_runner(livi_root)

Configure the global LIVI runner.

tl.external.get_livi_runner()

Return the global LIVIRunner, raising if not configured.

tl.external.train_livi(adata_or_dd, ...[, ...])

Train a LIVI model on single-cell RNA-seq data.

tl.external.infer_livi(adata_or_dd, ...[, ...])

Extract latent factors from a trained LIVI model.

tl.external.run_livi_association_testing(...)

Run genetic association testing on LIVI donor embeddings.

tl.external.save_livi_results(results, ...)

Save infer_livi() results as TSV files.

tl.external.load_livi_results(output_dir[, ...])

Load TSV files written by save_livi_results().

train_livi_annbatch, build_annbatch_collection, read_g_from_dd_store, CisGenotype, LIVICisBatchAdapter and AnnbatchLIVIDataModule provide an annbatch-streamed training path for datasets too large to fit in memory. They require the extra torch, pytorch_lightning and annbatch dependencies.