HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
67 stars 31 forks source link

Error in plotPbExprs #128

Closed bioguy2018 closed 4 years ago

bioguy2018 commented 4 years ago

Dear developers, I have faced a problem while running the function plotPbExprs() on my dataset. I get the following error:

plotPbExprs(sce, facet_by = "antigen", ncol = 4)

Error in h(simpleError(msg, call)) : error in evaluating the argument 'i' in selecting a method for function '[': No features matched the specified marker class.

I have checked my panel and my md files and everything looks fine there and I do have a col as antigen followed another col to specify type or state (in my case all are types) so I can't get why is it happening.

I also get the error message in the following modified version of the code: > plotPbExprs(sce, features = "type", facet_by = "antigen", color_by = "condition", size_by = TRUE, geom = "points", jitter = FALSE, ncol = 5)

Error in FUN(X[[i]], ...) : object 'condition' not found

I am not sure why it is happening cause with color_by = "sample_id" the code works.

HelenaLC commented 4 years ago
  1. The default argument is features = "state". In your case, all features are type, hence "No features matched he specified marker class". Using plotPbExprs(sce, facet_by = "antigen", ncol = 4) with features = "type" or = NULL (= plot all features) should resolve this.
  2. I ran your function call with the example data from the package and did not get an error, so not sure why this is failing. What's the output for colData(sce)? What do the sample_ids look like (table(sce$sample_id))? If you could come up with a minimal example with the example data from the package that'd help!
# this doesn't fail
data(PBMC_fs, PBMC_panel, PBMC_md)
sce <- prepData(PBMC_fs, PBMC_panel, PBMC_md)
sce <- cluster(sce, verbose = FALSE)

plotPbExprs(sce, features = "type", 
    facet_by = "antigen", color_by = "sample_id", 
    size_by = TRUE, geom = "points", jitter = FALSE, ncol = 5)
bioguy2018 commented 4 years ago

Dear Helena, Thanks a lot for your reply! I tried to set features= NULL or type but then I got the a different error but the same as I mentioned before: Error in FUN(X[[i]], ...) : object 'condition' not found the colData(sce) returns something like this

DataFrame with 18335 rows and 3 columns

 sample_id condition cluster_id
 <factor>  <factor>   <factor>

