Check that user-defined gene input matches expected values

matchesGene2Symbol(x, genes, gene2symbol, .xname = getNameInParent(x))

Arguments

x

Object.

genes

character. Gene identifiers.

gene2symbol

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

.xname

Name of object defined in x. Not intended to be used directly.

Value

TRUE on success; FALSE on failure, with cause set.

Note

Updated 2019-08-11.

Examples

x <- S4Vectors::DataFrame( "sample1" = c(1L, 2L), "sample2" = c(3L, 4L), row.names = c("gene1", "gene2") ) print(x)
#> DataFrame with 2 rows and 2 columns #> sample1 sample2 #> <integer> <integer> #> gene1 1 3 #> gene2 2 4
g2s <- Gene2Symbol( object = S4Vectors::DataFrame( geneID = c("ENSG00000000003", "ENSG00000000005"), geneName = c("TSPAN6", "TNMD"), row.names = rownames(x) ) ) print(g2s)
#> Gene2Symbol with 2 rows and 2 columns #> geneID geneName #> <character> <character> #> gene1 ENSG00000000003 TSPAN6 #> gene2 ENSG00000000005 TNMD
geneIDs <- g2s[["geneID"]] print(geneIDs)
#> [1] "ENSG00000000003" "ENSG00000000005"
geneNames <- g2s[["geneName"]] print(geneNames)
#> [1] "TSPAN6" "TNMD"
matchesGene2Symbol(x = x, genes = geneIDs, gene2symbol = g2s)
#> [1] TRUE
matchesGene2Symbol(x = x, genes = geneNames, gene2symbol = g2s)
#> [1] TRUE