top_svgs

top_svgs(data, n=10, fdr=1.0, layer=None, table_key=None)

The top SVGs from :func:spanorm_svg (R topSVGs).

Parameters

Name Type Description Default
data An AnnData or SpatialData carrying SVG results. required
n int Maximum number of genes returned. 10
fdr float False discovery rate threshold in [0, 1]; genes with svg_fdr <= fdr are kept. 1.0
layer str | None Counts layer (default X). Like R’s checkSPE, the counts are validated; the SVG columns are the only other thing checked. None
table_key str | None The table to read, for SpatialData. None

Returns

Name Type Description
A frame with columns svg_F, svg_p and svg_fdr, indexed by gene name and sorted
by FDR (ties in gene order). A gene whose FDR is NaN is kept, with all-NaN statistics, after
the sorted finite rows and counted toward n, as R's results\[svg.fdr <= fdr, \] keeps
one all-NA row per NaN (R names them NA, NA.1, …; here they keep the gene name).

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)
# adata: also holds spatially variable gene results from sn.spanorm_svg(adata)
sn.top_svgs(adata, n=10)
svg_F svg_p svg_fdr
SCGB2A2 1096.013695 0.000000e+00 0.000000e+00
MBP 447.108924 4.683545e-319 7.048735e-317
PLP1 240.430765 2.526428e-185 2.534849e-183
GFAP 220.641223 2.223948e-171 1.673521e-169
MT-ND3 149.724084 1.629786e-119 9.811313e-118
MT-CO2 117.581734 5.689124e-95 2.854044e-93
MALAT1 115.023992 5.459574e-93 2.347617e-91
MT-ATP6 100.151055 2.235906e-81 8.412597e-80
TUBA1B 94.125105 1.249232e-76 4.177987e-75
TMSB10 88.267687 5.427387e-72 1.633643e-70