From 0813dbf52a57dd72214f0f9726795fb25af4c861 Mon Sep 17 00:00:00 2001 From: marcelcosta Date: Wed, 17 Apr 2024 17:29:14 +0200 Subject: [PATCH] Modificar gates_save para que no de error de ambiguedad --- functionsCyto.R | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/functionsCyto.R b/functionsCyto.R index 3a3d98d..7a24931 100644 --- a/functionsCyto.R +++ b/functionsCyto.R @@ -235,13 +235,14 @@ LMD2FCS<-function(files, output.dir=NULL){ gates_save<-function(gs, file="gates.rds", save=T, include=NULL){ gates.list<-list() - pop_paths<-gs_get_pop_paths(gs)[gs_get_pop_paths(gs) != "root"] - if(!is.null(include)){pop_paths<-pop_paths[pop_paths %in% include]} - pop_paths<-lapply(pop_paths, function(x) rev(rev(strsplit(x, "/")[[1]])[1:2])) - for (gate in pop_paths){ + pop_paths_full<-gs_get_pop_paths(gs)[gs_get_pop_paths(gs) != "root"] + if(!is.null(include)){pop_paths_full<-pop_paths_full[pop_paths %in% include]} + pop_paths<-lapply(pop_paths_full, function(x) rev(rev(strsplit(x, "/")[[1]])[1:2])) + for (gate.in in 1:length(pop_paths)){ + gate<-pop_paths[[gate.in]] parent<-if (gate[1] == ""){"root"}else{gate[1]} gated_pop<-gate[2] - gates.list[[paste0(parent,"/",gated_pop)]]<-gs_pop_get_gate(gs, gated_pop) + gates.list[[paste0(parent,"/",gated_pop)]]<-gs_pop_get_gate(gs, pop_paths_full[gate.in]) } if(save){saveRDS(gates.list, file)} return(gates.list)