Convert genes to symbols

convertGenesToSymbols(object, ...)

convertSymbolsToGenes(object, ...)

# S4 method for GRanges
convertGenesToSymbols(object, strict = FALSE)

# S4 method for Matrix
convertGenesToSymbols(object, gene2symbol, strict = FALSE)

# S4 method for SummarizedExperiment
convertGenesToSymbols(object, strict = FALSE)

# S4 method for character
convertGenesToSymbols(object, gene2symbol, strict = FALSE, quiet = FALSE)

# S4 method for matrix
convertGenesToSymbols(object, gene2symbol, strict = FALSE)

# S4 method for SummarizedExperiment
convertSymbolsToGenes(object)

Arguments

object

Object.

strict

logical(1). Require that all identifiers contain gene name (symbol) metadata stored in the object. Disabled by default, to support objects containing custom gene identifiers, such as FASTA spike-ins.

gene2symbol

Gene2Symbol. Gene-to-symbol mappings. Must contain geneId and geneName columns. See Gene2Symbol for more information.

quiet

logical(1). Perform command quietly, suppressing messages.

...

Additional arguments.

Value

Modified object of same class.

Note

Updated 2021-08-10.

Examples

data(RangedSummarizedExperiment, package = "AcidTest") rse <- RangedSummarizedExperiment object <- rse g2s <- Gene2Symbol(object) print(g2s)
#> Gene2Symbol with 500 rows and 2 columns #> geneId geneName #> <character> <character> #> gene001 ENSG00000000003.15 TSPAN6 #> gene002 ENSG00000000005.6 TNMD #> gene003 ENSG00000000419.12 DPM1 #> gene004 ENSG00000000457.14 SCYL3 #> gene005 ENSG00000000460.17 C1orf112 #> ... ... ... #> gene496 ENSG00000032742.17 IFT88 #> gene497 ENSG00000033011.13 ALG1 #> gene498 ENSG00000033030.15 ZCCHC8 #> gene499 ENSG00000033050.9 ABCF2 #> gene500 ENSG00000033100.16 CHPF2
genes <- head(g2s[["geneId"]]) print(genes)
#> [1] "ENSG00000000003.15" "ENSG00000000005.6" "ENSG00000000419.12" #> [4] "ENSG00000000457.14" "ENSG00000000460.17" "ENSG00000000938.13"
## character ==== x <- convertGenesToSymbols(genes, gene2symbol = g2s) print(x)
#> ENSG00000000003.15 ENSG00000000005.6 ENSG00000000419.12 ENSG00000000457.14 #> "TSPAN6" "TNMD" "DPM1" "SCYL3" #> ENSG00000000460.17 ENSG00000000938.13 #> "C1orf112" "FGR"
## matrix ==== samples <- head(colnames(object)) counts <- matrix( data = seq_len(length(genes) * length(samples)), byrow = TRUE, nrow = length(genes), ncol = length(samples), dimnames = list(genes, samples) ) print(counts)
#> sample01 sample02 sample03 sample04 sample05 sample06 #> ENSG00000000003.15 1 2 3 4 5 6 #> ENSG00000000005.6 7 8 9 10 11 12 #> ENSG00000000419.12 13 14 15 16 17 18 #> ENSG00000000457.14 19 20 21 22 23 24 #> ENSG00000000460.17 25 26 27 28 29 30 #> ENSG00000000938.13 31 32 33 34 35 36
x <- convertGenesToSymbols(counts, gene2symbol = g2s) print(x)
#> sample01 sample02 sample03 sample04 sample05 sample06 #> TSPAN6 1 2 3 4 5 6 #> TNMD 7 8 9 10 11 12 #> DPM1 13 14 15 16 17 18 #> SCYL3 19 20 21 22 23 24 #> C1orf112 25 26 27 28 29 30 #> FGR 31 32 33 34 35 36
## SummarizedExperiment ==== x <- convertGenesToSymbols(rse) print(x)
#> class: RangedSummarizedExperiment #> dim: 500 12 #> metadata(3): version date interestingGroups #> assays(1): counts #> rownames(500): TSPAN6 TNMD ... ABCF2 CHPF2 #> rowData names(9): broadClass description ... geneName seqCoordSystem #> colnames(12): sample01 sample02 ... sample11 sample12 #> colData names(1): condition
## Interconvert back to gene IDs. y <- convertSymbolsToGenes(x) print(y)
#> class: RangedSummarizedExperiment #> dim: 500 12 #> metadata(3): version date interestingGroups #> assays(1): counts #> rownames(500): ENSG00000000003.15 ENSG00000000005.6 ... #> ENSG00000033050.9 ENSG00000033100.16 #> rowData names(9): broadClass description ... geneName seqCoordSystem #> colnames(12): sample01 sample02 ... sample11 sample12 #> colData names(1): condition