selecting multiple clusters from flowClust::tmixFilter
1
0
Entering edit mode
@gene_bioconductor-22210
Last seen 7 months ago
United States

I'm trying to incorporate tmixFilter into a flowCore/flowWorkspace-based FACS data analysis. The primary problem I'm having is that I need to select multiple clusters the tmixFilter results and I can't find any examples a "flowCore"-y way of doing that.

Below is what I have been doing, but it's a complicated workflow that doesn't fit in well with the flowCore-family of workflows. For example, I'd like to incorporate this gating into a GatingWorkflow and be able to use the various plotting functions to visualize gating and backgating.

# 'fs' is a flowSet object
ssca_fsca_tmix <- flowCore::filter(fs, tmixFilter('SSCA_FSCA', c("FSC-A","SSC-A"), K=6, level=0.95))

# now I need to figure out which of the 6 clusters per flowFrame are the ones I need
# there are usually two
FSC_A.bounds <- c(70000,170000)
SSC_A.bounds <- c(10000,50000)

tmix_gate_summary <- tibble(i=seq_along(ssca_fsca_tmix)) %>% 
    # pull out the raw FSC-A and SSC-A data and combine it with the tmixFilter cluster assignment
    mutate(raw.data = map(i, ~tibble(
        `FSC-A`=fs[[.x]]@exprs[,"FSC-A"],
        `SSC-A`=fs[[.x]]@exprs[,"SSC-A"],
        cluster=ssca_fsca_tmix@.Data[[.x]]@subSet
    ))) %>%
    # calculate median FSC-A and SSC-A values for each tmixFilter cluster
    mutate(summary.data = map(raw.data, function(x){
        x %>% dplyr::filter(!is.na(cluster)) %>% 
            group_by(cluster) %>%
            summarize(`FSC-A`=median(`FSC-A`),`SSC-A`=median(`SSC-A`))
    })) %>%
    # identify the clusters with medians in the desired ranges
    mutate(selected.clusters = map(summary.data, function(x){
        x %>% dplyr::filter(
                between(`FSC-A`, FSC_A.bounds[1], FSC_A.bounds[2]),
                between(`SSC-A`, SSC_A.bounds[1], SSC_A.bounds[2])
            ) %>% pull(cluster)
    }))

# use flowClust::split to pull out the desired clusters from each flowFrame
flowFrames <- lapply(seq_along(fs), function(j) {
    cluster_numbers <- tmix_gate_summary %>% 
        dplyr::filter(i == j) %>% 
        pull(selected.clusters) %>%
        unlist
    split(fs[[j]], ssca_fsca_tmix[[j]], population=list(my_filter=cluster_numbers))
})

# combine these back into a new flowSet
fs_gated <- flowSet(lapply(flowFrames, function(x) x$my_filter ))

As an alternate workflow, I did come across cytoUtils::tmix2DGate. I can get the clusters out of that, and pull them out at as ellipse gates, but I can't figure out how to create gates which are the union of these multiple ellipse gates per flowFrame.

flowClust tmixFilter • 887 views
ADD COMMENT
0
Entering edit mode
Jiang, Mike ★ 1.3k
@jiang-mike-4886
Last seen 3.2 years ago
(Private Address)

flowCore::workflow was deprecated by flowWorkspace::GatingSet for representing/storing/manipulating the gating trees and gated subpopulation data. Take a look at the vignette of flowWorkspace for the basics of adding/querying the gates through GatingSet. On top of that, you can further automate your gating process by using openCyto. Regarding to the union of gates, it can achieved by flowWorkspace::booleanFilter or (boolGate method within the context of openCyto)

ADD COMMENT
0
Entering edit mode

Thanks, Mike.

For a tmixFilter which returns multiple clusters, is there a way to turn an individual cluster (let's say cluster 4 out of k=6 clusters) as a gate? In the vignettes, I'm seeing gates accessed as "myGate+" or "myGate-", I haven't come across example code for something like "myGate #4".

ADD REPLY

Login before adding your answer.

Traffic: 1043 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6