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

Error in add_pop function #197

Closed abbatidanilo closed 5 years ago

abbatidanilo commented 5 years ago

Hello, I am trying to execute a singlet gate with the following commands:

gS <- GatingSet(flow_Set)
trans <- logicleTransform(w = 0.5, t = 262144, m = 4.5, a = 0)
inv <- inverseLogicleTransform(trans = trans)
trans.obj <- flow_trans("logicle", trans, inv, n = 5, equal.space = FALSE)
transList <- transformerList(from = pDname_subset, trans.obj)
gS.t <- transform(gS, transList)
FSC <- paste(pDname[1], pDname[2], sep = ",")
Singlets = add_pop(gS.t, alias = "Singlets", pop = "+", parent = "root", dims = FSC, gating_method = "singletGate",gating_args = "wider_gate=TRUE,subsample_pct=0.1" )

The two dimensions in the FCS variable are of course FSC-A and FCS-H accordingly with the correct dimensions in the flowSet. Please notice than the following command:

read.FCS(filename = "tmpdata/perc0.2dfF_sample_1.fcs") 

behaves normally with no error. It returns (for the every flowFrame - here only the first is reported):

_flowFrame object 'clean_p1_10p2_5sample1.fcs' with 8481 cells and 13 observables: name desc range minRange maxRange $P1 FSC-A FSC-A 262144 0.0000000 262144 $P2 FSC-H FSC-H 262144 0.0000000 262144 $P3 SSC-A SSC-A 262144 0.0000000 262144 $P4 FITC-A CD3 262144 0.0000000 262144 $P5 PE-A CD95 262144 0.0000000 262144 $P6 PerCP-A 7AAD 262144 0.0000000 262144 $P7 PE-Cy7-A CD45Ra 262144 0.0000000 262144 $P8 APC-A CD62L 262144 -0.1038134 262144 $P9 APC-Cy7-A CD8 262144 0.0000000 262144 $P10 Pacific Blue-A CD4 262144 0.0000000 262144 $P11 BV510-A BV510-A 262144 0.0000000 262144 $P12 Time Time 262144 0.0000000 262144 $P13 density density 4713 0.0000000 4712 198 keywords are stored in the 'description' slot

In any case I uploaded the .zip with all the flowFrame used I get the following error:

