"Añadir análisis no vacunación"
This commit is contained in:
+65
-19
@@ -213,7 +213,7 @@ server <- function(input, output) {
|
|||||||
analysis$taula_def<-NULL
|
analysis$taula_def<-NULL
|
||||||
observe({
|
observe({
|
||||||
if (!is.null(input$file_analy)){
|
if (!is.null(input$file_analy)){
|
||||||
analysis$taula<-read.xlsx(input$file_analy$datapath, sheet = 1)
|
analysis$taula<-read.xlsx(input$file_analy$datapath, sheet = 1, check.names = F, sep.names = " ")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
output$ntable<-renderTable({
|
output$ntable<-renderTable({
|
||||||
@@ -224,23 +224,28 @@ server <- function(input, output) {
|
|||||||
cutoff<-750
|
cutoff<-750
|
||||||
|
|
||||||
table<-analysis$taula
|
table<-analysis$taula
|
||||||
table<- table %>% add_column("0"=0, .before="12")
|
if ("ID.animal" %in% colnames(table)){table<-rename(table, "ID animal"=`ID.animal`)}
|
||||||
table[table$ID.tumor == "R","0"]<-NA
|
if ("ID" %in% colnames(table)){table<-rename(table, "ID animal"=ID)}
|
||||||
table<-melt(table, id=colnames(table)[1:6], variable.name = "Timepoint")
|
if ("ID.tumor" %in% colnames(table)){table<-rename(table, "ID tumor"=`ID.tumor`)}
|
||||||
|
# table[table$ID.tumor == "R","0"]<-NA
|
||||||
|
col_nodays<-c("ID", "Cage","Group", "ID.animal","ID animal", "ID.tumor", "ID tumor", "TS","DPV", "Absorbance")
|
||||||
|
table<-melt(table, id=colnames(table)[colnames(table) %in% col_nodays], variable.name = "Timepoint")
|
||||||
|
table$Timepoint<-gsub("[A-Za-z ]","",table$Timepoint)
|
||||||
|
table$Timepoint<-factor(table$Timepoint, levels=mixedsort(as.numeric(as.character(unique(table$Timepoint)))))
|
||||||
if ("DPV" %in% colnames(table)){
|
if ("DPV" %in% colnames(table)){
|
||||||
table<-dcast(table, Cage+ID.animal+ID.tumor+Group+Timepoint~DPV, value.var = "value")
|
table<-dcast(table, Cage+`ID animal`+`ID tumor`+Group+Timepoint~DPV, value.var = "value")
|
||||||
table$Major<-table$Major/1000
|
table$Major<-table$Major/1000
|
||||||
table$Minor<-table$Minor/1000
|
table$Minor<-table$Minor/1000
|
||||||
table["Volume"]<-((table$Major*table$Minor*table$Minor)*(pi/6))*1000
|
table["Volume"]<-((table$Major*table$Minor*table$Minor)*(pi/6))*1000
|
||||||
}
|
}
|
||||||
if ("TS" %in% colnames(table)){
|
if ("TS" %in% colnames(table)){
|
||||||
table<-dcast(table, Cage+ID.animal+ID.tumor+Group+Timepoint~TS, value.var = "value")
|
table<-dcast(table, Cage+`ID animal`+`ID tumor`+Group+Timepoint~TS, value.var = "value")
|
||||||
table["Volume"]<-table$`TS-Deep`*table$`TS-Length`*table$`TS-Width`*pi/6
|
table["Volume"]<-table$`TS-Deep`*table$`TS-Length`*table$`TS-Width`*pi/6
|
||||||
}
|
}
|
||||||
|
if (!"Volume" %in% colnames(table)){table<-rename(table, "Volume"=value)}
|
||||||
table<-table %>% filter(!is.na(Group))
|
table<-table %>% filter(!is.na(Group))
|
||||||
analysis$taula_def<-table
|
analysis$taula_def<-table
|
||||||
|
table_plot<-dcast(dcast(table %>% filter(!is.na(Volume)), `ID animal`+Group+Timepoint~., value.var = "Volume", fun.aggregate = mean), Group~Timepoint)
|
||||||
table_plot<-dcast(dcast(table %>% filter(!is.na(Volume)), Cage+`ID.animal`+Group+Timepoint~., value.var = "Volume", fun.aggregate = mean), Group~Timepoint)
|
|
||||||
table_plot
|
table_plot
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -248,30 +253,55 @@ server <- function(input, output) {
|
|||||||
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
|
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
|
||||||
observeEvent(analysis$taula_def, {})
|
observeEvent(analysis$taula_def, {})
|
||||||
table<-analysis$taula_def
|
table<-analysis$taula_def
|
||||||
|
if (input$vacc == "Sí"){
|
||||||
ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=Group))+
|
ggplot(table, aes(as.numeric(as.character(Timepoint)), 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")+
|
||||||
geom_point(stat="summary")+
|
geom_point(stat="summary")+
|
||||||
facet_grid(factor(ID.tumor, labels = c("Vaccination", "Rechallenge"))~., scale="free_y")+
|
facet_grid(factor(`ID tumor`, labels = c("Vaccination", "Rechallenge"))~., scale="free_y")+
|
||||||
labs(x="Days after tumor challenge")+
|
labs(x="Days after tumor challenge")+
|
||||||
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(as.numeric(as.character(table$Timepoint))) / 5)+1)*5))+
|
scale_x_continuous(expand = expansion(mult = c(0,0.05)), limits = c(0, (round(max(as.numeric(as.character(table$Timepoint))) / 5)+1)*5))+
|
||||||
theme_bw()
|
theme_bw()
|
||||||
|
}else{
|
||||||
|
ggplot(table, aes(Timepoint, Volume, color=Group, group=Group))+
|
||||||
|
geom_errorbar(stat="summary",width=0.05)+
|
||||||
|
geom_line(stat="summary")+
|
||||||
|
geom_point(stat="summary")+
|
||||||
|
labs(x="Days after tumor challenge")+
|
||||||
|
scale_y_continuous(expand = expansion(mult = c(0,0.05)))+
|
||||||
|
theme_bw()+
|
||||||
|
theme(axis.text.x=element_text(angle=45, hjust=1))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
output$cin_indiv<-renderPlot({
|
output$cin_indiv<-renderPlot({
|
||||||
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
|
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
|
||||||
observeEvent(analysis$taula_def, {})
|
observeEvent(analysis$taula_def, {})
|
||||||
table<-analysis$taula_def
|
table<-analysis$taula_def
|
||||||
ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=paste0(Cage,ID.animal)))+
|
if (input$vacc == "Sí"){
|
||||||
|
ggplot(table, aes(as.numeric(as.character(Timepoint)), Volume, color=Group, group=`ID animal`))+
|
||||||
# geom_errorbar(stat="summary", width=0.05)+
|
# geom_errorbar(stat="summary", width=0.05)+
|
||||||
geom_line()+
|
geom_line()+
|
||||||
geom_point()+
|
geom_point()+
|
||||||
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(as.numeric(as.character(table$Timepoint))) / 5)+1)*5))+
|
scale_x_continuous(expand = expansion(mult = c(0,0.05)), 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")+
|
facet_grid(factor(`ID tumor`, labels = c("Vaccination", "Rechallenge"))~Group, scale="free_y")+
|
||||||
labs(x="Days after tumor challenge")+
|
labs(x="Days after tumor challenge")+
|
||||||
theme_bw()
|
theme_bw()
|
||||||
|
}else{
|
||||||
|
ggplot(table, aes(Timepoint, Volume, color=Group, group=`ID animal`))+
|
||||||
|
# geom_errorbar(stat="summary", width=0.05)+
|
||||||
|
geom_line()+
|
||||||
|
geom_point()+
|
||||||
|
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(as.numeric(as.character(table$Timepoint))) / 5)+1)*5))+
|
||||||
|
facet_wrap(.~Group)+
|
||||||
|
labs(x="Days after tumor challenge")+
|
||||||
|
theme_bw()+
|
||||||
|
theme(axis.text.x=element_text(angle=45, hjust=1))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
output$stats<-renderPrint({
|
output$stats<-renderPrint({
|
||||||
@@ -281,16 +311,16 @@ server <- function(input, output) {
|
|||||||
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
|
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
|
||||||
observeEvent(analysis$taula_def, {})
|
observeEvent(analysis$taula_def, {})
|
||||||
table<-analysis$taula_def
|
table<-analysis$taula_def
|
||||||
if (oneside != ""){
|
if (input$vacc == "No"){
|
||||||
tableR<-filter(table, ID.tumor == rechallenge) %>% filter(!is.na(Volume))
|
table<-filter(table, !is.na(Volume))
|
||||||
summary(aov(Volume~Group+Timepoint+Error(ID.animal), data=table[table$ID.tumor == oneside,]))
|
summary(aov(Volume~Group+Timepoint+Error(`ID animal`), 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))
|
||||||
if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$Timepoint)) > 1){
|
if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$Timepoint)) > 1){
|
||||||
print(paste0("Side: ",side))
|
print(paste0("Side: ",side))
|
||||||
# print(summary(aov(Volume~Group+Timepoint+Error(paste0(ID.animal,Cage)), data=tableR)))
|
# print(summary(aov(Volume~Group+Timepoint+Error(paste0(ID animal,Cage)), data=tableR)))
|
||||||
print(summary(aov(Volume~Group+Timepoint+Error(ID.animal), data=tableR)))
|
print(summary(aov(Volume~Group+Timepoint+Error(`ID animal`), data=tableR)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,8 +333,24 @@ server <- function(input, output) {
|
|||||||
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
|
if (!is.null(input$file_analy) & !is.null(analysis$taula_def)){
|
||||||
table<-analysis$taula_def
|
table<-analysis$taula_def
|
||||||
table_stats<-list()
|
table_stats<-list()
|
||||||
|
if (input$vacc == "No"){
|
||||||
|
table<-table%>%filter(!is.na(Volume))
|
||||||
|
if (length(unique(table$Volume)) > 1){
|
||||||
|
table_stats<-multi_stats(table, "Volume", "Timepoint", "Group", stat.test=stattest)
|
||||||
|
}
|
||||||
|
table_kw<-as.data.frame(matrix(nrow=0, ncol=2))
|
||||||
|
for (point in unique(table$Timepoint)){
|
||||||
|
len_group<-length(unique(table %>% filter(Timepoint == point) %>% pull(Group)))
|
||||||
|
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]]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
colnames(table_kw)<-c("Timepoint", "KW-p.val")
|
||||||
|
table_stats<-merge(table_stats, table_kw)
|
||||||
|
|
||||||
|
}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))
|
||||||
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", "Timepoint", "Group", stat.test=stattest)
|
||||||
}
|
}
|
||||||
@@ -318,6 +364,7 @@ server <- function(input, output) {
|
|||||||
colnames(table_kw)<-c("Timepoint", "KW-p.val")
|
colnames(table_kw)<-c("Timepoint", "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 = "ID tumor")
|
||||||
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)
|
||||||
@@ -330,4 +377,3 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
shinyApp(ui = ui, server = server)
|
shinyApp(ui = ui, server = server)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user