diff --git a/invivos/app.R b/invivos/app.R index b3af629..a3b3ec0 100755 --- a/invivos/app.R +++ b/invivos/app.R @@ -432,29 +432,47 @@ server <- function(input, output) { } }) output$cin_indiv<-renderPlot({ - if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){ - observeEvent(analysis$taula_def, {}) - table<-analysis$taula_def - print(table) + if (!is.null(input$file_analy) & !is.null(analysis$taula)){ + observeEvent(analysis$taula, {}) + table<-analysis$taula + + animals<-unique(table$Animal) + sides<-unique(table$Side) + groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group) + basal<-data.frame( + Cage="", + Animal=rep(animals, each=length(sides)), + Date="", + DayPostInoc=0, + Group=rep(groups, each=length(sides)), + Side=rep(sides, length(animals)), + Weight="", + Long="", + Wide="", + Volume=0, + Observations="" + ) + table<-rbind(table, basal) + if (input$vacc == "Sí"){ - ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=`ID animal`))+ + ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Animal))+ # geom_errorbar(stat="summary", width=0.05)+ geom_line()+ geom_point()+ scale_y_continuous(expand = expansion(mult = c(0,0.05)))+ - scale_x_continuous(expand = expansion(mult = c(0,0.05)), limits = c(0, (round(max(as.numeric(as.character(table$Timepoint))) / 5)+1)*5))+ - facet_grid(factor(`ID tumor`, labels = c("Vaccination", "Rechallenge"))~Group, scale="free_y")+ - labs(x="Days after tumor challenge")+ + scale_x_continuous(expand = expansion(mult = c(0,0.05)), limits = c(0, (round(max(table$DayPostInoc) / 5)+1)*5))+ + facet_grid(factor(Side, labels = c("Vaccination", "Rechallenge"))~Group, scale="free_y")+ + labs(x="Days after tumor inoculation")+ theme_bw() }else{ - ggplot(table, aes(Timepoint, Volume, color=Group, group=paste0(`ID animal`, `ID tumor`)))+ + ggplot(table, aes(DayPostInoc, Volume, color=Group, group=paste0(Animal, Side)))+ # geom_errorbar(stat="summary", width=0.05)+ geom_line()+ geom_point()+ scale_y_continuous(expand = expansion(mult = c(0,0.05)))+ # scale_x_continuous(expand = expansion(mult = c(0,0.05)), limits = c(0, (round(max(as.numeric(as.character(table$Timepoint))) / 5)+1)*5))+ facet_wrap(.~Group)+ - labs(x="Days after tumor challenge")+ + labs(x="Days after tumor inoculation")+ theme_bw()+ theme(axis.text.x=element_text(angle=45, hjust=1)) }