diffsvg.tl.gene_set_test#
- diffsvg.tl.gene_set_test(model_setup, gene_sets, *, summary=('level', 'slope'), method='rotation', n_rotations=9999, min_size=3, random_state=0)#
Test whether the genes of a set change together between the conditions, with slides as replicates.
Every slide contributes one level and one slope per gene (
replicate_summaries), so the slide, not the cell, is the unit of replication.method="rotation"(default) is a self-contained rotation test (Wu et al. 2010, as limma’sroast): per gene a two-sample t, per set their (weighted) mean, compared with random rotations of the slides’ residuals. Rotating all genes together keeps their correlation, so sets of co-regulated genes are not overconfident.method="ulm"runs decoupler’s univariate linear model on the per-gene t values instead (a competitive test; needspip install decoupler).On random splits of the slides of three datasets the rotation test called 1 to 4% of sets at p < 0.05; sets of 10 genes with a 2% level shift were detected in 80% of cases, where single genes were not.
- Parameters:
- model_setup
setup_model’s output for data binned withsample.- gene_sets
{name: [genes]}, or a decoupler network (source,targetand optionallyweightcolumns, e.g.decoupler.op.hallmark()). Signed weights (e.g. PROGENy) make the set statistic a weighted mean, so genes expected to go down count with a negative sign.- summary default:
('level', 'slope') Which per-slide summaries to test:
"level","slope"or both.- method default:
'rotation' "rotation"or"ulm".- n_rotations default:
9999 Rotations for the rotation test; the smallest p-value is
1 / (n_rotations + 1).- min_size default:
3 Sets with fewer genes in the data are skipped.
- random_state default:
0 Seed for the rotations.
- Returns:
pandas.DataFrame One row per set and summary:
size,mean_t(positive: higher, or steeper, in condition 1), and for the rotation testpval_up,pval_down,pval_mixed(genes changing in either direction),pval(two-sided) andpval_adj(Benjamini-Hochberg over the sets of each summary). Formethod="ulm",mean_tis decoupler’s score andpvalits p-value as decoupler returns it (already adjusted across the sets).