cellink.tl.external.scores_to_gmt#
- cellink.tl.external.scores_to_gmt(scores, out_file, top_frac=0.1, ascending=False, gene_map=None, set_name_prefix='', min_genes=1)#
Convert a genes × cell-types score DataFrame to MAGMA GMT format.
Each cell type becomes one gene set containing the top (or bottom)
top_fracfraction of genes ranked by score. This is the Python-API equivalent ofmake_magma_gmt.pyin the combined_pipeline.GMT format:
set_name\\tNA\\tGENE1\\tGENE2\\t...(one line per set).- Parameters:
scores (
DataFrame) – DataFrame with genes as rows and cell types as columns. Index should contain gene identifiers (ENSG IDs or gene symbols).top_frac (
float(default:0.1)) – Fraction of genes to select per cell type (default 0.10 = top 10%).ascending (
bool(default:False)) – IfTrue, select the bottomtop_fracgenes (lowest scores) instead of the top.gene_map (
str|Path|Series|None(default:None)) –Optional mapping from gene symbols to ENSG IDs. Accepts:
strorPath— path to a two-column TSV with headersgene_nameandensg_id.pd.Series— index = gene symbol, values = ENSG ID.
If provided, non-ENSG index entries are translated and rows that still do not look like ENSG IDs after mapping are dropped.
set_name_prefix (
str(default:'')) – String prepended to every set name (e.g."brainscope_scz_seismic_top").min_genes (
int(default:1)) – Minimum number of genes required to write a gene set. Sets with fewer genes are skipped with a warning.
- Return type:
- Returns:
Path Path to the written GMT file.
Examples
>>> from cellink.tl.external import scores_to_gmt, run_magma_gsa >>> gmt = scores_to_gmt(specificity_df, "ExcL23_top10.gmt", set_name_prefix="brainscope_seismic_top") >>> run_magma_gsa(gene_results="scz.genes.raw", set_annot=str(gmt), out_prefix="results/scz_gsa")
See also
genesets_dir_to_entrez_gmtConvert LDSC .GeneSet files → GMT.
scores_to_covarConvert scores to MAGMA gene property covariate file.
run_magma_gsaRun MAGMA gene-set analysis with the GMT.