HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
66 stars 30 forks source link

Subset out of bounds issue #357

Closed LenHC closed 6 months ago

LenHC commented 1 year ago

Hello, I keep getting "Error: Subset out of bounds" when using prepData. Here is my code:

sce <- prepData(fcsdir, panel=panel, md=metadata, transform=FALSE, panel_cols=list(channel="fcs_colname", antigen="antigen"), md_cols=list(file="correctedFileName", id="SampleID", factors=metaatt), FACS = TRUE)

Sessioninfo: > sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.4

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.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.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: America/New_York tzcode source: internal

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

other attached packages: [1] CATALYST_1.24.0 SingleCellExperiment_1.22.0 [3] SummarizedExperiment_1.30.2 Biobase_2.60.0
[5] GenomicRanges_1.52.0 GenomeInfoDb_1.36.1
[7] IRanges_2.34.1 S4Vectors_0.38.1
[9] BiocGenerics_0.46.0 MatrixGenerics_1.12.2
[11] matrixStats_1.0.0 stringr_1.5.0
[13] cowplot_1.1.1 patchwork_1.1.2
[15] dplyr_1.1.2 magrittr_2.0.3
[17] readxl_1.4.2 xlsx_0.6.5
[19] knitr_1.43 uwot_0.1.16
[21] Matrix_1.5-4.1 tidyr_1.3.0
[23] cyCombine_0.2.15 PeacoQC_1.10.0
[25] flowAI_1.30.0 flowVS_1.32.0
[27] flowStats_4.12.0 flowViz_1.64.0
[29] lattice_0.21-8 ggcyto_1.28.0
[31] flowWorkspace_4.12.0 ncdfFlow_2.46.0
[33] BH_1.81.0-1 ggplot2_3.4.2
[35] flowCore_2.12.0

loaded via a namespace (and not attached): [1] bitops_1.0-7 httr_1.4.6
[3] RColorBrewer_1.1-3 doParallel_1.0.17
[5] Rgraphviz_2.44.0 tools_4.3.0
[7] backports_1.4.1 utf8_1.2.3
[9] R6_2.5.1 mgcv_1.8-42
[11] GetoptLong_1.0.5 withr_2.5.0
[13] gridExtra_2.3 cli_3.6.1
[15] textshaping_0.3.6 sandwich_3.0-2
[17] labeling_0.4.2 nnls_1.4
[19] mvtnorm_1.2-2 robustbase_0.99-0
[21] genefilter_1.82.1 ggridges_0.5.4
[23] systemfonts_1.0.4 colorRamps_2.3.1
[25] rrcov_1.7-4 scater_1.28.0
[27] plotrix_3.8-2 limma_3.56.2
[29] RSQLite_2.3.1 generics_0.1.3
[31] shape_1.4.6 gtools_3.9.4
[33] car_3.1-2 interp_1.1-4
[35] RProtoBufLib_2.12.0 ggbeeswarm_0.7.2
[37] fansi_1.0.4 abind_1.4-5
[39] lifecycle_1.0.3 multcomp_1.4-25
[41] edgeR_3.42.4 carData_3.0-5
[43] Rtsne_0.16 grid_4.3.0
[45] blob_1.2.4 crayon_1.5.2
[47] beachmat_2.16.0 annotate_1.78.0
[49] xlsxjars_0.6.1 KEGGREST_1.40.0
[51] pillar_1.9.0 ComplexHeatmap_2.16.0
[53] rjson_0.2.21 fda_6.1.4
[55] corpcor_1.6.10 codetools_0.2-19
[57] glue_1.6.2 kohonen_3.0.12
[59] data.table_1.14.8 vctrs_0.6.3
[61] png_0.1-8 cellranger_1.1.0
[63] gtable_0.3.3 cachem_1.0.8
[65] ks_1.14.0 xfun_0.39
[67] S4Arrays_1.0.4 fds_1.8
[69] pracma_2.4.2 ConsensusClusterPlus_1.64.0 [71] pcaPP_2.0-3 survival_3.5-5
[73] rJava_1.0-6 iterators_1.0.14
[75] cytolib_2.12.0 TH.data_1.1-2
[77] nlme_3.1-162 bit64_4.0.5
[79] RcppAnnoy_0.0.21 irlba_2.3.5.1
[81] vipor_0.4.5 KernSmooth_2.23-21
[83] colorspace_2.1-0 DBI_1.1.3
[85] mnormt_2.1.1 tidyselect_1.2.0
[87] bit_4.0.5 compiler_4.3.0
[89] graph_1.78.0 BiocNeighbors_1.18.0
[91] DelayedArray_0.26.6 scales_1.2.1
[93] DEoptimR_1.0-14 hexbin_1.28.3
[95] digest_0.6.32 rainbow_3.7
[97] rmarkdown_2.23 XVector_0.40.0
[99] htmltools_0.5.5 pkgconfig_2.0.3
[101] jpeg_0.1-10 changepoint_2.2.4
[103] sparseMatrixStats_1.12.2 highr_0.10
[105] fastmap_1.1.1 rlang_1.1.1
[107] GlobalOptions_0.1.2 DelayedMatrixStats_1.22.1
[109] farver_2.1.1 zoo_1.8-12
[111] BiocParallel_1.34.2 mclust_6.0.0
[113] BiocSingular_1.16.0 RCurl_1.98-1.12
[115] scuttle_1.10.1 GenomeInfoDbData_1.2.10
[117] munsell_0.5.0 Rcpp_1.0.10
[119] viridis_0.6.3 ggnewscale_0.4.9
[121] stringi_1.7.12 zlibbioc_1.46.0
[123] MASS_7.3-60 plyr_1.8.8
[125] parallel_4.3.0 ggrepel_0.9.3
[127] deldir_1.0-9 Biostrings_2.68.1
[129] splines_4.3.0 circlize_0.4.15
[131] locfit_1.5-9.8 igraph_1.5.0
[133] ggpubr_0.6.0 ggsignif_0.6.4
[135] ScaledMatrix_1.8.1 reshape2_1.4.4
[137] XML_3.99-0.14 drc_3.0-1
[139] evaluate_0.21 emdist_0.3-2
[141] latticeExtra_0.6-30 deSolve_1.36
[143] foreach_1.5.2 tweenr_2.0.2
[145] purrr_1.0.1 polyclip_1.10-4
[147] clue_0.3-64 ggforce_0.4.1
[149] rsvd_1.0.5 broom_1.0.5
[151] xtable_1.8-4 rstatix_0.7.2
[153] viridisLite_0.4.2 IDPmisc_1.1.20
[155] ragg_1.2.5 tibble_3.2.1
[157] beeswarm_0.4.0 memoise_2.0.1
[159] FlowSOM_2.8.0 AnnotationDbi_1.62.2
[161] cluster_2.1.4 sva_3.48.0
[163] hdrcde_3.4

