API#

Main workflow#

Bin the cells along the distance to the anchor, fit and test every gene, and look at the results.

pp.bin_obs(adata, anchor, condition[, ...])

Assign each cell a bin along anchor, bin every gene's expression, and precompute the spline design matrices diffsvg.tl.setup_model needs.

tl.setup_model(adata[, likelihood, priors])

Configure the per-gene GAM, given adata pre-processed by diffsvg.pp.bin_obs.

tl.fit_model(adata, model_setup[, ...])

Fit every per-gene model from setup_model, in parallel, and summarize the result.

tl.gene_set_test(model_setup, gene_sets, *)

Test whether the genes of a set change together between the conditions, with slides as replicates.

pl.plot_volcano(stats_df[, x, pvalue, ...])

Volcano plot of per-gene curve difference vs. significance.

pl.plot_prediction_curve(adata, gene[, ...])

Plot the predicted expression curve (posterior mean +/- credible band) per gene, for both conditions.

datasets.legnini23([cache_dir])

Neural organoid-like cultures with and without SHH induction (Legnini et al. 2023).

Checking the settings#

tl.check_stability(adata, anchor, condition, ...)

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

pl.plot_stability(result[, kind, metric, ...])

Visualize a diffsvg.tl.check_stability result.

pl.plot_pvalue_histogram(stats_df[, pvalue, ...])

QC histogram of a per-gene p-value column; should look roughly uniform under the null.

Single samples and clustering#

tl.fit_profiles(adata, model_setup[, ...])

Fit the condition-free model for every gene, giving one expression profile per gene.

tl.one_vs_rest(adata, gene[, curves_key, ...])

Compare one gene's expression profile against every other gene's.

tl.cluster_curves(adata[, by, n_clusters, ...])

Group genes by the shape of their fitted curves, with k-means on the spline coefficients.

pl.plot_cluster_curves(adata[, cluster_key, ...])

One curve plot per cluster, with the fitted curve of each gene overlaid in its own colour.

Low-level functions#

The building blocks of the functions above, for custom models and tests.

pp.bin_counts(adata, genes, anchor, category)

Average expression of one or more genes in windows along anchor, per category level.

pp.BinnedData(genes, Y, intercept_initvals, ...)

Output of bin_obs, consumed by diffsvg.tl.setup_model.

pp.build_spline_basis(x, interior_knots[, ...])

Build a (centered, intercept-free) B-spline design matrix for x.

pp.compute_interior_knots(n_bsplines[, degree])

Interior knot positions (plus the 0/1 endpoints) for a B-spline basis on [0, 1].

pp.spline_basis_at(binned, x)

Evaluate the spline basis of binned at new anchor values.

tl.replicate_summaries(model_setup)

Level and slope of every gene in every slide, on the anchor range where the cells are.

tl.parallel_curves_test(beta_1, metric[, ...])

Test whether two condition curves are parallel, up to a shape difference tau.

tl.shape_metric([n_bsplines, degree, ...])

Quadratic form Q that measures how far two condition curves are from parallel.

tl.DiffSVGModelSetup(binned, likelihood[, ...])

Config bundle returned by setup_model and consumed by fit_model.

tl.StabilityResult(stats, ranks, similarity, ...)

What check_stability found; consumed by diffsvg.pl.plot_stability.