testSpiDE

Test niche-dependent differential expression

Description

Always runs the pooled test: for every (gene, index cell type, niche cell type), whether the gene’s expression in the index type changes with the density of the niche type, within patients, consistently across patients. If a condition is given (here, or recorded by fitSpiDE()), it also runs the condition-specific test: whether that slope differs between the two conditions – a between-patient contrast of within-patient slopes.

Usage

testSpiDE(object, condition = NULL, ...)

## S4 method for signature 'SpiDEFit'
testSpiDE(
  object,
  condition = NULL,
  procedure = c("pooled_or_heterogeneity", "heterogeneity", "filtered", "all"),
  fdr = 0.05,
  strata = NULL,
  BPPARAM = BiocParallel::SerialParam(),
  ...
)

Arguments

object a SpiDEFit from fitSpiDE().
condition NULL (use the condition recorded by fitSpiDE(), if any) or a character naming a two-level, patient-level colData column. With the sandwich engine it must be the condition the model was fitted with. The contrast is second level minus first (factor levels, else sorted values).
… unused.
procedure “pooled_or_heterogeneity”, “heterogeneity”, “filtered” or “all”, see Details. The default is “pooled_or_heterogeneity” for the slopes engine and “filtered” for the sandwich engine.
fdr the FDR level of the filter.
strata NULL (the fit’s) or a patient-level column adjusted for in the slopes engine’s condition test (e.g. slide, where the condition is confounded with it).
BPPARAM a BiocParallelParam; the slopes engine’s condition-specific test is run in parallel over genes.

Details

The condition-specific test is carried out within a family of triplets chosen without looking at the condition, so the choice is exact under any relabelling of patients and the multiplicity budget is spent on triplets with something for the condition to explain:

  • procedure = “pooled_or_heterogeneity” (the slopes engine’s default): the triplets that pass either filter below.

  • procedure = “heterogeneity”: the triplets whose slopes vary between patients more than their sampling variances allow (Cochran’s Q across patients, the statistic behind the between-patient variance; Benjamini-Hochberg over every triplet at fdr). A condition effect is such variation, including one whose two conditions’ slopes cancel in the pooled slope. With few patients the pooled test passes little, and this filter carries the condition test.

  • procedure = “filtered” (the sandwich engine’s default, and the slopes engine’s to spiDE 0.99.36): the triplets whose pooled test passes at fdr. It keeps a modest condition difference on a strong pooled slope, which the heterogeneity test, spread over every patient, can miss.

  • procedure = “all”: every triplet.

The heterogeneity filter needs each patient’s slopes, so it is the slopes engine’s only. The calibration vignette has the measurements behind the default.

The slopes engine’s pooled test refers its moderated t statistic to limma’s degrees of freedom scaled by the Kish effective share of the patients (the proportional rule), so a column whose weights rest on a few patients is not credited with the others. To spiDE 0.99.36 the df were the smaller of limma’s df and the Kish effective number of patients less one, which is conservative with few patients.

Value

a SpiDEResults; read it with results().

Examples

library("spiDE")

data(toySpiDE)
spe <- buildNiches(toySpiDE, sigma = 30)
fit <- fitSpiDE(spe, index = "A", sigma = 30)
res <- testSpiDE(fit, condition = "condition", procedure = "all")
res
SpiDEResults (slopes engine)
  pooled across patients: 40 tests, 2 at FDR 0.05
  condition-specific (Responder - Non-responder; all family): 40 tests, 0 at FDR 0.05
head(results(res))