Browse Source

Cambio de formato de la pestaña exportar.

master
marcelcosta 1 year ago
parent
commit
552fe4cfe1
1 changed files with 56 additions and 35 deletions
  1. +56
    -35
      invivos/app.R

+ 56
- 35
invivos/app.R

@ -621,48 +621,69 @@ server <- function(input, output) {
##Exportar ##Exportar
output$expPlotUI<- renderUI({ output$expPlotUI<- renderUI({
observeEvent(analysis$taula_def, {})
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
observeEvent(analysis$taula, {})
if (!is.null(input$file_analy) & !is.null(analysis$taula)){
plotOutput("expPlot", width=paste0(input$width/10,"px"), height = paste0(input$height/10, "px")) plotOutput("expPlot", width=paste0(input$width/10,"px"), height = paste0(input$height/10, "px"))
} }
}) })
output$expPlot <- renderPlot({ output$expPlot <- renderPlot({
observeEvent(analysis$taula_def, {})
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
table<-analysis$taula_def
observeEvent(analysis$taula, {})
if (!is.null(input$file_analy) & !is.null(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$fig_id %in% c("Cinética Grupo", "Cinética Individual")){ if (input$fig_id %in% c("Cinética Grupo", "Cinética Individual")){
if (input$fig_id == "Cinética Grupo"){ if (input$fig_id == "Cinética Grupo"){
if (input$vacc == "Sí"){ if (input$vacc == "Sí"){
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,`ID tumor`, Timepoint) %>%
errbar<-table %>% group_by(Group,Side,DayPostInoc) %>%
summarise(mean=mean(Volume, na.rm=T), std=std(Volume)) %>% summarise(mean=mean(Volume, na.rm=T), std=std(Volume)) %>%
mutate(Timepoint2=as.numeric(as.character(Timepoint))) %>%
mutate(Timepoint2=as.numeric(as.character(DayPostInoc))) %>%
mutate(x=Timepoint2-input$`errorbar-width`, xend=Timepoint2+input$`errorbar-width`) mutate(x=Timepoint2-input$`errorbar-width`, xend=Timepoint2+input$`errorbar-width`)
g<-ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=Group))+
scale_x_continuous(expand = expansion(mult = c(0,0.0)),
breaks=sort(unique(errbar$Timepoint2)),
limits = c(0,max(as.numeric(as.character(table$Timepoint)))*1.1))+
facet_grid(factor(`ID tumor`, labels = c("Vaccination", "Rechallenge"))~., scale="free_y")+
g<-ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+
geom_errorbar(stat="summary", width=0.05)+
geom_line(stat="summary")+
geom_point(stat="summary")+
facet_grid(factor(Side, labels = c("Vaccination", "Rechallenge"))~., scale="free_y")+
labs(x="Days after tumor inoculation")+
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(table$DayPostInoc) / 5)+1)*5))+
theme_bw()+ theme_bw()+
geom_segment(data=errbar, aes(y=mean, yend=mean+std, x=Timepoint2, xend=Timepoint2))+ geom_segment(data=errbar, aes(y=mean, yend=mean+std, x=Timepoint2, xend=Timepoint2))+
geom_segment(data=errbar, aes(y=mean+std, yend=mean+std, geom_segment(data=errbar, aes(y=mean+std, yend=mean+std,
x=x,xend=xend)) x=x,xend=xend))
}else{ }else{
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, Timepoint) %>%
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)) %>%
mutate(Timepoint2=as.numeric(as.character(Timepoint))) %>%
mutate(Timepoint2=as.numeric(as.character(DayPostInoc))) %>%
mutate(x=Timepoint2-input$`errorbar-width`, xend=Timepoint2+input$`errorbar-width`) mutate(x=Timepoint2-input$`errorbar-width`, xend=Timepoint2+input$`errorbar-width`)
g<-ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=Group))+
scale_x_continuous(expand = expansion(mult = c(0,0.0)),
breaks=sort(unique(errbar$Timepoint2)),
limits = c(0,max(as.numeric(as.character(table$Timepoint)))*1.1))+
# limits = c(0, (round(max(as.numeric(as.character(table$Timepoint))) / 5)+1)*5))+
g<-ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+
geom_errorbar(stat="summary",width=0.05)+
geom_line(stat="summary")+
geom_point(stat="summary")+
labs(x="Days after tumor challenge")+
scale_y_continuous(expand = expansion(mult = c(0,0.05)))+
theme_bw()+ theme_bw()+
theme(axis.text.x=element_text(angle=45, hjust=1))+
geom_segment(data=errbar, aes(y=mean, yend=mean+std, x=Timepoint2, xend=Timepoint2))+ geom_segment(data=errbar, aes(y=mean, yend=mean+std, x=Timepoint2, xend=Timepoint2))+
geom_segment(data=errbar, aes(y=mean+std, yend=mean+std, geom_segment(data=errbar, aes(y=mean+std, yend=mean+std,
x=x,xend=xend)) x=x,xend=xend))
@ -670,17 +691,17 @@ 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í"){
g<-ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=`ID animal`))+
scale_x_continuous(expand = expansion(mult = c(0,0.0)),
breaks=sort(unique(as.numeric(as.character(table$Timepoint)))),
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")+
theme_bw()
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)))),
limits = c(0, (round(max(as.numeric(as.character(table$DayPostInoc))) / 5)+1)*5))+
facet_grid(factor(Side, labels = c("Vaccination", "Rechallenge"))~Group, scale="free_y")+
theme_bw()
}else{ }else{
g<-ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=`ID animal`))+
scale_x_continuous(expand = expansion(mult = c(0,0.0)),
breaks=sort(unique(as.numeric(as.character(table$Timepoint)))),
limits = c(0,max(as.numeric(as.character(table$Timepoint)))*1.1))+
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)))),
limits = c(0,max(as.numeric(as.character(table$DayPostInoc)))*1.1))+
facet_wrap(.~Group)+ facet_wrap(.~Group)+
theme_bw() theme_bw()
} }
@ -729,9 +750,9 @@ server <- function(input, output) {
g<-list() g<-list()
count<-1 count<-1
for (side in c("L","R")){ for (side in c("L","R")){
tableR<-filter(table, `ID tumor` == side) %>% filter(!is.na(Volume))
endtime<-dcast(tableR %>% filter(Volume < input$cutoff), Cage+`ID animal`+`ID tumor`+Group~., value.var = "Timepoint", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".")
endtime["Dead"]<-dcast(tableR, Cage+`ID animal`+`ID tumor`+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") > input$cutoff
tableR<-filter(table, Side == side) %>% filter(!is.na(Volume))
endtime<-dcast(tableR %>% filter(Volume < input$cutoff), Cage+Animal+Side+Group~., value.var = "DayPostInoc", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".")
endtime["Dead"]<-dcast(tableR, Cage+Animal+Side+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") > input$cutoff
table_tumor<-endtime table_tumor<-endtime
if (input$colors != ""){ if (input$colors != ""){
col<-input$colors col<-input$colors
@ -751,8 +772,8 @@ server <- function(input, output) {
}else{ }else{
tableR<-table %>% filter(!is.na(Volume)) tableR<-table %>% filter(!is.na(Volume))
endtime<-dcast(tableR %>% filter(Volume < input$cutoff), `ID animal`+Group~., value.var = "Timepoint", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".")
endtime["Dead"]<-dcast(tableR, `ID animal`+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") > input$cutoff
endtime<-dcast(tableR %>% filter(Volume < input$cutoff), Animal+Group~., value.var = "DayPostInoc", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".")
endtime["Dead"]<-dcast(tableR, Animal+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") > input$cutoff
table_tumor<-endtime table_tumor<-endtime
if (input$colors != ""){ if (input$colors != ""){
col<-input$colors col<-input$colors

Loading…
Cancel
Save