Browse Source

Cambiar Supervivencia y Kluskal de formato.

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

+ 17
- 17
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)))
}
}
}

Loading…
Cancel
Save