addMetaFraction: addMetaFraction

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

addMetaFractionR Documentation

addMetaFraction

Description

Add a new metadata column to a Seurat object, representing the fraction of a gene set in the transcriptome (expressed as a percentage).

Usage

addMetaFraction(
  obj,
  col.name = "percent.mito",
  gene.symbol.pattern = c("^MT\\.|^MT-", FALSE)[1],
  assay = "RNA",
  layer = "data",
  gene.set = FALSE,
  verbose = TRUE
)

Arguments

obj

Seurat object to which the new metadata column will be added. Default: ls.Seurat[1]

col.name

Name of the new metadata column to be added. Default: 'percent.mito'

gene.symbol.pattern

Regular expression pattern to match gene symbols. Default: c("^MT\.|^MT-", FALSE)1

assay

Name of the assay to be used. Default: 'RNA'

layer

Name of the layer to be used. Default: 'data'

gene.set

A set of gene symbols. If specified, it will be used instead of gene.symbol.pattern. Default: FALSE.

verbose

Logical indicating whether to display detailed messages (TRUE) or not (FALSE). Default: TRUE.

See Also

colSums

Examples

## Not run: 
if (interactive()) {
  ls.Seurat[[1]] <- addMetaFraction(col.name = "percent.mito", gene.symbol.pattern = "^MT\\.|^MT-", obj = ls.Seurat[[1]])
  ls.Seurat[[1]] <- addMetaFraction(col.name = "percent.ribo", gene.symbol.pattern = "^RPL|^RPS", obj = ls.Seurat[[1]])
  ls.Seurat[[1]] <- addMetaFraction(col.name = "percent.AC.GenBank", gene.symbol.pattern = "^AC[0-9]{6}\\.", obj = ls.Seurat[[1]])
  ls.Seurat[[1]] <- addMetaFraction(col.name = "percent.AL.EMBL", gene.symbol.pattern = "^AL[0-9]{6}\\.", obj = ls.Seurat[[1]])
  ls.Seurat[[1]] <- addMetaFraction(col.name = "percent.LINC", gene.symbol.pattern = "^LINC0", obj = ls.Seurat[[1]])
  ls.Seurat[[1]] <- addMetaFraction(col.name = "percent.MALAT1", gene.symbol.pattern = "^MALAT1", obj = ls.Seurat[[1]])
  colnames(ls.Seurat[[1]]@meta.data)
  HGA_MarkerGenes <- c(
    "ENO1", "IGFBP2", "WSB1", "DDIT4", "PGK1", "BNIP3", "FAM162A", "TPI1",
    "VEGFA", "PDK1", "PGAM1", "IER2", "FOS", "BTG1", "EPB41L4A-AS1", "NPAS4", "HK2", "BNIP3L",
    "JUN", "ENO2", "GAPDH", "ANKRD37", "ALDOA", "GADD45G", "TXNIP"
  )
  sobj <- addMetaFraction(col.name = "percent.HGA", gene.set = HGA_MarkerGenes, obj = sobj)
}

## End(Not run)

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