|
|
@ -84,14 +84,24 @@ server <- function(input, output) { |
|
|
|
dades$db<-NULL |
|
|
|
observe({ |
|
|
|
if (!is.null(input$file_sizes)){ |
|
|
|
dades$taula<-read.xlsx(input$file_sizes$datapath, sheet = 1) |
|
|
|
taula<-read.xlsx(input$file_sizes$datapath, sheet = 1, sep.names = " ") |
|
|
|
if ("DPV" %in% colnames(taula)){ |
|
|
|
taula<-dcast(taula, Cage+`ID animal`+`ID tumor`+Group~DPV, value.var = "0") |
|
|
|
# taula$Major<-taula$Major/1000 |
|
|
|
# taula$Minor<-taula$Minor/1000 |
|
|
|
# taula["Volume"]<-((taula$Major*taula$Minor*taula$Minor)*(pi/6))*1000 |
|
|
|
taula$Major<-taula$Major |
|
|
|
taula$Minor<-taula$Minor |
|
|
|
taula["Volume"]<-((taula$Major*taula$Minor*taula$Minor)*(pi/6)) |
|
|
|
} |
|
|
|
dades$taula<-taula |
|
|
|
dades$groups<-read.xlsx(input$file_sizes$datapath, sheet = 2)[,1] |
|
|
|
} |
|
|
|
}) |
|
|
|
output$firstPlot <- renderPlot({ |
|
|
|
observeEvent(dades$taula, {}) |
|
|
|
if (!is.null(dades$taula)){ |
|
|
|
ggplot(dades$taula, aes(x="1", y=Volumen))+geom_quasirandom(width=0.2) |
|
|
|
ggplot(dades$taula, aes(x="1", y=Volume))+geom_quasirandom(width=0.2) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
@ -124,13 +134,14 @@ server <- function(input, output) { |
|
|
|
df<-dades$taula |
|
|
|
up_cuttof<-input$upcut |
|
|
|
low_cuttof<-input$lowcut |
|
|
|
df<-df[df$Volumen < up_cuttof & df$Volumen > low_cuttof,] |
|
|
|
df["Mouse"]<-gsub("[a-zA-Z]", "", df$MouseID) |
|
|
|
df<-df[df$Volume <= up_cuttof & df$Volume >= low_cuttof,] |
|
|
|
|
|
|
|
s<-shapiro.test(df$Volumen)[[2]] |
|
|
|
|
|
|
|
ngroup<-length(dades$groups) |
|
|
|
# df["Mouse"]<-gsub("[a-zA-Z]", "", df$MouseID) |
|
|
|
print(df$Volume) |
|
|
|
s<-shapiro.test(df$Volume)[[2]] |
|
|
|
|
|
|
|
ngroup<-length(dades$groups) |
|
|
|
ind.list<-list() |
|
|
|
pval.list<-list() |
|
|
|
lvn.list<-list() |
|
|
@ -138,32 +149,39 @@ server <- function(input, output) { |
|
|
|
for (data in 1:input$iterations){ |
|
|
|
interr=T |
|
|
|
while(interr == T){ |
|
|
|
ind<-sample(rep(dades$groups, each=7), length(unique(df$Mouse))) |
|
|
|
df_temp<-merge(df, data.frame("Mouse"=unique(df$Mouse), "group"=as.factor(ind))) |
|
|
|
interr<-any(table(df_temp$group) < floor(nrow(df_temp)/5) | table(df_temp$group) > ceiling(nrow(df_temp)/5)) |
|
|
|
ind<-sample(rep(dades$groups, each=ceiling(length(unique(df$`ID animal`))/ngroup)), length(unique(df$`ID animal`))) |
|
|
|
df_temp<-merge(df[,c("ID animal", "ID tumor","Volume")], data.frame("ID animal"=unique(df$`ID animal`), "group"=as.factor(ind),check.names=F)) |
|
|
|
if ((nrow(df_temp)/ngroup) %% 2 == 0){ |
|
|
|
interr<-any(table(df_temp$group) < floor(nrow(df_temp)/ngroup) | table(df_temp$group) > ceiling(nrow(df_temp)/ngroup)) |
|
|
|
}else{ |
|
|
|
interr<-any(table(df_temp$group) < (floor(nrow(df_temp)/ngroup)-1) | table(df_temp$group) > (ceiling(nrow(df_temp)/ngroup)+1)) |
|
|
|
} |
|
|
|
} |
|
|
|
ind.list[[data]]<-df_temp[,c("MouseID","group")] |
|
|
|
lvn.list[data]<-leveneTest(Volumen ~ group, data = df_temp[,3:4])[[2]][1] |
|
|
|
ind.list[[data]]<-df_temp[,c("ID animal", "ID tumor","group","Volume")] |
|
|
|
lvn.list[data]<-leveneTest(Volume ~ group, data = df_temp[,3:4])[[2]][1] |
|
|
|
if (s < 0.05){ |
|
|
|
k<-kruskal.test(df_temp$Volumen,df_temp$group) |
|
|
|
k<-kruskal.test(df_temp$Volume,df_temp$group) |
|
|
|
test.list[data]<-k[[1]][1] |
|
|
|
pval.list[data]<-k[[3]][1] |
|
|
|
}else{ |
|
|
|
res.aov<-aov(Volumen~group, data=df_temp) |
|
|
|
res.aov<-aov(Volume~group, data=df_temp) |
|
|
|
pval.list[data]<-summary(res.aov)[[1]][[5]][1] |
|
|
|
test.list[data]<-summary(res.aov)[[1]][[4]][1] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
index<-which(unlist(lvn.list) == min(unlist(lvn.list)[which(unlist(pval.list) %in% sort(unlist(pval.list), decreasing = T)[1:20])])) |
|
|
|
df_def<-merge(df, ind.list[[index]]) |
|
|
|
if ("Group" %in% colnames(df_def)){ |
|
|
|
df_def<-df_def %>% select(-"Group") |
|
|
|
} |
|
|
|
dades$db<-df_def |
|
|
|
print(df_def) |
|
|
|
|
|
|
|
ggplot(df_def, aes(group, Volumen))+ |
|
|
|
ggplot(df_def, aes(group, Volume))+ |
|
|
|
geom_boxplot(outlier.alpha = F)+ |
|
|
|
geom_jitter(width=0.25)+ |
|
|
|
geom_point(stat="summary", color="blue", size=3)+ |
|
|
|
lims(y=c(0,max(df_def$Volumen)+10)) |
|
|
|
geom_point(stat="summary", color="blue", size=3) |
|
|
|
# lims(y=c(0,max(df_def$Volume)+10)) |
|
|
|
}) |
|
|
|
output$distPlot <- renderPlot({ |
|
|
|
observeEvent(dades$taula, {}) |
|
|
@ -184,28 +202,31 @@ server <- function(input, output) { |
|
|
|
timepoint<-c(7,10,13,16,19,22,25) |
|
|
|
|
|
|
|
if (!is.null(input$file_sizes)){ |
|
|
|
template<-expand.grid(dades$db$MouseID, timepoint) |
|
|
|
colnames(template)<-c("MouseID", "Timepoint") |
|
|
|
template<-template[order(template$Timepoint, template$MouseID),] |
|
|
|
template<-merge(template, dades$db[c("MouseID", "group")]) |
|
|
|
if (input$measure_sys == "L-W-D"){ |
|
|
|
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)]<-"" |
|
|
|
dtemplate<-df$db %>% select(-Volume) |
|
|
|
dtemplate<-melt(dtemplate, id=c("Cage", "ID animal", "ID tumor", "group"), variable.name = "DPV", value.name = "0") %>% rename("Group"="group") |
|
|
|
dtemplate<-dtemplate[,c("Cage", "ID animal", "ID tumor", "Group", "DPV", "0")] |
|
|
|
# template<-expand.grid(dades$db$MouseID, timepoint) |
|
|
|
# colnames(template)<-c("MouseID", "Timepoint") |
|
|
|
# template<-template[order(template$Timepoint, template$MouseID),] |
|
|
|
# template<-merge(template, dades$db[c("MouseID", "group")]) |
|
|
|
# if (input$measure_sys == "L-W-D"){ |
|
|
|
# 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{ |
|
|
|
template<-expand.grid(LETTERS[1:ncages], 1:5, id_tumors, timepoint)[,-2] |
|
|
|
colnames(template)<-c("Cage", "ID tumor", "Timepoint") |
|
|
|