|
|
@ -1,8 +1,6 @@ |
|
|
|
library(shiny) |
|
|
|
# library(ggplot2) |
|
|
|
library(reshape2) |
|
|
|
library(openxlsx) |
|
|
|
# library(dplyr) |
|
|
|
library(car) |
|
|
|
library(ggbeeswarm) |
|
|
|
library(gtools) |
|
|
@ -104,7 +102,9 @@ server <- function(input, output) { |
|
|
|
} |
|
|
|
dades$taula<-taula |
|
|
|
dades$groups<-read.xlsx(input$file_sizes$datapath, sheet = 2, colName=F)[,1] |
|
|
|
dades$sex<-read.xlsx(input$file_sizes$datapath, sheet = 3, sep.names = " ") |
|
|
|
if (readxl::excel_sheets(input$file_sizes$datapath) %>% length > 2){ |
|
|
|
dades$sex<-read.xlsx(input$file_sizes$datapath, sheet = 3, sep.names = " ") |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
output$firstPlot <- renderPlot({ |
|
|
@ -150,7 +150,12 @@ server <- function(input, output) { |
|
|
|
low_cuttof<-input$lowcut |
|
|
|
# print(up_cuttof) |
|
|
|
df<-df[df$Volume < up_cuttof & df$Volume >= low_cuttof,] |
|
|
|
df<-merge(df, dades$sex) |
|
|
|
if (is.null(dades$sex)){ |
|
|
|
df<-add_column(df, sex="undefined") |
|
|
|
}else{ |
|
|
|
df<-merge(df, dades$sex) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# df["Mouse"]<-gsub("[a-zA-Z]", "", df$MouseID) |
|
|
|
# print(df$Volume) |
|
|
@ -159,7 +164,7 @@ server <- function(input, output) { |
|
|
|
ngroup<-length(dades$groups) |
|
|
|
df_def<-list() |
|
|
|
# print(head(df)) |
|
|
|
for (sex.var in c("male","female")){ |
|
|
|
for (sex.var in unique(df$sex)){ |
|
|
|
# print(sex.var) |
|
|
|
df_sex<-df %>% filter(`sex` == sex.var) |
|
|
|
ind.list<-list() |
|
|
@ -194,33 +199,46 @@ server <- function(input, output) { |
|
|
|
# print(df_sex) |
|
|
|
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) |
|
|
|
# df_def<-rbind(df_def[[1]], df_def[[2]], make.row.names=F) |
|
|
|
if ("Group" %in% colnames(df_def)){ |
|
|
|
df_def<-df_def %>% select(-"Group") |
|
|
|
} |
|
|
|
df_def<-merge(merge(dades$taula, dades$sex) %>% select(-Group), df_def[,c("ID animal", "group")] %>% unique, all=T, by="ID animal") %>% select(c(`ID animal`, `sex`,`ID tumor`, Volume, Cage, Major, Minor, group)) |
|
|
|
df_def<-merge( |
|
|
|
if(!is.null(dades$sex)){merge(dades$taula, dades$sex)}else{dades$taula %>% add_column(sex="undefined")} %>% select(-Group), |
|
|
|
df_def[,c("ID animal", "group")] %>% unique, all=T, by="ID animal") %>% |
|
|
|
select(c(`ID animal`, `sex`,`ID tumor`, Volume, Cage, Major, Minor, group)) |
|
|
|
df_def[!paste0(df_def$`ID animal`, df_def$`ID tumor`) %in% paste0(df$`ID animal`, df$`ID tumor`),"group"]<-NA |
|
|
|
dades$db<-df_def |
|
|
|
|
|
|
|
ggarrange( |
|
|
|
ggplot(df_def, aes(group, Volume))+ |
|
|
|
geom_boxplot(outlier.alpha = F)+ |
|
|
|
geom_jitter(width=0.25, aes(color=sex))+ |
|
|
|
geom_point(stat="summary", color="blue", size=3)+ |
|
|
|
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5)), |
|
|
|
# lims(y=c(0,max(df_def$Volume)+10)) |
|
|
|
ggarrange( |
|
|
|
ggplot(df_def, aes(sex, Volume))+ |
|
|
|
if (is.null(dades$sex)){ |
|
|
|
ggplot(df_def, aes(group, Volume))+ |
|
|
|
geom_boxplot(outlier.alpha = F)+ |
|
|
|
geom_quasirandom(width=0.3), |
|
|
|
ggplot(df_def, aes(group, fill=sex))+ |
|
|
|
geom_bar(stat="count", color="black", position="dodge")+ |
|
|
|
guides(fill="none")+ |
|
|
|
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5)), ncol = 1, heights = c(0.35, 0.65)), |
|
|
|
nrow = 1, aligh="h", widths = c(0.65, 0.35)) |
|
|
|
geom_jitter(width=0.25)+ |
|
|
|
geom_point(stat="summary", color="blue", size=3)+ |
|
|
|
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5)) |
|
|
|
}else{ |
|
|
|
ggarrange( |
|
|
|
ggplot(df_def, aes(group, Volume))+ |
|
|
|
geom_boxplot(outlier.alpha = F)+ |
|
|
|
geom_jitter(width=0.25, aes(color=sex))+ |
|
|
|
geom_point(stat="summary", color="blue", size=3)+ |
|
|
|
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5)), |
|
|
|
# lims(y=c(0,max(df_def$Volume)+10)) |
|
|
|
ggarrange( |
|
|
|
ggplot(df_def, aes(sex, Volume))+ |
|
|
|
geom_boxplot(outlier.alpha = F)+ |
|
|
|
geom_quasirandom(width=0.3), |
|
|
|
ggplot(df_def, aes(group, fill=sex))+ |
|
|
|
geom_bar(stat="count", color="black", position="dodge")+ |
|
|
|
guides(fill="none")+ |
|
|
|
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5)), ncol = 1, heights = c(0.35, 0.65)), |
|
|
|
nrow = 1, aligh="h", widths = c(0.65, 0.35)) |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
output$distPlot <- renderPlot({ |
|
|
|
observeEvent(dades$taula, {}) |
|
|
|
if (!is.null(dades$taula)){ |
|
|
|