diff --git a/invivos/app.R b/invivos/app.R index 8bab990..1b08f06 100755 --- a/invivos/app.R +++ b/invivos/app.R @@ -48,6 +48,7 @@ ui <- fluidPage( checkboxInput("filter_stats","Filtrar Estadística"), checkboxInput("increase_volume","Usar Incremento de Volumen"), checkboxInput("operated","Cortar al operar", value = TRUE), + checkboxInput("dead","Eliminar ratones muertos", value = FALSE), downloadButton("downloadVolume", "Descargar Volúmenes") ), mainPanel( @@ -456,11 +457,17 @@ server <- function(input, output) { firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>% select(DayPostInoc, Side) %>% unique() %>% group_by(Side) %>% summarise(FirstOper=min(DayPostInoc)) - + deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>% + pull(Animal) + print(deadmice) if (input$operated == TRUE){ for (i in 1:nrow(firstoper)){ table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i]) } + }else{ + if(input$dead == TRUE){ + table<-table %>% filter(!Animal %in% deadmice) + } } ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+ @@ -480,6 +487,12 @@ server <- function(input, output) { if (input$operated == TRUE){ table<-table %>% filter(DayPostInoc < firstoper) + }else{ + deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>% + pull(Animal) + if(input$dead == TRUE){ + table<-table %>% filter(!Animal %in% deadmice) + } } ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+ @@ -518,6 +531,20 @@ server <- function(input, output) { table<-rbind(table, basal) if (input$vacc == "Sí"){ + firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>% + select(DayPostInoc, Side) %>% unique() %>% + group_by(Side) %>% summarise(FirstOper=min(DayPostInoc)) + if (input$operated == TRUE){ + for (i in 1:nrow(firstoper)){ + table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i]) + } + }else{ + if(input$dead == TRUE){ + deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>% + pull(Animal) + table<-table %>% filter(!Animal %in% deadmice) + } + } ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Animal))+ # geom_errorbar(stat="summary", width=0.05)+ geom_line()+ @@ -528,6 +555,19 @@ server <- function(input, output) { labs(x="Days after tumor inoculation")+ theme_bw() }else{ + firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>% + pull(DayPostInoc) %>% min(na.rm = T) + print(firstoper) + + if (input$operated == TRUE){ + table<-table %>% filter(DayPostInoc < firstoper) + }else{ + deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>% + pull(Animal) + if(input$dead == TRUE){ + table<-table %>% filter(!Animal %in% deadmice) + } + } ggplot(table, aes(DayPostInoc, Volume, color=Group, group=paste0(Animal, Side)))+ # geom_errorbar(stat="summary", width=0.05)+ geom_line()+ @@ -713,6 +753,12 @@ server <- function(input, output) { for (i in 1:nrow(firstoper)){ table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i]) } + }else{ + if(input$dead == TRUE){ + deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>% + pull(Animal) + table<-table %>% filter(!Animal %in% deadmice) + } } std<-function(x, na.rm=T){sd(x, na.rm=na.rm)/sqrt(length(x))} errbar<-table %>% group_by(Group,Side,DayPostInoc) %>% @@ -739,7 +785,14 @@ server <- function(input, output) { if (input$operated == TRUE){ table<-table %>% filter(DayPostInoc < firstoper) + }else{ + deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>% + pull(Animal) + if(input$dead == TRUE){ + table<-table %>% filter(!Animal %in% deadmice) + } } + std<-function(x, na.rm=T){sd(x, na.rm=na.rm)/sqrt(length(x))} errbar<-table %>% group_by(Group, DayPostInoc) %>% summarise(mean=mean(Volume, na.rm=T), std=std(Volume)) %>% @@ -761,6 +814,22 @@ server <- function(input, output) { } if (input$fig_id == "Cinética Individual"){ if (input$vacc == "Sí"){ + firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>% + select(DayPostInoc, Side) %>% unique() %>% + group_by(Side) %>% summarise(FirstOper=min(DayPostInoc)) + + if (input$operated == TRUE){ + for (i in 1:nrow(firstoper)){ + table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i]) + } + }else{ + if(input$dead == TRUE){ + deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>% + pull(Animal) + table<-table %>% filter(!Animal %in% deadmice) + } + } + g<-ggplot(table, aes(as.numeric(as.character(DayPostInoc)), Volume, color=Group, group=Animal))+ scale_x_continuous(expand = expansion(mult = c(0,0.0)), breaks=sort(unique(as.numeric(as.character(table$DayPostInoc)))), @@ -768,6 +837,20 @@ server <- function(input, output) { facet_grid(factor(Side, labels = c("Vaccination", "Rechallenge"))~Group, scale="free_y")+ theme_bw() }else{ + firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>% + pull(DayPostInoc) %>% min(na.rm = T) + print(firstoper) + + if (input$operated == TRUE){ + table<-table %>% filter(DayPostInoc < firstoper) + }else{ + deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>% + pull(Animal) + if(input$dead == TRUE){ + table<-table %>% filter(!Animal %in% deadmice) + } + } + g<-ggplot(table, aes(as.numeric(as.character(DayPostInoc)), Volume, color=Group, group=Animal))+ scale_x_continuous(expand = expansion(mult = c(0,0.0)), breaks=sort(unique(as.numeric(as.character(table$DayPostInoc)))),