diff --git a/invivos/app.R b/invivos/app.R index bf52926..84e9717 100644 --- a/invivos/app.R +++ b/invivos/app.R @@ -39,7 +39,8 @@ ui <- fluidPage( fileInput(inputId = "file_analy", label = "Hoja de análisis", multiple = F), selectInput(inputId = "vacc", "Experimento de Vacunación", selected = "No", choices = c("Sí","No")), uiOutput('cutoffUI'), - checkboxInput("filter_stats","Filtrar Estadística") + checkboxInput("filter_stats","Filtrar Estadística"), + downloadButton("downloadVolume", "Descargar Volúmenes") ), mainPanel( h3('Ratones'), @@ -280,6 +281,7 @@ server <- function(input, output) { analysis<-reactiveValues() analysis$taula<-NULL analysis$taula_def<-NULL + analysis$taula_vol<-NULL observe({ if (!is.null(input$file_analy)){ analysis$taula<-read.xlsx(input$file_analy$datapath, sheet = 1, check.names = F, sep.names = " ") @@ -289,6 +291,7 @@ server <- function(input, output) { if (!is.null(analysis$taula_def)){ observeEvent(analysis$taula_def, {}) max_val<-max(analysis$taula_def$Volume, na.rm = T) + print(max_val) sliderInput("cutoff", "Cutoff para Survival", min=0, max=round(max_val), step=round(max_val)/200, value=max_val) } }) @@ -303,12 +306,13 @@ server <- function(input, output) { if ("ID" %in% colnames(table)){table<-rename(table, "ID animal"=ID)} if ("ID.tumor" %in% colnames(table)){table<-rename(table, "ID tumor"=`ID.tumor`)} # table[table$ID.tumor == "R","0"]<-NA - col_nodays<-c("ID", "Cage","Group", "ID.animal","ID animal", "ID.tumor", "ID tumor", "TS","DPV", "Absorbance") + col_nodays<-c("ID","Code", "Cage","Group", "ID.animal","ID animal", "ID.tumor", "ID tumor", "TS","DPV", "Absorbance") if (length(grep(0, colnames(table)[!colnames(table) %in% col_nodays])) == 0){ table["0"]<-0 } table<-melt(table, id=colnames(table)[colnames(table) %in% col_nodays], variable.name = "Timepoint") table$Timepoint<-gsub("[A-Za-z ]","",table$Timepoint) + print(table) if ("DPV" %in% colnames(table)){ table<-dcast(table, Cage+`ID animal`+`ID tumor`+Group+Timepoint~DPV, value.var = "value") table$Major<-table$Major @@ -323,6 +327,7 @@ server <- function(input, output) { table<-table %>% filter(!is.na(Group)) table$Timepoint<-factor(table$Timepoint, levels=mixedsort(as.numeric(as.character(unique(table$Timepoint))))) analysis$taula_def<-table + analysis$taula_vol<-dcast(table, Cage+`ID animal`+`ID tumor`~Volume) table_plot<-dcast(dcast(table %>% filter(!is.na(Volume)), `ID animal`+Group+Timepoint~., value.var = "Volume", fun.aggregate = mean), Group~Timepoint) table_plot } @@ -358,6 +363,7 @@ server <- function(input, output) { if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){ observeEvent(analysis$taula_def, {}) table<-analysis$taula_def + print(table , ) if (input$vacc == "Sí"){ ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=`ID animal`))+ # geom_errorbar(stat="summary", width=0.05)+ @@ -498,6 +504,18 @@ server <- function(input, output) { } }) + output$downloadVolumes <- downloadHandler( + + filename = function() { + paste("invivo-vols", ".xlsx", sep="") + }, + content = function(file){ + dtemplate<-analysis$taula_vol + write.xlsx(dtemplate,file) + } + ) + + ##Exportar output$expPlotUI<- renderUI({ observeEvent(analysis$taula_def, {}) if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){