flowjo_to_gatingset() subset samples issue
0
0
Entering edit mode
@5dff3b52
Last seen 2.6 years ago
United States

Hi Bioconductor Community -

I run multiple experiments on a flow cytometer at the same time in multiple 96-well plates. I gate the data in FlowJo and then want to further analyze each experiment individually in R. My problem is that I am unable to grab just the subset of samples from a particular experiment when generating a gating set using the CytoML::flowjo_to_gatingset() function.

For example, if I have a flow cytometry run with four A1 Well_001.fcs samples (keyword = $FIL), and I only am interested in analyzing one of those samples, the documentation for the function suggests I should be able to add a parameter such as the '$TOT' keyword to generate unique sample identifier to help subset, but I can't get this to work.

Here is my process. I first load the FlowJo workspace into R:

>library(CytoML)
>
>wsfile <- flowjo_workspace.wsp # path flowjo workspace file
>
>ws <- open_flowjo_xml(wsfile)
>ws

Groups in Workspace
              Name Num.Samples
1      All Samples         264
2 Panel 10 Plate 1          72
3 Panel 10 Plate 2          72
4 Panel 10 Plate 3          72
5 Panel 10 Plate 4          48

>fj_ws_get_samples(ws)

sampleID            name  count pop.counts
1          8 A1 Well_001.fcs   1024         27
2         83 A1 Well_001.fcs  11096         27
3        155 A1 Well_001.fcs   5040         27
4        224 A1 Well_001.fcs 181896         27
5          9 A2 Well_002.fcs  22984         27
6         84 A2 Well_002.fcs  11120         27
7        156 A2 Well_002.fcs   9072         27
8        225 A2 Well_002.fcs 144856         27
9         10 A3 Well_003.fcs  22856         27
10        85 A3 Well_003.fcs  17040         27
11       157 A3 Well_003.fcs  14872         27
12       226 A3 Well_003.fcs 153888         27
13        11 A4 Well_004.fcs  44040         27

The samples in each group have the same $FIL names: A1 Well_001.fcs, A2 Well_002, A3 Well_003.fcs, etc, with group 5 having fewer samples. I omitted many rows from the fj_ws_get_samples(ws) printout.

I then only want to create a gating set from sampleIDs 4 and 13 from the above output (they belong to different workspace groups). I think I should store their $TOT values in a vector to pass to the function, but the gating set (gs) contains 8 samples, not the expected 2 samples: "A1 Well_001.fcs_181896" and "A3 Well_003.fcs_17040".

>total <- c("181896", "17040")
>
>gs <- flowjo_to_gatingset(ws, 
>                          name = "All Samples", 
>                          subset = `$TOT` %in% total, 
>                          keywords = "$TOT")
>
>sampleNames(gs)

[1] "A1 Well_001.fcs_1024"   "A1 Well_001.fcs_11096"  "A1 Well_001.fcs_5040"   "A1 Well_001.fcs_181896"
[5] "A3 Well_003.fcs_22856"  "A3 Well_003.fcs_17040"  "A3 Well_003.fcs_14872"  "A3 Well_003.fcs_153888"

I have also tried something more explicit with no luck:

>total <- c("A1 Well_001.fcs_181896", "A3 Well_003.fcs_17040")
>
>gs <- flowjo_to_gatingset(ws, 
>                          name = "All Samples", 
>                          subset = paste(`$FIL`, `$TOT`, sep="_") %in% total, 
>                          keywords = c("$FIL","$TOT"))
>
>sampleNames(gs)

[1] "A1 Well_001.fcs_1024"   "A1 Well_001.fcs_11096"  "A1 Well_001.fcs_5040"   "A1 Well_001.fcs_181896"
[5] "A3 Well_003.fcs_22856"  "A3 Well_003.fcs_17040"  "A3 Well_003.fcs_14872"  "A3 Well_003.fcs_153888"

The gating set contains all of the "A1 Well_001.fcs" and "A3 Well_003.fcs" files, and I can't figure out how to just subset the two files of interest. I've also played around with the additional.keys, additional.sampleID, and greedy_match parameters with no luck.

