Compare commits
35 Commits
88e2ab7664
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0887ab933a | |||
| a3eaf3e7a9 | |||
| 1237794f62 | |||
| bbf19befaf | |||
| 3a9907c480 | |||
| cda5d7f881 | |||
| 8539caa993 | |||
| 7783dc6c4b | |||
| fe865f55e4 | |||
| b01f7bb11d | |||
| 459a8001fe | |||
| 455901a1db | |||
| 43776f80cb | |||
| d9a5689c99 | |||
| 092a788125 | |||
| 80362a28db | |||
| 9f0cda73eb | |||
| 16088aac2b | |||
| fd6493320f | |||
| 8dc0177515 | |||
| 35a73598d3 | |||
| 0e4ef399fd | |||
| 2ca8e2b212 | |||
| 54a20f10c7 | |||
| 3e6b97c546 | |||
| fa2c784602 | |||
| 633fb5f953 | |||
| c416a850b5 | |||
| e481ee411c | |||
| 4eccf7e527 | |||
| 552fe4cfe1 | |||
| c6de7d7d41 | |||
| 603f06db66 | |||
| bdbd8edf9d | |||
| dde77d987c |
+432
-170
@@ -26,6 +26,7 @@ ui <- fluidPage(
|
|||||||
uiOutput('ncages'),
|
uiOutput('ncages'),
|
||||||
uiOutput('ntumors'),
|
uiOutput('ntumors'),
|
||||||
# selectInput(inputId = "measure_sys", "Sistema de medida", selected = "L-W-D", choices = c("L-W-D","Min-Max","Absorbance")),
|
# selectInput(inputId = "measure_sys", "Sistema de medida", selected = "L-W-D", choices = c("L-W-D","Min-Max","Absorbance")),
|
||||||
|
uiOutput('day_vol'),
|
||||||
uiOutput('lowcut'),
|
uiOutput('lowcut'),
|
||||||
uiOutput('upcut'),
|
uiOutput('upcut'),
|
||||||
uiOutput('goButton'),
|
uiOutput('goButton'),
|
||||||
@@ -46,6 +47,8 @@ ui <- fluidPage(
|
|||||||
uiOutput('cutoffUI'),
|
uiOutput('cutoffUI'),
|
||||||
checkboxInput("filter_stats","Filtrar Estadística"),
|
checkboxInput("filter_stats","Filtrar Estadística"),
|
||||||
checkboxInput("increase_volume","Usar Incremento de Volumen"),
|
checkboxInput("increase_volume","Usar Incremento de Volumen"),
|
||||||
|
checkboxInput("operated","Cortar al operar", value = TRUE),
|
||||||
|
checkboxInput("dead","Eliminar ratones muertos", value = FALSE),
|
||||||
downloadButton("downloadVolume", "Descargar Volúmenes")
|
downloadButton("downloadVolume", "Descargar Volúmenes")
|
||||||
),
|
),
|
||||||
mainPanel(
|
mainPanel(
|
||||||
@@ -64,6 +67,7 @@ ui <- fluidPage(
|
|||||||
h3('Seleccionar figura'),
|
h3('Seleccionar figura'),
|
||||||
selectInput("fig_id", "", selected="", choices=c("Cinética Grupo", "Cinética Individual", "Survival")),
|
selectInput("fig_id", "", selected="", choices=c("Cinética Grupo", "Cinética Individual", "Survival")),
|
||||||
h3('Formato'),
|
h3('Formato'),
|
||||||
|
selectInput("unit_fact", "Factor de unidad", choices = c("0.001","1","1000"), selected="1"),
|
||||||
sliderInput("width", "Ancho", min=1000, max=20000, step=1000, value=10000),
|
sliderInput("width", "Ancho", min=1000, max=20000, step=1000, value=10000),
|
||||||
sliderInput("height", "Altura", min=1000, max=20000, step=1000, value=6000),
|
sliderInput("height", "Altura", min=1000, max=20000, step=1000, value=6000),
|
||||||
textInput("colors", label="Colors", value=""),
|
textInput("colors", label="Colors", value=""),
|
||||||
@@ -86,9 +90,14 @@ ui <- fluidPage(
|
|||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Define server logic required to draw a histogram
|
# Define server logic required to draw a histogram
|
||||||
server <- function(input, output) {
|
server <- function(input, output) {
|
||||||
|
|
||||||
|
# Diseño ------------------------------------------------------------------
|
||||||
|
|
||||||
# Diseño
|
# Diseño
|
||||||
dades<-reactiveValues()
|
dades<-reactiveValues()
|
||||||
dades$taula<-NULL
|
dades$taula<-NULL
|
||||||
@@ -97,22 +106,39 @@ server <- function(input, output) {
|
|||||||
dades$db<-NULL
|
dades$db<-NULL
|
||||||
observe({
|
observe({
|
||||||
if (!is.null(input$file_sizes)){
|
if (!is.null(input$file_sizes)){
|
||||||
taula<-read.xlsx(input$file_sizes$datapath, sheet = 1, sep.names = " ")
|
table<-read.xlsx(input$file_sizes$datapath, sheet = 1, check.names = F, sep.names = " ", detectDates = T,cols=1:11)
|
||||||
if ("DPV" %in% colnames(taula)){
|
if("ID.animal" %in% colnames(table)){
|
||||||
taula<-dcast(taula, Cage+`ID animal`+`ID tumor`+Group~DPV, value.var = "0")
|
table<-table %>%
|
||||||
# taula$Major<-taula$Major/1000
|
rename(Animal=`ID.animal`, Side=`ID.tumor`)
|
||||||
# taula$Minor<-taula$Minor/1000
|
table<-table %>% gather(DayPostInoc, Value, which(!is.na(as.numeric(colnames(table))))) %>%
|
||||||
# taula["Volume"]<-((taula$Major*taula$Minor*taula$Minor)*(pi/6))*1000
|
relocate(DayPostInoc, .before = Group) %>% spread(DPV, Value) %>%
|
||||||
taula$Major<-taula$Major
|
rename(Long=Major, Wide=Minor) %>%
|
||||||
taula$Minor<-taula$Minor
|
add_column(Date="", .after = "Animal") %>%
|
||||||
taula["Volume"]<-((taula$Major*taula$Minor*taula$Minor)*(pi/6))
|
add_column(Weight="", .after="Group") %>%
|
||||||
|
add_column(Volume="",Observations="") %>%
|
||||||
|
relocate(Side, .after = "Group")
|
||||||
|
table$DayPostInoc<-as.numeric(table$DayPostInoc)
|
||||||
}
|
}
|
||||||
if ("TS" %in% colnames(taula)){
|
table$Date<-format(table$Date, format="%d/%m/%Y")
|
||||||
taula<-dcast(taula, Cage+`ID animal`+`ID tumor`+Group~TS, value.var = "0")
|
if ("sex" %in% colnames(table)){table<-select(table, -sex)}
|
||||||
taula["Volume"]<-taula$`TS-Deep`*taula$`TS-Length`*taula$`TS-Width`*pi/6
|
if ("Abs" %in% colnames(table)){
|
||||||
|
table<-rename(table, "Volume"="Abs")
|
||||||
|
}else{
|
||||||
|
for (i in 1:nrow(table)){
|
||||||
|
long<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Long"]),"+", fixed = T)[[1]]))
|
||||||
|
wide<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Wide"]),"+", fixed = T)[[1]]))
|
||||||
|
table[i,"Volume"]<-sum(sapply(1:length(long), function(x) (long[x]*wide[x]*wide[x])*(pi/6)))
|
||||||
|
}
|
||||||
|
table$Volume<-as.numeric(table$Volume)
|
||||||
}
|
}
|
||||||
dades$taula<-taula
|
|
||||||
dades$groups<-read.xlsx(input$file_sizes$datapath, sheet = 2, colNames=F)[,1]
|
if ("Cage" %in% colnames(table)){
|
||||||
|
table$Animal<-paste0(table$Cage, table$Animal)
|
||||||
|
table<-table[,-which(colnames(table) == "Cage")]
|
||||||
|
}
|
||||||
|
|
||||||
|
dades$taula<-table
|
||||||
|
dades$groups<-read.xlsx(input$file_sizes$datapath, sheet = "Groups", colNames=F)[,1]
|
||||||
if (readxl::excel_sheets(input$file_sizes$datapath) %>% length > 2){
|
if (readxl::excel_sheets(input$file_sizes$datapath) %>% length > 2){
|
||||||
dades$sex<-read.xlsx(input$file_sizes$datapath, sheet = 3, sep.names = " ")
|
dades$sex<-read.xlsx(input$file_sizes$datapath, sheet = 3, sep.names = " ")
|
||||||
}
|
}
|
||||||
@@ -121,7 +147,15 @@ server <- function(input, output) {
|
|||||||
output$firstPlot <- renderPlot({
|
output$firstPlot <- renderPlot({
|
||||||
observeEvent(dades$taula, {})
|
observeEvent(dades$taula, {})
|
||||||
if (!is.null(dades$taula)){
|
if (!is.null(dades$taula)){
|
||||||
ggplot(dades$taula, aes(x="1", y=Volume))+geom_hline(yintercept = c(input$lowcut, input$upcut), color="red")+geom_quasirandom(width=0.2)
|
ggplot(dades$taula %>% filter(DayPostInoc == input$day_vol), aes(x="1", y=Volume))+
|
||||||
|
geom_hline(yintercept = c(input$lowcut, input$upcut), color="red")+
|
||||||
|
geom_quasirandom(width=0.2)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
output$day_vol<-renderUI({
|
||||||
|
if (!is.null(dades$taula)){
|
||||||
|
selectInput("day_vol", "Día para volúmenes", choices = sort(unique(dades$taula$DayPostInoc)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -132,15 +166,17 @@ server <- function(input, output) {
|
|||||||
})
|
})
|
||||||
output$lowcut<-renderUI({
|
output$lowcut<-renderUI({
|
||||||
if (!is.null(dades$taula)){
|
if (!is.null(dades$taula)){
|
||||||
cut.max<-round(max(dades$taula$Volume, na.rm = T), 2)
|
taula<-dades$taula %>% filter(DayPostInoc == input$day_vol)
|
||||||
step<-round(max(dades$taula$Volume, na.rm = T)/100, 2)
|
cut.max<-round(max(taula$Volume, na.rm = T), 2)
|
||||||
|
step<-round(max(taula$Volume, na.rm = T)/100, 2)
|
||||||
sliderInput("lowcut", "Corte inferior", min=0, max=cut.max, step=step, value=0)
|
sliderInput("lowcut", "Corte inferior", min=0, max=cut.max, step=step, value=0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
output$upcut<-renderUI({
|
output$upcut<-renderUI({
|
||||||
if (!is.null(dades$taula)){
|
if (!is.null(dades$taula)){
|
||||||
cut.max<-round(max(dades$taula$Volume, na.rm = T), 2)+0.01
|
taula<-dades$taula %>% filter(DayPostInoc == input$day_vol)
|
||||||
step<-round(max(dades$taula$Volume, na.rm = T)/20, 2)
|
cut.max<-round(max(taula$Volume, na.rm = T), 2)+0.01
|
||||||
|
step<-round(max(taula$Volume, na.rm = T)/20, 2)
|
||||||
sliderInput("upcut", "Corte superior", min=0, max=cut.max, step=step, value=cut.max)
|
sliderInput("upcut", "Corte superior", min=0, max=cut.max, step=step, value=cut.max)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -161,11 +197,12 @@ server <- function(input, output) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
grafic<-eventReactive(input$goButton,{
|
grafic<-eventReactive(input$goButton,{
|
||||||
df<-dades$taula
|
df<-dades$taula %>% filter(DayPostInoc == input$day_vol)
|
||||||
df<-df[!is.na(df$Volume),]
|
df<-df[!is.na(df$Volume),]
|
||||||
|
print(df)
|
||||||
up_cuttof<-input$upcut
|
up_cuttof<-input$upcut
|
||||||
low_cuttof<-input$lowcut
|
low_cuttof<-input$lowcut
|
||||||
# print(up_cuttof)
|
|
||||||
df<-df[df$Volume < up_cuttof & df$Volume >= low_cuttof,]
|
df<-df[df$Volume < up_cuttof & df$Volume >= low_cuttof,]
|
||||||
if (is.null(dades$sex)){
|
if (is.null(dades$sex)){
|
||||||
df<-add_column(df, sex="undefined")
|
df<-add_column(df, sex="undefined")
|
||||||
@@ -173,16 +210,14 @@ server <- function(input, output) {
|
|||||||
df<-merge(df, dades$sex)
|
df<-merge(df, dades$sex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# df["Mouse"]<-gsub("[a-zA-Z]", "", df$MouseID)
|
# df["Mouse"]<-gsub("[a-zA-Z]", "", df$MouseID)
|
||||||
# print(df$Volume)
|
|
||||||
s<-shapiro.test(df$Volume)[[2]]
|
s<-shapiro.test(df$Volume)[[2]]
|
||||||
|
|
||||||
ngroup<-length(dades$groups)
|
ngroup<-length(dades$groups)
|
||||||
df_def<-list()
|
df_def<-list()
|
||||||
# print(head(df))
|
|
||||||
for (sex.var in unique(df$sex)){
|
for (sex.var in unique(df$sex)){
|
||||||
# print(sex.var)
|
|
||||||
df_sex<-df %>% filter(`sex` == sex.var)
|
df_sex<-df %>% filter(`sex` == sex.var)
|
||||||
ind.list<-list()
|
ind.list<-list()
|
||||||
pval.list<-list()
|
pval.list<-list()
|
||||||
@@ -191,8 +226,8 @@ server <- function(input, output) {
|
|||||||
for (data in 1:input$iterations){
|
for (data in 1:input$iterations){
|
||||||
interr=T
|
interr=T
|
||||||
while(interr == T){
|
while(interr == T){
|
||||||
ind<-sample(rep(dades$groups, each=ceiling(length(unique(df_sex$`ID animal`))/ngroup)), length(unique(df_sex$`ID animal`)))
|
ind<-sample(rep(dades$groups, each=ceiling(length(unique(df_sex$Animal))/ngroup)), length(unique(df_sex$Animal)))
|
||||||
df_sex<-merge(df_sex[,c("ID animal", "ID tumor","Volume")], data.frame("ID animal"=unique(df_sex$`ID animal`), "group"=as.factor(ind),check.names=F))
|
df_sex<-merge(df_sex[,c("Animal", "Side","Volume")], data.frame("Animal"=unique(df_sex$Animal), "group"=as.factor(ind),check.names=F))
|
||||||
if ((nrow(df_sex)/ngroup) %% 2 == 0){
|
if ((nrow(df_sex)/ngroup) %% 2 == 0){
|
||||||
interr<-any(table(df_sex$group) < floor(nrow(df_sex)/ngroup) | table(df_sex$group) > ceiling(nrow(df_sex)/ngroup))
|
interr<-any(table(df_sex$group) < floor(nrow(df_sex)/ngroup) | table(df_sex$group) > ceiling(nrow(df_sex)/ngroup))
|
||||||
}else{
|
}else{
|
||||||
@@ -200,7 +235,7 @@ server <- function(input, output) {
|
|||||||
interr<-diff(range(table(ind))) > 1
|
interr<-diff(range(table(ind))) > 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ind.list[[data]]<-df_sex[,c("ID animal","ID tumor","group","Volume")]
|
ind.list[[data]]<-df_sex[,c("Animal","Side","group","Volume")]
|
||||||
lvn.list[data]<-leveneTest(Volume ~ group, data = df_sex[,3:4])[[2]][1]
|
lvn.list[data]<-leveneTest(Volume ~ group, data = df_sex[,3:4])[[2]][1]
|
||||||
if (s < 0.05){
|
if (s < 0.05){
|
||||||
k<-kruskal.test(df_sex$Volume,df_sex$group)
|
k<-kruskal.test(df_sex$Volume,df_sex$group)
|
||||||
@@ -213,33 +248,36 @@ server <- function(input, output) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
index<-which(unlist(lvn.list) == min(unlist(lvn.list)[which(unlist(pval.list) %in% sort(unlist(pval.list), decreasing = T)[1:20])]))[1]
|
index<-which(unlist(lvn.list) == min(unlist(lvn.list)[which(unlist(pval.list) %in% sort(unlist(pval.list), decreasing = T)[1:20])]))[1]
|
||||||
# print(df_sex)
|
|
||||||
df_def[[sex.var]]<-merge(df_sex %>% select(-group), ind.list[[index]])
|
df_def[[sex.var]]<-merge(df_sex %>% select(-group), ind.list[[index]])
|
||||||
}
|
}
|
||||||
df_def<-do.call(rbind, c(df_def, make.row.names=F))
|
df_def<-do.call(rbind, c(df_def, make.row.names=F))
|
||||||
# lapply(df_def, function(x) x %>% as_tibble %>% print(n=Inf))
|
|
||||||
# df_def<-rbind(df_def[[1]], df_def[[2]], make.row.names=F)
|
|
||||||
if ("Group" %in% colnames(df_def)){
|
if ("Group" %in% colnames(df_def)){
|
||||||
df_def<-df_def %>% select(-"Group")
|
df_def<-df_def %>% select(-"Group")
|
||||||
}
|
}
|
||||||
|
|
||||||
df_def<-merge(
|
df_def<-merge(
|
||||||
if(!is.null(dades$sex)){merge(dades$taula, dades$sex)}else{dades$taula %>% add_column(sex="undefined")} %>% select(-Group),
|
if(!is.null(dades$sex)){merge(dades$taula %>% filter(DayPostInoc == input$day_vol), dades$sex)%>% select(-Group)}else{
|
||||||
df_def[,c("ID animal", "group")] %>% unique, all=T, by="ID animal")
|
dades$taula %>% filter(DayPostInoc == input$day_vol) %>% add_column(sex="undefined")} %>% select(-Group),
|
||||||
if("DPV" %in% colnames(df_def)){df_def<-select(df_def, c(`ID animal`, `sex`,`ID tumor`, Volume, Cage, Major, Minor, group))}
|
df_def[,c("Animal", "group")] %>% unique, all=T, by="Animal")
|
||||||
if("TS-Deep" %in% colnames(df_def)){df_def<-select(df_def, c(`ID animal`, `sex`,`ID tumor`, Volume, Cage, `TS-Deep`,`TS-Length`,`TS-Width`, group))}
|
df_def<-df_def %>% rename(Group=group)
|
||||||
|
|
||||||
df_def[!paste0(df_def$`ID animal`, df_def$`ID tumor`) %in% paste0(df$`ID animal`, df$`ID tumor`),"group"]<-NA
|
df_def<-select(df_def, Animal, sex, Date, DayPostInoc, Group, Side, Weight, Long, Wide, Volume, Observations)
|
||||||
|
# if("DPV" %in% colnames(df_def)){df_def<-select(df_def, c(`ID animal`, `sex`,`ID tumor`, Volume, Cage, Major, Minor, group))}
|
||||||
|
# if("TS-Deep" %in% colnames(df_def)){df_def<-select(df_def, c(`ID animal`, `sex`,`ID tumor`, Volume, Cage, `TS-Deep`,`TS-Length`,`TS-Width`, group))}
|
||||||
|
|
||||||
|
df_def[!paste0(df_def$Animal, df_def$Side) %in% paste0(df$Animal, df$Side),"Group"]<-NA
|
||||||
dades$db<-df_def
|
dades$db<-df_def
|
||||||
|
|
||||||
if (is.null(dades$sex)){
|
if (is.null(dades$sex)){
|
||||||
ggplot(df_def, aes(group, Volume))+
|
ggplot(df_def, aes(Group, Volume))+
|
||||||
geom_boxplot(outlier.alpha = F)+
|
geom_boxplot(outlier.alpha = F)+
|
||||||
geom_jitter(width=0.25)+
|
geom_jitter(width=0.25)+
|
||||||
geom_point(stat="summary", color="blue", size=3)+
|
geom_point(stat="summary", color="blue", size=3)+
|
||||||
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5))
|
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5))
|
||||||
}else{
|
}else{
|
||||||
ggarrange(
|
ggarrange(
|
||||||
ggplot(df_def, aes(group, Volume))+
|
ggplot(df_def, aes(Group, Volume))+
|
||||||
geom_boxplot(outlier.alpha = F)+
|
geom_boxplot(outlier.alpha = F)+
|
||||||
geom_jitter(width=0.25, aes(color=sex))+
|
geom_jitter(width=0.25, aes(color=sex))+
|
||||||
geom_point(stat="summary", color="blue", size=3)+
|
geom_point(stat="summary", color="blue", size=3)+
|
||||||
@@ -249,7 +287,7 @@ server <- function(input, output) {
|
|||||||
ggplot(df_def, aes(sex, Volume))+
|
ggplot(df_def, aes(sex, Volume))+
|
||||||
geom_boxplot(outlier.alpha = F)+
|
geom_boxplot(outlier.alpha = F)+
|
||||||
geom_quasirandom(width=0.3),
|
geom_quasirandom(width=0.3),
|
||||||
ggplot(df_def, aes(group, fill=sex))+
|
ggplot(df_def, aes(Group, fill=sex))+
|
||||||
geom_bar(stat="count", color="black", position="dodge")+
|
geom_bar(stat="count", color="black", position="dodge")+
|
||||||
guides(fill="none")+
|
guides(fill="none")+
|
||||||
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5)), ncol = 1, heights = c(0.35, 0.65)),
|
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5)), ncol = 1, heights = c(0.35, 0.65)),
|
||||||
@@ -269,8 +307,8 @@ server <- function(input, output) {
|
|||||||
observeEvent(dades$db, {})
|
observeEvent(dades$db, {})
|
||||||
if (!is.null(dades$db)){
|
if (!is.null(dades$db)){
|
||||||
df<-dades$db
|
df<-dades$db
|
||||||
df_sum<-dcast(df, group~., value.var = "Volume", fun.aggregate = mean, na.rm=T) %>% rename("Mean"=".")
|
df_sum<-dcast(df, Group~., value.var = "Volume", fun.aggregate = mean, na.rm=T) %>% rename("Mean"=".")
|
||||||
df_sum["SEM"]<-dcast(df, group~., value.var = "Volume", fun.aggregate = std.error, na.rm=T) %>% pull(`.`)
|
df_sum["SEM"]<-dcast(df, Group~., value.var = "Volume", fun.aggregate = std.error, na.rm=T) %>% pull(`.`)
|
||||||
df_sum
|
df_sum
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -278,7 +316,7 @@ server <- function(input, output) {
|
|||||||
observeEvent(dades$db, {})
|
observeEvent(dades$db, {})
|
||||||
if (!is.null(dades$db)){
|
if (!is.null(dades$db)){
|
||||||
df<-dades$db
|
df<-dades$db
|
||||||
df %>% arrange(group)
|
df %>% arrange(Group)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -294,31 +332,15 @@ server <- function(input, output) {
|
|||||||
# timepoint<-c(7,10,13,16,19,22,25)
|
# timepoint<-c(7,10,13,16,19,22,25)
|
||||||
|
|
||||||
if (!is.null(input$file_sizes)){
|
if (!is.null(input$file_sizes)){
|
||||||
# dtemplate<-dades$db %>% select(-Volume,-sex)
|
template<-dades$db %>%
|
||||||
# dtemplate<-melt(dtemplate, id=c("Cage", "ID animal", "ID tumor", "group"), variable.name = "DPV", value.name = "0") %>% rename("Group"="group")
|
select(Animal, Group) %>% unique()
|
||||||
# dtemplate<-dtemplate[,c("Cage", "ID animal", "ID tumor", "Group", "DPV", "0")] %>% arrange(`ID animal`, `ID tumor`)
|
dtemplate<-merge(dades$taula %>% select(-Group), template) %>%
|
||||||
# template<-expand.grid(dades$db$MouseID, timepoint)
|
arrange(DayPostInoc, Animal, Side) %>%
|
||||||
# colnames(template)<-c("MouseID", "Timepoint")
|
select(Animal, Date, DayPostInoc, Group, Side,
|
||||||
# template<-template[order(template$Timepoint, template$MouseID),]
|
Weight, Long, Wide, Volume, Observations)
|
||||||
# template<-merge(template, dades$db[c("MouseID", "group")])
|
if ("Abs" %in% colnames(read.xlsx(input$file_sizes$datapath, sheet = 1, check.names = F, sep.names = " ", detectDates = T,cols=1:11))){
|
||||||
# if (input$measure_sys == "L-W-D"){
|
dtemplate<-rename(dtemplate, "Abs"="Volume")
|
||||||
# template<-rbind(template, template, template)
|
}
|
||||||
# template<-template[order(template$Timepoint, template$MouseID),]
|
|
||||||
# template["TS"]<-rep(c("TS-Length", "TS-Width", "TS-Deep"), nrow(template)/3)
|
|
||||||
# dtemplate<-dcast(template, MouseID+group+TS~Timepoint)
|
|
||||||
# dtemplate<-dtemplate[mixedorder(as.character(dtemplate$MouseID)),]
|
|
||||||
# }
|
|
||||||
# if (input$measure_sys == "Min-Max"){
|
|
||||||
# template<-rbind(template, template)
|
|
||||||
# template<-template[order(template$Timepoint, template$MouseID),]
|
|
||||||
# template["DPV"]<-rep(c("Major", "Minor"), nrow(template)/2)
|
|
||||||
# dtemplate<-dcast(template, MouseID+group+DPV~Timepoint)
|
|
||||||
# dtemplate<-dtemplate[mixedorder(as.character(dtemplate$MouseID)),]
|
|
||||||
# }
|
|
||||||
# dtemplate<-dtemplate %>% add_column(.after="MouseID", "ID tumor"=dtemplate$MouseID)%>% rename(`ID animal`=MouseID)
|
|
||||||
# dtemplate["ID tumor"]<-gsub("[[:digit:]]","",dtemplate$`ID tumor`)
|
|
||||||
# dtemplate["ID animal"]<-gsub("[LR]","",dtemplate$`ID animal`)
|
|
||||||
# dtemplate[,5:ncol(dtemplate)]<-""
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
template<-data.frame(
|
template<-data.frame(
|
||||||
@@ -334,36 +356,87 @@ server <- function(input, output) {
|
|||||||
Volume="",
|
Volume="",
|
||||||
Observations=""
|
Observations=""
|
||||||
)
|
)
|
||||||
|
template<-template %>% mutate(Animal=paste0(Cage,Animal)) %>% select(-Cage)
|
||||||
dtemplate<-template
|
dtemplate<-template
|
||||||
}
|
}
|
||||||
write.xlsx(list("Measures"=dtemplate, "Groups"=NULL,"Sex"=NULL), file)
|
write.xlsx(list("Measures"=dtemplate, "Groups"=NULL,"Sex"=NULL), file)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Análisis
|
|
||||||
|
# Análisis ----------------------------------------------------------------
|
||||||
|
|
||||||
analysis<-reactiveValues()
|
analysis<-reactiveValues()
|
||||||
analysis$taula<-NULL
|
analysis$taula<-NULL
|
||||||
analysis$taula_def<-NULL
|
analysis$taula_def<-NULL
|
||||||
analysis$taula_vol<-NULL
|
analysis$taula_vol<-NULL
|
||||||
observe({
|
observe({
|
||||||
if (!is.null(input$file_analy)){
|
if (!is.null(input$file_analy)){
|
||||||
table<-read.xlsx(input$file_analy$datapath, sheet = 1, check.names = F, sep.names = " ")
|
table<-read.xlsx(input$file_analy$datapath, sheet = 1, check.names = F, sep.names = " ", detectDates = T,cols=1:11)
|
||||||
|
if("ID.animal" %in% colnames(table)){
|
||||||
|
table<-table %>%
|
||||||
|
rename(Animal=`ID.animal`, Side=`ID.tumor`)
|
||||||
|
table<-table %>% gather(DayPostInoc, Value, which(!is.na(as.numeric(colnames(table))))) %>%
|
||||||
|
relocate(DayPostInoc, .before = Group) %>% spread(DPV, Value) %>%
|
||||||
|
rename(Long=Major, Wide=Minor) %>%
|
||||||
|
add_column(Date="", .after = "Animal") %>%
|
||||||
|
add_column(Weight="", .after="Group") %>%
|
||||||
|
add_column(Volume="",Observations="") %>%
|
||||||
|
relocate(Side, .after = "Group")
|
||||||
|
table$DayPostInoc<-as.numeric(table$DayPostInoc)
|
||||||
|
}
|
||||||
|
table$Date<-format(table$Date, format="%d/%m/%Y")
|
||||||
if ("sex" %in% colnames(table)){table<-select(table, -sex)}
|
if ("sex" %in% colnames(table)){table<-select(table, -sex)}
|
||||||
table$Long<-gsub(",",".", table$Long)
|
|
||||||
table$Wide<-gsub(",",".", table$Wide)
|
|
||||||
for (i in 1:nrow(table)){
|
for (i in 1:nrow(table)){
|
||||||
long<-as.numeric(strsplit(table[i,"Long"],"+", fixed = T)[[1]])
|
long<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Long"]),"+", fixed = T)[[1]]))
|
||||||
wide<-as.numeric(strsplit(table[i,"Wide"],"+", fixed = T)[[1]])
|
wide<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Wide"]),"+", fixed = T)[[1]]))
|
||||||
table[i,"Volume"]<-sum(sapply(1:length(long), function(x) (long[x]*wide[x]*wide[x])*(pi/6)))
|
table[i,"Volume"]<-sum(sapply(1:length(long), function(x) (long[x]*wide[x]*wide[x])*(pi/6)))
|
||||||
}
|
}
|
||||||
|
table$Volume<-as.numeric(table$Volume)
|
||||||
|
if ("Cage" %in% colnames(table)){
|
||||||
|
table$Animal<-paste0(table$Cage, table$Animal)
|
||||||
|
table<-table[,-which(colnames(table) == "Cage")]
|
||||||
|
}
|
||||||
|
|
||||||
|
## Autocompletado de grupo
|
||||||
|
table_group<-merge(
|
||||||
|
table %>% select(Animal, Group) %>% unique() %>% group_by(Animal) %>% count(),
|
||||||
|
table %>% select(Animal, Group) %>% unique()
|
||||||
|
) %>% filter(!is.na(Group) | Group != "") %>% select(-n)
|
||||||
|
|
||||||
|
table<-merge(
|
||||||
|
table %>% select(-Group),
|
||||||
|
table_group
|
||||||
|
) %>% relocate(Group, .after = DayPostInoc) %>%
|
||||||
|
arrange(DayPostInoc, Animal, Side)
|
||||||
|
|
||||||
|
if("Groups" %in% readxl::excel_sheets(input$file_analy$datapath)){
|
||||||
|
levels<-read.xlsx(input$file_analy$datapath, sheet = "Groups", colNames=F)[,1]
|
||||||
|
table$Group<-factor(table$Group, levels=levels)
|
||||||
|
table<-filter(table, !is.na(Group))
|
||||||
|
}else(table$Group<-factor(table$Group))
|
||||||
|
|
||||||
|
|
||||||
|
if (input$increase_volume){
|
||||||
|
cols<-colnames(table)
|
||||||
|
timepoints<-unique(table$DayPostInoc)
|
||||||
|
table_old<-select(table, -Volume)
|
||||||
|
table_vols<-table %>%
|
||||||
|
select(-Weight, -Date, -Long, -Wide,-Observations) %>%
|
||||||
|
spread(DayPostInoc, Volume) %>%
|
||||||
|
mutate(across(all_of(as.character(timepoints)), function(x){(x*100/`0`)-100})) %>%
|
||||||
|
gather(DayPostInoc, Volume, all_of(as.character(timepoints))) %>%
|
||||||
|
mutate(Volume=case_when(Volume < 0 ~ 0, T~Volume))
|
||||||
|
table<-merge(table_old, table_vols)[,cols]
|
||||||
|
}
|
||||||
|
|
||||||
analysis$taula<-table
|
analysis$taula<-table
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
output$cutoffUI<-renderUI({
|
output$cutoffUI<-renderUI({
|
||||||
if (!is.null(analysis$taula_def)){
|
if (!is.null(analysis$taula)){
|
||||||
observeEvent(analysis$taula_def, {})
|
observeEvent(analysis$taula, {})
|
||||||
max_val<-max(analysis$taula_def$Volume, na.rm = T)
|
max_val<-max(analysis$taula$Volume, na.rm = T)
|
||||||
# print(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)
|
sliderInput("cutoff", "Cutoff para Survival", min=0, max=round(max_val, digits=2), step=round(max_val, digits=2)/200, value=max_val)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -375,17 +448,10 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
table<-analysis$taula
|
table<-analysis$taula
|
||||||
table<-table %>% filter(!is.na(Group))
|
table<-table %>% filter(!is.na(Group))
|
||||||
if (input$increase_volume){
|
|
||||||
timepoints<-unique(table$Timepoint)
|
|
||||||
table<-table %>% select(-Major, -Minor) %>%
|
|
||||||
spread(Timepoint, Volume) %>%
|
|
||||||
mutate(across(all_of(timepoints), function(x){(x*100/`0`)-100})) %>%
|
|
||||||
gather(Timepoint, Volume, -Cage, -`ID animal`, -`ID tumor`, -Group) %>%
|
|
||||||
mutate(Volume=case_when(Volume < 0 ~ 0, T~Volume))
|
|
||||||
}
|
|
||||||
table %>% group_by(Group, DayPostInoc, Side) %>% count() %>% spread(DayPostInoc, n)
|
table %>% group_by(Group, DayPostInoc, Side) %>% count() %>% spread(DayPostInoc, n)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
output$cin_group<-renderPlot({
|
output$cin_group<-renderPlot({
|
||||||
if (!is.null(input$file_analy) & !is.null(analysis$taula)){
|
if (!is.null(input$file_analy) & !is.null(analysis$taula)){
|
||||||
observeEvent(analysis$taula, {})
|
observeEvent(analysis$taula, {})
|
||||||
@@ -395,7 +461,6 @@ server <- function(input, output) {
|
|||||||
sides<-unique(table$Side)
|
sides<-unique(table$Side)
|
||||||
groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group)
|
groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group)
|
||||||
basal<-data.frame(
|
basal<-data.frame(
|
||||||
Cage="",
|
|
||||||
Animal=rep(animals, each=length(sides)),
|
Animal=rep(animals, each=length(sides)),
|
||||||
Date="",
|
Date="",
|
||||||
DayPostInoc=0,
|
DayPostInoc=0,
|
||||||
@@ -407,8 +472,27 @@ server <- function(input, output) {
|
|||||||
Volume=0,
|
Volume=0,
|
||||||
Observations=""
|
Observations=""
|
||||||
)
|
)
|
||||||
table<-rbind(table, basal)
|
if (!(0 %in% table$DayPostInoc) | sum(table[table$DayPostInoc == 0,"Volume"],na.rm = T) == 0){
|
||||||
|
table<-rbind(table, basal)
|
||||||
|
}
|
||||||
|
|
||||||
if (input$vacc == "Sí"){
|
if (input$vacc == "Sí"){
|
||||||
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
|
select(DayPostInoc, Side) %>% unique() %>%
|
||||||
|
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
|
||||||
|
if (input$operated == TRUE & nrow(firstoper) > 0){
|
||||||
|
for (i in 1:nrow(firstoper)){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+
|
ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+
|
||||||
geom_errorbar(stat="summary", width=0.05)+
|
geom_errorbar(stat="summary", width=0.05)+
|
||||||
geom_line(stat="summary")+
|
geom_line(stat="summary")+
|
||||||
@@ -417,8 +501,23 @@ server <- function(input, output) {
|
|||||||
labs(x="Days after tumor inoculation")+
|
labs(x="Days after tumor inoculation")+
|
||||||
scale_y_continuous(expand = expansion(mult = c(0,0.05)))+
|
scale_y_continuous(expand = expansion(mult = c(0,0.05)))+
|
||||||
scale_x_continuous(expand = expansion(mult = c(0,0.05)), limits = c(0, (round(max(table$DayPostInoc) / 5)+1)*5))+
|
scale_x_continuous(expand = expansion(mult = c(0,0.05)), limits = c(0, (round(max(table$DayPostInoc) / 5)+1)*5))+
|
||||||
theme_bw()
|
theme_bw()
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
|
pull(DayPostInoc) %>% min(na.rm = T)
|
||||||
|
if (firstoper == Inf){firstoper<-c()}
|
||||||
|
|
||||||
|
if (input$operated == TRUE & length(firstoper) > 0){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper)
|
||||||
|
}else{
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+
|
ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+
|
||||||
geom_errorbar(stat="summary",width=0.05)+
|
geom_errorbar(stat="summary",width=0.05)+
|
||||||
geom_line(stat="summary")+
|
geom_line(stat="summary")+
|
||||||
@@ -440,7 +539,6 @@ server <- function(input, output) {
|
|||||||
sides<-unique(table$Side)
|
sides<-unique(table$Side)
|
||||||
groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group)
|
groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group)
|
||||||
basal<-data.frame(
|
basal<-data.frame(
|
||||||
Cage="",
|
|
||||||
Animal=rep(animals, each=length(sides)),
|
Animal=rep(animals, each=length(sides)),
|
||||||
Date="",
|
Date="",
|
||||||
DayPostInoc=0,
|
DayPostInoc=0,
|
||||||
@@ -452,9 +550,25 @@ server <- function(input, output) {
|
|||||||
Volume=0,
|
Volume=0,
|
||||||
Observations=""
|
Observations=""
|
||||||
)
|
)
|
||||||
table<-rbind(table, basal)
|
if (!(0 %in% table$DayPostInoc) | sum(table[table$DayPostInoc == 0,"Volume"],na.rm = T) == 0){
|
||||||
|
table<-rbind(table, basal)
|
||||||
|
}
|
||||||
|
|
||||||
if (input$vacc == "Sí"){
|
if (input$vacc == "Sí"){
|
||||||
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
|
select(DayPostInoc, Side) %>% unique() %>%
|
||||||
|
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
|
||||||
|
if (input$operated == TRUE & nrow(firstoper) > 0){
|
||||||
|
for (i in 1:nrow(firstoper)){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Animal))+
|
ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Animal))+
|
||||||
# geom_errorbar(stat="summary", width=0.05)+
|
# geom_errorbar(stat="summary", width=0.05)+
|
||||||
geom_line()+
|
geom_line()+
|
||||||
@@ -465,6 +579,19 @@ server <- function(input, output) {
|
|||||||
labs(x="Days after tumor inoculation")+
|
labs(x="Days after tumor inoculation")+
|
||||||
theme_bw()
|
theme_bw()
|
||||||
}else{
|
}else{
|
||||||
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
|
pull(DayPostInoc) %>% min(na.rm = T)
|
||||||
|
if (firstoper == Inf){firstoper<-c()}
|
||||||
|
|
||||||
|
if (input$operated == TRUE & length(firstoper) > 0){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper)
|
||||||
|
}else{
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
ggplot(table, aes(DayPostInoc, Volume, color=Group, group=paste0(Animal, Side)))+
|
ggplot(table, aes(DayPostInoc, Volume, color=Group, group=paste0(Animal, Side)))+
|
||||||
# geom_errorbar(stat="summary", width=0.05)+
|
# geom_errorbar(stat="summary", width=0.05)+
|
||||||
geom_line()+
|
geom_line()+
|
||||||
@@ -480,18 +607,33 @@ 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í"){
|
||||||
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
|
select(DayPostInoc, Side) %>% unique() %>%
|
||||||
|
if (firstoper == Inf){firstoper<-c()}
|
||||||
|
|
||||||
|
if (input$operated == TRUE & length(firstoper) > 0){
|
||||||
|
for (i in 1:nrow(firstoper)){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
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), 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, 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(end, 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"),
|
# legend.labs = paste(c("< median", ">= median"), "MICA"),
|
||||||
@@ -510,13 +652,27 @@ server <- function(input, output) {
|
|||||||
do.call(grid.arrange, g)
|
do.call(grid.arrange, g)
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
|
pull(DayPostInoc) %>% min(na.rm = T)
|
||||||
|
if (firstoper == Inf){firstoper<-c()}
|
||||||
|
|
||||||
|
if (input$operated == TRUE & length(firstoper) > 0){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper)
|
||||||
|
}else{
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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(end, Dead) ~ Group, data=table_tumor),
|
||||||
pval = T, pval.method = T,
|
pval = T, pval.method = T,
|
||||||
# legend.labs = paste(c("< median", ">= median"), "MICA"),
|
# legend.labs = paste(c("< median", ">= median"), "MICA"),
|
||||||
ggtheme=theme_classic(base_size=15)
|
ggtheme=theme_classic(base_size=15)
|
||||||
@@ -530,19 +686,16 @@ 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(summary(aov(Volume~Group+Timepoint+Error(paste0(ID animal,Cage)), data=tableR)))
|
|
||||||
print(summary(aov(Volume~Group+Timepoint+Error(`ID animal`), data=tableR)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -551,42 +704,42 @@ server <- function(input, output) {
|
|||||||
output$tab_stats<-renderTable({
|
output$tab_stats<-renderTable({
|
||||||
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)){
|
||||||
table<-analysis$taula_def
|
table<-analysis$taula
|
||||||
table_stats<-list()
|
table_stats<-list()
|
||||||
if (input$vacc == "No"){
|
if (input$vacc == "No"){
|
||||||
table<-table%>%filter(!is.na(Volume))
|
table<-table%>%filter(!is.na(Volume))
|
||||||
if (length(unique(table$Volume)) > 1){
|
if (length(unique(table$Volume)) > 1){
|
||||||
table_stats<-multi_stats(table, "Volume", "Timepoint", "Group", stat.test=stattest)
|
table_stats<-multi_stats(table, "Volume", "DayPostInoc", "Group", stat.test=stattest)
|
||||||
}
|
}
|
||||||
table_kw<-as.data.frame(matrix(nrow=0, ncol=2))
|
table_kw<-as.data.frame(matrix(nrow=0, ncol=2))
|
||||||
for (point in unique(table$Timepoint)){
|
for (point in unique(table$DayPostInoc)){
|
||||||
len_group<-length(unique(table %>% filter(Timepoint == point) %>% pull(Group)))
|
len_group<-length(unique(table %>% filter(DayPostInoc == point) %>% pull(Group)))
|
||||||
if (len_group > 1){
|
if (len_group > 1){
|
||||||
table_kw<-rbind(table_kw, data.frame(point,kruskal.test(table %>% filter(Timepoint == point) %>% pull(Volume), table %>% filter(Timepoint == point) %>% pull(Group))[3][[1]]))
|
table_kw<-rbind(table_kw, data.frame(point,kruskal.test(table %>% filter(DayPostInoc == point) %>% pull(Volume), table %>% filter(DayPostInoc == point) %>% pull(Group))[3][[1]]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
colnames(table_kw)<-c("Timepoint", "KW-p.val")
|
colnames(table_kw)<-c("DayPostInoc", "KW-p.val")
|
||||||
table_stats<-merge(table_stats, table_kw)
|
table_stats<-merge(table_stats, table_kw)
|
||||||
|
|
||||||
}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){
|
if (length(unique(tableR$Volume)) > 1){
|
||||||
table_stats[[side]]<-multi_stats(tableR, "Volume", "Timepoint", "Group", stat.test=stattest)
|
table_stats[[side]]<-multi_stats(tableR, "Volume", "DayPostInoc", "Group", stat.test=stattest)
|
||||||
}
|
}
|
||||||
table_kw<-as.data.frame(matrix(nrow=0, ncol=2))
|
table_kw<-as.data.frame(matrix(nrow=0, ncol=2))
|
||||||
for (point in unique(tableR$Timepoint)){
|
for (point in unique(tableR$DayPostInoc)){
|
||||||
len_group<-length(unique(tableR %>% filter(Timepoint == point) %>% pull(Group)))
|
len_group<-length(unique(tableR %>% filter(DayPostInoc == point) %>% pull(Group)))
|
||||||
if (len_group > 1){
|
if (len_group > 1){
|
||||||
table_kw<-rbind(table_kw, data.frame(point,kruskal.test(tableR %>% filter(Timepoint == point) %>% pull(Volume), tableR %>% filter(Timepoint == point) %>% pull(Group))[3][[1]]))
|
table_kw<-rbind(table_kw, data.frame(point,kruskal.test(tableR %>% filter(DayPostInoc == point) %>% pull(Volume), tableR %>% filter(DayPostInoc == point) %>% pull(Group))[3][[1]]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
colnames(table_kw)<-c("Timepoint", "KW-p.val")
|
colnames(table_kw)<-c("DayPostInoc", "KW-p.val")
|
||||||
table_stats[[side]]<-merge(table_stats[[side]], table_kw)
|
table_stats[[side]]<-merge(table_stats[[side]], table_kw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table_stats_def<-bind_rows(table_stats, .id = "ID tumor")
|
table_stats_def<-bind_rows(table_stats, .id = "Side")
|
||||||
if (input$filter_stats == T){
|
if (input$filter_stats == T){
|
||||||
table_stats_def %>% filter(p.adj < 0.05)
|
table_stats_def %>% filter(p.adj < 0.05)
|
||||||
}else{
|
}else{
|
||||||
@@ -602,54 +755,107 @@ server <- function(input, output) {
|
|||||||
},
|
},
|
||||||
content = function(file){
|
content = function(file){
|
||||||
dtemplate<-analysis$taula
|
dtemplate<-analysis$taula
|
||||||
write.xlsx(dtemplate,file)
|
write.xlsx(dtemplate,file, )
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
##Exportar
|
|
||||||
|
# Exportar ----------------------------------------------------------------
|
||||||
|
|
||||||
output$expPlotUI<- renderUI({
|
output$expPlotUI<- renderUI({
|
||||||
observeEvent(analysis$taula_def, {})
|
observeEvent(analysis$taula, {})
|
||||||
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
|
if (!is.null(input$file_analy) & !is.null(analysis$taula)){
|
||||||
plotOutput("expPlot", width=paste0(input$width/10,"px"), height = paste0(input$height/10, "px"))
|
plotOutput("expPlot", width=paste0(input$width/10,"px"), height = paste0(input$height/10, "px"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
output$expPlot <- renderPlot({
|
output$expPlot <- renderPlot({
|
||||||
observeEvent(analysis$taula_def, {})
|
observeEvent(analysis$taula, {})
|
||||||
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
|
if (!is.null(input$file_analy) & !is.null(analysis$taula)){
|
||||||
table<-analysis$taula_def
|
table<-analysis$taula
|
||||||
|
table$Volume<-table$Volume*as.numeric(input$unit_fact)
|
||||||
|
animals<-unique(table$Animal)
|
||||||
|
sides<-unique(table$Side)
|
||||||
|
groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group)
|
||||||
|
basal<-data.frame(
|
||||||
|
Animal=rep(animals, each=length(sides)),
|
||||||
|
Date="",
|
||||||
|
DayPostInoc=0,
|
||||||
|
Group=rep(groups, each=length(sides)),
|
||||||
|
Side=rep(sides, length(animals)),
|
||||||
|
Weight="",
|
||||||
|
Long="",
|
||||||
|
Wide="",
|
||||||
|
Volume=0,
|
||||||
|
Observations=""
|
||||||
|
)
|
||||||
|
if (!(0 %in% table$DayPostInoc) | sum(table[table$DayPostInoc == 0,"Volume"],na.rm = T) == 0){
|
||||||
|
table<-rbind(table, basal)
|
||||||
|
}
|
||||||
if (input$fig_id %in% c("Cinética Grupo", "Cinética Individual")){
|
if (input$fig_id %in% c("Cinética Grupo", "Cinética Individual")){
|
||||||
if (input$fig_id == "Cinética Grupo"){
|
if (input$fig_id == "Cinética Grupo"){
|
||||||
if (input$vacc == "Sí"){
|
if (input$vacc == "Sí"){
|
||||||
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
|
select(DayPostInoc, Side) %>% unique() %>%
|
||||||
|
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
|
||||||
|
|
||||||
|
if (input$operated == TRUE){
|
||||||
|
for (i in 1:nrow(firstoper)){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
std<-function(x, na.rm=T){sd(x, na.rm=na.rm)/sqrt(length(x))}
|
std<-function(x, na.rm=T){sd(x, na.rm=na.rm)/sqrt(length(x))}
|
||||||
errbar<-table %>% group_by(Group,`ID tumor`, Timepoint) %>%
|
errbar<-table %>% group_by(Group,Side,DayPostInoc) %>%
|
||||||
summarise(mean=mean(Volume, na.rm=T), std=std(Volume)) %>%
|
summarise(mean=mean(Volume, na.rm=T), std=std(Volume)) %>%
|
||||||
mutate(Timepoint2=as.numeric(as.character(Timepoint))) %>%
|
mutate(Timepoint2=as.numeric(as.character(DayPostInoc))) %>%
|
||||||
mutate(x=Timepoint2-input$`errorbar-width`, xend=Timepoint2+input$`errorbar-width`)
|
mutate(x=Timepoint2-input$`errorbar-width`, xend=Timepoint2+input$`errorbar-width`)
|
||||||
|
|
||||||
g<-ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=Group))+
|
g<-ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+
|
||||||
scale_x_continuous(expand = expansion(mult = c(0,0.0)),
|
geom_errorbar(stat="summary", width=0.05)+
|
||||||
breaks=sort(unique(errbar$Timepoint2)),
|
geom_line(stat="summary")+
|
||||||
limits = c(0,max(as.numeric(as.character(table$Timepoint)))*1.1))+
|
geom_point(stat="summary")+
|
||||||
facet_grid(factor(`ID tumor`, labels = c("Vaccination", "Rechallenge"))~., scale="free_y")+
|
facet_grid(factor(Side, labels = c("Vaccination", "Rechallenge"))~., scale="free_y")+
|
||||||
|
labs(x="Days after tumor inoculation")+
|
||||||
|
scale_y_continuous(expand = expansion(mult = c(0,0.05)))+
|
||||||
|
scale_x_continuous(expand = expansion(mult = c(0,0.05)), limits = c(0, (round(max(table$DayPostInoc) / 5)+1)*5))+
|
||||||
theme_bw()+
|
theme_bw()+
|
||||||
geom_segment(data=errbar, aes(y=mean, yend=mean+std, x=Timepoint2, xend=Timepoint2))+
|
geom_segment(data=errbar, aes(y=mean, yend=mean+std, x=Timepoint2, xend=Timepoint2))+
|
||||||
geom_segment(data=errbar, aes(y=mean+std, yend=mean+std,
|
geom_segment(data=errbar, aes(y=mean+std, yend=mean+std,
|
||||||
x=x,xend=xend))
|
x=x,xend=xend))
|
||||||
}else{
|
}else{
|
||||||
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
|
pull(DayPostInoc) %>% min(na.rm = T)
|
||||||
|
|
||||||
|
if (input$operated == TRUE){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper)
|
||||||
|
}else{
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std<-function(x, na.rm=T){sd(x, na.rm=na.rm)/sqrt(length(x))}
|
std<-function(x, na.rm=T){sd(x, na.rm=na.rm)/sqrt(length(x))}
|
||||||
errbar<-table %>% group_by(Group, Timepoint) %>%
|
errbar<-table %>% group_by(Group, DayPostInoc) %>%
|
||||||
summarise(mean=mean(Volume, na.rm=T), std=std(Volume)) %>%
|
summarise(mean=mean(Volume, na.rm=T), std=std(Volume)) %>%
|
||||||
mutate(Timepoint2=as.numeric(as.character(Timepoint))) %>%
|
mutate(Timepoint2=as.numeric(as.character(DayPostInoc))) %>%
|
||||||
mutate(x=Timepoint2-input$`errorbar-width`, xend=Timepoint2+input$`errorbar-width`)
|
mutate(x=Timepoint2-input$`errorbar-width`, xend=Timepoint2+input$`errorbar-width`)
|
||||||
|
|
||||||
g<-ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=Group))+
|
g<-ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+
|
||||||
scale_x_continuous(expand = expansion(mult = c(0,0.0)),
|
geom_errorbar(stat="summary",width=0.05)+
|
||||||
breaks=sort(unique(errbar$Timepoint2)),
|
geom_line(stat="summary")+
|
||||||
limits = c(0,max(as.numeric(as.character(table$Timepoint)))*1.1))+
|
geom_point(stat="summary")+
|
||||||
# limits = c(0, (round(max(as.numeric(as.character(table$Timepoint))) / 5)+1)*5))+
|
labs(x="Days after tumor challenge")+
|
||||||
|
scale_y_continuous(expand = expansion(mult = c(0,0.05)))+
|
||||||
theme_bw()+
|
theme_bw()+
|
||||||
|
theme(axis.text.x=element_text(angle=45, hjust=1))+
|
||||||
geom_segment(data=errbar, aes(y=mean, yend=mean+std, x=Timepoint2, xend=Timepoint2))+
|
geom_segment(data=errbar, aes(y=mean, yend=mean+std, x=Timepoint2, xend=Timepoint2))+
|
||||||
geom_segment(data=errbar, aes(y=mean+std, yend=mean+std,
|
geom_segment(data=errbar, aes(y=mean+std, yend=mean+std,
|
||||||
x=x,xend=xend))
|
x=x,xend=xend))
|
||||||
@@ -657,17 +863,46 @@ server <- function(input, output) {
|
|||||||
}
|
}
|
||||||
if (input$fig_id == "Cinética Individual"){
|
if (input$fig_id == "Cinética Individual"){
|
||||||
if (input$vacc == "Sí"){
|
if (input$vacc == "Sí"){
|
||||||
g<-ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=`ID animal`))+
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
scale_x_continuous(expand = expansion(mult = c(0,0.0)),
|
select(DayPostInoc, Side) %>% unique() %>%
|
||||||
breaks=sort(unique(as.numeric(as.character(table$Timepoint)))),
|
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
|
||||||
limits = c(0, (round(max(as.numeric(as.character(table$Timepoint))) / 5)+1)*5))+
|
|
||||||
facet_grid(factor(`ID tumor`, labels = c("Vaccination", "Rechallenge"))~Group, scale="free_y")+
|
if (input$operated == TRUE){
|
||||||
theme_bw()
|
for (i in 1:nrow(firstoper)){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g<-ggplot(table, aes(as.numeric(as.character(DayPostInoc)), Volume, color=Group, group=Animal))+
|
||||||
|
scale_x_continuous(expand = expansion(mult = c(0,0.0)),
|
||||||
|
breaks=sort(unique(as.numeric(as.character(table$DayPostInoc)))),
|
||||||
|
limits = c(0, (round(max(as.numeric(as.character(table$DayPostInoc))) / 5)+1)*5))+
|
||||||
|
facet_grid(factor(Side, labels = c("Vaccination", "Rechallenge"))~Group, scale="free_y")+
|
||||||
|
theme_bw()
|
||||||
}else{
|
}else{
|
||||||
g<-ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=`ID animal`))+
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
scale_x_continuous(expand = expansion(mult = c(0,0.0)),
|
pull(DayPostInoc) %>% min(na.rm = T)
|
||||||
breaks=sort(unique(as.numeric(as.character(table$Timepoint)))),
|
|
||||||
limits = c(0,max(as.numeric(as.character(table$Timepoint)))*1.1))+
|
if (input$operated == TRUE){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper)
|
||||||
|
}else{
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g<-ggplot(table, aes(as.numeric(as.character(DayPostInoc)), Volume, color=Group, group=paste0(Animal,Side)))+
|
||||||
|
scale_x_continuous(expand = expansion(mult = c(0,0.0)),
|
||||||
|
breaks=sort(unique(as.numeric(as.character(table$DayPostInoc)))),
|
||||||
|
limits = c(0,max(as.numeric(as.character(table$DayPostInoc)))*1.1))+
|
||||||
facet_wrap(.~Group)+
|
facet_wrap(.~Group)+
|
||||||
theme_bw()
|
theme_bw()
|
||||||
}
|
}
|
||||||
@@ -712,23 +947,38 @@ 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í"){
|
||||||
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
|
select(DayPostInoc, Side) %>% unique() %>%
|
||||||
|
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
|
||||||
|
if (input$operated == TRUE){
|
||||||
|
for (i in 1:nrow(firstoper)){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
g<-list()
|
g<-list()
|
||||||
count<-1
|
count<-1
|
||||||
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*as.numeric(input$unit_fact))), 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, 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(end, 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
|
||||||
)
|
)
|
||||||
@@ -737,19 +987,31 @@ server <- function(input, output) {
|
|||||||
g_surv_vacc<-g
|
g_surv_vacc<-g
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||||
|
pull(DayPostInoc) %>% min(na.rm = T)
|
||||||
|
|
||||||
|
if (input$operated == TRUE){
|
||||||
|
table<-table %>% filter(DayPostInoc < firstoper)
|
||||||
|
}else{
|
||||||
|
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||||
|
pull(Animal)
|
||||||
|
if(input$dead == TRUE){
|
||||||
|
table<-table %>% filter(!Animal %in% deadmice)
|
||||||
|
}
|
||||||
|
}
|
||||||
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<-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, `ID animal`+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") > input$cutoff
|
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(end, 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
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user