diffsvg.tl.check_stability#

diffsvg.tl.check_stability(adata, anchor, condition, grid, baseline=None, genes=50, rank_by=None, higher_is_stronger=True, top_k=10, n_seeds=2, n_workers=1, progressbar=True, random_state=0, design_matrix='design_matrix', sample_kwargs=None, test='parallel', tau=None, sample=None, inference='auto')#

Re-rank genes under every combination in grid and measure how much the ranking moves.

Parameters:
adata

Annotated data matrix, with anchor/condition in adata.obsm[design_matrix]. Never modified: each run bins and fits out-of-place.

anchor

Passed to diffsvg.pp.bin_obs. condition is required - the ranking being checked is the differential one, so the condition-free models are out of scope here.

condition

Passed to diffsvg.pp.bin_obs. condition is required - the ranking being checked is the differential one, so the condition-free models are out of scope here.

design_matrix default: 'design_matrix'

Passed to diffsvg.pp.bin_obs. condition is required - the ranking being checked is the differential one, so the condition-free models are out of scope here.

grid

{parameter: [values]} over any of ("n_bsplines", "degree", "n_bins", "window_radius", "layer") (these re-bin) and ("likelihood", "priors", "use_binned") (these only refit). Priors are varied by passing a list of override dicts, e.g. {"priors": [{"beta": ("normal", 0.0, 0.5)}, {"beta": ("normal", 0.0, 2.0)}]}; see diffsvg.tl.model.DEFAULT_PRIORS.

baseline default: None

The configuration everything is compared against, as a dict of parameter values. Defaults to the first value of each grid axis.

genes default: 50

Number of genes to subsample (default 50), an explicit list, or None for all of them. The same genes are used for every run - a different subsample per run would confound the comparison.

rank_by default: None

Column of fit_model’s statistics table to rank on, and whether larger means stronger. Rank on a statistic rather than a p-value: the Wald test’s p-values are computed against the panel, so subsampling shifts them and they do not compare across runs. Defaults to "parallel_stat" for test="parallel" and "wald_stat" for test="wald".

higher_is_stronger default: True

Column of fit_model’s statistics table to rank on, and whether larger means stronger. Rank on a statistic rather than a p-value: the Wald test’s p-values are computed against the panel, so subsampling shifts them and they do not compare across runs. Defaults to "parallel_stat" for test="parallel" and "wald_stat" for test="wald".

top_k default: 10

Size of the “top genes” set used for the overlap metric.

n_seeds default: 2

How many times to run the baseline, each with a different random_seed, to establish the noise floor. 1 skips it. Ignored when every run uses exact inference: the statistics are then deterministic and the noise floor is 1.

n_workers default: 1

As in fit_model; sample_kwargs is where to make the sweep cheaper (e.g. {"draws": 300, "tune": 300}), since ranking needs far less precision than a final fit. The per-run progress bars are suppressed in favour of one bar over runs.

progressbar default: True

As in fit_model; sample_kwargs is where to make the sweep cheaper (e.g. {"draws": 300, "tune": 300}), since ranking needs far less precision than a final fit. The per-run progress bars are suppressed in favour of one bar over runs.

sample_kwargs default: None

As in fit_model; sample_kwargs is where to make the sweep cheaper (e.g. {"draws": 300, "tune": 300}), since ranking needs far less precision than a final fit. The per-run progress bars are suppressed in favour of one bar over runs.

random_state default: 0

Seed for the gene subsample.

test default: 'parallel'

Which condition test every run uses, as in fit_model.

tau default: None

Which condition test every run uses, as in fit_model.

inference default: 'auto'

Passed to fit_model.

sample default: None

Passed to diffsvg.pp.bin_obs: the replicate column for data with several replicates per condition, so every run uses the model with replicate effects (needs window_radius=None and test="parallel"). Without it, data with replicates is pooled and the rankings are over-confident.

Returns:

StabilityResult