Any help would be much appreciated!

>sessionInfo( )

R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] plyr_1.8.7               forcats_0.5.1            ggpubr_0.4.0             kableExtra_1.3.4        
 [5] ggprism_1.0.3            gridExtra_2.3            ggcyto_1.22.0            flowWorkspace_4.6.0     
 [9] ncdfFlow_2.40.0          BH_1.78.0-0              RcppArmadillo_0.11.0.0.0 flowCore_2.6.0          
[13] assertr_2.8              CytoML_2.6.0             humarrow_0.0.0.9000      ggplot2_3.3.5           
[17] dplyr_1.0.8              readr_2.1.2             

loaded via a namespace (and not attached):
  [1] colorspace_2.0-3    ggsignif_0.6.3      ellipsis_0.3.2      rprojroot_2.0.3     cytolib_2.6.2       base64enc_0.1-3    
  [7] fs_1.5.2            rstudioapi_0.13     hexbin_1.28.2       remotes_2.4.2       bit64_4.0.5         fansi_1.0.3        
 [13] xml2_1.3.3          cachem_1.0.6        knitr_1.39          pkgload_1.2.4       jsonlite_1.8.0      broom_0.8.0        
 [19] png_0.1-7           graph_1.72.0        BiocManager_1.30.17 compiler_4.1.0      httr_1.4.2          backports_1.4.1    
 [25] Matrix_1.3-3        fastmap_1.1.0       cli_3.2.0           htmltools_0.5.2     prettyunits_1.1.1   tools_4.1.0        
 [31] gtable_0.3.0        glue_1.6.2          rappdirs_0.3.3      Rcpp_1.0.8.3        carData_3.0-5       Biobase_2.54.0     
 [37] jquerylib_0.1.4     cellranger_1.1.0    vctrs_0.4.1         svglite_2.1.0       xfun_0.30           stringr_1.4.0      
 [43] ps_1.7.0            brio_1.1.3          testthat_3.1.3      rvest_1.0.2         lifecycle_1.0.1     devtools_2.4.3     
 [49] rstatix_0.7.0       XML_3.99-0.9        zlibbioc_1.40.0     scales_1.2.0        vroom_1.5.7         RProtoBufLib_2.6.0 
 [55] hms_1.1.1           parallel_4.1.0      RBGL_1.70.0         RColorBrewer_1.1-3  yaml_2.3.5          curl_4.3.2         
 [61] reticulate_1.24     memoise_2.0.1       aws.signature_0.6.0 sass_0.4.1          latticeExtra_0.6-29 stringi_1.7.6      
 [67] highr_0.9           S4Vectors_0.32.4    desc_1.4.1          BiocGenerics_0.40.0 pkgbuild_1.3.1      rlang_1.0.2        
 [73] pkgconfig_2.0.3     systemfonts_1.0.4   matrixStats_0.62.0  evaluate_0.15       lattice_0.20-44     purrr_0.3.4        
 [79] bit_4.0.4           tidyselect_1.1.2    processx_3.5.3      magrittr_2.0.3      R6_2.5.1            generics_0.1.2     
 [85] pillar_1.7.0        withr_2.5.0         abind_1.4-5         tibble_3.1.6        crayon_1.5.1        car_3.0-12         
 [91] utf8_1.2.2          tzdb_0.3.0          rmarkdown_2.14      aws.s3_0.3.21       jpeg_0.1-9          usethis_2.1.5      
 [97] readxl_1.4.0        data.table_1.14.2   callr_3.7.0         Rgraphviz_2.38.0    digest_0.6.29       webshot_0.5.3      
[103] tidyr_1.2.0         RcppParallel_5.1.5  stats4_4.1.0        munsell_0.5.0       viridisLite_0.4.0   bslib_0.3.1        
[109] sessioninfo_1.2.2
CytoML • 702 views
ADD COMMENT

Login before adding your answer.

Traffic: 589 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