Adds new externally generated features to the SPATA2 object's meta data.

addFeatures(
  object,
  feature_df,
  feature_names = NULL,
  key_variable = "barcodes",
  overwrite = FALSE,
  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.

feature_df

A data.frame that contains a variable called barcodes as well as the variables that are to be joined.

feature_names

Character vector or NULL. Determines which feature variables to add. See details for more.

overwrite

Logical value. Must be TRUE to allow overwriting.

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

The updated input object, containing the added, removed or computed results.

Details

If you are only interested in adding specific features to the SPATA2 object you can specify those with the feature_names-argument. If no variables are specified this way all variables found in feature_df for argument feature_df are taken. (Apart from variables called barcodes, sample, x and y).

Eventually the new features are joined via dplyr::left_join() over the key-variables barcodes or x and y. Additional steps secure the joining process.

Examples

library(SPATA2)
library(tidyverse)

data("example_data")

object <- example_data$object_UKF275T_diet

meta_df <- getMetaDf(object)

names(meta_df)

new_meta_df <-
 dplyr::transmute(
   .data = meta_df,
   barcodes = barcodes,
   new_feat = sample(letters[1:5], size = nrow(meta_df), replace = T) %>% as.factor()
   )

object <- addFeatures(object, feature_df = new_meta_df)

plotSurface(object, color_by = "new_feat")