go2DT <- function(enrichdf, data, orderby = NULL, nrows = NULL) {
if(!is.data.frame(enrichdf) | !is.data.frame(data)){
stop("enrichdf and data should be data.frame")
}
names(data) <- c("SYMBOL", "ENTREZID")
if(!is.null(orderby)){
orderby = match.arg(orderby, c("DE", "P.DE", "N", "Term"))
if(orderby=="P.DE" | orderby =="Term"){
enrichdf <- enrichdf %>% arrange(get(orderby))
} else{ enrichdf <- enrichdf %>% arrange(desc(get(orderby)))}
}
enrichdf2 <- enrichdf %>%
mutate(url = paste0("<a href='http://amigo.geneontology.org/amigo/search/bioentity?q=",
go_id,"'>",go_id,"</a>"))
CAup <- enrichdf2[, c(1, 2, 3, 4, 5, 7, 8, 9)]
CAup$genes <- gsub(",", ", ", CAup$genes)
for (i in seq(1:length(CAup$genes))) {
mg <- as.numeric(unlist(strsplit(CAup$genes[i], ", ")))
mg2 <- match(mg, data$ENTREZID)
CAup$genes[i] <- paste0(data[mg2, 1], collapse = ", ")
}
splitGenes <- strsplit(CAup$genes, ", ")
CAup$genes <- lapply(
splitGenes, function(x){
paste(sort(x), collapse = ", ")
}
)
if(!is.null(nrows) & is.numeric(nrows)){
CAup <- CAup[1:nrows, ]
}
CAup <- CAup %>% mutate(P.DE = format(P.DE, scientific = T, digits = 4))
return(CAup)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.