Browse Source

Implementar la posibilidad de eliminar los ratones que hayan muerto prematuramente.

master
marcelcosta 1 year ago
parent
commit
16088aac2b
1 changed files with 84 additions and 1 deletions
  1. +84
    -1
      invivos/app.R

+ 84
- 1
invivos/app.R

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

Loading…
Cancel
Save