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) print(levels)
table$Group<-factor(table$Group, levels=levels) table$Group<-factor(table$Group, levels=levels)
table<-filter(table, !is.na(Group)) table<-filter(table, !is.na(Group))
}
}else(table$Group<-factor(table$Group))
print(str(table)) print(str(table))
analysis$taula<-table analysis$taula<-table
} }
@ -816,23 +816,24 @@ server <- function(input, output) {
hues <- seq(15, 375, length=n+1) hues <- seq(15, 375, length=n+1)
hcl(h=hues, l=l, c=100)[1:n] hcl(h=hues, l=l, c=100)[1:n]
} }
if (input$vacc == "Sí"){ if (input$vacc == "Sí"){
g<-list() g<-list()
count<-1 count<-1
for (side in c("L","R")){ for (side in c("L","R")){
tableR<-filter(table, Side == side) %>% filter(!is.na(Volume)) 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 table_tumor<-endtime
if (input$colors != ""){ if (input$colors != ""){
col<-input$colors
col<-strsplit(input$colors, ",")[[1]]
}else{ }else{
col<-gg_color_hue(length(unique(endtime$Group))) 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, pval = T, pval.method = T,
title = side, title = side,
# 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 palette = col
) )
@ -842,18 +843,18 @@ 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), 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 table_tumor<-endtime
if (input$colors != ""){ if (input$colors != ""){
col<-input$colors
col<-strsplit(input$colors, ",")[[1]]
}else{ }else{
col<-gg_color_hue(length(unique(table_tumor$Group))) 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, 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 palette = col
) )
} }

Loading…
Cancel
Save