Skip to contents

Performs spatial tests on spatial cytometry data.

Usage

spicy(
  cells,
  condition,
  subject = NULL,
  covariates = NULL,
  from = NULL,
  to = NULL,
  imageIDCol = "imageID",
  cellTypeCol = "cellType",
  spatialCoordCols = c("x", "y"),
  alternateResult = NULL,
  verbose = FALSE,
  weights = TRUE,
  weightsByPair = FALSE,
  weightFactor = 1,
  window = "convex",
  window.length = NULL,
  BPPARAM = BiocParallel::SerialParam(),
  sigma = NULL,
  Rs = NULL,
  minLambda = 0.05,
  edgeCorrect = TRUE,
  includeZeroCells = FALSE,
  ...
)

Arguments

cells

A SummarizedExperiment or data frame that contains at least the variables x and y, giving the location coordinates of each cell, and cellType.

condition

A character specifying which column which contains the condition or `Surv` objects

subject

Vector of subject IDs corresponding to each image if cells is a data frame.

covariates

Vector of covariate names that should be included in the mixed effects model as fixed effects.

from

vector of cell types which you would like to compare to the to vector

to

vector of cell types which you would like to compare to the from vector

imageIDCol

The image ID if using SingleCellExperiment.

cellTypeCol

The cell type if using SingleCellExperiment.

spatialCoordCols

The spatial coordinates if using a SingleCellExperiment.

alternateResult

An pairwise association statistic between each combination of celltypes in each image.

verbose

logical indicating whether to output messages.

weights

logical indicating whether to include weights based on cell counts.

weightsByPair

logical indicating whether weights should be calculated for each cell type pair.

weightFactor

numeric that controls the convexity of the weight function.

window

Should the window around the regions be 'square', 'convex' or 'concave'.

window.length

A tuning parameter for controlling the level of concavity when estimating concave windows.

BPPARAM

A BiocParallelParam object.

sigma

A numeric variable used for scaling when fitting inhomogeneous L-curves.

Rs

A vector of radii that the measures of association should be calculated. If NULL, Rs = c(20, 50, 100) is specified by default.

minLambda

Minimum value for density for scaling when fitting inhomogeneous L-curves.

edgeCorrect

A logical indicating whether to perform edge correction.

includeZeroCells

A logical indicating whether to include cells with zero counts in the pairwise association calculation.

...

Other options.

Value

Data frame of p-values.

Examples

data("diabetesData")

# Test with random effect for patient on a pairwise combination of cell
# types.
spicy(diabetesData,
  condition = "stage", subject = "case",
  from = "Tc", to = "Th"
)
#> 
#> Number of cell type pairs: 1
#> Number of differentially localised cell type pairs: 
#> [1] 0

# Test all pairwise combinations of cell types without random effect of
# patient.
if (FALSE) { # \dontrun{
spicyTest <- spicy(diabetesData, condition = "stage", subject = "case")
} # }

# Test all pairwise combination of cell types with random effect of patient.
if (FALSE) { # \dontrun{
spicy(diabetesData, condition = "condition", subject = "subject")
} # }