|
@ -127,6 +127,11 @@ server <- function(input, output) { |
|
|
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) |
|
|
table$Volume<-as.numeric(table$Volume) |
|
|
|
|
|
if ("Cage" %in% colnames(table)){ |
|
|
|
|
|
table$Animal<-paste0(table$Cage, table$Animal) |
|
|
|
|
|
table<-table[,-which(colnames(table) == "Cage")] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
dades$taula<-table |
|
|
dades$taula<-table |
|
|
dades$groups<-read.xlsx(input$file_sizes$datapath, sheet = "Groups", colNames=F)[,1] |
|
|
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){ |
|
@ -252,7 +257,7 @@ server <- function(input, output) { |
|
|
if(!is.null(dades$sex)){merge(dades$taula %>% filter(DayPostInoc == input$day_vol), dades$sex)}else{ |
|
|
if(!is.null(dades$sex)){merge(dades$taula %>% filter(DayPostInoc == input$day_vol), dades$sex)}else{ |
|
|
dades$taula %>% filter(DayPostInoc == input$day_vol) %>% add_column(sex="undefined")} %>% select(-Group), |
|
|
dades$taula %>% filter(DayPostInoc == input$day_vol) %>% add_column(sex="undefined")} %>% select(-Group), |
|
|
df_def[,c("Animal", "group")] %>% unique, all=T, by="Animal") %>% rename(Group=group) |
|
|
df_def[,c("Animal", "group")] %>% unique, all=T, by="Animal") %>% rename(Group=group) |
|
|
df_def<-select(df_def, Cage, Animal, Date, DayPostInoc, Group, Side, Weight, Long, Wide, Volume, Observations) |
|
|
|
|
|
|
|
|
df_def<-select(df_def, Animal, 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("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))} |
|
|
# 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))} |
|
|
|
|
|
|
|
@ -326,7 +331,7 @@ server <- function(input, output) { |
|
|
select(Animal, Group) %>% unique() |
|
|
select(Animal, Group) %>% unique() |
|
|
dtemplate<-merge(dades$taula %>% select(-Group), template) %>% |
|
|
dtemplate<-merge(dades$taula %>% select(-Group), template) %>% |
|
|
arrange(DayPostInoc, Animal, Side) %>% |
|
|
arrange(DayPostInoc, Animal, Side) %>% |
|
|
select(Cage, Animal, Date, DayPostInoc, Group, Side, |
|
|
|
|
|
|
|
|
select(Animal, Date, DayPostInoc, Group, Side, |
|
|
Weight, Long, Wide, Volume, Observations) |
|
|
Weight, Long, Wide, Volume, Observations) |
|
|
}else{ |
|
|
}else{ |
|
|
|
|
|
|
|
@ -343,6 +348,7 @@ 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) |
|
@ -379,7 +385,10 @@ server <- function(input, output) { |
|
|
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) |
|
|
table$Volume<-as.numeric(table$Volume) |
|
|
table$Animal<-paste0(table$Cage, table$Animal) |
|
|
|
|
|
|
|
|
if ("Cage" %in% colnames(table)){ |
|
|
|
|
|
table$Animal<-paste0(table$Cage, table$Animal) |
|
|
|
|
|
table<-table[,-which(colnames(table) == "Cage")] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
## Autocompletado de grupo |
|
|
## Autocompletado de grupo |
|
|
table_group<-merge( |
|
|
table_group<-merge( |
|
@ -391,7 +400,6 @@ server <- function(input, output) { |
|
|
table %>% select(-Group), |
|
|
table %>% select(-Group), |
|
|
table_group |
|
|
table_group |
|
|
) %>% relocate(Group, .after = DayPostInoc) %>% |
|
|
) %>% relocate(Group, .after = DayPostInoc) %>% |
|
|
relocate(Cage, .before = Animal) %>% |
|
|
|
|
|
arrange(DayPostInoc, Animal, Side) |
|
|
arrange(DayPostInoc, Animal, Side) |
|
|
|
|
|
|
|
|
if("Groups" %in% readxl::excel_sheets(input$file_analy$datapath)){ |
|
|
if("Groups" %in% readxl::excel_sheets(input$file_analy$datapath)){ |
|
@ -425,7 +433,7 @@ server <- function(input, output) { |
|
|
table<-table %>% select(-Major, -Minor) %>% |
|
|
table<-table %>% select(-Major, -Minor) %>% |
|
|
spread(Timepoint, Volume) %>% |
|
|
spread(Timepoint, Volume) %>% |
|
|
mutate(across(all_of(timepoints), function(x){(x*100/`0`)-100})) %>% |
|
|
mutate(across(all_of(timepoints), function(x){(x*100/`0`)-100})) %>% |
|
|
gather(Timepoint, Volume, -Cage, -`ID animal`, -`ID tumor`, -Group) %>% |
|
|
|
|
|
|
|
|
gather(Timepoint, Volume, -`ID animal`, -`ID tumor`, -Group) %>% |
|
|
mutate(Volume=case_when(Volume < 0 ~ 0, T~Volume)) |
|
|
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) |
|
@ -436,13 +444,11 @@ server <- function(input, output) { |
|
|
observeEvent(analysis$taula, {}) |
|
|
observeEvent(analysis$taula, {}) |
|
|
table<-analysis$taula |
|
|
table<-analysis$taula |
|
|
|
|
|
|
|
|
table$Animal<-paste0(table$Cage, table$Animal) |
|
|
|
|
|
print(table) |
|
|
print(table) |
|
|
animals<-unique(table$Animal) |
|
|
animals<-unique(table$Animal) |
|
|
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, |
|
@ -515,12 +521,10 @@ server <- function(input, output) { |
|
|
observeEvent(analysis$taula, {}) |
|
|
observeEvent(analysis$taula, {}) |
|
|
table<-analysis$taula |
|
|
table<-analysis$taula |
|
|
|
|
|
|
|
|
table$Animal<-paste0(table$Cage, table$Animal) |
|
|
|
|
|
animals<-unique(table$Animal) |
|
|
animals<-unique(table$Animal) |
|
|
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, |
|
@ -608,8 +612,8 @@ server <- function(input, output) { |
|
|
g<-list() |
|
|
g<-list() |
|
|
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), 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 |
|
|
table_tumor<<-endtime |
|
|
|
|
|
|
|
|
g[side]<-ggsurvplot(survfit(Surv(end, Dead) ~ Group, data=table_tumor), |
|
|
g[side]<-ggsurvplot(survfit(Surv(end, Dead) ~ Group, data=table_tumor), |
|
@ -676,7 +680,6 @@ server <- function(input, output) { |
|
|
tableR<-filter(table, Side == side) %>% filter(!is.na(Volume)) |
|
|
tableR<-filter(table, Side == side) %>% filter(!is.na(Volume)) |
|
|
if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$DayPostInoc)) > 1){ |
|
|
if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$DayPostInoc)) > 1){ |
|
|
print(paste0("Side: ",side)) |
|
|
print(paste0("Side: ",side)) |
|
|
# print(summary(aov(Volume~Group+DayPostInoc+Error(paste0(Animal,Cage)), data=tableR))) |
|
|
|
|
|
print(summary(aov(Volume~Group+DayPostInoc+Error(Animal), data=tableR))) |
|
|
print(summary(aov(Volume~Group+DayPostInoc+Error(Animal), data=tableR))) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -761,7 +764,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, |
|
@ -951,8 +953,8 @@ server <- function(input, output) { |
|
|
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*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)) |
|
|
|
|
|
|
|
|
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, 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<-strsplit(input$colors, ",")[[1]] |
|
|
col<-strsplit(input$colors, ",")[[1]] |
|
|