RGLab / flowIncubator

Routines that don't belong to the core flow packages yet.
1 stars 3 forks source link

group multiple gatingsets #2

Closed mikejiang closed 11 years ago

mikejiang commented 11 years ago

The current flowWorkspace::rbind2 assumes the gatingsets to merge are already homogeneous i.e. the identical gating schemes and flow data structure.

From time to time, we need to automatically group all the individual GatingSets based on their: 1 gating schemes 2 flow data structures (drop the unused channels if needed ) and merge them into several bigger GatingSets.

mikejiang commented 11 years ago

Remove the 'split' method since the name is ambiguous. Instead,the argument "test.run = TRUE" is added to "merge" method:

It simply divides the original gatingSets into groups without actual merging the data when rest.run is TRUE.

merge(GatingSetList(gs_list), test.run = TRUE)

When rest.run is FALSE, The merging is done and returns GatingSetList that contains multiple GatingSets each of which share the same gating and data structure.

gs_list_merged <- merge(GatingSetList(gs_list) , test.run = FALSE)
mikejiang commented 11 years ago

The method below masked the base::merge method for data.frames.

setMethod("merge",signature=c("list"),function(x,...)

I guess the signature "list" is too generic , we are better off to rename it to "merge_gs"

ramhiser commented 11 years ago

I too have come across this issue. In some of my scripts I used base:::merge as a fix: merge_gs sounds fine to me.

On Tue, Apr 23, 2013 at 3:26 PM, Mike Jiang notifications@github.comwrote:

The method below masked the base::merge method for data.frames.

setMethod("merge",signature=c("list"),function(x,...)

I guess the signature "list" is too generic , we are better off to rename it to a "merge_gs"

— Reply to this email directly or view it on GitHubhttps://github.com/RGLab/flowIncubator/issues/2#issuecomment-16890755 .

John A. Ramey, Ph.D. Gottardo Lab, Vaccine and Infectious Disease Division Fred Hutchinson Cancer Research Center http://www.ramhiser.com Twitter: @ramhiser

mikejiang commented 11 years ago

looks like we want to give an option to remove redundant terminal gates automatically in order for the labkey to proceed the merging regardless of the inhomogeneous gating trees.

mikejiang commented 11 years ago

@ldash , here is some internal APIs for labkey to use:

#1.group gatingsets into groups by their tree structures
gs_groups <- .groupByTree(list(gs1,gs2)) 
gs_groups #if length ==1, skip 2,3, go directly to 4

#2. check and see whether the  descrepency of  tree structures can be resolved 
#    by removing some terminal gates 
toRemove <- .checkRedundantNodes(gs_groups) 
toRemove #this is the warning you want to report to the user before the actual deletion

#3. go ahead to drop those gates
.dropRedundantNodes(gs_groups,toRemove)

#4. proceed the final merging
new_group <- unlist(gs_groups)
res <- .mergeGS(new_group) 
res[[1]] #this is the gslist you need