Joins data.frames of the SPATA2 objects observations with additional variables, such as molecular data, signatures, and meta features.

joinWithVariables(
  object,
  variables,
  spata_df = getCoordsDf(object),
  smooth = FALSE,
  smooth_span = NULL,
  normalize = NULL,
  uniform_variables = "keep",
  verbose = NULL,
  ...
)

Arguments

object

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

variables

Character vector. The names of the data variables of interest.

smooth

Logical. If TRUE, a loess fit is used to smooth the values.

smooth_span

Numeric value. Controls the degree of smoothing. Given to argument span of stats::loess().

normalize

Logical. If set to TRUE values will be scaled to 0-1.

Hint: Variables that are uniformly expressed can not be scaled and are discarded.

verbose

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

(Warning messages will always be printed.)

...

Used to absorb deprecated arguments or functions.

Value

A data frame containing spatial data joined with additional variables.

Details

This function joins spatial data from spata_df with additional variables specified in 'variables'. It retrieves molecular data, signatures, and meta features from the provided object and adds them to the spatial data frame. Additionally, it can perform smoothing and normalization on numeric variables if desired. The 'uniform' parameter determines how variables with uniform values are handled.

Note

This function replaces the old joinWith(), joinWithGenes(), joinWithFeatures() functions!

See also

Examples

# Join spatial data with molecular and/or meta features

library(SPATA2)

object <- loadExampleObject("UKFT275", process = TRUE, meta = TRUE)

coords_df <- getCoordsDf(object)

joined_data <- joinWithVariables(object, spata_df = coords_df, variables = c("GFAP", "bayes_space", "HM_HYXPOXIA"))