Skip to contents

Annotate features in a Seurat object with additional metadata from databases or a GTF file.

Usage

AnnotateFeatures(
  object,
  species = "Homo_sapiens",
  IDtype = c("symbol", "ensembl_id", "entrez_id"),
  db = NULL,
  db_update = FALSE,
  db_version = "latest",
  convert_species = TRUE,
  Ensembl_version = NULL,
  mirror = NULL,
  gtf = NULL,
  merge_gtf_by = "gene_name",
  columns = c("seqname", "feature", "start", "end", "strand", "gene_id", "gene_name",
    "gene_type"),
  assays = "RNA",
  overwrite = FALSE,
  verbose = TRUE,
  srt = NULL,
  ...
)

Arguments

object

Seurat object to be annotated.

species

"Homo_sapiens" or "Mus_musculus".

IDtype

Type of identifier to use for annotation. Options are "symbol", "ensembl_id", or "entrez_id".

db

Character vector of database or resource selectors: "GO", "GO_BP", "GO_CC", "GO_MF", "KEGG", "WikiPathway", "Reactome", "CORUM", "MP", "DO", "HPO", "PFAM", "Chromosome", "GeneType", "Enzyme", "TF", "CSPA", "Surfaceome", "SPRomeDB", "VerSeDa", "TFLink", "hTFtarget", "TRRUST", "JASPAR", "ENCODE", "MSigDB", "CellTalk", "CellChat", "CytoTRACE2" or "MSigDB_<collection>". A vector may combine sources. See the corresponding preparation function for source-specific settings.

db_update

Force a refresh. FALSE loads the cache when available.

db_version

Database version to retrieve.

convert_species

Use a species-converted database when the annotation is missing for species.

Ensembl_version

Ensembl version. NULL uses the latest.

mirror

URL of the mirror to use for Ensembl database.

gtf

Path to the GTF file to be used for annotation.

merge_gtf_by

Column name to merge the GTF file by.

columns

Vector of column names to be used from the GTF file. Default is "seqname", "feature", "start", "end", "strand", "gene_id", "gene_name", "gene_type".

assays

Character vector of assay names to be annotated.

overwrite

Whether to overwrite existing metadata.

verbose

Whether to print the message. Default is TRUE.

srt

Deprecated alias for object; supply exactly one of the two. It will be removed in scop 1.0.0.

...

Arguments passed to other functions.

See also

Examples

data(pancreas_sub)
pancreas_sub <- AnnotateFeatures(
  pancreas_sub,
  species = "Mus_musculus",
  db = "TF"
)
#> ℹ [2026-11-12 04:57:18] Species: "Mus_musculus"
#> ℹ [2026-11-12 04:57:18] Preparing database: TF
head(
  GetFeaturesData(
    pancreas_sub
  )
)
#>               highly_variable_genes   TF
#> Xkr4                          False <NA>
#> Mrpl15                        False <NA>
#> Npbwr1                         <NA> <NA>
#> 4732440D04Rik                 False <NA>
#> Gm26901                       False <NA>
#> Sntg1                          True <NA>

# Annotate features using a GTF file
gtf_file <- "path/to/genes.gtf"
if (FALSE) { # \dontrun{
pancreas_sub <- AnnotateFeatures(
  pancreas_sub,
  gtf = gtf_file
)
head(
  GetFeaturesData(
    pancreas_sub
  )
)
} # }