calculateAverageMetaData: Calculate Average Metadata for Seurat Object

View source: R/Seurat.Utils.Metadata.R

calculateAverageMetaDataR Documentation

Calculate Average Metadata for Seurat Object

Description

Computes specified metrics (e.g., median, mean) for given metadata features across each category defined by an identity column in a Seurat object's metadata. This function allows for flexible metric calculation on specified features, providing insights into the data distribution.

Usage

calculateAverageMetaData(
  obj = combined.obj,
  meta.features = c("nFeature_RNA", "percent.ribo", "percent.mito"),
  ident = GetClusteringRuns()[1],
  metrics = list(median = median, mean = mean),
  verbose = TRUE,
  max.categ = 30
)

Arguments

obj

A Seurat object containing metadata to be analyzed. Defaults to combined.obj.

meta.features

A character vector specifying which metadata features to calculate metrics for. Defaults to c("nFeature_RNA", "percent.ribo", "percent.mito").

ident

The name of the identity column used to group the data before calculating metrics. The default is the second entry from GetNamedClusteringRuns().

metrics

A list of named metrics to calculate for the metadata features, where names are the metric names (e.g., 'median', 'mean') and values are the corresponding functions. Defaults to list('median' = median, 'mean' = mean).

verbose

Logical flag indicating whether to print detailed information about the metrics calculation process. Defaults to TRUE.

max.categ

max number of groups in ident.

Value

A list containing data frames with calculated metrics for each specified metadata feature, grouped by the identity categories. Each data frame corresponds to one of the specified metrics.

Examples

# Assuming `combined.obj` is a Seurat object with relevant metadata columns:
results <- calculateAverageMetaData(
  obj = combined.obj,
  meta.features = c("nFeature_RNA", "nCount_RNA"),
  metrics = list("median" = median, "mean" = mean),
  verbose = TRUE
)
# This will return a list with data frames containing the median and mean
# of "nFeature_RNA" and "percent.ribo" for each category in "ident_column_name".


vertesy/Seurat.utils documentation built on Dec. 4, 2024, 5:20 p.m.