R/plotKegg.R

Defines functions plotKegg

plotKegg <- function(enrichdf, nrows = 30, orderby=NULL){
    require(plotly)
    if(!is.data.frame(enrichdf)){
        stop("enrichdf should be data.frame")
    }
    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)))}
    }
    p <- enrichdf[1:nrows,] %>%
        plot_ly(x=~DE, y=~pathID, text=~Pathway, type = "bar",
                marker = list(color='rgb(117,107,177)'),
                orientation = "v") %>%
        layout(margin = list(l=100), yaxis = list(title=""),
               title="Kegg pathways")
    return(p)
}
fpsanz/enrichGene documentation built on Feb. 20, 2020, 3:20 a.m.