addFeatures: Add a new feature

View source: R/add.R

addFeaturesR Documentation

Add a new feature

Description

Adds new externally generated variables to the spata-object's feature data to make them available for all SPATA-intern functions.

Usage

addFeatures(
  object,
  feature_df,
  feature_names = NULL,
  key_variable = "barcodes",
  overwrite = FALSE,
  of_sample = NA
)

Arguments

object

A valid spata-object.

feature_df

A data.frame that contains the key variables as well as the informative variables that are to be joined.

feature_names

Character vector or NULL. See details for more.

key_variable

Character value. Either 'barcodes' or 'coordinates'. If set to 'coordinates' the feature_df-input must contain numeric x- and y- variables.

Key variables are variables in a data.frame that uniquely identify each observation - in this case each barcode-spot. In SPATA the barcode-variable is a key-variable on its own, x- and y-coordinates work as key-variables if they are used combined.

overwrite

Logical. If the specified feature names already exist in the current spata-object this argument must be set to TRUE in order to overwrite them.

of_sample

This argument is currently inactive. It might be reactivated when spata-objects can store more than one sample.

Details

If you are only interested in adding specific features to the spata-object you can specify those with the feature_names-argument. If no variables are specified this way all variables found in the input data.frame 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.

Value

The input spata2 object containing the added or computed results.

Examples

#Not run:

mncl_clusters <- findMonocleClusters(object = spata_obj)

spata_obj <- addFeatures(object = spata_obj,
                         feature_names = NULL, # add all variables...
                         feature_df = mncl_clusters # ... from the data.frame 'mncl_clusters'
                         )

getGroupingOptions(object = spata_obj)

kueckelj/SPATA2 documentation built on March 16, 2024, 10:25 a.m.