Guest User

Untitled

a guest
Oct 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. # Alpha Module Server function
  2.  
  3.  
  4. #Helper Function in order to load Rda without names
  5.  
  6. loadRData <- function(fileName){
  7. #loads an RData file, and returns it
  8. load(fileName)
  9. get(ls()[ls() != "fileName"])
  10. }
  11.  
  12.  
  13. alphaServer <- function(input, output, session) {
  14. # TODO: Put Server logic here
  15.  
  16. userData<-reactiveValues()
  17.  
  18. observeEvent(input$file1, {
  19. userData$df <- loadRData(input$file1$datapath)
  20.  
  21. })
  22.  
  23. output$phylo <- renderPlot({
  24. title <- "Alpha Diversity Metrics"
  25. selected_theme<-switch(input$plotTheme,
  26. "Grey theme" = theme_gray() ,
  27. "Black & White theme" =theme_bw(),
  28. "Classic theme" = theme_classic()
  29.  
  30. )
  31.  
  32. theme_set(selected_theme)
  33. have_input<-input$file1 #Check if user input exists
  34.  
  35. if(!is.null(have_input)){
  36. validate(need(class(userData$df)!="phyloseq","Only phyloseq files are currently supported"))
  37. plot_richness(userData$df, measures = c("Observed", input$groupSelection))
  38.  
  39. }
  40.  
  41. else if (input$dataSelection == "global") {
  42. data("GlobalPatterns")
  43. plot_richness(GlobalPatterns, measures = c("Observed", input$groupSelection))
  44. } else if (input$dataSelection == "esophagus") {
  45. data("esophagus")
  46. plot_richness(esophagus, measures = c("Observed", input$groupSelection))
  47. }
  48. })
  49. }
Add Comment
Please, Sign In to add comment