Learn R Programming

scPipeline (version 0.2.0.0)

ConvertGeneIdentifiers: Convert Gene Identifiers in a Seurat Object

Description

This function takes a Seurat object with gene identifiers as row names (e.g., RefSeq, Ensembl, Entrez) and converts those identifiers to gene symbols (or Ensembl Gene IDs) using the biomaRt package. The function can handle various types of gene identifiers and returns a Seurat object with updated row names.

Usage

ConvertGeneIdentifiers(
  seurat_object,
  id_type = "refseq",
  to_id_type = "symbol"
)

Value

A Seurat object with updated gene names (row names) based on the specified conversion.

Arguments

seurat_object

A Seurat object. The row names of the Seurat object's data or assay slot should represent gene identifiers (e.g., RefSeq, Ensembl, or Entrez IDs).

id_type

A string specifying the type of the input gene identifiers. Options are: "refseq", "ensembl", "entrez". Default is "refseq".

to_id_type

A string specifying the type of output gene identifiers. Options are: "symbol", "ensembl". Default is "symbol".

Examples

Run this code
# \donttest{
# Read 10X counts data from matrix.mtx, barcodes.tsv and genes.tsv
library(Seurat)
counts <- Read10X(data.dir = "../inst/extdata", gene.column = 1)

# Create Seurat object without batch correction
seurat_obj <- SeuratPreprocess(counts)
seurat_obj <- SeuratLowDim(seurat_obj)
# Convert RefSeq IDs to gene symbols
seurat_obj_converted <- ConvertGeneIdentifiers(
  seurat_obj,
  id_type = "refseq",
  to_id_type = "symbol"
)
# }

Run the code above in your browser using DataLab