_Error: (converted from warning) Error in : failed at perc0.2dfF_sample1.fcs Error in rlm.default(x, y, weights, method = method, wt.method = wt.method, : (converted from warning) 'rlm' failed to converge in 5 steps

I also tried a simpler version without the latest two parameters:

Singlets = add_pop(gS.t, alias = "Singlets", pop = "+", parent = "root", dims = FSC, gating_method = "singletGate")

but I got the same error

Is there any way to overcome this behavior? Please tell me if you need any other element for your analysis

thank you cheers

ori.zip

gfinak commented 5 years ago

I cannot reproduce your issue:

library(flowCore)
library(flowWorkspace)
#> Loading required package: ncdfFlow
#> Loading required package: RcppArmadillo
#> Loading required package: BH
library(openCyto)
#> Registered S3 method overwritten by 'R.oo':
#>   method        from       
#>   throw.default R.methodsS3
f<-list.files(pattern = '1707.*.fcs', path = "~/Downloads/", full.names = TRUE)
flow_Set <- read.flowSet(f)
pDname_subset <- colnames(flow_Set)[4:11]
gS <- GatingSet(flow_Set)
#> .
#> ......done!
trans <- logicleTransform(w = 0.5, t = 262144, m = 4.5, a = 0)
inv <- inverseLogicleTransform(trans = trans)
trans.obj <- flow_trans("logicle", trans, inv, n = 5, equal.space = FALSE)
transList <- transformerList(from = pDname_subset, trans.obj)
gS.t <- transform(gS, transList)
FSC <- "FSC-A,FSC-H"
Singlets = add_pop(gS.t, alias = "Singlets", pop = "+", parent = "root", dims = FSC, gating_method = "singletGate",gating_args = "wider_gate=TRUE,subsample_pct=0.1" )
#> Warning: 'add_pop' is deprecated.
#> Use 'gs_add_gating_method' instead.
#> See help("Deprecated")
#> ...
#> done

getPopStats(gS.t)
#> Warning: '.local' is deprecated.
#> Use 'gs_pop_get_count_fast' instead.
#> See help("Deprecated")
#>                   name Population Parent Count ParentCount
#> 1: 170718_Tube_001.fcs  /Singlets   root 10776       10945
#> 2: 170718_Tube_002.fcs  /Singlets   root 11551       11938
#> 3: 170718_Tube_003.fcs  /Singlets   root 10838       11187
#> 4: 170718_Tube_004.fcs  /Singlets   root 10764       11343
#> 5: 170718_Tube_005.fcs  /Singlets   root 15803       16546
#> 6: 170718_Tube_006.fcs  /Singlets   root 13838       14622
#> 7: 170718_Tube_007.fcs  /Singlets   root 13111       13503

sessionInfo()
#> R version 3.6.0 Patched (2019-05-02 r76454)
#> Platform: x86_64-apple-darwin16.7.0 (64-bit)
#> Running under: macOS Sierra 10.12.6
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] parallel  stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#> [1] openCyto_1.23.2           flowWorkspace_3.33.1     
#> [3] ncdfFlow_2.31.3           BH_1.69.0-1              
#> [5] RcppArmadillo_0.9.600.4.0 flowCore_1.51.7          
#> 
#> loaded via a namespace (and not attached):
#>  [1] mclust_5.4.5        Rcpp_1.0.1          mvtnorm_1.0-11     
#>  [4] lattice_0.20-38     corpcor_1.6.9       gtools_3.8.1       
#>  [7] assertthat_0.2.1    digest_0.6.20       plyr_1.8.4         
#> [10] R6_2.4.0            stats4_3.6.0        pcaPP_1.9-73       
#> [13] ellipse_0.4.1       evaluate_0.14       highr_0.8          
#> [16] pillar_1.4.2        zlibbioc_1.29.0     rlang_0.4.0        
#> [19] data.table_1.12.2   Rgraphviz_2.27.0    hexbin_1.27.3      
#> [22] R.utils_2.9.0       R.oo_1.22.0         Matrix_1.2-17      
#> [25] rmarkdown_1.14      splines_3.6.0       stringr_1.4.0      
#> [28] munsell_0.5.0       compiler_3.6.0      xfun_0.8           
#> [31] pkgconfig_2.0.2     BiocGenerics_0.29.2 mnormt_1.5-5       
#> [34] IDPmisc_1.1.19      htmltools_0.3.6     tidyselect_0.2.5   
#> [37] tibble_2.1.3        gridExtra_2.3       matrixStats_0.54.0 
#> [40] flowViz_1.47.4      rrcov_1.4-7         crayon_1.3.4       
#> [43] dplyr_0.8.3         MASS_7.3-51.4       R.methodsS3_1.7.1  
#> [46] grid_3.6.0          RBGL_1.59.8         gtable_0.3.0       
#> [49] magrittr_1.5        flowStats_3.43.8    scales_1.0.0       
#> [52] graph_1.61.1        RcppParallel_4.4.3  KernSmooth_2.23-15 
#> [55] stringi_1.4.4       latticeExtra_0.6-28 robustbase_0.93-5  
#> [58] RColorBrewer_1.1-2  tools_3.6.0         Biobase_2.43.1     
#> [61] glue_1.3.1          DEoptimR_1.0-8      purrr_0.3.2        
#> [64] ks_1.11.5           yaml_2.2.0          clue_0.3-57        
#> [67] colorspace_1.4-1    cluster_2.1.0       flowClust_3.21.4   
#> [70] fda_2.4.8           knitr_1.23

Created on 2019-07-24 by the reprex package (v0.3.0)

There is an argument to singletGate in flowStats named maxit which is set to 5. Let's start by seeing what version of R and the flow tools you are using (show your sessionInfo()), and then we'll see if we can settle on reproducibility of this bug report, then whether a fix is needed. Created on 2019-07-24 by the reprex package (v0.3.0)

abbatidanilo commented 5 years ago

Thank you Greg for your quick response. Here you have:

sessionInfo() R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale: [1] LC_COLLATE=English_World.1252 LC_CTYPE=English_World.1252 LC_MONETARY=English_World.1252 LC_NUMERIC=C
[5] LC_TIME=English_World.1252

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

