Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cyto_gate_apply fails to restore quadrant gate from gatingTemplate #220

Open
rwbaer opened this issue Oct 26, 2024 · 1 comment
Open

cyto_gate_apply fails to restore quadrant gate from gatingTemplate #220

rwbaer opened this issue Oct 26, 2024 · 1 comment
Labels
Bug Something isn't working

Comments

@rwbaer
Copy link

rwbaer commented Oct 26, 2024

Describe the bug
Can't reconstruct quadrant gates from a gatingTemplate

To Reproduce
Steps to reproduce the behavior:

  1. Create a gating templat
  2. Restart R, create the gatingset again from the same dateausing the gaing template,
    and cyto_gatingTemplate_apply(gsSamp, "Samples-Template.csv")
  3. The gating set creation fails at reproducing the quad gate
  4. Try to remove the quad gate so that it can be created by hand, it won't delete because it doesn't exist
  5. Try to recreate the quad gate, it can't be created because it already exists

I'm not clear whether this is important, but the alias gets created as Q1,Q2,Q3,Q4 despite the fact that I create it originally with 4 distinct names. It is hard to finde a clear description of how these names are to be handled in flowworkspace, but they seem to be handled largely as 4 individual gates which can be referenced by name. My template file is attached further down.

That said, using the alias alias = Q1,Q2,Q3,Q4, did not assist in gate removal.

The error for the sequencd is shown below


> cyto_gatingTemplate_apply(gsSamp, "Samples-Template.csv")
Applying Samples-Template.csv to the GatingSet...
Skip preprocessing! Population 'Non-Debris' already exists.
Skip gating! Population 'Non-Debris' already exists.
Skip preprocessing! Population 'Single Cells' already exists.
Skip gating! Population 'Single Cells' already exists.
Skip preprocessing! Population 'Bait' already exists.
Skip gating! Population 'Bait' already exists.
Skip preprocessing! Population 'Macrophages' already exists.
Skip gating! Population 'Macrophages' already exists.
Error in length(gs_nodes) == 0 || !popAlias %in% gs_nodes : 
  'length = 4' in coercion to 'logical(1)'
In addition: Warning messages:
1: In .local(from, to, graph) :
  edges replaced: ‘/Non-Debris/Single Cells/Macrophages|/Non-Debris/Single Cells/Macrophages/PredMac’
2: In .local(from, to, graph) :
  edges replaced: ‘/Non-Debris/Single Cells/Bait|/Non-Debris/Single Cells/Bait/PredMel’
cyto_nodes(gsSamp)
[1] "root"                                 "/Non-Debris"                          "/Non-Debris/Single Cells"            
[4] "/Non-Debris/Single Cells/Bait"        "/Non-Debris/Single Cells/Macrophages"
cyto_gate_draw(gsSamp, 
               parent = "Single Cells", 
               alias = c("Q1", "Q2", "Q3", "Q4"), 
               channels = c("FL3-AREA", "FL1-AREA"), 
               type = 'quadrant',
               gatingTemplate =  "Samples-Template.csv")
Q1 & Q2 & Q3 & Q4 already exists in Samples-Template.csv.
Error in FUN(X[[i]], ...) : 
  Supply another gatingTemplate or edit gate(s) using cyto_gate_edit.

 cyto_gate_remove(gsSamp, 
+                parent = "Single Cells", 
+                alias = c("Q1", "Q2", "Q3", "Q4"), 
+                channels = c("FL3-AREA", "FL1-AREA"), 
+                type = 'quadrant',
+                gatingTemplate =  "Samples-Template.csv")
Error in FUN(X[[i]], ...) : Q1 does not exist in this GatingSet!

# ======================
# Try again after recompute()
# ======================
recompute(gsSamp)
done!
> cyto_nodes(gsSamp)
[1] "root"                                 "/Non-Debris"                          "/Non-Debris/Single Cells"            
[4] "/Non-Debris/Single Cells/Bait"        "/Non-Debris/Single Cells/Macrophages"


> cyto_gate_draw(gsSamp, 
+                parent = "Single Cells", 
+                alias = c("Q1", "Q2", "Q3", "Q4"), 
+                channels = c("FL3-AREA", "FL1-AREA"), 
+                type = 'quadrant',
+                gatingTemplate =  "Samples-Template.csv")
Q1 & Q2 & Q3 & Q4 already exists in Samples-Template.csv.
Error in FUN(X[[i]], ...) : 
  Supply another gatingTemplate or edit gate(s) using cyto_gate_edit.


> cyto_gate_remove(gsSamp, 
+                parent = "Single Cells", 
+                alias = c("Q1", "Q2", "Q3", "Q4"), 
+                channels = c("FL3-AREA", "FL1-AREA"), 
+                type = 'quadrant',
+                gatingTemplate =  "Samples-Template.csv")
Error in FUN(X[[i]], ...) : Q1 does not exist in this GatingSet!
> 

Expected behavior
As this set of quad gates worked fine when originally constructed, I expected it to read in and get recreated from the template. I am uploading the template file so that you can see the details.

Samples-Template.csv

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS:
  • Host Name: CYBER-TOWER
    OS Name: Microsoft Windows 11 Pro Insider Preview
    OS Version: 10.0.27729 N/A Build 27729
    OS Manufacturer: Microsoft Corporation

Additional context

Sys.info()
sysname release version nodename machine login user effective_user
"Windows" "10 x64" "build 27729" "CYBER-TOWER" "x86-64" "rbaer" "rbaer" "rbaer"
R.Version()
$platform
[1] "x86_64-w64-mingw32"

$arch
[1] "x86_64"

$os
[1] "mingw32"

