Compare commits
15 Commits
e6c2a32ddb
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 560540cf1a | |||
| bd52e8c452 | |||
| 43b807cc63 | |||
| cb38ea347d | |||
| 6671939939 | |||
| a6f0c97d47 | |||
| 56484a5903 | |||
| b5323436ec | |||
| a57fb3aac8 | |||
| dbb8e1ed0d | |||
| 51acdd0ece | |||
| 001f64cc76 | |||
| f45ebfd106 | |||
| 38e902cef0 | |||
| 3492b7f7ef |
+247
-30
@@ -88,6 +88,7 @@ ui <- fluidPage(
|
|||||||
tabsetPanel(
|
tabsetPanel(
|
||||||
tabPanel("Entrada",
|
tabPanel("Entrada",
|
||||||
actionButton("goButtonDir","Selecciona directorio fenotipo"),
|
actionButton("goButtonDir","Selecciona directorio fenotipo"),
|
||||||
|
textInput("cytopath", label="Directorio fenotipo", value=""),
|
||||||
textOutput("session"),
|
textOutput("session"),
|
||||||
hr(),
|
hr(),
|
||||||
actionButton("fcsconvert", "Convertir a fcs"),
|
actionButton("fcsconvert", "Convertir a fcs"),
|
||||||
@@ -143,24 +144,28 @@ server <- function(input, output) {
|
|||||||
print(CCfile)
|
print(CCfile)
|
||||||
if (input$dbtype == "UM"){
|
if (input$dbtype == "UM"){
|
||||||
dta<<-odbcConnectAccess2007(access.file = UMfile,
|
dta<<-odbcConnectAccess2007(access.file = UMfile,
|
||||||
pwd = .rs.askForPassword("Enter password:"))
|
pwd = getPass::getPass("Enter password:"))
|
||||||
}
|
}
|
||||||
if (input$dbtype == "OV"){
|
if (input$dbtype == "OV"){
|
||||||
dta<<-odbcConnectAccess2007(access.file = OVfile,
|
dta<<-odbcConnectAccess2007(access.file = OVfile,
|
||||||
pwd = .rs.askForPassword("Enter password:"))
|
pwd = getPass::getPass("Enter password:"))
|
||||||
}
|
}
|
||||||
if (input$dbtype == "CC"){
|
if (input$dbtype == "CC"){
|
||||||
dta<<-odbcConnectAccess2007(access.file = CCfile,
|
dta<<-odbcConnectAccess2007(access.file = CCfile,
|
||||||
pwd = .rs.askForPassword("Enter password:"))
|
pwd = getPass::getPass("Enter password:"))
|
||||||
}
|
}
|
||||||
print(dta)
|
print(dta)
|
||||||
if (input$backup == T){
|
if (input$backup == T){
|
||||||
if (! input$dbtype %in% c("UM","OV")){
|
if (! input$dbtype %in% c("UM","OV")){
|
||||||
sqlBackUp(bu.dir="CC_BU")
|
sqlBackUp(dbfile = CCfile, bu.dir="CC_BU")
|
||||||
}else{
|
|
||||||
sqlBackUp()
|
|
||||||
}
|
}
|
||||||
|
if (input$dbtype == "UM"){
|
||||||
|
sqlBackUp(dbfile = UMfile)
|
||||||
|
}
|
||||||
|
if (input$dbtype == "OV"){
|
||||||
|
sqlBackUp(dbfile = OVfile)
|
||||||
|
}
|
||||||
|
print("Back up realizado.")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -379,7 +384,7 @@ server <- function(input, output) {
|
|||||||
new.samp.df<-data.frame("NHC"=values[["DF"]]$NHC, "samples"=new.samp) %>% merge(sqlFetch(dta,"OVID"), all.x=T) %>% arrange(samples)
|
new.samp.df<-data.frame("NHC"=values[["DF"]]$NHC, "samples"=new.samp) %>% merge(sqlFetch(dta,"OVID"), all.x=T) %>% arrange(samples)
|
||||||
samples.exp<-merge(samples %>% slice(0), new.samp.df %>% select(-NHC), all=T) %>% select(colnames(samples)) %>% arrange(samples)
|
samples.exp<-merge(samples %>% slice(0), new.samp.df %>% select(-NHC), all=T) %>% select(colnames(samples)) %>% arrange(samples)
|
||||||
if (today==TRUE){
|
if (today==TRUE){
|
||||||
samples.exp$IQ_date<-format(Sys.Date(), "%d/%m/%y")
|
samples.exp$Date_extraction<-format(Sys.Date(), "%d/%m/%y")
|
||||||
}
|
}
|
||||||
|
|
||||||
nhc.table<-values[["DF"]]
|
nhc.table<-values[["DF"]]
|
||||||
@@ -753,6 +758,7 @@ server <- function(input, output) {
|
|||||||
sqlFetch(dta, "NITROGEN"),
|
sqlFetch(dta, "NITROGEN"),
|
||||||
file=paste0(NitroRoute, format(Sys.time(), format="%Y%m%d"),"-","UM-Nitrogen.xlsx")
|
file=paste0(NitroRoute, format(Sys.time(), format="%Y%m%d"),"-","UM-Nitrogen.xlsx")
|
||||||
)
|
)
|
||||||
|
print("Backup Creado.")
|
||||||
|
|
||||||
table<-read.xlsx(paste0(gsub("/BU_NITRO/", "", NitroRoute),"/Nitrogen_ICO.xlsx"))
|
table<-read.xlsx(paste0(gsub("/BU_NITRO/", "", NitroRoute),"/Nitrogen_ICO.xlsx"))
|
||||||
|
|
||||||
@@ -783,6 +789,7 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
sqlDrop(dta, "NITROGEN")
|
sqlDrop(dta, "NITROGEN")
|
||||||
sqlSave(dta, table.um %>% select(-FECHA) %>% filter(!is.na(CODIGO)), tablename="NITROGEN", rownames=F)
|
sqlSave(dta, table.um %>% select(-FECHA) %>% filter(!is.na(CODIGO)), tablename="NITROGEN", rownames=F)
|
||||||
|
print("Tabla Actualizada.")
|
||||||
}
|
}
|
||||||
if (input$dbtype == "OV"){
|
if (input$dbtype == "OV"){
|
||||||
## Copia de backup
|
## Copia de backup
|
||||||
@@ -796,6 +803,7 @@ server <- function(input, output) {
|
|||||||
sqlFetch(dta, "NITROGEN"),
|
sqlFetch(dta, "NITROGEN"),
|
||||||
file=paste0(NitroRoute, format(Sys.time(), format="%Y%m%d"),"-","OV-Nitrogen.xlsx")
|
file=paste0(NitroRoute, format(Sys.time(), format="%Y%m%d"),"-","OV-Nitrogen.xlsx")
|
||||||
)
|
)
|
||||||
|
print("Backup Creado.")
|
||||||
|
|
||||||
## Lectura del excel
|
## Lectura del excel
|
||||||
table<-read.xlsx(paste0(gsub("/BU_NITRO/", "", NitroRoute),"/Nitrogen_ICO.xlsx"))
|
table<-read.xlsx(paste0(gsub("/BU_NITRO/", "", NitroRoute),"/Nitrogen_ICO.xlsx"))
|
||||||
@@ -821,6 +829,7 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
sqlDrop(dta, "NITROGEN")
|
sqlDrop(dta, "NITROGEN")
|
||||||
sqlSave(dta, table.ov, tablename="NITROGEN", rownames=F)
|
sqlSave(dta, table.ov, tablename="NITROGEN", rownames=F)
|
||||||
|
print("Tabla Actualizada.")
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -923,9 +932,14 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
pops<-sqlFetch(dta, "POPULATIONS")
|
pops<-sqlFetch(dta, "POPULATIONS")
|
||||||
|
|
||||||
g_pop<-pops %>% dplyr::filter(samples == input$id) %>% gather(pop,value,-samples) %>%
|
g_pop<-pops %>%
|
||||||
mutate(pop=factor(pop, levels=c("CD45pos_Alive","T_cells","CD8","CD4","DN","NK", "B_cells",
|
dplyr::filter(sample == input$id) %>%
|
||||||
"CD45neg_LDneg","EpCAMneg_HLAIneg","EpCAMneg_HLAIpos","EpCAMpos_HLAIpos"))) %>%
|
gather(pop,value,-sample, -code, -fc_time) %>%
|
||||||
|
# mutate(pop=factor(pop, levels=c("CD45pos_Alive","T_cells","CD8","CD4","DN","NK", "B_cells",
|
||||||
|
# "CD45neg_LDneg","EpCAMneg_HLAIneg","EpCAMneg_HLAIpos","EpCAMpos_HLAIpos"))) %>%
|
||||||
|
# mutate(pop=factor(pop, levels=c("CD45pos_Alive","T_cells","CD8","CD4","DN","NK", "B_cells",
|
||||||
|
# "CD45neg_LDneg","EpCAMneg_HLAIneg","EpCAMneg_HLAIpos","EpCAMpos_HLAIpos"))) %>%
|
||||||
|
mutate(value=as.numeric(gsub(",",".",value))) %>%
|
||||||
ggplot(aes(pop, value))+
|
ggplot(aes(pop, value))+
|
||||||
geom_bar(stat="identity", color="black", fill="grey70")+
|
geom_bar(stat="identity", color="black", fill="grey70")+
|
||||||
labs(title = input$id, y="% parent", x="")+
|
labs(title = input$id, y="% parent", x="")+
|
||||||
@@ -969,7 +983,11 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
observe({
|
observe({
|
||||||
if(input$goButtonDir > 0){
|
if(input$goButtonDir > 0){
|
||||||
cito_dir<<-choose.dir() %>% gsub("\\","/",. ,fixed=T) %>% paste0("/")
|
if (input$cytopath == ""){
|
||||||
|
cito_dir<<-choose.dir() %>% gsub("\\","/",. ,fixed=T) %>% paste0("/")
|
||||||
|
}else{
|
||||||
|
cito_dir<<-input$cytopath %>% gsub("\\","/",. ,fixed=T) %>% gsub("/$", "", .) %>% paste0("/")
|
||||||
|
}
|
||||||
|
|
||||||
output$session <- renderText(
|
output$session <- renderText(
|
||||||
cito_dir
|
cito_dir
|
||||||
@@ -1008,7 +1026,7 @@ server <- function(input, output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (input$phenotype == "IC"){
|
if (input$phenotype == "IC"){
|
||||||
route<-cito_dir
|
route<-stringi::stri_enc_tonative(cito_dir)
|
||||||
|
|
||||||
ws<-open_flowjo_xml(paste0(route,"IC.wsp"))
|
ws<-open_flowjo_xml(paste0(route,"IC.wsp"))
|
||||||
gs<-flowjo_to_gatingset(ws, name="All Samples")
|
gs<-flowjo_to_gatingset(ws, name="All Samples")
|
||||||
@@ -1016,25 +1034,178 @@ server <- function(input, output) {
|
|||||||
sampleNames(gs)<-sapply(sampleNames(gs), function(x) strsplit(x, "ICs ")[[1]][2]) %>%
|
sampleNames(gs)<-sapply(sampleNames(gs), function(x) strsplit(x, "ICs ")[[1]][2]) %>%
|
||||||
gsub("[[:space:]][0-9]*.fcs_.[0-9]*","", . , perl = T)
|
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])
|
||||||
|
)
|
||||||
|
|
||||||
|
print("Booleanos CD8")
|
||||||
|
for (i in 1:length(bool.comb)){
|
||||||
|
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])
|
||||||
|
}
|
||||||
|
|
||||||
|
print("Booleanos CD4")
|
||||||
|
for (i in 1:length(bool.comb)){
|
||||||
|
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)
|
||||||
|
|
||||||
names<-sampleNames(gs) %>% gsub("ab|Ab|AB|iso|Iso|ISO| ","",.) %>% unique()
|
names<-sampleNames(gs) %>% gsub("ab|Ab|AB|iso|Iso|ISO| ","",.) %>% unique()
|
||||||
|
|
||||||
nodes<-gs_get_pop_paths(gs)
|
nodes<-gs_get_pop_paths(gs)
|
||||||
nodes_parent<-nodes[!grepl("CTLA4|LAG3|PD1|TIGIT|TIM3|root$", nodes)]
|
# nodes<-gsub("â\u0081»", "-", nodes)
|
||||||
nodes_cd4<-nodes[grepl("CTLA4$|LAG3$|PD1$|TIGIT$|TIM3$", nodes) & grepl("/CD4/",nodes)]
|
# nodes<-gsub("â\u0081º", "+", nodes)
|
||||||
nodes_cd8<-nodes[grepl("CTLA4$|LAG3$|PD1$|TIGIT$|TIM3$", nodes) & grepl("/CD8/",nodes)]
|
nodes<-nodes[grepl("CTLA4", 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("-", "n", pop$pop, fixed=T)
|
||||||
|
pop$pop<-gsub("+", "p", pop$pop, fixed=T)
|
||||||
|
pop$pop<-gsub(" ", "_", pop$pop)
|
||||||
|
|
||||||
|
pop["Type"]<-"ab"
|
||||||
|
pop[grepl("iso|ISO|Iso",pop$sample),"Type"]<-"iso"
|
||||||
|
pop$sample<-gsub("iso|ISO|Iso|ab|AB|Ab| ","",pop$sample)
|
||||||
|
|
||||||
|
pop_sp<-pop %>% spread(Type, percent)
|
||||||
|
pop_sp["Net"]<-pop_sp$ab
|
||||||
|
pop_sp[!grepl("CTLA4n_LAG3n_PD1n_TIGITn_TIM3n",pop_sp$pop),"Net"]<-pop_sp[!grepl("CTLA4n_LAG3n_PD1n_TIGITn_TIM3n",pop_sp$pop),"ab"]-pop_sp[!grepl("CTLA4n_LAG3n_PD1n_TIGITn_TIM3n",pop_sp$pop),"iso"]
|
||||||
|
pop_sp$Net[pop_sp$Net < 0]<-0
|
||||||
|
pop_sp["Population"]<-str_extract(pop_sp$pop, "/CD[4,8]{1}/") %>% gsub("/","",.)
|
||||||
|
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) %>%
|
||||||
|
gather(pop, value, -sample,-Population) %>% summarise(n=100-sum(value)) %>% pull(n)
|
||||||
|
if (input$dbtype == "OV"){
|
||||||
|
pop_sp <- rename(pop_sp, "samples"="sample")
|
||||||
|
}
|
||||||
|
if (input$dbtype %in% c("UM", "CC")){
|
||||||
|
pop_sp <- rename(pop_sp, "CODIGO"="sample")
|
||||||
|
}
|
||||||
|
|
||||||
|
pop_sql<-sqlFetch(dta, "IC") %>% slice(0)
|
||||||
|
pop_sp<-pop_sp %>% merge(pop_sql, all=T) %>% select(colnames(pop_sql))
|
||||||
|
|
||||||
for (id in names){
|
for (id in names){
|
||||||
print(id)
|
print(id)
|
||||||
iso<-sampleNames(gs)[grepl(id, sampleNames(gs)) & grepl("iso|Iso|ISO",sampleNames(gs))]
|
iso<-sampleNames(gs)[grepl(id, sampleNames(gs)) & grepl("iso|Iso|ISO",sampleNames(gs))]
|
||||||
ab<-sampleNames(gs)[grepl(id, sampleNames(gs)) & grepl("ab|Ab|AB",sampleNames(gs))]
|
ab<-sampleNames(gs)[grepl(id, sampleNames(gs)) & grepl("ab|Ab|AB",sampleNames(gs))]
|
||||||
|
|
||||||
g1<-ggcyto_arrange(autoplot(gs[[ab]], nodes_parent, bins=128), nrow=1)
|
if (input$dbtype == "OV"){
|
||||||
g2<-ggcyto_arrange(autoplot(gs[[iso]], nodes_cd8, bins=64), nrow=1)
|
data<-pop_sp %>% filter(samples == id)
|
||||||
g3<-ggcyto_arrange(autoplot(gs[[ab]], nodes_cd8, bins=64), nrow=1)
|
data1<-data %>% gather(phen, value, -samples, -Population)
|
||||||
g4<-ggcyto_arrange(autoplot(gs[[iso]], nodes_cd4, bins=64), nrow=1)
|
}
|
||||||
g5<-ggcyto_arrange(autoplot(gs[[ab]], nodes_cd4, bins=64), nrow=1)
|
if (input$dbtype %in% c("UM", "CC")){
|
||||||
g_all<-gridExtra::gtable_rbind(g1,g2,g3,g4,g5)
|
data<-pop_sp %>% filter(CODIGO == id)
|
||||||
ggsave(paste0(route,id,".IC.png"), g_all, width = 10, height = 10)
|
data1<-data %>% gather(phen, value, -CODIGO, -Population)
|
||||||
|
}
|
||||||
|
|
||||||
|
data1$phen<-gsub("p","+",data1$phen)
|
||||||
|
data1$phen<-gsub("n","-",data1$phen)
|
||||||
|
data1$phen<-gsub("_"," ",data1$phen)
|
||||||
|
|
||||||
|
data1$phen<-gsub("n","-",data1$phen, fixed = T)
|
||||||
|
data1$phen<-gsub("p","+",data1$phen, fixed = T)
|
||||||
|
data1$phen<-gsub("_"," ",data1$phen)
|
||||||
|
data1[data1$value < 0.5, "phen"]<-"Other"
|
||||||
|
data1$phen<-gsub("[A-Z]*-*[0-9T]- *", "", data1$phen)
|
||||||
|
data1$phen<-gsub("+ $", "", data1$phen)
|
||||||
|
data1$phen[data1$phen == ""]<-"All Negative"
|
||||||
|
|
||||||
|
# data1<-data1 %>% filter(value > 0.5)
|
||||||
|
|
||||||
|
data1["phen1"]<-"PD1"
|
||||||
|
data1[!grepl("PD1+", data1$phen),"phen1"]<-NA
|
||||||
|
|
||||||
|
data1["phen2"]<-"TIM3"
|
||||||
|
data1[!grepl("TIM3+", data1$phen),"phen2"]<-NA
|
||||||
|
|
||||||
|
data1["phen3"]<-"CTLA4"
|
||||||
|
data1[!grepl("CTLA4+", data1$phen),"phen3"]<-NA
|
||||||
|
|
||||||
|
data1["phen4"]<-"TIGIT"
|
||||||
|
data1[!grepl("TIGIT+", data1$phen),"phen4"]<-NA
|
||||||
|
|
||||||
|
data1["phen5"]<-"LAG3"
|
||||||
|
data1[!grepl("LAG3+", data1$phen),"phen5"]<-NA
|
||||||
|
|
||||||
|
data1<-data1 %>% arrange(desc(value))
|
||||||
|
data2<-data1 %>% filter(!phen %in% c("All Negative","Other"))
|
||||||
|
data1<-rbind(data2, data1 %>% filter(phen %in% c("All Negative","Other")) %>% arrange(desc(phen)))
|
||||||
|
|
||||||
|
data_cd8<-data1 %>% filter(Population == "CD8")
|
||||||
|
data_cd4<-data1 %>% filter(Population == "CD4")
|
||||||
|
|
||||||
|
data_cd8$ymax<-cumsum(data_cd8$value)
|
||||||
|
data_cd8$ymin<-c(0, head(data_cd8$ymax, n=-1))
|
||||||
|
|
||||||
|
data_cd4$ymax<-cumsum(data_cd4$value)
|
||||||
|
data_cd4$ymin<-c(0, head(data_cd4$ymax, n=-1))
|
||||||
|
|
||||||
|
data1<-rbind(data_cd8, data_cd4)
|
||||||
|
|
||||||
|
|
||||||
|
color<-c(c("CTLA4+ LAG3+ PD1+ TIGIT+ TIM3+"="black","All Negative"="grey90","Other"="grey50", "PD1+"="#C07AFF", "CTLA4+"="#3EB3DE","TIM3+"="#5EF551","LAG3+"="#DEBB3E","TIGIT+"="#FA7055"),
|
||||||
|
c("CTLA4+ PD1+"="#6666FF","PD1+ TIM3+"="#849CA8", "LAG3+ PD1+"="#C47F9F","PD1+ TIGIT+"="#D259AA", "CTLA4+ TIM3+"="#4ED498", "CTLA4+ LAG3+"="#8EB78E", "CTLA4+ TIGIT+"="#9C929A", "LAG3+ TIM3+"="#9ED848", "TIGIT+ TIM3+"="#ACB353", "LAG3+ TIGIT+"="#EC964A"),
|
||||||
|
c("CTLA4+ PD1+ TIGIT+"="#B86B6A","CTLA4+ PD1+ TIGIT+ TIM3+"="#B81515","LAG3+ PD1+ TIGIT+"="#007D8A", "PD1+ TIGIT+ TIM3+"="#D64545", "LAG3+ PD1+ TIGIT+ TIM3+"="#0f5860", "LAG3+ TIGIT+ TIM3+"="#50cad3"))
|
||||||
|
basic.color<-color[c("PD1+","TIGIT+","TIM3+","CTLA4+","LAG3+")]
|
||||||
|
names(basic.color)<-c("PD1","TIGIT","TIM3","CTLA4","LAG3")
|
||||||
|
# Make the plot
|
||||||
|
g_coex<-ggplot(data1)+
|
||||||
|
facet_grid(factor(Population, levels=c("CD8","CD4"))~.)+
|
||||||
|
geom_rect(aes(ymax=ymax, ymin=ymin, xmax=4.5, xmin=0), fill=color[data1$phen])+
|
||||||
|
geom_rect(aes(ymax=ymax, ymin=ymin, xmax=5.4, xmin=5, fill=factor(phen1, levels=c("PD1","TIGIT","TIM3","CTLA4","LAG3"))))+
|
||||||
|
geom_rect(aes(ymax=ymax, ymin=ymin, xmax=5.9, xmin=5.5, fill=factor(phen4, levels=c("PD1","TIGIT","TIM3","CTLA4","LAG3"))))+
|
||||||
|
geom_rect(aes(ymax=ymax, ymin=ymin, xmax=6.4, xmin=6, fill=factor(phen2, levels=c("PD1","TIGIT","TIM3","CTLA4","LAG3"))))+
|
||||||
|
geom_rect(aes(ymax=ymax, ymin=ymin, xmax=6.9, xmin=6.5, fill=factor(phen3, levels=c("PD1","TIGIT","TIM3","CTLA4","LAG3"))))+
|
||||||
|
geom_rect(aes(ymax=ymax, ymin=ymin, xmax=7.4, xmin=7, fill=factor(phen5, levels=c("PD1","TIGIT","TIM3","CTLA4","LAG3"))))+
|
||||||
|
scale_fill_manual(values = basic.color, na.value="#FFFFFF00", drop=F, limits=c("PD1","TIGIT","TIM3","CTLA4","LAG3"), name="IC")+
|
||||||
|
coord_polar(theta="y") + # Try to remove that to understand how the chart is built initially
|
||||||
|
xlim(c(0, 8)) +# Try to remove that to see how to make a pie chart
|
||||||
|
theme_classic()+
|
||||||
|
theme(strip.background = element_blank(),
|
||||||
|
strip.text = element_text(size=12, face="bold"),
|
||||||
|
axis.line = element_blank(),
|
||||||
|
axis.ticks = element_blank(),
|
||||||
|
# plot.margin = margin(-200,0,0,0),
|
||||||
|
axis.text = element_blank())
|
||||||
|
|
||||||
|
nodes<-gs_get_pop_paths(gs)
|
||||||
|
nodes_parent<-nodes[!grepl("CTLA4|LAG3|PD1|TIGIT|TIM3|root$", nodes)]
|
||||||
|
nodes_cd4<-nodes[grepl("CTLA4$|LAG3$|PD1$|TIGIT$|TIM3$", nodes) & grepl("/CD4/",nodes)]
|
||||||
|
nodes_cd8<-nodes[grepl("CTLA4$|LAG3$|PD1$|TIGIT$|TIM3$", nodes) & grepl("/CD8/",nodes)]
|
||||||
|
|
||||||
|
# g1<-ggcyto_arrange(autoplot(gs[[ab]], nodes_parent, bins=128), nrow=1)
|
||||||
|
# g2<-ggcyto_arrange(autoplot(gs[[iso]], nodes_cd8, bins=64), nrow=1)
|
||||||
|
# g3<-ggcyto_arrange(autoplot(gs[[ab]], nodes_cd8, bins=64), nrow=1)
|
||||||
|
# g4<-ggcyto_arrange(autoplot(gs[[iso]], nodes_cd4, bins=64), nrow=1)
|
||||||
|
# g5<-ggcyto_arrange(autoplot(gs[[ab]], nodes_cd4, bins=64), nrow=1)
|
||||||
|
g1<-ggcyto_arrange(autoplot(gs[[ab]], nodes_parent), nrow=1)
|
||||||
|
g2<-ggcyto_arrange(autoplot(gs[[iso]], nodes_cd8), nrow=1)
|
||||||
|
g3<-ggcyto_arrange(autoplot(gs[[ab]], nodes_cd8), nrow=1)
|
||||||
|
g4<-ggcyto_arrange(autoplot(gs[[iso]], nodes_cd4), nrow=1)
|
||||||
|
g5<-ggcyto_arrange(autoplot(gs[[ab]], nodes_cd4), nrow=1)
|
||||||
|
g_dots<-gridExtra::gtable_rbind(g1,g2,g3,g4,g5)
|
||||||
|
|
||||||
|
g_all<-ggpubr::ggarrange(g_dots, g_coex, nrow=1, widths=c(0.65,0.35))
|
||||||
|
ggsave(paste0(route,id,".IC.png"), g_all, width = 14, height = 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1079,17 +1250,47 @@ server <- function(input, output) {
|
|||||||
sampleNames(gs)<-sapply(sampleNames(gs), function(x) strsplit(x, "ICs ")[[1]][2]) %>%
|
sampleNames(gs)<-sapply(sampleNames(gs), function(x) strsplit(x, "ICs ")[[1]][2]) %>%
|
||||||
gsub("[[:space:]][0-9]*.fcs_.[0-9]*","", . , perl = T)
|
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<-gs_get_pop_paths(gs)
|
||||||
# nodes<-gsub("â\u0081»", "-", nodes)
|
# nodes<-gsub("â\u0081»", "-", nodes)
|
||||||
# nodes<-gsub("â\u0081º", "+", nodes)
|
# nodes<-gsub("â\u0081º", "+", nodes)
|
||||||
nodes<-nodes[grepl("CTLA4", 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<-gs_pop_get_stats(gs, nodes=nodes,type="percent") %>% as.data.frame %>% mutate(percent=percent*100)
|
||||||
pop$percent<-round(pop$percent, digits=2)
|
pop$percent<-round(pop$percent, digits=2)
|
||||||
|
|
||||||
pop$pop<-gsub("â\u0081»", "n", pop$pop)
|
# pop$pop<-gsub("â\u0081»", "n", pop$pop)
|
||||||
pop$pop<-gsub("â\u0081º", "p", 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$pop<-gsub(" ", "_", pop$pop)
|
||||||
|
|
||||||
pop["Type"]<-"ab"
|
pop["Type"]<-"ab"
|
||||||
@@ -1104,12 +1305,28 @@ server <- function(input, output) {
|
|||||||
pop_sp$pop<-sapply(strsplit(pop_sp$pop, "/"), tail, 1)
|
pop_sp$pop<-sapply(strsplit(pop_sp$pop, "/"), tail, 1)
|
||||||
|
|
||||||
pop_sp<-pop_sp %>% select(-ab,-iso) %>% spread(pop,Net)
|
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)
|
gather(pop, value, -sample,-Population) %>% summarise(n=100-sum(value)) %>% pull(n)
|
||||||
pop_sp <- rename(pop_sp, "samples"="sample")
|
if (input$dbtype == "OV"){
|
||||||
|
pop_sp <- rename(pop_sp, "samples"="sample")
|
||||||
|
}
|
||||||
|
if (input$dbtype %in% c("UM", "CC")){
|
||||||
|
pop_sp <- rename(pop_sp, "CODIGO"="sample")
|
||||||
|
}
|
||||||
|
|
||||||
|
pop_sql<-sqlFetch(dta, "IC") %>% slice(0)
|
||||||
|
pop_sp<-pop_sp %>% merge(pop_sql, all=T) %>% select(colnames(pop_sql))
|
||||||
|
|
||||||
|
if (input$dbtype == "OV"){
|
||||||
|
vartypes<-rep("Number", pop_sp %>% select(-samples, -Population) %>% colnames %>% length)
|
||||||
|
names(vartypes)<-pop_sp %>% select(-samples, -Population) %>% colnames
|
||||||
|
}
|
||||||
|
if (input$dbtype %in% c("UM", "CC")){
|
||||||
|
vartypes<-rep("Number", pop_sp %>% select(-CODIGO, -Population) %>% colnames %>% length)
|
||||||
|
names(vartypes)<-pop_sp %>% select(-CODIGO, -Population) %>% colnames
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
vartypes<-rep("Number", pop_sp %>% select(-samples, -Population) %>% colnames %>% length)
|
|
||||||
names(vartypes)<-pop_sp %>% select(-samples, -Population) %>% colnames
|
|
||||||
|
|
||||||
sqlSave(dta, pop_sp, tablename="IC", append = T, varTypes = vartypes, rownames = F)
|
sqlSave(dta, pop_sp, tablename="IC", append = T, varTypes = vartypes, rownames = F)
|
||||||
print("Tabla IC sincronizada.")
|
print("Tabla IC sincronizada.")
|
||||||
|
|||||||
Reference in New Issue
Block a user