Screens the sample for numeric variables that follow specific expression changes along the course of the spatial trajectory.

spatialTrajectoryScreening(
  object,
  id,
  variables,
  n_bins = NA_integer_,
  binwidth = getCCD(object),
  model_subset = NULL,
  model_remove = NULL,
  model_add = NULL,
  method_padj = "fdr",
  summarize_with = "mean",
  verbose = NULL
)

Arguments

object

An object of class spata2.

id

Character value. Denotes the spatial trajectory of interest.

variables

Character vector. All numeric variables (meaning genes, gene-sets and numeric features) that are supposed to be included in the screening process.

n_bins

Numeric value or vector of length 2. Specifies exactly how many bins are created. (See details for more.)

binwidth

Distance value. The width of the bins to which the barcode-spots are assigned. Defaults to the center-center distance: binwidth = getCCD(object).

model_subset

Character value. Used as a regex to subset models. Use validModelNames() to obtain all model names that are known to SPATA2 and showModels() to visualize them.

model_remove

Character value. Used as a regex to remove models are not supposed to be included.

model_add

Named list. Every slot in the list must be either a formula containing a function that takes a numeric vector as input and returns a numeric vector with the same length as its input vector. Or a numeric vector with the same length as the input vector. Test models with showModels().

method_padj

Character value. The method with which adjusted p-values are calculated. Use validPadjMethods() to obtain all valid input options.

summarize_with

Character value. Either 'mean' or 'median'. Specifies the function with which the bins are summarized.

verbose

Logical. If set to TRUE informative messages regarding the computational progress will be printed.

(Warning messages will always be printed.)

Value

An object of class SpatialTrajectoryScreening. See documentation with ?ImageAnnotationScreening for more information.

Details

How the algorithm works: All barcode-spots that fall into the scope of the trajectory are projected on the trajectory's course. These projection values indicate if a barcode-spot is rather located at the beginning or at the end of the trajectory. Barcode-spots are binned by their projection values.

How many bins area created depends on the input for argument binwidth or n_bins as well as on the length of trajectory. As the length of the trajectory is fixed only one argument of the latter two must be provided. The other one is calculated based on the equation shown below.

n_bins = length_of_trajectory / binwidth

binwidth = length_of_trajectory / n_bins

and for every numeric variable included the mean-expression of each bin is calculated. As the bins can be aligned in an ascending order (ascending in relation to the directory of the trajectory), so can the bin-wise mean expression of each variable. Doing so results in inferred expression changes along the trajectory. Use plotTrajectoryLineplot() to visualize this concept.

The inferred expression changes are fitted against predefined models to find variables whose expression e.g. increases, decreases or peaks over the course of the trajectory. Use showModels() to visualize the inbuilt models.

How good a model fits is evaluated by pearson correlation and the area under the curve of the gene-model-residuals.