Cambiar Supervivencia y Kluskal de formato.

This commit is contained in:
2023-02-10 14:26:17 +01:00
parent 4eccf7e527
commit e481ee411c
+17 -17
View File
@@ -493,15 +493,15 @@ server <- function(input, output) {
}) })
output$survival<-renderPlot({ output$survival<-renderPlot({
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){ if (!is.null(input$file_analy) & !is.null(analysis$taula)){
observeEvent(analysis$taula_def, {}) observeEvent(analysis$taula, {})
table<-analysis$taula_def table<-analysis$taula
if (input$vacc == "Sí"){ if (input$vacc == "Sí"){
g<-list() g<-list()
for (side in c("L","R")){ for (side in c("L","R")){
tableR<-filter(table, `ID tumor` == side) %>% filter(!is.na(Volume)) tableR<-filter(table, Side == 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<-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+`ID animal`+`ID tumor`+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") > input$cutoff 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
g[side]<-ggsurvplot(survfit(Surv(table_tumor$end, table_tumor$Dead) ~ table_tumor$Group, data=table_tumor), 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{ }else{
tableR<-table %>% filter(!is.na(Volume)) 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~., endtime<-dcast(if(length(unique(tableR$DayPostInoc)) > 1){tableR %>% filter(Volume < input$cutoff)}else{tableR}, Animal+Side+Group~.,
value.var = "Timepoint", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".") value.var = "DayPostInoc", 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["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 table_tumor<<-endtime
g<-ggsurvplot(survfit(Surv(table_tumor$end, table_tumor$Dead) ~ table_tumor$Group, data=table_tumor), 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({ output$stats<-renderPrint({
stattest<-"dunn" stattest<-"dunn"
oneside<-"" oneside<-""
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){ if (!is.null(input$file_analy) & !is.null(analysis$taula)){
observeEvent(analysis$taula_def, {}) observeEvent(analysis$taula, {})
table<-analysis$taula_def table<-analysis$taula
if (input$vacc == "No"){ if (input$vacc == "No"){
table<-filter(table, !is.na(Volume)) 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{ }else{
for (side in c("L","R")){ for (side in c("L","R")){
tableR<-filter(table, `ID tumor` == side) %>% filter(!is.na(Volume)) tableR<-filter(table, Side == side) %>% filter(!is.na(Volume))
if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$Timepoint)) > 1){ if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$DayPostInoc)) > 1){
print(paste0("Side: ",side)) print(paste0("Side: ",side))
# print(summary(aov(Volume~Group+Timepoint+Error(paste0(ID animal,Cage)), data=tableR))) # print(summary(aov(Volume~Group+DayPostInoc+Error(paste0(Animal,Cage)), data=tableR)))
print(summary(aov(Volume~Group+Timepoint+Error(`ID animal`), data=tableR))) print(summary(aov(Volume~Group+DayPostInoc+Error(Animal), data=tableR)))
} }
} }
} }