Learn R Programming

Seurat (version 5.0.3)

PercentageFeatureSet: Calculate the percentage of all counts that belong to a given set of features

Description

This function enables you to easily calculate the percentage of all the counts belonging to a subset of the possible features for each cell. This is useful when trying to compute the percentage of transcripts that map to mitochondrial genes for example. The calculation here is simply the column sum of the matrix present in the counts slot for features belonging to the set divided by the column sum for all features times 100.

Usage

PercentageFeatureSet(
  object,
  pattern = NULL,
  features = NULL,
  col.name = NULL,
  assay = NULL
)

Value

Returns a vector with the proportion of the feature set or if md.name is set, returns a Seurat object with the proportion of the feature set stored in metadata.

Arguments

object

A Seurat object

pattern

A regex pattern to match features against

features

A defined feature set. If features provided, will ignore the pattern matching

col.name

Name in meta.data column to assign. If this is not null, returns a Seurat object with the proportion of the feature set stored in metadata.

assay

Assay to use

Examples

Run this code
data("pbmc_small")
# Calculate the proportion of transcripts mapping to mitochondrial genes
# NOTE: The pattern provided works for human gene names. You may need to adjust depending on your
# system of interest
pbmc_small[["percent.mt"]] <- PercentageFeatureSet(object = pbmc_small, pattern = "^MT-")

Run the code above in your browser using DataLab