other attached packages: [1] umap_0.2.2.0 Rtsne_0.15 ConsensusClusterPlus_1.48.0 FlowSOM_1.16.0
[5] factoextra_1.0.5 matrixStats_0.54.0 limma_3.40.2 spade_1.10.4
[9] Rclusterpp_0.2.4 Rcpp_1.0.1 igraph_1.2.4.1 flowStats_3.42.0
[13] cluster_2.1.0 flowAI_1.14.0 ggcyto_1.12.0 flowViz_1.48.0
[17] lattice_0.20-38 openCyto_1.22.2 flowWorkspace_3.32.0 ncdfFlow_2.30.1
[21] BH_1.69.0-1 RcppArmadillo_0.9.600.4.0 flowCore_1.50.0 heatmaply_0.16.0
[25] viridis_0.5.1 viridisLite_0.3.0 ggrepel_0.8.1 rhandsontable_0.3.7
[29] reshape2_1.4.3 RColorBrewer_1.1-2 plotly_4.9.0 forcats_0.4.0
[33] stringr_1.4.0 dplyr_0.8.3 purrr_0.3.2 readr_1.3.1
[37] tidyr_0.8.3 tibble_2.1.3 ggplot2_3.2.0 tidyverse_1.2.1
[41] DT_0.7 shinyWidgets_0.4.8 shinycssloaders_0.2.0 shinydashboard_0.7.1
[45] shinythemes_1.1.2 shiny_1.3.2

loaded via a namespace (and not attached): [1] changepoint_2.2.2 readxl_1.3.1 backports_1.1.4 plyr_1.8.4 lazyeval_0.2.2 splines_3.6.0
[7] crosstalk_1.0.0 fda_2.4.8 digest_0.6.20 foreach_1.4.4 htmltools_0.3.6 gdata_2.18.0
[13] magrittr_1.5 ks_1.11.5 gclus_1.3.2 modelr_0.1.4 RcppParallel_4.4.3 R.utils_2.9.0
[19] colorspace_1.4-1 rvest_0.3.4 rrcov_1.4-7 xfun_0.8 haven_2.1.1 crayon_1.3.4
[25] jsonlite_1.6 hexbin_1.27.3 graph_1.62.0 zeallot_0.1.0 zoo_1.8-6 iterators_1.0.10
[31] glue_1.3.1 flowClust_3.22.0 registry_0.5-1 gtable_0.3.0 zlibbioc_1.30.0 webshot_0.5.1
[37] IDPmisc_1.1.19 Rgraphviz_2.28.0 BiocGenerics_0.30.0 DEoptimR_1.0-8 scales_1.0.0 mvtnorm_1.0-11
[43] xtable_1.8-4 clue_0.3-57 reticulate_1.12 mclust_5.4.5 tsne_0.1-3 stats4_3.6.0
[49] htmlwidgets_1.3 httr_1.4.0 gplots_3.0.1.1 XML_3.98-1.20 pkgconfig_2.0.2 R.methodsS3_1.7.1
[55] labeling_0.3 tidyselect_0.2.5 rlang_0.4.0 later_0.8.0 munsell_0.5.0 cellranger_1.1.0
[61] tools_3.6.0 cli_1.1.0 generics_0.0.2 broom_0.5.2 evaluate_0.14 yaml_2.2.0
[67] knitr_1.23 robustbase_0.93-5 caTools_1.17.1.2 dendextend_1.12.0 packrat_0.5.0 RBGL_1.60.0
[73] nlme_3.1-140 mime_0.7 R.oo_1.22.0 xml2_1.2.0 compiler_3.6.0 rstudioapi_0.10
[79] pcaPP_1.9-73 stringi_1.4.3 Matrix_1.2-17 vctrs_0.2.0 pillar_1.4.2 BiocManager_1.30.4 [85] data.table_1.12.2 bitops_1.0-6 corpcor_1.6.9 seriation_1.2-7 httpuv_1.5.1 R6_2.4.0
[91] latticeExtra_0.6-28 promises_1.0.1 TSP_1.1-7 KernSmooth_2.23-15 gridExtra_2.3 codetools_0.2-16
[97] MASS_7.3-51.4 gtools_3.8.1 assertthat_0.2.1 withr_2.1.2 mnormt_1.5-5 hms_0.5.0
[103] grid_3.6.0 rmarkdown_1.14 Biobase_2.44.0 lubridate_1.7.4 ellipse_0.4.1

gfinak commented 5 years ago

I'd suggest upgrading to the development versions of the flow packages. It appears the bug is fixed there, or at least with those versions I don't experience this issue.