Browse Source

Solucionando algunos problemas del análisis. Cutoff, ausencia de ID tumor...

master
Costa 2 years ago
parent
commit
72ba3b75cd
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      invivos/app.R

+ 5
- 5
invivos/app.R

@ -345,7 +345,7 @@ server <- function(input, output) {
observeEvent(analysis$taula_def, {}) observeEvent(analysis$taula_def, {})
max_val<-max(analysis$taula_def$Volume, na.rm = T) max_val<-max(analysis$taula_def$Volume, na.rm = T)
# print(max_val) # print(max_val)
sliderInput("cutoff", "Cutoff para Survival", min=0, max=round(max_val), step=round(max_val)/200, value=max_val)
sliderInput("cutoff", "Cutoff para Survival", min=0, max=round(max_val, digits=2), step=round(max_val, digits=2)/200, value=max_val)
} }
}) })
output$ntable<-renderTable({ output$ntable<-renderTable({
@ -360,7 +360,7 @@ server <- function(input, output) {
if ("ID.tumor" %in% colnames(table)){table<-rename(table, "ID tumor"=`ID.tumor`)} if ("ID.tumor" %in% colnames(table)){table<-rename(table, "ID tumor"=`ID.tumor`)}
# table[table$ID.tumor == "R","0"]<-NA # table[table$ID.tumor == "R","0"]<-NA
col_nodays<-c("ID","Code", "Cage","Group", "ID.animal","ID animal", "ID.tumor", "ID tumor", "TS","DPV", "Absorbance") col_nodays<-c("ID","Code", "Cage","Group", "ID.animal","ID animal", "ID.tumor", "ID tumor", "TS","DPV", "Absorbance")
if (length(grep(0, colnames(table)[!colnames(table) %in% col_nodays])) == 0){
if (length(grep(0, colnames(table)[!colnames(table) %in% col_nodays])) == 0 & input$vacc == "Sí"){
table["0"]<-0 table["0"]<-0
} }
table<-melt(table, id=colnames(table)[colnames(table) %in% col_nodays], variable.name = "Timepoint") table<-melt(table, id=colnames(table)[colnames(table) %in% col_nodays], variable.name = "Timepoint")
@ -474,8 +474,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, `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
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),
@ -497,7 +497,7 @@ server <- function(input, output) {
table<-analysis$taula_def table<-analysis$taula_def
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`), data=table))
summary(aov(Volume~Group+Timepoint+Error(`ID animal`+`ID tumor`), 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, `ID tumor` == side) %>% filter(!is.na(Volume))

Loading…
Cancel
Save