simulate_expression_pattern_sas: Expression pattern simulation

simulate_expression_pattern_sasR Documentation

Expression pattern simulation

Description

Simulates expression patterns by modelling expression dependent on the distance to a spatial annotation.

Usage

simulate_expression_pattern_sas(
  object,
  ids,
  simulations,
  core,
  distance = "dte",
  resolution = recSgsRes(object),
  angle_span = c(0, 360),
  noise_levels = seq(0, 100, length.out = 21),
  noise_types = c("ed", "ep", "fp", "cb"),
  range_sim = c(0, 1),
  range_random = base::range(range_sim),
  model_add = NULL,
  model_remove = NULL,
  seed = 123,
  npref = "SE",
  nsep = ".",
  verbose = TRUE
)

simulate_expression_pattern_sts(
  object,
  id,
  simulations,
  width,
  resolution = recSgsRes(object),
  noise_levels = seq(0, 100, length.out = 21),
  noise_types = c("ed", "ep", "fp", "cb"),
  range_sim = c(0, 1),
  range_random = base::range(range_sim),
  model_add = NULL,
  seed = 123,
  npref = "SE",
  nsep = ".",
  verbose = TRUE
)

simulate_random_expression(
  object,
  n_total,
  range_sim = c(0, 1),
  seed = 123,
  naming = "SE.RANDOM.{i}",
  verbose = TRUE
)

Arguments

object

An object of class SPATA2 or, in case of S4 generics, objects of classes for which a method has been defined.

ids

Character vector. Specifies the IDs of the spatial annotations of interest.

simulations

A list of simulation lists. A simulations list is a list that contains at least three slots that provide instructions for a set of simulations:

  • id Character value. The overall ID of the simulation.

  • n Integer. The number of simulations.

  • model Character value. The name of the model based on which you want to simulate the expression.

A simulation list can have an additional slot called noise_levels which, if present, overwrites the input for noise_levels for the specific simulation.

distance

Distance measure. Specifies the distance from the border of the spatial annotation to the horizon in the periphery up to which the screening is conducted. Defaults to a distance that covers the whole tissue section the spatial annotation is located on using distToEdge(). (This distance must not be exceeded.)

resolution

Distance measure. The resolution with which the expression gradient is inferred. Defaults are platform specific. See more in detail section of recSgsRes().

angle_span

Numeric vector of length 2. Confines the area screened by an angle span relative to the center of its closest spatial annotation.

noise_levels

A vector of integers between 0-100 (inclusive). Indicate the respective levels of noise to be added to each simulation in percent. 0 indicates no noise. 100 indicates only noise.

range_sim

The range of the output simulation values.

range_random

The range of the values randomly assigned to areas outside of the area of interest.

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().

model_remove

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

seed

Numeric value, given to set.seed().

npref

Prefix for the simulations. Defaults to SG (simulated gene.)

nsep

Character value with which to separate the aspects that build the name of each simulation.

verbose

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

(Warning messages will always be printed.)

Details

Simulation names are created according to the function call stringr::str_c(npref, nsep, "NP", nl, nsep, sim_id, nsep, n, sep = ""). Where nl is the noise level of the simulation, sim_id corresponds to the slot id of the simulation list and n is the index of the simulation in case slot n of the simulation instruction is bigger than one.

Value

Matrix with rownames corresponding to the simulation names and colnames corresponding to the barcodes of the object.


theMILOlab/SPATA2 documentation built on Feb. 8, 2025, 11:41 p.m.