$crt
[1] "ucrt"

$system
[1] "x86_64, mingw32"

$status
[1] ""

$major
[1] "4"

$minor
[1] "4.1"

$year
[1] "2024"

$month
[1] "06"

$day
[1] "14"

$svn rev
[1] "86737"

$language
[1] "R"

$version.string
[1] "R version 4.4.1 (2024-06-14 ucrt)"

$nickname
[1] "Race for Your Life"

sessionInfo()
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 27729)

Matrix products: default

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

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
[1] shiny_1.9.1 patchwork_1.3.0 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1
[6] dplyr_1.1.4 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1 tibble_3.2.1
[11] tidyverse_2.0.0 CytoML_2.16.0 ggcyto_1.32.0 ncdfFlow_2.50.0 BH_1.84.0-0
[16] ggplot2_3.5.1 cytoverse_0.0.0.9000 CytoExploreR_1.1.0 openCyto_2.16.1 flowWorkspace_4.16.0
[21] flowCore_2.16.0

loaded via a namespace (and not attached):
[1] RBGL_1.80.0 gridExtra_2.3 rlang_1.1.4 magrittr_2.0.3 matrixStats_1.4.1 compiler_4.4.1
[7] png_0.1-8 vctrs_0.6.5 reshape2_1.4.4 pkgconfig_2.0.3 crayon_1.5.3 fastmap_1.2.0
[13] utf8_1.2.4 promises_1.3.0 rmarkdown_2.28 sessioninfo_1.2.2 tzdb_0.4.0 graph_1.82.0
[19] xfun_0.48 zlibbioc_1.50.0 cachem_1.1.0 jsonlite_1.8.9 later_1.3.2 parallel_4.4.1
[25] R6_2.5.1 bslib_0.8.0 stringi_1.8.4 RColorBrewer_1.1-3 reticulate_1.39.0 jquerylib_0.1.4
[31] Rcpp_1.0.13 knitr_1.48 zoo_1.8-12 timechange_0.3.0 httpuv_1.6.15 Matrix_1.7-0
[37] tidyselect_1.2.1 rstudioapi_0.16.0 yaml_2.3.10 lattice_0.22-6 plyr_1.8.9 Biobase_2.64.0
[43] withr_3.0.1 askpass_1.2.1 evaluate_1.0.0 Rtsne_0.17 EmbedSOM_2.1.2 pillar_1.9.0
[49] flowAI_1.34.0 stats4_4.4.1 generics_0.1.3 S4Vectors_0.42.1 hms_1.1.3 munsell_0.5.1
[55] scales_1.3.0 xtable_1.8-4 glue_1.8.0 changepoint_2.2.4 tools_4.4.1 hexbin_1.28.4
[61] robustbase_0.99-4-1 data.table_1.16.0 RSpectra_0.16-2 fs_1.6.4 visNetwork_2.1.2 XML_3.99-0.17
[67] grid_4.4.1 flowClust_3.42.0 RProtoBufLib_2.16.0 umap_0.2.10.0 colorspace_2.1-1 cli_3.6.3
[73] rsvd_1.0.5 rhandsontable_0.3.8 fansi_1.0.6 cytolib_2.16.0 Rgraphviz_2.48.0 gtable_0.3.5
[79] DEoptimR_1.1-3 sass_0.4.9 digest_0.6.37 BiocGenerics_0.50.0 farver_2.1.2 htmlwidgets_1.6.4
[85] memoise_2.0.1 htmltools_0.5.8.1 lifecycle_1.0.4 mime_0.12 openssl_2.2.2 MASS_7.3-60.2

@rwbaer rwbaer added the Bug Something isn't working label Oct 26, 2024
@rwbaer
Copy link
Author

rwbaer commented Oct 26, 2024

I tried the following:

# Build the quad gate by hand
qg <- quadGate("FL1-AREA"= 4.33097491134075, "FL3-AREA"= 4.97256199594861) # flowCore function)
nodeIDs <- gs_pop_add(gsSamp, qg, parent="Single Cells") # flowWorkspace function
nodeIDs
gs_get_pop_paths(gsSamp)
recompute(gsSamp)
gs_get_pop_paths(gsSamp, path = "auto") 
cyto_gate_rename(gsSamp, alias = c("Violet-AREA-Orange-AREA+", 
                                   "Violet-AREA+Orange-AREA+",
                                   "Violet-AREA+Orange-AREA-",
                                    "Violet-AREA-Orange-AREA-"),
                 names = c("Q1","Q2", "Q3", "Q4"), gatingTemplate = "Samples-Template.csv")

This added the expected quad gates with default names. However, it also produced an error when I tried to rename the gates in the template.

Although, I might have expected an "already exists" error for the Q1,Q2,Q3,Q4, I instead got the following error.

Error in cyto_gate_rename(gsSamp, alias = c("Violet-AREA-Orange-AREA+", :
Supplied gate(s) do not exist in this GatingSet.

They did exist in the "memory" gating set as confirmed by gs_get_pop_paths(gsSamp)

Despite the error from cyto_gate_rename(), the gate appear in the live (memory version) of the gating set when plotted and were usable to create two boolean gates

# first predMac
cyto_gate_bool(
  gsSamp,
  parent = "Macrophages",
  alias = "PredMac1",
  logic = "Macrophages&Q2",
  gatingTemplate = "Samples-Template.csv"
)
 
# Now Melanoma(Bait) Cells
cyto_gate_bool(
  gsSamp,
  parent = "Bait",
  alias = "PredMel1",
  logic = "Bait&Q2",
  gatingTemplate = "Samples-Template.csv"
)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant