Compare commits

..

6 Commits

+13 -9
View File
@@ -1,4 +1,4 @@
gs_export_pop<-function(gs, pop, trim.channels=T){
gs_export_pop<-function(gs, pop, trim.channels=T, inverse.transform=F){
pop.dt<-c()
# Initializes the progress bar
pb <- txtProgressBar(min = 0, # Minimum value of the progress bar
@@ -10,7 +10,7 @@ gs_export_pop<-function(gs, pop, trim.channels=T){
for (i in 1:length(gs)){
samp<-sampleNames(gs)[i]
data<-as.data.frame(flowCore::exprs(gh_pop_get_data(gs[[samp]], pop))) %>% add_column("Sample"=samp)
data<-as.data.frame(flowCore::exprs(gh_pop_get_data(gs[[samp]], pop, inverse.transform=inverse.transform))) %>% add_column("Sample"=samp)
if (length(pop.dt) > 0){
pop.dt<-rbind(pop.dt, data)
}else{
@@ -71,7 +71,7 @@ transform_gs<-function(gs, saveparams=NULL, trans_params_obj=NULL, index=1){
if (is.null(trans_params_obj)){
log_mark<-colnames(gs)[!grepl("FS|SS|Time", colnames(gs))]
trans_params<-lapply(log_mark, function(x) list(channel=x, scale="biexp",maxvalue=250000,pos=4, widthBasis=-400, max=5, min=0))
trans_params<-lapply(log_mark, function(x) list(channel=x, scale="biexp",maxvalue=250000,pos=4, widthBasis=-400, max=10^3.7, min=0))
names(trans_params)<-log_mark
log_mark_lin<-colnames(gs)[grepl("FS|SS|Time", colnames(gs))]
trans_params_lin<-lapply(log_mark_lin, function(x) list(channel=x, scale="lin",
@@ -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_full %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)
@@ -285,7 +286,9 @@ gs_gate_interactive_regate2<-function(gs, filterId, sample=1, subset="root", ...
dims<-list(names(gs_pop_get_gate(gs, filterId)[[1]]@parameters)[1],
names(gs_pop_get_gate(gs, filterId)[[1]]@parameters)[2])
childrens<-gs_pop_get_children_recursive(gs, filterId)
if (length(childrens)>0){
childrens_gate<-gates_save(gs, save=F, include=childrens)
}
gs_pop_add(gs, gs_pop_get_gate(gs, filterId), parent=subset, name="duplicated")
@@ -296,6 +299,7 @@ gs_gate_interactive_regate2<-function(gs, filterId, sample=1, subset="root", ...
dims = dims, regate=T, overlayGates = "duplicated")
gs_pop_remove(gs, "duplicated")
if (length(childrens)>0){
gates_apply(gs, childrens_gate)
}
}