RGLab / openCyto

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

mindensity selecting only positive #218

Closed fbenedett closed 4 years ago

fbenedett commented 4 years ago

Hello, I looked at the issues and I found a similar problem submitted by another user: https://github.com/RGLab/openCyto/issues/97

The point is that in my case I don't have a gating template, so the solution given there does not apply directly to me.

I try to do the following:

  for(n in 1:length(fset)){
    g <- openCyto:::.mindensity(fset[[n]], channel = "SSC_A", positive=FALSE)
    autoplot(fset[[n]], "SSC_A") +geom_gate(g)
    fset[[n]]=Subset(fset[[n]], g)

Where "fset" is a flow Set. THe mindensity always select the positive population even if "positive" is false. Any help please?

sessionInfo() R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.5 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3 LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] matrixStats_0.55.0 flowClust_3.22.0 openCyto_1.22.2 factoextra_1.0.7
[5] cluster_2.1.0 RColorBrewer_1.1-2 Rtsne_0.15 ConsensusClusterPlus_1.48.0 [9] pheatmap_1.0.12 reshape2_1.4.3 dplyr_1.0.2 ggcyto_1.12.0
[13] flowWorkspace_3.32.0 ncdfFlow_2.30.1 BH_1.69.0-1 RcppArmadillo_0.9.800.1.0
[17] ggplot2_3.2.1 flowCore_1.50.0 readxl_1.3.1 FlowSOM_1.16.0
[21] igraph_1.2.4.1

loaded via a namespace (and not attached): [1] Biobase_2.44.0 splines_3.6.3 R.utils_2.9.0 ellipse_0.4.1 gtools_3.8.1 RcppParallel_4.4.4 [7] stats4_3.6.3 latticeExtra_0.6-28 RBGL_1.60.0 cellranger_1.1.0 robustbase_0.93-5 ggrepel_0.8.1
[13] pillar_1.4.4 lattice_0.20-41 glue_1.4.1 digest_0.6.25 colorspace_1.4-1 Matrix_1.2-18
[19] R.oo_1.22.0 plyr_1.8.6 pcaPP_1.9-73 XML_3.98-1.20 pkgconfig_2.0.3 tsne_0.1-3
[25] fda_2.4.8 zlibbioc_1.30.0 purrr_0.3.3 corpcor_1.6.9 mvtnorm_1.0-11 scales_1.1.1
[31] flowStats_3.42.0 tibble_3.0.2 farver_2.0.3 generics_0.0.2 ellipsis_0.3.0 withr_2.1.2
[37] flowViz_1.48.0 BiocGenerics_0.30.0 hexbin_1.27.3 lazyeval_0.2.2 mnormt_1.5-5 mclust_5.4.5
[43] magrittr_1.5 crayon_1.3.4 IDPmisc_1.1.19 ks_1.11.5 R.methodsS3_1.7.1 MASS_7.3-52
[49] graph_1.62.0 tools_3.6.3 data.table_1.13.0 lifecycle_0.2.0 stringr_1.4.0 munsell_0.5.0
[55] compiler_3.6.3 rlang_0.4.7 grid_3.6.3 rstudioapi_0.11 labeling_0.3 gtable_0.3.0
[61] rrcov_1.4-7 R6_2.4.0 gridExtra_2.3 knitr_1.29 clue_0.3-57 KernSmooth_2.23-17 [67] Rgraphviz_2.28.0 stringi_1.4.3 parallel_3.6.3 Rcpp_1.0.5 vctrs_0.3.2 DEoptimR_1.0-8
[73] tidyselect_1.1.0 xfun_0.15

gfinak commented 4 years ago

@jacobpwagner didn't this come up recently? I thought we had a fix.

jacobpwagner commented 4 years ago

This seems to working as expected in my testing:

> library(flowCore)
> library(flowWorkspace)
> library(openCyto)
> library(ggcyto)
> gs <- load_gs(system.file("extdata", "gs_manual", package = "flowWorkspaceData"))
> g1 <- openCyto::gate_mindensity(gh_pop_get_data(gs[[1]], "singlets"), "<B710-A>")
> g2 <- openCyto::gate_mindensity(gh_pop_get_data(gs[[1]], "singlets"), "<B710-A>", positive = FALSE)
> g1
Rectangular gate '' with dimensions:
  <B710-A>: (1891.44412322368,Inf)
> g2
Rectangular gate '' with dimensions:
  <B710-A>: (-Inf,1891.44412322368)
> g1 <- openCyto:::.mindensity(gh_pop_get_data(gs[[1]], "singlets"), channels="<B710-A>")
> g2 <- openCyto:::.mindensity(gh_pop_get_data(gs[[1]], "singlets"), channels="<B710-A>", positive = FALSE)
> g1
Rectangular gate '' with dimensions:
  <B710-A>: (1891.44412322368,Inf)
> g2
Rectangular gate '' with dimensions:
  <B710-A>: (-Inf,1891.44412322368)

@fbenedett , can you provide a reproducible example? There are example datasets in flowCore and flowWorkspaceData. Given the nature of the issue, any dataset will probably suffice.

gfinak commented 4 years ago

@fbenedett I think it's time to update to Bioconductor 3.11 and R 4. That's the official release. You're writing us about a bug that doesn't exist in the current version.

jacobpwagner commented 4 years ago

Just linking the fix that went in before Bioconductor 3.10: https://github.com/RGLab/openCyto/commit/cbaf751afe8637b367f7bc571b7e3d711859b90a