It is useful when we want to alter the popluation at events level yet without removing or adding the existing gates.

gh_pop_set_indices(obj, y, z)

Arguments

obj

GatingHierarchy object

y

character node name or path

z

logical vector as local event indices relative to node y

Examples

library(flowWorkspace) dataDir <- system.file("extdata",package="flowWorkspaceData") suppressMessages(gs <- load_gs(list.files(dataDir, pattern = "gs_manual",full = TRUE))) gh <- gs[[1]] #get pop counts pop.stats <- gh_pop_get_stats(gh, nodes = c("CD3+", "CD4", "CD8")) pop.stats
#> pop count #> 1: CD3+ 54483 #> 2: CD4 34032 #> 3: CD8 14564
# subsample 30% cell events at CD3+ node total <- gh_pop_get_count(gh, "root") gInd <- seq_len(total) #create integer index for cd3 gInd <- sample.int(total, size = total * 0.3) #randomly select 30% #convert it to logicle index gInd.logical <- rep(FALSE, total) gInd.logical[gInd] <- TRUE #replace the original index stored at GatingHierarchy gh_pop_set_indices(gh, "CD3+", gInd.logical) #check the updated pop counts gh_pop_get_stats(gs[[1]], nodes = c("CD3+", "CD4", "CD8")) #note that CD4, CD8 are not updated
#> pop count #> 1: CD3+ 35859 #> 2: CD4 34032 #> 3: CD8 14564
#update all the descendants of CD3+ nodes <- gh_pop_get_descendants(gh, "CD3+") for (node in nodes) suppressMessages(recompute(gh, node)) gh_pop_get_stats(gs[[1]], nodes = c("CD3+", "CD4", "CD8")) #now all are update to date
#> pop count #> 1: CD3+ 35859 #> 2: CD4 11148 #> 3: CD8 4984