> head(panel) A tibble: 6 × 2 fcs_colname antigen

1 Alexa Fluor 594-A CXCR4 2 Alexa Fluor 647-A CellROX 3 BB700-A CD16 4 BUV395-A CD10 5 BV510-A CD11b 6 BV650-A CD63 ```> colnames(metadata)``` [1] "FileName" [2] "optPreprocessedFileName" [3] "flowAICleaned-optPreprocessedFileName" [4] "fixedPreprocessedFileName" [5] "flowAICleaned-fixedPreprocessedFileName" [6] "correctedFileName" [7] "Experiment" [8] "ExperimentID" [9] "Sample" [10] "SampleID" [11] "Donor" [12] "DonorID" [13] "Condition" [14] "Stimulus" [15] "DrugTreatment" [16] "Drug" [17] "Concentration" [18] "Duration" [19] "NumCells" [20] "Panel" ```> traceback()``` 4: stop("Subset out of bounds", call. = FALSE) 3: fs[match(md[[md_cols$file]], ids)] 2: fs[match(md[[md_cols$file]], ids)] 1: prepData(fcsdir, panel = panel, md = metadata, transform = FALSE, panel_cols = list(channel = "fcs_colname", antigen = "antigen"), md_cols = list(file = "correctedFileName", id = "SampleID", factors = metaatt), FACS = TRUE)
HelenaLC commented 1 year ago

Hard to help given the information you provided. Could you perhaps post the output of running traceback() after the error occurs? Also, please enclose code in code blocks (3 back ticks before and after) to make it more legible 🙏

LenHC commented 1 year ago

Hello Helena, thanks for the reply. I just added traceback() information and enclosed the codes!

HelenaLC commented 1 year ago

The code being run up to this point should be something like this ... I'd suggest running through this to figure out the issue. Looks like something might be off with the FCS file identifiers.

fs <- CATALYST:::.read_fs(fcsdir, "common") # internal helper calling 'flowCore::read.flowSet'
ids0 <- md[[md_cols$file]] # should me 'md$correctedFileName'
ids1 <- fsApply(fs, identifier) # what are these? 
ids2 <- keyword(fs, "FILENAME") # and these?
if (length(unlist(ids2)) == length(fs))
  ids2 <- basename(ids2)
check1 <- all(ids1 %in% ids0) # what is this?
check2 <- all(ids2 %in% ids0) # and this?
ids_use <- which(c(check1, check2))[1]
ids <- list(ids1, ids2)[[ids_use]] 
fs <- fs[match(md[[md_cols$file]], ids) # error here
LenHC commented 1 year ago

Hello Helena, I see... I will try these suggestions and get back to you.

HelenaLC commented 6 months ago

closing due to inactivity.