RGLab / openCyto

A package that provides data analysis pipeline for flow cytometry.
GNU Affero General Public License v3.0
75 stars 29 forks source link

Quad gates not working #254

Open sbg30 opened 2 months ago

sbg30 commented 2 months ago

Hi,

I am currently facing a problem previously reported but the provided solution did not resolve it (https://github.com/RGLab/openCyto/issues/201), I am trying to add a quad gate to an existing gatingset :

wsfile <- open_flowjo_xml('~/Documents/ICS/240506/fcs_files/07-May-2024.wsp') gatingset <- flowjo_to_gatingset(wsfile)

class(wsfile)

plot(gatingset) autoplot(gatingset[[2]])

gs_add_gating_method_init(gatingset)

gs_add_gating_method( gatingset, alias = "A,B,C,D", pop = "*", parent = "cd3neg", dims = "Comp-BUV563-A,Comp-BV605-A", gating_method = "gate_quad_sequential", gating_args = list(gFunc = 'mindensity') )

But it creates the following error:

Error in (function (fs, pp_res, gFunc, popAlias, channels, gFunc_args) : failed at 181503.fcs_0000000000000123906 Error in UseMethod("filter") : no applicable method for 'filter' applied to an object of class "flowFrame"

I also tried to create all the gates manually from raw data:

fcsfilesloaded <- load_cytoset_from_fcs(fcsfilesraw, transformation = F, compensation = F) [...] But I end up facing the same error

I made sure I had the last version of the different packages:

R version 4.4.1 (2024-06-14) Platform: aarch64-apple-darwin20 Running under: macOS Ventura 13.2.1

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Paris tzcode source: internal

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

other attached packages: [1] patchwork_1.2.0 paletteer_1.6.0 ggsci_3.2.0 forcats_1.0.0 rstatix_0.7.2 [6] ggpubr_0.6.0 stringr_1.5.1 gt_0.10.1 purrr_1.0.2 dplyr_1.1.4 [11] ggcyto_1.33.0 ncdfFlow_2.51.0 BH_1.84.0-0 ggplot2_3.5.1 flowAI_1.35.0 [16] CytoML_2.17.0 openCyto_2.17.1 flowWorkspace_4.17.0 flowCore_2.17.0

loaded via a namespace (and not attached): [1] changepoint_2.2.4 tidyselect_1.2.1 farver_2.1.2 fastmap_1.2.0 XML_3.99-0.17 [6] digest_0.6.36 lifecycle_1.0.4 magrittr_2.0.3 compiler_4.4.1 rlang_1.1.4 [11] tools_4.4.1 utf8_1.2.4 yaml_2.3.8 data.table_1.15.4 knitr_1.47 [16] ggsignif_0.6.4 labeling_0.4.3 htmlwidgets_1.6.4 plyr_1.8.9 xml2_1.3.6 [21] RColorBrewer_1.1-3 abind_1.4-5 withr_3.0.0 RProtoBufLib_2.17.0 BiocGenerics_0.51.0 [26] grid_4.4.1 stats4_4.4.1 fansi_1.0.6 colorspace_2.1-0 scales_1.3.0 [31] cli_3.6.3 rmarkdown_2.27 generics_0.1.3 rstudioapi_0.16.0 reshape2_1.4.4 [36] zlibbioc_1.51.1 parallel_4.4.1 BiocManager_1.30.23 matrixStats_1.3.0 vctrs_0.6.5 [41] jsonlite_1.8.8 carData_3.0-5 cytolib_2.17.0 car_3.1-2 S4Vectors_0.43.0 [46] RBGL_1.81.0 Rgraphviz_2.49.0 hexbin_1.28.3 tidyr_1.3.1 glue_1.7.0 [51] rematch2_2.1.2 stringi_1.8.4 gtable_0.3.5 munsell_0.5.1 tibble_3.2.1 [56] pillar_1.9.0 htmltools_0.5.8.1 graph_1.83.0 R6_2.5.1 evaluate_0.24.0 [61] lattice_0.22-6 Biobase_2.65.0 backports_1.5.0 broom_1.0.6 Rcpp_1.0.12 [66] flowClust_3.43.0 gridExtra_2.3 xfun_0.45 zoo_1.8-12 pkgconfig_2.0.3

Is there something I am doing wrong ?

Thanks

sbg30 commented 2 months ago

EDIT: I have found a conflicting package that had another "filter" function and removed it, allowing for the gate_quad_sequential function to operate.

However, I still face some difficulties while trying to use it in a gatingTemplate csv file:

When I tried to use this:

alias pop parent dims gating_method gating_args
A,B,C,D * cd3neg cd16,cd56 gate_quad_sequential gFunc='mindensity'

I face the same error as was described before (https://github.com/RGLab/openCyto/issues/241) : Error in pops[[2]] : subscript out of bounds

I then assumed that the new version had not been merged yet and that pop=* is not yet available for the quadGate.seq ?

But then when I tried

alias pop parent dims gating_method gating_args
'* +/-+/- cd3neg cd16,cd56 gate_quad_sequential gFunc='mindensity'
nk + cd3neg cd16,cd56 boolGate !cd16-cd56-

Then I face another error : Error in h(simpleError(msg, call)) : error in evaluating the argument 'from' in selecting a method for function 'addEdge': Not able to to find reference to: cd16-cd56- (same thing if I use the channels BUV563-A and BV605-A instead of the marker names). Even though the quad gates are correctly designed (displayed through ggcyto), it looks like the reference gating names created by the quadgate are not correctly included in the gating tree ?

Thanks !