renameSmallCategories: Rename Small Categories in Seurat Object Metadata

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

renameSmallCategoriesR Documentation

Rename Small Categories in Seurat Object Metadata

Description

This function renames categories within a specified identity column of a Seurat object's metadata that have fewer cells than a specified minimum threshold. Categories below this threshold are renamed to a common name, typically "unclear", to clean up small, potentially noisy categories.

Usage

renameSmallCategories(
  obj,
  idents = c("predicted.class", "predicted.cluster", "predicted.subclass"),
  min.cells = max(round((ncol(obj))/2000), 10),
  new.name = "unclear"
)

Arguments

obj

A Seurat object containing the metadata with categories to be cleaned.

idents

A character vector specifying the names of the identity columns within obj@meta.data where categories are to be renamed.

min.cells

An integer specifying the minimum number of cells a category must have to retain its original name. Categories with fewer cells than this threshold will be renamed. Defaults to the greater of the total number of columns divided by 2000 or 10.

new.name

A character string specifying the new name to assign to small categories. Defaults to "unclear".

Value

Returns the Seurat object with renamed categories in the specified metadata columns.

Examples

# Assuming obj is a Seurat object with identity columns "ident1" and "ident2":
idents <- c("ident1", "ident2")
obj <- renameSmallCategories(obj, idents = idents)


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