kegg2DT <- 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", "Pathway"))
if(orderby=="P.DE" | orderby =="Pathway"){
enrichdf <- enrichdf %>% arrange(get(orderby))
} else{ enrichdf <- enrichdf %>% arrange(desc(get(orderby)))}
}
enrichdf2 <- enrichdf %>%
mutate(pathway = limma::strsplit2(enrichdf$pathID, ":")[, 2],
genesURL = gsub(",", "+", genes)) %>%
mutate(url = paste0("<a href='https://www.kegg.jp/kegg-bin/show_pathway?",
pathway, "/", genesURL, "'>", pathway, "</a>"))
CAup <- enrichdf2[, c(1, 2, 3, 4, 6, 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.