"Añadir soporte para varios Mocks"
This commit is contained in:
@@ -52,19 +52,32 @@ server <- function(input, output) {
|
|||||||
table<-dades$taula[,colnames(dades$taula) != "Groups"]
|
table<-dades$taula[,colnames(dades$taula) != "Groups"]
|
||||||
t_mean<-dcast(melt(table, id="Mice"),Mice~variable, mean, na.rm=T)
|
t_mean<-dcast(melt(table, id="Mice"),Mice~variable, mean, na.rm=T)
|
||||||
|
|
||||||
t_substr<-data.frame("Mice"=t_mean[,1],
|
if (length(grep("Mock", colnames(t_mean))) == 1){
|
||||||
as.data.frame(t(apply(t_mean[,2:ncol(table)], 1, function(x) x-x[mock])))
|
t_substr<-data.frame("Mice"=t_mean[,1],
|
||||||
)
|
as.data.frame(t(apply(t_mean[,2:ncol(table)], 1, function(x) x-x[mock])))
|
||||||
t_mean_group<-merge(t_mean, unique(dades$taula[c("Mice","Groups")]), id="Mice")
|
)
|
||||||
mock_mean<-dcast(t_mean_group, Groups~., value.var=mock, mean)
|
t_mean_group<-merge(t_mean, unique(dades$taula[c("Mice","Groups")]), id="Mice")
|
||||||
mock_mean[,2]<-mock_mean[,2]*2
|
t_mean_group$Groups<-as.factor(t_mean_group$Groups)
|
||||||
mock_mean[mock_mean$. < input$umbral_pos,2]<-input$umbral_pos
|
mock_mean<-dcast(t_mean_group, Groups~., value.var=mock, mean)
|
||||||
|
mock_mean[,2]<-mock_mean[,2]*2
|
||||||
t_substr<-merge(t_substr, unique(dades$taula[c("Mice","Groups")]), id="Mice")
|
mock_mean[mock_mean$. < input$umbral_pos,2]<-input$umbral_pos
|
||||||
t_substr<-t_substr[,c(1, ncol(t_substr), 2:(ncol(t_substr)-1))]
|
|
||||||
t_substr<-t_substr[,c("Mice", "Groups", colnames(t_substr)[!colnames(t_substr) %in% c("Mice", "Groups")])]
|
t_substr<-merge(t_substr, unique(dades$taula[c("Mice","Groups")]), id="Mice")
|
||||||
t_substr[,3:ncol(t_substr)]<-apply(t_substr[,3:ncol(t_substr)],2, function(x) replace(x, which(x < 0),0))
|
t_substr<-t_substr[,c(1, ncol(t_substr), 2:(ncol(t_substr)-1))]
|
||||||
colnames(t_substr)<-c("Mice", "Groups", colnames(t_mean)[2:ncol(t_mean)])
|
t_substr<-t_substr[,c("Mice", "Groups", colnames(t_substr)[!colnames(t_substr) %in% c("Mice", "Groups")])]
|
||||||
|
t_substr[,3:ncol(t_substr)]<-apply(t_substr[,3:ncol(t_substr)],2, function(x) replace(x, which(x < 0),0))
|
||||||
|
colnames(t_substr)<-c("Mice", "Groups", colnames(t_mean)[2:ncol(t_mean)])
|
||||||
|
}else{
|
||||||
|
print(1)
|
||||||
|
t_especifica<-t_mean[,grep("Mock_", colnames(t_mean), invert=T)]
|
||||||
|
t_mock<-t_mean[,c(which(colnames(t_mean) == "Mice"),grep("Mock_", colnames(t_mean)))]
|
||||||
|
t_temp<-melt(t_especifica, variable.name = "condition", value.name = "spots")
|
||||||
|
t_temp["spots_mock"]<-melt(t_mock, variable.name = "condition")[,"value"]
|
||||||
|
t_substr<-data.frame(t_temp[c("Mice","condition")], "spots"=t_temp["spots"]-t_temp["spots_mock"])
|
||||||
|
t_substr<-dcast(t_substr, Mice~condition)
|
||||||
|
t_substr<-merge(t_substr, unique(dades$taula[c("Mice","Groups")]), id="Mice")
|
||||||
|
t_substr$Groups<-as.factor(t_substr$Groups)
|
||||||
|
}
|
||||||
|
|
||||||
t_substr_gp<-t_substr
|
t_substr_gp<-t_substr
|
||||||
t_substr_gp[3:ncol(t_substr)]<-apply(t_substr[3:ncol(t_substr)], 2, function(x) gsub(".",",",x, fixed=T))
|
t_substr_gp[3:ncol(t_substr)]<-apply(t_substr[3:ncol(t_substr)], 2, function(x) gsub(".",",",x, fixed=T))
|
||||||
@@ -74,17 +87,6 @@ server <- function(input, output) {
|
|||||||
write.xlsx(doc, "data4graphpad.xlsx",rowNames=T)
|
write.xlsx(doc, "data4graphpad.xlsx",rowNames=T)
|
||||||
|
|
||||||
t<-melt(t_substr[,!colnames(t_substr) %in% c(ctrl, mock)])
|
t<-melt(t_substr[,!colnames(t_substr) %in% c(ctrl, mock)])
|
||||||
if (input$test == "T-test (adj Holm)"){
|
|
||||||
t_stats<-multi_stats(t, "value", "variable", "Groups", stat.test = "ttest")
|
|
||||||
}
|
|
||||||
if (input$test == "Wilcoxon (adj Holm)"){
|
|
||||||
t_stats<-multi_stats(t, "value", "variable", "Groups", stat.test = "wilcox")
|
|
||||||
}
|
|
||||||
|
|
||||||
dades$stats<<-t_stats
|
|
||||||
t_stats<-t_stats %>% filter(p.signif != "ns")
|
|
||||||
|
|
||||||
t_maps<-generate_labstats(t_stats, t, "value", "variable", "Groups")
|
|
||||||
|
|
||||||
if (input$showstats == F){
|
if (input$showstats == F){
|
||||||
t_stats<-as.data.frame(matrix(nrow=0, ncol=6))
|
t_stats<-as.data.frame(matrix(nrow=0, ncol=6))
|
||||||
@@ -98,21 +100,34 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
set.seed(123)
|
set.seed(123)
|
||||||
if (input$positive == T){
|
if (input$positive == T){
|
||||||
ggplot(melt(t_substr, id=c("Mice", ctrl, "Groups")), aes(variable, value))+
|
if (input$test == "T-test (adj Holm)"){
|
||||||
labs(x="", y="Spots/2.5*10^5 cells")+
|
t_stats<-multi_stats(t, "value", "variable", "Groups", stat.test = "ttest")
|
||||||
# geom_errorbar(stat="summary", position=position_dodge(width=0.9), width=0.5, aes(fill=Groups))+
|
}
|
||||||
geom_hline(data=mock_mean, aes(color=Groups, yintercept = `.`))+
|
if (input$test == "Wilcoxon (adj Holm)"){
|
||||||
# geom_bar(stat="summary", position="dodge", color="black", aes(fill=Groups))+
|
t_stats<-multi_stats(t, "value", "variable", "Groups", stat.test = "wilcox")
|
||||||
geom_boxplot(color="black", aes(fill=Groups), alpha=0.4, outlier.alpha = 0)+
|
}
|
||||||
geom_jitter(position=position_jitterdodge(jitter.width = 0.2), shape=21, aes(fill=Groups), size=3)+
|
|
||||||
# geom_quasirandom(position = position_quasirandom(), shape=21)+
|
dades$stats<<-t_stats
|
||||||
scale_x_discrete(limits=colnames(t_substr)[!colnames(t_substr) %in% c("Mice", "Groups", ctrl, mock)])+
|
t_stats<-t_stats %>% filter(p.signif != "ns")
|
||||||
geom_segment(data=t_maps$brackets, aes(x=x1, xend=x2, y=y1, yend=y2), color="black")+
|
|
||||||
geom_text(data=t_stats, aes(t_maps$label$x, t_maps$label$y, label=p.signif), color="black")+
|
t_maps<-generate_labstats(t_stats, t, "value", "variable", "Groups")
|
||||||
theme_bw()+
|
|
||||||
theme(axis.text.x=element_text(angle=45, hjust=1))
|
ggplot(melt(t_substr, id=c("Mice", ctrl, "Groups")), aes(variable, value))+
|
||||||
|
labs(x="", y="Spots/2.5*10^5 cells")+
|
||||||
|
# geom_errorbar(stat="summary", position=position_dodge(width=0.9), width=0.5, aes(fill=Groups))+
|
||||||
|
geom_hline(data=mock_mean, aes(color=Groups, yintercept = `.`))+
|
||||||
|
# geom_bar(stat="summary", position="dodge", color="black", aes(fill=Groups))+
|
||||||
|
geom_boxplot(color="black", aes(fill=Groups), alpha=0.4, outlier.alpha = 0)+
|
||||||
|
geom_jitter(position=position_jitterdodge(jitter.width = 0.2), shape=21, aes(fill=Groups), size=3)+
|
||||||
|
# geom_quasirandom(position = position_quasirandom(), shape=21)+
|
||||||
|
scale_x_discrete(limits=colnames(t_substr)[!colnames(t_substr) %in% c("Mice", "Groups", ctrl, mock)])+
|
||||||
|
geom_segment(data=t_maps$brackets, aes(x=x1, xend=x2, y=y1, yend=y2), color="black")+
|
||||||
|
geom_text(data=t_stats, aes(t_maps$label$x, t_maps$label$y, label=p.signif), color="black")+
|
||||||
|
theme_bw()+
|
||||||
|
theme(axis.text.x=element_text(angle=45, hjust=1))
|
||||||
}else{
|
}else{
|
||||||
ggplot(melt(t_substr, id=c("Mice", ctrl, "Groups")), aes(variable, value))+
|
ids<-if(ctrl %in% colnames(t_substr)){c("Mice", ctrl, "Groups")}else{c("Mice", "Groups")}
|
||||||
|
ggplot(melt(t_substr, id=ids), aes(variable, value))+
|
||||||
labs(x="", y="Spots/2.5*10^5 cells")+
|
labs(x="", y="Spots/2.5*10^5 cells")+
|
||||||
# geom_errorbar(stat="summary", position=position_dodge(width=0.9), width=0.5, aes(fill=Groups))+
|
# geom_errorbar(stat="summary", position=position_dodge(width=0.9), width=0.5, aes(fill=Groups))+
|
||||||
# geom_bar(stat="summary", position="dodge", color="black", aes(fill=Groups))+
|
# geom_bar(stat="summary", position="dodge", color="black", aes(fill=Groups))+
|
||||||
|
|||||||
Reference in New Issue
Block a user