Browse Source

Correcció de bugs a l'exportar survival.

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

+ 13
- 12
invivos/app.R

@ -397,7 +397,7 @@ server <- function(input, output) {
print(levels)
table$Group<-factor(table$Group, levels=levels)
table<-filter(table, !is.na(Group))
}
}else(table$Group<-factor(table$Group))
print(str(table))
analysis$taula<-table
}
@ -816,23 +816,24 @@ server <- function(input, output) {
hues <- seq(15, 375, length=n+1)
hcl(h=hues, l=l, c=100)[1:n]
}
if (input$vacc == "Sí"){
g<-list()
count<-1
for (side in c("L","R")){
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
endtime<-dcast(tableR %>% filter(Volume < (input$cutoff*as.numeric(input$unit_fact))), 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*as.numeric(input$unit_fact))
table_tumor<-endtime
if (input$colors != ""){
col<-input$colors
col<-strsplit(input$colors, ",")[[1]]
}else{
col<-gg_color_hue(length(unique(endtime$Group)))
}
g[[count]]<-ggsurvplot(survfit(Surv(table_tumor$end, table_tumor$Dead) ~ table_tumor$Group, data=table_tumor),
table_tumor$Group<-factor(table_tumor$Group, levels = levels(analysis$taula$Group))
g[[count]]<-ggsurvplot(survfit(Surv(table_tumor$end, table_tumor$Dead) ~ Group, data=table_tumor),
pval = T, pval.method = T,
title = side,
# legend.labs = paste(c("< median", ">= median"), "MICA"),
ggtheme=theme_classic(base_size=input$`font-size`),
palette = col
)
@ -842,18 +843,18 @@ server <- function(input, output) {
}else{
tableR<-table %>% filter(!is.na(Volume))
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
endtime<-dcast(tableR %>% filter(Volume < (input$cutoff*as.numeric(input$unit_fact))), 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*as.numeric(input$unit_fact))
table_tumor<-endtime
if (input$colors != ""){
col<-input$colors
col<-strsplit(input$colors, ",")[[1]]
}else{
col<-gg_color_hue(length(unique(table_tumor$Group)))
}
g<-ggsurvplot(survfit(Surv(table_tumor$end, table_tumor$Dead) ~ table_tumor$Group, data=table_tumor),
table_tumor$Group<-factor(table_tumor$Group, levels = levels(analysis$taula$Group))
g<-ggsurvplot(survfit(Surv(table_tumor$end, table_tumor$Dead) ~ Group, data=table_tumor),
pval = T, pval.method = T,
# legend.labs = paste(c("< median", ">= median"), "MICA"),
ggtheme=theme_classic(base_size=input$`font-size`),
# ggtheme=theme_classic(base_size=input$`font-size`),
palette = col
)
}

Loading…
Cancel
Save