From a57fb3aac87c8deb16c30da46fe8fa95ded6468e Mon Sep 17 00:00:00 2001 From: marcelcosta Date: Wed, 6 Apr 2022 16:54:51 +0200 Subject: [PATCH] =?UTF-8?q?Gates=20booleanas=20se=20hacen=20en=20R=20y=20n?= =?UTF-8?q?o=20en=20Flowjo=20(que=20enlentece=20mucho=20el=20an=C3=A1lisis?= =?UTF-8?q?).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BDAccess/app.R | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/BDAccess/app.R b/BDAccess/app.R index 33f9d25..63e2a48 100644 --- a/BDAccess/app.R +++ b/BDAccess/app.R @@ -1079,17 +1079,47 @@ server <- function(input, output) { sampleNames(gs)<-sapply(sampleNames(gs), function(x) strsplit(x, "ICs ")[[1]][2]) %>% gsub("[[:space:]][0-9]*.fcs_.[0-9]*","", . , perl = T) + bool.comb<-apply( + expand.grid(c("","!"), c("","!"),c("","!"), c("","!"), c("","!")), + 1, + function(x) paste0(x[1],"CTLA4 & ",x[2],"LAG3 & ",x[3],"PD1 & ",x[4], "TIGIT & ",x[5], "TIM3") + ) + + bool.name<-apply( + expand.grid(c("+","-"), c("+","-"),c("+","-"), c("+","-"), c("+","-")), + 1, + function(x) paste0("CTLA4",x[1]," LAG3",x[2]," PD1",x[3]," TIGIT",x[4]," TIM3",x[5]) + ) + + for (i in 1:length(bool.comb)){ + print("Booleanos CD8") + call<-substitute(booleanFilter(v), list(v=as.symbol(bool.comb[i]))) + boolgate<-eval(call) + gs_pop_add(gs, boolgate, parent="CD8", name = bool.name[i]) + } + + for (i in 1:length(bool.comb)){ + print("Booleanos CD4") + call<-substitute(booleanFilter(v), list(v=as.symbol(bool.comb[i]))) + boolgate<-eval(call) + gs_pop_add(gs, boolgate, parent="CD4", name = bool.name[i]) + } + + recompute(gs) + nodes<-gs_get_pop_paths(gs) # nodes<-gsub("â\u0081»", "-", nodes) # nodes<-gsub("â\u0081º", "+", nodes) nodes<-nodes[grepl("CTLA4", nodes)] - nodes<-nodes[!grepl("CD4$|CD8$|CTLA4$|TIM3$|PD1$|LAG3$|TIGIT$|/CTLA4â\u0081»$|/TIM3â\u0081»$|/PD1â\u0081»$|/LAG3â\u0081»$|/TIGITâ\u0081»$", nodes)] + nodes<-nodes[!grepl("CD4$|CD8$|CTLA4$|TIM3$|PD1$|LAG3$|TIGIT$", nodes)] pop<-gs_pop_get_stats(gs, nodes=nodes,type="percent") %>% as.data.frame %>% mutate(percent=percent*100) pop$percent<-round(pop$percent, digits=2) - pop$pop<-gsub("â\u0081»", "n", pop$pop) - pop$pop<-gsub("â\u0081º", "p", pop$pop) + # pop$pop<-gsub("â\u0081»", "n", pop$pop) + # pop$pop<-gsub("â\u0081º", "p", pop$pop) + pop$pop<-gsub("-", "n", pop$pop, fixed=T) + pop$pop<-gsub("+", "p", pop$pop, fixed=T) pop$pop<-gsub(" ", "_", pop$pop) pop["Type"]<-"ab" @@ -1104,10 +1134,13 @@ server <- function(input, output) { pop_sp$pop<-sapply(strsplit(pop_sp$pop, "/"), tail, 1) pop_sp<-pop_sp %>% select(-ab,-iso) %>% spread(pop,Net) - pop_sp$`CTLA4n_LAG3n_PD1n_TIGITn_TIM3n`<- pop_sp %>% select(-`CTLA4n_LAG3n_PD1n_TIGITn_TIM3n`) %>% group_by(sample,Population) %>% + pop_sp$CTLA4n_LAG3n_PD1n_TIGITn_TIM3n<- pop_sp %>% select(-CTLA4n_LAG3n_PD1n_TIGITn_TIM3n) %>% group_by(sample,Population) %>% gather(pop, value, -sample,-Population) %>% summarise(n=100-sum(value)) %>% pull(n) pop_sp <- rename(pop_sp, "samples"="sample") + pop_sql<-sqlFetch(dta, "IC") %>% slice(0) + pop_sp<-pop_sp %>% merge(pop_sql, all=T) %>% select(colnames(pop_sql)) + vartypes<-rep("Number", pop_sp %>% select(-samples, -Population) %>% colnames %>% length) names(vartypes)<-pop_sp %>% select(-samples, -Population) %>% colnames