This function computes various meta features for the specified assay in the SPATA2 object and adds them to the object's metadata.

computeMetaFeatures(
  object,
  assay_name = activeAssay(object),
  overwrite = FALSE
)

Arguments

object

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

assay_name

Only relevant if the SPATA2 object contains more than one assay: Denotes the assay of interest and thus the molecular modality to use. Defaults to the active assay as set by activateAssay().

overwrite

Logical value. Must be TRUE to allow overwriting.

Value

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

Details

This function computes the following meta features for each observation in the specified assay. The computed features are added to the metadata of the SPATA2 object with the following naming conventions:

  • n_counts_<assay_name>: The total number of counts for each observation.

  • n_distinct_<assay_name>: The number of distinct molecules (non-zero entries) for each observation.

  • avg_cpm_<assay_name>: The average counts per molecule for each observation, computed as the total number of counts divided by the number of distinct molecules.

If the overwrite parameter is set to TRUE, existing features with the same names will be overwritten. Otherwise, the function will check for the presence of existing features and will not overwrite them unless explicitly instructed to do so.

Examples


library(SPATA2)

object <- loadExampleObject("UKF269T")

getAssayNames(object)

getMetaDf(object)

object <- computeMetaFeatures(object, asay_name = "gene")

getMetaDf(object)

plotSurface(object, color_by = "n_counts_gene")