Reference#

Everything the package exports, built from the docstrings.

The pipeline#

pace_fit runs all four stages and returns one object. The stages each take a fit and return it with one more layer attached, for when you want to stop partway or re-run a later one with different settings.

pace.pace_fit

Fit PACE and attach every reporting layer.

pace.pace_model

Fit the PACE model, without the reporting layers.

pace.pace_shrink

Shrink the neighbour slopes and attach them to the fit.

pace.pace_decompose

Decompose the variance and attach both tables to the fit.

pace.pace_drivers

Rank each pair's drivers and attach the tables to the fit.

Readouts#

pace.neighbour_slopes

The shrunken slopes, with a local false sign rate per effect.

pace.variance_decomposition

The per-gene variance decomposition.

pace.top_drivers

The per-pair driver tables, or one pair's.

pace.pair_variance

Each neighbour's share of a focal type's spatial variance.

pace.cell_contamination

Per cell: the contamination loading, and the fraction it explains.

pace.anchor_genes

The genes that most mark each cell type, which anchor its contamination.

pace.cell_types

The cell types, in the order they index the random-effect rows.

pace.pace_params

What the fit was run with.

pace.fit_state

The solver's own output: coefficients, errors, dispersions, loadings.

pace.fit_statistics

The per-cell-type statistics, rebuilding the means a gene block at a time.

pace.fitted_means

Rebuild the fitted means for a block of genes.

Figures#

pace.plot_decomposition

Stacked bars of each focal type's variance blocks, as R draws them.

pace.plot_pair_heatmap

The pair heatmap, oriented as R draws it: FOCAL on x, NEIGHBOUR on y.

pace.plot_drivers

The top genes mediating one pair, as R draws them.

pace.plot_proximity

A gene's raw counts against how many of a neighbour type a cell has.

pace.plot_shrinkage

What the shrinkage did: the raw slope against the shrunken one.

Building and inspecting a fit#

pace.build_neighbourhood

The kernel-weighted neighbour abundances, before any fitting.

pace.ambient_field

The sparse cross-cell-type contamination field, in compressed-column form.

pace.stash_pace

Copy a fit's readouts into adata.uns, leaving the solver state behind.

pace.compact_fit

Drop what a saved fit does not need, keeping every readout.

Objects#

pace.PaceFit

A fitted model, with the pieces the readouts need.

pace.FitStatistics

Per-(cell type, gene) summaries of the fitted means.

The numerical core#

Single stages, for anyone who wants one on its own rather than a whole fit.

pace.mash

Canonical multivariate adaptive shrinkage for one slice.

pace.driver_scores

Driver scores for one focal-neighbour pair.

pace.pair_variance_pratt

Pratt attribution of spatial variance across a focal type's neighbours.