From e481ee411c2be2a2a68de3073a8150115c7e248f Mon Sep 17 00:00:00 2001 From: marcelcosta Date: Fri, 10 Feb 2023 14:26:17 +0100 Subject: [PATCH] Cambiar Supervivencia y Kluskal de formato. --- invivos/app.R | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/invivos/app.R b/invivos/app.R index 4b5836f..c17631e 100755 --- a/invivos/app.R +++ b/invivos/app.R @@ -493,15 +493,15 @@ server <- function(input, output) { }) output$survival<-renderPlot({ - if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){ - observeEvent(analysis$taula_def, {}) - table<-analysis$taula_def + if (!is.null(input$file_analy) & !is.null(analysis$taula)){ + observeEvent(analysis$taula, {}) + table<-analysis$taula if (input$vacc == "Sí"){ g<-list() 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 g[side]<-ggsurvplot(survfit(Surv(table_tumor$end, table_tumor$Dead) ~ table_tumor$Group, data=table_tumor), @@ -524,9 +524,9 @@ server <- function(input, output) { }else{ tableR<-table %>% filter(!is.na(Volume)) - endtime<-dcast(if(length(unique(tableR$Timepoint)) > 1){tableR %>% filter(Volume < input$cutoff)}else{tableR}, `ID animal`+`ID tumor`+Group~., - value.var = "Timepoint", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".") - endtime["Dead"]<-dcast(tableR, `ID animal`+`ID tumor`+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") >= input$cutoff + endtime<-dcast(if(length(unique(tableR$DayPostInoc)) > 1){tableR %>% filter(Volume < input$cutoff)}else{tableR}, Animal+Side+Group~., + value.var = "DayPostInoc", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".") + endtime["Dead"]<-dcast(tableR, Animal+Side+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") >= input$cutoff table_tumor<<-endtime g<-ggsurvplot(survfit(Surv(table_tumor$end, table_tumor$Dead) ~ table_tumor$Group, data=table_tumor), @@ -543,19 +543,19 @@ server <- function(input, output) { output$stats<-renderPrint({ stattest<-"dunn" oneside<-"" - if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){ - observeEvent(analysis$taula_def, {}) - table<-analysis$taula_def + if (!is.null(input$file_analy) & !is.null(analysis$taula)){ + observeEvent(analysis$taula, {}) + table<-analysis$taula if (input$vacc == "No"){ table<-filter(table, !is.na(Volume)) - summary(aov(Volume~Group+Timepoint+Error(`ID animal`+`ID tumor`), data=table)) + summary(aov(Volume~Group+DayPostInoc+Error(Animal+Side), data=table)) }else{ for (side in c("L","R")){ - tableR<-filter(table, `ID tumor` == side) %>% filter(!is.na(Volume)) - if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$Timepoint)) > 1){ + tableR<-filter(table, Side == side) %>% filter(!is.na(Volume)) + if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$DayPostInoc)) > 1){ print(paste0("Side: ",side)) - # print(summary(aov(Volume~Group+Timepoint+Error(paste0(ID animal,Cage)), data=tableR))) - print(summary(aov(Volume~Group+Timepoint+Error(`ID animal`), data=tableR))) + # print(summary(aov(Volume~Group+DayPostInoc+Error(paste0(Animal,Cage)), data=tableR))) + print(summary(aov(Volume~Group+DayPostInoc+Error(Animal), data=tableR))) } } }