knitr::opts_chunk$set(echo = F) library(shiny) library(DT) library(mzrtsim) data("hmdbcms") data("monams1")
inputPanel( sliderInput( "ncomp", "Numbers of the compounds", min = 10, max = 2000, value = 100 ), sliderInput( "ncpeaks", "Percentage of the compounds influnced by condition", min = 0, max = 1, value = 0.1 ), sliderInput( "nbpeaks", "Percentage of the peaks influnced by batch", min = 0, max = 1, value = 0.3 ), radioButtons('batchtype', 'batch type', c('m','b','mb'), 'mb'), radioButtons(inputId = 'db', label='database', choices = c('HMDB','MoNA'), selected = 'HMDB') ) sim <- reactive({ if(input$db == 'HMDB'){ data("hmdbcms") return(mzrtsim(ncomp = input$ncomp, ncpeaks = input$ncpeaks, nbpeaks = input$nbpeaks,db=hmdbcms,batchtype=input$batchtype)) } else if(input$db == 'MoNA'){ data("monams1") return(mzrtsim(ncomp = input$ncomp, ncpeaks = input$ncpeaks, nbpeaks = input$nbpeaks,db=monams1,batchtype=input$batchtype)) } })
DT::renderDataTable({ sim <- sim() rbind.data.frame(Label = sim$group$sample_group, sim$data) }) downloadHandler('simdata.csv', content = function(file) { sim <- sim() data <- rbind.data.frame(Label = sim$group$sample_group, sim$data) write.csv(data, file) })
DT::renderDataTable({ sim <- sim() rbind.data.frame(sim$group$sample_group,sim$matrix) }) downloadHandler('matrix.csv', content = function(file) { sim <- sim() data <- rbind.data.frame(sim$group$sample_group,sim$matrix) write.csv(data, file) })
DT::renderDataTable({ sim <- sim() rbind.data.frame(sim$group$sample_group,sim$batch,sim$bmatrix) }) downloadHandler('batch.csv', content = function(file) { sim <- sim() data <- rbind.data.frame(sim$group$sample_group,sim$bmatrix) write.csv(data, file) })
DT::renderDataTable({ sim <- sim() rbind.data.frame(sim$group$sample_group, sim$batch, sim$cmatrix) }) downloadHandler('con.csv', content = function(file) { sim <- sim() data <- rbind.data.frame(sim$group$sample_group, sim$batch, sim$cmatrix) write.csv(data, file) })
DT::renderDataTable({ sim <- sim() rbind.data.frame(sim$group$sample_group, sim$batch, sim$compmatrix) }) downloadHandler('cb.csv', content = function(file) { sim <- sim() data <- rbind.data.frame(sim$group$sample_group, sim$batch, sim$compmatrix) write.csv(data, file) })
DT::renderDataTable({ sim <- sim() sim$changec }) downloadHandler('conc.csv', content = function(file) { sim <- sim() data <- sim$changec write.csv(data, file) })
DT::renderDataTable({ sim <- sim() sim$changeb }) downloadHandler('batc.csv', content = function(file) { sim <- sim() data <- sim$changeb write.csv(data, file) })
DT::renderDataTable({ sim <- sim() sim$changem }) downloadHandler('batmc.csv', content = function(file) { sim <- sim() data <- sim$changem write.csv(data, file) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.