Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added keyoutput parameter to setReadable and modified EXTID2NAME func… #66

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions R/setReadable.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
##' mapping geneID to gene Symbol
##' mapping geneID to gene Symbol:
##'
##'
##' @title setReadable
##' @param x enrichResult Object
##' @param OrgDb OrgDb
##' @param keyType keyType of gene
##' @param keyType keyType of symbol/gene name
##' @return enrichResult Object
##' @author Yu Guangchuang
##' @export
setReadable <- function(x, OrgDb, keyType="auto") {

# Added keyoutput = 'SYMBOL' as an optional parameter so it accepts other OrgDB columns as output
setReadable <- function(x, OrgDb, keyType="auto", keyoutput = 'SYMBOL') {
OrgDb <- load_OrgDb(OrgDb)
if (!'SYMBOL' %in% columns(OrgDb)) {
warning("Fail to convert input geneID to SYMBOL since no SYMBOL information available in the provided OrgDb...")
if (! keyoutput %in% columns(OrgDb)) {
warning(paste0("Fail to convert input geneID to SYMBOL since no ", keyoutput ," information available in the provided OrgDb..."))
}

if (!(is(x, "enrichResult") || is(x, "groupGOResult") || is(x, "gseaResult") || is(x,"compareClusterResult")))
Expand Down Expand Up @@ -50,7 +53,8 @@ setReadable <- function(x, OrgDb, keyType="auto") {
genes <- x@gene
}

gn <- EXTID2NAME(OrgDb, genes, keyType)
# Added keyoutput as an additional parameter in EXTID2NAME function.
gn <- EXTID2NAME(OrgDb, genes, keyType, keyoutput)


if(isCompare) {
Expand Down
12 changes: 10 additions & 2 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ rebuildAnnoData.internal <- function(eg.do) {
##' @param OrgDb OrgDb
##' @param geneID entrez gene ID
##' @param keytype keytype
##' @param keyoutput keytype
##' @return gene symbol
##' @importMethodsFrom AnnotationDbi select
##' @importMethodsFrom AnnotationDbi keys
Expand All @@ -297,14 +298,21 @@ rebuildAnnoData.internal <- function(eg.do) {
##' @importFrom GOSemSim load_OrgDb
##' @export
##' @author Guangchuang Yu \url{http://guangchuangyu.github.io}
EXTID2NAME <- function(OrgDb, geneID, keytype) {
EXTID2NAME <- function(OrgDb, geneID, keytype, keyoutput = "SYMBOL") {
# Added keyoutput = "SYMBOL" as a parameter so it is possible to define other columns as output
my_db <- OrgDb
OrgDb <- load_OrgDb(OrgDb)
kt <- keytypes(OrgDb)
if (! keytype %in% kt) {
stop("keytype is not supported...")
}

if (! keyoutput %in% columns(OrgDb)) {
stop(paste0("keyoutput ", keyoutput ," is not supported in db ", my_db))
}

gn.df <- suppressMessages(select(OrgDb, keys=geneID, keytype=keytype, columns="SYMBOL"))
# I replaced columns="SYMBOL" with columns=keyoutput
gn.df <- suppressMessages(select(OrgDb, keys=geneID, keytype=keytype, columns=keyoutput))
gn.df <- unique(gn.df)
colnames(gn.df) <- c("GeneID", "SYMBOL")

Expand Down