Uses the stored SpaNorm fit as the full model, fits (or reuses) a nested model without the splines representing biology, and compares them per gene by a likelihood ratio F-test. The statistics are written to var["svg_F"], var["svg_p"] and var["svg_fdr"], the unclamped statistic to var["svg_F_raw"], and the null fit is stored as spanorm_null. When the full fit is polished, the null is polished with the same settings (and the pre-polish null is kept as spanorm_null_unpolished).
Parameters
Name
Type
Description
Default
data
An AnnData or SpatialData on which :func:~spanormpy.spanorm has been run, with the raw counts in X or layer.
required
backend
str
"auto", "cpu" or "gpu", used to fit the null model.
'auto'
verbose
bool
Print progress messages (to stderr, like R’s message).
True
layer
str | None
Counts layer (default X) and, for SpatialData, the table.
None
table_key
str | None
Counts layer (default X) and, for SpatialData, the table.
None
copy
bool
Return a modified copy instead of modifying data in place.
False
random_state
int
Seed of the generator behind the null model’s dispersion subsampling.
0
Returns
Name
Type
Description
None, or with copy=True a modified copy of the same container type.
Examples
Note
The code below runs when the site is built, on a small pre-fitted subset of HumanDLPFC (301 genes x 4015 spots; spanorm(sample_p=0.05, df_tps=2), spanorm_svg() and spanorm_pca() already applied) that is fitted once per build and loaded as adata. The outputs are those of the code shown.
import spanormpy as sn# adata: the HumanDLPFC AnnData (raw counts in X, coordinates in obsm["spatial"]),# already fitted with sn.spanorm(adata, sample_p=0.05, df_tps=2)sn.spanorm_svg(adata)adata.var.filter(like="svg_").head()