Test neighbourhood-dependent differential expression
Source:R/AllGenerics.R, R/testSpiDE.R
testSpiDE.RdCompletes a spiDE analysis: for each bandwidth, per-gene Wald/Brown inference
is computed (block-wise, in parallel) if not already present; p-values are
combined across bandwidths by a log-likelihood-weighted Cauchy combination;
and a hierarchical (gene -> index cell type -> niche cell type) Benjamini-
Hochberg procedure identifies significant neighbourhood-dependent DE. Results
are returned as a tidy table via results().
Usage
testSpiDE(object, ...)
# S4 method for class 'SpiDEResults'
testSpiDE(
object,
spe = NULL,
assay = "counts",
fdr = 0.05,
weight.thresh = 0.1,
combine = c("cauchy", "brown"),
block.size = NULL,
backend = c("auto", "cpu", "gpu"),
gpu.mem.budget = NULL,
BPPARAM = BiocParallel::SerialParam(),
...
)Arguments
- object
a SpiDEResults from
fitSpiDE().- ...
ignored.
- spe
the SpatialExperiment used for fitting (required to compute the Wald/Brown inference if it is not already present on the fits).
- assay
a character, the counts assay (used only if inference must be computed).
- fdr
a numeric in (0, 1], the target false discovery rate (default 0.05). Up/Down association directions are tested separately and combined, which is mathematically equivalent to gating the reported, combined
fdr.gene/fdr.index/fdr.nichevalues atfdrdirectly - sofdr = 1returns every (gene, index, niche) result, unfiltered.- weight.thresh
a numeric, Cauchy weights below this are set to zero.
- combine
one of "cauchy" or "brown", the within-gene combiner for the correlated niche p-values (gene-level and per-index-cell-type). "cauchy" (default) is the correlation-agnostic Cauchy combination test (ACAT), which controls type-I error under correlation without estimating a correlation matrix; "brown" is the correlation-aware Brown's method. Used only if the Wald inference is not already present on the fits.
- block.size
a numeric, genes per inference block (NULL = a single block on the CPU backend, or a memory-bounded auto-selected size on the GPU backend).
- backend
a character, the compute backend for the inference stage ("auto", "cpu", or "gpu"). The GPU backend batches the per-gene Wald covariance and NB math across each block via
SpaNorm's tensor engine; it also forces a serialBPPARAM(with a warning) to avoid multiple processes contending for one GPU device. Used only if the Wald inference is not already present on the fits.- gpu.mem.budget
a numeric, the GPU memory budget in bytes used to size inference blocks (NULL auto-detects; only relevant for the GPU backend). The batched Wald covariance is bounded separately, by a gene sub-batch sized from this budget on the GPU path and from
getOption("spiDE.cov.mem.budget", 2e9)on the CPU path – raise the latter to trade memory for speed on wide (random-slope) designs.- BPPARAM
a BiocParallelParam for the inference stage.
Examples
data(toySpiDE)
spe <- buildNiches(toySpiDE, sigma = 20)
res <- fitSpiDE(spe, condition = "condition", sigma = 20, verbose = FALSE)
res <- testSpiDE(res, spe = spe)
head(results(res))
#> gene ct_index ct_niche bandwidth.max coef t DirectionGene
#> 1 G1 A B 20 3.173422 4.63951 Up
#> DirectionIndex DirectionNiche fdr.gene fdr.index fdr.niche
#> 1 Up Up 0.0005520939 2.760426e-05 9.201414e-06