1 Ctrl-export_heart_embryo_001_v.fcs Ctrl 89 2 Ctrl-export_heart_embryo_001_v.fcs Ctrl 78 3 Ctrl-export_heart_embryo_001_v.fcs Ctrl 27 4 Ctrl-export_heart_embryo_001_v.fcs Ctrl 88 5 Ctrl-export_heart_embryo_001_v.fcs Ctrl 53 ... ... ... ... 18331 KO-export_heart_embryo_016_v.fcs KO 39 18332 KO-export_heart_embryo_016_v.fcs KO 38 18333 KO-export_heart_embryo_016_v.fcs KO 12 `

and the sample ids are like this: Ctrl-export_heart_embryo_001_v.fcs Ctrl-export_heart_embryo_003_v.fcs Ctrl-export_heart_embryo_006_v.fcs 2607 2597 1994 Ctrl-export_heart_embryo_008_v.fcs Ctrl-export_heart_embryo_009_v.fcs Ctrl-export_heart_embryo_011_v.fcs 3000 1511 1622 KO-export_heart_embryo_007_v.fcs KO-export_heart_embryo_014_v.fcs KO-export_heart_embryo_016_v.fcs 3000 1498 506

I couldn't really reproduce the error with your data but I also can't understand what can be wrong with my data? I prepared in in the same manner and I have the necessary columns like condition and smaple id

HelenaLC commented 4 years ago

Could you please post

bioguy2018 commented 4 years ago

Dear Helena, Thanks a lot for the reply! here are the requested information

sessionInfo()

R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)   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] tools     stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base   other attached packages: [1] ggplot2_3.3.2               readxl_1.3.1                RColorBrewer_1.1-2          CATALYST_1.12.2 [5] SingleCellExperiment_1.10.1 HDCytoData_1.8.0            flowCore_2.0.1              SummarizedExperiment_1.18.2 [9] DelayedArray_0.14.0         matrixStats_0.56.0          Biobase_2.48.0              GenomicRanges_1.40.0 [13] GenomeInfoDb_1.24.2         IRanges_2.22.2              S4Vectors_0.26.1            ExperimentHub_1.14.0 [17] AnnotationHub_2.20.0        BiocFileCache_1.12.0        dbplyr_1.4.4                BiocGenerics_0.34.0   loaded via a namespace (and not attached): [1] circlize_0.4.10               drc_3.0-1                     plyr_1.8.6 [4] igraph_1.2.5                  ConsensusClusterPlus_1.52.0   splines_4.0.2 [7] BiocParallel_1.22.0           scater_1.16.2                 TH.data_1.0-10 [10] digest_0.6.25                 htmltools_0.5.0               viridis_0.5.1 [13] magrittr_1.5                  memoise_1.1.0                 CytoML_2.0.5 [16] cluster_2.1.0                 openxlsx_4.1.5                ComplexHeatmap_2.4.2 [19] RcppParallel_5.0.2            sandwich_2.5-1                flowWorkspace_4.0.6 [22] cytolib_2.0.3                 jpeg_0.1-8.1                  colorspace_1.4-1 [25] blob_1.2.1                    rappdirs_0.3.1                ggrepel_0.8.2 [28] haven_2.3.1                   xfun_0.15                     dplyr_1.0.0 [31] crayon_1.3.4                  RCurl_1.98-1.2                jsonlite_1.7.0 [34] hexbin_1.28.1                 graph_1.66.0                  survival_3.2-3 [37] zoo_1.8-8                     glue_1.4.1                    gtable_0.3.0 [40] nnls_1.4                      zlibbioc_1.34.0               XVector_0.28.0 [43] GetoptLong_1.0.2              ggcyto_1.16.0                 BiocSingular_1.4.0 [46] car_3.0-8                     Rgraphviz_2.32.0              shape_1.4.4 [49] abind_1.4-5                   scales_1.1.1                  mvtnorm_1.1-1 [52] DBI_1.1.0                     Rcpp_1.0.5                    plotrix_3.7-8 [55] viridisLite_0.3.0             xtable_1.8-4                  clue_0.3-57 [58] rsvd_1.0.3                    foreign_0.8-80                bit_1.1-15.2 [61] FlowSOM_1.20.0                tsne_0.1-3                    httr_1.4.2 [64] FNN_1.1.3                     ellipsis_0.3.1                farver_2.0.3 [67] pkgconfig_2.0.3               XML_3.99-0.4                  uwot_0.1.8 [70] labeling_0.3                  tidyselect_1.1.0              rlang_0.4.6 [73] reshape2_1.4.4                later_1.1.0.1                 AnnotationDbi_1.50.1 [76] munsell_0.5.0                 BiocVersion_3.11.1            cellranger_1.1.0 [79] generics_0.0.2                RSQLite_2.2.0                 ggridges_0.5.2 [82] stringr_1.4.0                 fastmap_1.0.1                 yaml_2.2.1 [85] knitr_1.29                    bit64_0.9-7                   zip_2.0.4 [88] purrr_0.3.4                   RBGL_1.64.0                   mime_0.9 [91] xml2_1.3.2                    compiler_4.0.2                rstudioapi_0.11 [94] beeswarm_0.2.3                curl_4.3                      png_0.1-7 [97] interactiveDisplayBase_1.26.3 tibble_3.0.2                  stringi_1.4.6 [100] RSpectra_0.16-0               forcats_0.5.0                 lattice_0.20-41 [103] Matrix_1.2-18                 vctrs_0.3.1                   pillar_1.4.6 [106] lifecycle_0.2.0               BiocManager_1.30.10           GlobalOptions_0.1.2 [109] RcppAnnoy_0.0.16              BiocNeighbors_1.6.0           irlba_2.3.3 [112] data.table_1.12.8             cowplot_1.0.0                 bitops_1.0-6 [115] httpuv_1.5.4                  R6_2.4.1                      latticeExtra_0.6-29 [118] promises_1.1.1                gridExtra_2.3                 RProtoBufLib_2.0.0 [121] rio_0.5.16                    vipor_0.4.5                   codetools_0.2-16 [124] MASS_7.3-51.6                 gtools_3.8.2                  assertthat_0.2.1 [127] rjson_0.2.20                  withr_2.2.0                   multcomp_1.4-13 [130] GenomeInfoDbData_1.2.3        hms_0.5.3                     ncdfFlow_2.34.0 [133] grid_4.0.2                    DelayedMatrixStats_1.10.1     carData_3.0-4 [136] Rtsne_0.15                    shiny_1.5.0                   base64enc_0.1-3 [139] ggbeeswarm_0.6.0

MD: file_name sample_id condition subset
G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_001_c.fcs Ctrl-export_heart_embryo_001_c.fcs Ctrl CD31 subset.fcs
G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_003_c.fcs Ctrl-export_heart_embryo_003_c.fcs Ctrl CD31 subset.fcs
G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_006_c.fcs Ctrl-export_heart_embryo_006_c.fcs Ctrl CD31 subset.fcs
G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_008_c.fcs Ctrl-export_heart_embryo_008_c.fcs Ctrl CD31 subset.fcs
G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_009_c.fcs Ctrl-export_heart_embryo_009_c.fcs Ctrl CD31 subset.fcs
G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_011_c.fcs Ctrl-export_heart_embryo_011_c.fcs Ctrl CD31 subset.fcs
G:/UMAP/heart/cd31/KO-export_heart_embryo_007_c.fcs KO-export_heart_embryo_007_c.fcs KO CD31 subset.fcs
G:/UMAP/heart/cd31/KO-export_heart_embryo_014_c.fcs KO-export_heart_embryo_014_c.fcs KO CD31 subset.fcs
G:/UMAP/heart/cd31/KO-export_heart_embryo_016_c.fcs KO-export_heart_embryo_016_c.fcs KO CD31 subset.fcs

Panel:

marker_class antigen fcs_colname
type DLL4 FJComp.APC.A
type Notch1 FJComp.BV421.A
type Creld1 FJComp.PE.A
type SSC.A SSC.A
type FSC.A FSC.A

> colnames(myfs) [1] "FSC.A" "SSC.A" "FJComp.APC.A" "FJComp.BV421.A" "FJComp.PE.A"

fsApply(myfs, identifier)

Ctrl-export_heart_embryo_001_c.fcs "Ctrl-export_heart_embryo_001_c.fcs" Ctrl-export_heart_embryo_003_c.fcs "Ctrl-export_heart_embryo_003_c.fcs" Ctrl-export_heart_embryo_006_c.fcs "Ctrl-export_heart_embryo_006_c.fcs" Ctrl-export_heart_embryo_008_c.fcs "Ctrl-export_heart_embryo_008_c.fcs" Ctrl-export_heart_embryo_009_c.fcs "Ctrl-export_heart_embryo_009_c.fcs" Ctrl-export_heart_embryo_011_c.fcs "Ctrl-export_heart_embryo_011_c.fcs" KO-export_heart_embryo_007_c.fcs   "KO-export_heart_embryo_007_c.fcs" KO-export_heart_embryo_014_c.fcs   "KO-export_heart_embryo_014_c.fcs" KO-export_heart_embryo_016_c.fcs   "KO-export_heart_embryo_016_c.fcs"

keyword(myfs, "FILENAME")

FILENAME Ctrl-export_heart_embryo_001_c.fcs "G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_001_c.fcs" Ctrl-export_heart_embryo_003_c.fcs "G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_003_c.fcs" Ctrl-export_heart_embryo_006_c.fcs "G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_006_c.fcs" Ctrl-export_heart_embryo_008_c.fcs "G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_008_c.fcs" Ctrl-export_heart_embryo_009_c.fcs "G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_009_c.fcs" Ctrl-export_heart_embryo_011_c.fcs "G:/UMAP/heart/cd31/Ctrl-export_heart_embryo_011_c.fcs" KO-export_heart_embryo_007_c.fcs   "G:/UMAP/heart/cd31/KO-export_heart_embryo_007_c.fcs" KO-export_heart_embryo_014_c.fcs   "G:/UMAP/heart/cd31/KO-export_heart_embryo_014_c.fcs" KO-export_heart_embryo_016_c.fcs   "G:/UMAP/heart/cd31/KO-export_heart_embryo_016_c.fcs"

bioguy2018 commented 4 years ago

Dear Helena, I assume something must be wrong with annotation as with with some of my other data I could run this code! I will try to find it and later I will comment here! Maybe if you could realize it through the information I share I would be happy if you let me know but for now all good! Thanks a lot !

JudithBernett commented 2 years ago

It sounds like this is related to #249 ? We have found a similar issue when there are is only one additional column to patient_id and cluster_id (i.e. condition in this case).