markziemann / mitch

An R package for multi-dimensional pathway enrichment analysis
https://bioconductor.org/packages/mitch
Other
16 stars 4 forks source link

Replace taucharts with echarts4r #1

Closed markziemann closed 5 years ago

markziemann commented 5 years ago
df %>% 
  e_charts(State) %>% # initialise and set x
  e_line(Population, smooth = TRUE) %>%  # add a line
  e_area(Income, smooth = TRUE) %>%  # add area
  e_x_axis(name = "States") %>%  # add x axis name
  e_title("US States", "Population & Income") %>%  # Add title & subtitle
  e_theme("infographic") # theme
markziemann commented 5 years ago

After performing an enrichment analysis, it is possible to get it nearly perfect

library(echarts4r)
library(tidyverse)

myres<-head(res$enrichment_result,100)
myres$pointsize<-10

XCOL=colnames(myres)[4]
YCOL=colnames(myres)[5]

 myres %>%  
   tibble::rownames_to_column("model") %>% 
   mutate(set = paste(set, setSize, pMANOVA, p.adjustMANOVA , sep = ",")) %>%
   e_charts(s.rna) %>% 
   e_x_axis(name = XCOL) %>%  # add x axis name
   e_y_axis(name = YCOL) %>%  # add x axis name
   e_scatter(s.rna, s.k9a  , bind = set , symbolSize = 10  ) %>%
   e_tooltip(formatter = htmlwidgets::JS("
       function(params){
       var vals = params.name.split(',')
       return('<strong>' + vals[0] + 
       '</strong><br />s.x-axis: ' + parseFloat(params.value[0]).toFixed(2) + 
       '<br />s.y-axis: ' +  parseFloat(params.value[1]).toFixed(2)) +
       '<br />setSize: ' + vals[1] +
       '<br />p MANOVA: ' + Number(vals[2]).toPrecision(2) +
       '<br />p-adjust MANOVA: ' + Number(vals[3]).toPrecision(2) 
}"))