CytoExploreR
CytoExploreR copied to clipboard
cyto_gate_draw() error: subset out of bounds
Hi Dillon,
I've started using your package(s) again to analyse new data. I'm re-using a script from last year, which worked well, but with updated versions of all packages.
When drawing gates, I'm running into an unspecified problem. I can't find a solution online or here, on Github. Would you know what's going wrong?
My code:
library("flowCore")
library("flowWorkspace")
library("openCyto")
library("CytoExploreR")
library("dplyr")
path <- "20220405_FACS/"
setwd(path)
# Load files
fcs <- load_cytoset_from_fcs(path = path,
transformation = FALSE,
alter.names = TRUE,
sep = "\t",
phenoData = "samples.tsv"
)
#Check markers
cyto_markers(fcs)
cyto_details(fcs)
# Create gating set
gs <- GatingSet(fcs)
# Display sample names
sampleNames <- cyto_names(gs)
write.csv(sampleNames, "sampleNames.csv", row.names = FALSE)
# Fluorescent channels (display + select)
chans <- cyto_fluor_channels(gs)
chans
usedChans <- c("FL1-A", #GFP
"FL6-A", #DAPI
"FL11-A") #RFP
# All channels (display)
cyto_channels(gs)
# Log transformation
gs <- cyto_transform(gs,
channels = usedChans,
type="biex",
plot=TRUE,
axes_limits="machine",
maxValue=16777215)
# Create empty gatingTemplate
cyto_gatingTemplate_create("gates.csv")
# Select new gatingTemplate as active
cyto_gatingTemplate_select("gates.csv")
# Draw gates
# Cells
cyto_gate_draw(gs,
select=list(name="A1.fcs"),
parent = "root",
alias = "Cells",
channels = c("FSC-A","SSC-A"),
type = "polygon",
xlim = c(0,6000000),
ylim = c(0,8000000),
gatingTemplate = "gates.csv")
The error:
> cyto_gate_draw(gs,
+ select=list(name="A1.fcs"),
+ parent = "root",
+ alias = "Cells",
+ channels = c("FSC-A","SSC-A"),
+ type = "polygon",
+ xlim = c(0,6000000),
+ ylim = c(0,8000000),
+ gatingTemplate = "gates.csv")
Error: Subset out of bounds
> traceback()
10: stop("Subset out of bounds", call. = FALSE)
9: x[ind]
8: x[ind]
7: FUN(X[[i]], ...)
6: lapply(seq_len(length(pd_split)), function(z) {
ind <- match(pd_split[[z]][, "name"], cyto_names(x))
x[ind]
})
5: cyto_group_by(x, group_by = merge_by)
4: cyto_merge_by.flowSet(fs, merge_by = group_by, select = select)
3: cyto_merge_by(fs, merge_by = group_by, select = select)
2: cyto_gate_draw.GatingSet(gs, select = list(name = "A1.fcs"), parent = "root",
alias = "Cells", channels = c("FSC-A", "SSC-A"), type = "polygon",
xlim = c(0, 6000000), ylim = c(0, 8000000), gatingTemplate = "gates.csv")
1: cyto_gate_draw(gs, select = list(name = "A1.fcs"), parent = "root",
alias = "Cells", channels = c("FSC-A", "SSC-A"), type = "polygon",
xlim = c(0, 6000000), ylim = c(0, 8000000), gatingTemplate = "gates.csv")
Not sure if it helps, but the first lines of cyto_details:
> head(cyto_details(gs))
name varX varY date varZ donor gene
A1 A1.fcs 100 100 05-04-2022 K0 xxx none
A2 A2.fcs 0 100 05-04-2022 K0 xxx none
A3 A3.fcs 100 1 05-04-2022 K0 xxx none
A4 A4.fcs 0 1 05-04-2022 K0 xxx none
A5 A5.fcs 100 1000 05-04-2022 K0 xxx none
A6 A6.fcs 0 1000 05-04-2022 K0 xxx none
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 12.3.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] nl_NL.UTF-8/nl_NL.UTF-8/nl_NL.UTF-8/C/nl_NL.UTF-8/nl_NL.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggridges_0.5.3 dplyr_1.0.8 cytoqc_0.99.2 CytoML_2.7.2 ggcyto_1.18.0
[6] ncdfFlow_2.36.0 BH_1.78.0-0 RcppArmadillo_0.11.0.0.0 ggplot2_3.3.5 cytoverse_0.0.0.9000
[11] CytoExploreR_1.1.0 openCyto_2.5.4 flowWorkspace_4.7.1 flowCore_2.7.1
loaded via a namespace (and not attached):
[1] changepoint_2.2.3 systemfonts_1.0.4 plyr_1.8.7 splines_4.0.5 fda_5.5.1 usethis_2.1.5
[7] digest_0.6.29 htmltools_0.5.2 fansi_1.0.3 magrittr_2.0.3 memoise_2.0.1 cluster_2.1.3
[13] ks_1.13.4 hdrcde_3.4 aws.signature_0.6.0 remotes_2.4.2 RcppParallel_5.1.5 matrixStats_0.61.0
[19] R.utils_2.11.0 svglite_2.1.0 askpass_1.1 fds_1.8 cytolib_2.7.4 prettyunits_1.1.1
[25] jpeg_0.1-9 colorspace_2.0-3 rvest_1.0.2 rrcov_1.6-2 xfun_0.30 callr_3.7.0
[31] crayon_1.5.1 RCurl_1.98-1.6 jsonlite_1.8.0 hexbin_1.28.2 graph_1.68.0 zoo_1.8-9
[37] glue_1.6.2 kableExtra_1.3.4 flowClust_3.28.0 gtable_0.3.0 zlibbioc_1.36.0 webshot_0.5.2
[43] pkgbuild_1.3.1 IDPmisc_1.1.20 Rgraphviz_2.34.0 BiocGenerics_0.36.1 DEoptimR_1.0-11 scales_1.1.1
[49] mvtnorm_1.1-3 DBI_1.1.2 Rcpp_1.0.8.3 viridisLite_0.4.0 xtable_1.8-4 tmvnsim_1.0-2
[55] clue_0.3-60 reticulate_1.24 rsvd_1.0.5 mclust_5.4.9 deSolve_1.31 colortable_0.3.0
[61] DT_0.22 umap_0.2.8.0 stats4_4.0.5 htmlwidgets_1.5.4 httr_1.4.2 RColorBrewer_1.1-3
[67] ellipsis_0.3.2 rainbow_3.6 pkgconfig_2.0.3 XML_3.99-0.9 R.methodsS3_1.8.1 flowViz_1.54.0
[73] sass_0.4.1 utf8_1.2.2 flowStats_4.2.0 tidyselect_1.1.2 rlang_1.0.2 reshape2_1.4.4
[79] later_1.3.0 visNetwork_2.1.0 munsell_0.5.0 tools_4.0.5 cachem_1.0.6 cli_3.2.0
[85] generics_0.1.2 devtools_2.4.3 aws.s3_0.3.21 evaluate_0.15 stringr_1.4.0 fastmap_1.1.0
[91] yaml_2.3.5 processx_3.5.3 knitr_1.38 fs_1.5.2 EmbedSOM_2.1.1 robustbase_0.95-0
[97] purrr_0.3.4 RBGL_1.66.0 mime_0.12 rhandsontable_0.3.8 R.oo_1.24.0 pracma_2.3.8
[103] xml2_1.3.3 brio_1.1.3 compiler_4.0.5 rstudioapi_0.13 curl_4.3.2 png_0.1-7
[109] testthat_3.1.3 tibble_3.1.6 bslib_0.3.1 pcaPP_1.9-74 stringi_1.7.6 ps_1.6.0
[115] RSpectra_0.16-0 desc_1.4.1 lattice_0.20-45 Matrix_1.4-1 vctrs_0.4.0 pillar_1.7.0
[121] lifecycle_1.0.1 flowAI_1.20.1 BiocManager_1.30.16 jquerylib_0.1.4 data.table_1.14.2 bitops_1.0-7
[127] corpcor_1.6.10 httpuv_1.6.5 R6_2.5.1 latticeExtra_0.6-29 promises_1.2.0.1 gridExtra_2.3
[133] KernSmooth_2.23-20 RProtoBufLib_2.7.4 sessioninfo_1.2.2 MASS_7.3-56 gtools_3.9.2 assertthat_0.2.1
[139] pkgload_1.2.4 openssl_2.0.0 rprojroot_2.0.3 withr_2.5.0 mnormt_2.0.2 S4Vectors_0.28.1
[145] parallel_4.0.5 grid_4.0.5 tidyr_1.2.0 rmarkdown_2.13 Rtsne_0.15 Biobase_2.50.0
[151] shiny_1.7.1 base64enc_0.1-3 ellipse_0.4.2
Thank you,
Gautam
Hmmm... I think it is your selection criteria, can you include the printout of cyto_deatils(gs)
?
They're included in my opening post:
> head(cyto_details(gs))
name varX varY date varZ donor gene
A1 A1.fcs 100 100 05-04-2022 K0 xxx none
A2 A2.fcs 0 100 05-04-2022 K0 xxx none
A3 A3.fcs 100 1 05-04-2022 K0 xxx none
A4 A4.fcs 0 1 05-04-2022 K0 xxx none
A5 A5.fcs 100 1000 05-04-2022 K0 xxx none
A6 A6.fcs 0 1000 05-04-2022 K0 xxx none
Can you try setting select = 1
instead?
Same error.
> cyto_gate_draw(gs,
+ #select=list(name="A1.fcs"),
+ select=1,
+ parent = "root",
+ alias = "Cells",
+ channels = c("FSC-A","SSC-A"),
+ type = "polygon",
+ xlim = c(0,6000000),
+ ylim = c(0,8000000),
+ gatingTemplate = "gates.csv")
Error: Subset out of bounds
And if you remove select completely does it run?
No, still throws the same error.
Yeah OK it looks like the cyto_names()
may be out of sync with the rownames of cyto_details()
. I have already fixed this in the new version (coming soon), I can take a look tomorrow to see if I can patch it in the meantime.
Thank you, I really appreciate it.
@GKok I don't want to waste time fixing this for the current version. Perhaps in the meantime you could try running the following before gating:
cyto_details(gs)$name <- rownames(cyto_details(gs))
This should get everything back in sync and the gating should proceed.