Hello gang!
I'm sure I've been able to do this in the past with no issue, but I now seem unable to specify different parameters for alignment and clustering with cytonorm. When I do so, the script errors at train.cytonorm(). Here's an example that works when the same parameters are used for cellular.cols and cluster.cols, but fails when the latter is a subset of the former. I can provide the data too if you can't reproduce this.
# load packages ----
library(Spectre)
package.load()
# read data ----
abs_path <- R.utils::getAbsolutePath("../data/pre-batch correction")
data_list <- read.files(
file.loc = abs_path,
file.type = ".fcs",
do.embed.file.names = TRUE
)
cell_dat <- do.merge.files(dat = data_list)
# transform parameters ----
to_asinh <- names(cell_dat)[1:8]
cell_dat <- do.asinh(cell_dat, to_asinh, cofactor = 500)
transformed_cols <- paste0(to_asinh, "_asinh")
# add metadata ----
# just adds columns "Batch" and "Sample"
meta_dat <- read.csv("../data/pre-batch correction/sample_details.csv")
cell_dat <- do.add.cols(
cell_dat,
base.col = "FileName",
add.dat = meta_dat,
add.by = "FileName"
)
# prepare for alignment ----
reference_files <- c("Mock_01_A", "Mock_05_B")
reference_dat <- do.filter(cell_dat, "Sample", reference_files)
cytonorm <- prep.cytonorm(
dat = reference_dat,
cellular.cols = transformed_cols,
cluster.cols = transformed_cols[1:4], # this causes train.cytonorm to fail
batch.col = "Batch",
sample.col = "Sample"
)
# train cytonorm ----
cytonorm <- train.cytonorm(model = cytonorm, align.cols = transformed_cols) # fails
The final output is:
Training alignment - setup
Working directory is '[I removed this]'
Training alignment - file (batch) preparation
Training alignment - file (batch) and metacluster splitting
-- running File '1'
-- running File '2'
Training alignment - learning conversions
Processing cluster 1
Computing Quantiles
A (FileID 1)
Error in flowCore::exprs(ff)[, channels, drop = FALSE] :
subscript out of bounds
Here is my sessionInfo(), with Spectre 1.2.0, CytoNorm 2.0.8, and FlowSOM 2.0.8:
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.utf8 LC_CTYPE=English_United Kingdom.utf8 LC_MONETARY=English_United Kingdom.utf8
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.utf8
time zone: Europe/London
tzcode source: internal
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] Biobase_2.64.0 BiocGenerics_0.52.0 CytoNorm_2.0.8 viridis_0.6.5
[5] viridisLite_0.4.2 uwot_0.2.2 umap_0.2.10.0 scattermore_1.2
[9] scales_1.3.0 Rtsne_0.17 rsvd_1.0.5 rstudioapi_0.17.1
[13] RColorBrewer_1.1-3 pheatmap_1.0.12 patchwork_1.3.0 irlba_2.3.5.1
[17] Matrix_1.7-2 gtools_3.9.5 gridExtra_2.3 ggthemes_5.1.0
[21] ggpubr_0.6.0 ggpointdensity_0.1.0 FlowSOM_2.14.0 igraph_2.1.4
[25] flowCore_2.16.0 factoextra_1.0.7 ggplot2_3.5.1 dendsort_0.3.4
[29] data.table_1.16.4 colorRamps_2.3.4 Spectre_1.2.0.0.0.0.1728133410
loaded via a namespace (and not attached):
[1] tidyselect_1.2.1 dplyr_1.1.4 farver_2.1.2 R.utils_2.12.3
[5] tweenr_2.0.3 XML_3.99-0.18 lifecycle_1.0.4 cluster_2.1.6
[9] magrittr_2.0.3 compiler_4.4.1 rlang_1.1.4 tools_4.4.1
[13] knitr_1.49 ggsignif_0.6.4 labeling_0.4.3 askpass_1.2.1
[17] reticulate_1.40.0 ConsensusClusterPlus_1.68.0 abind_1.4-8 withr_3.0.2
[21] purrr_1.0.2 RProtoBufLib_2.16.0 R.oo_1.27.0 grid_4.4.1
[25] polyclip_1.10-7 stats4_4.4.1 colorspace_2.1-1 ggridges_0.5.6
[29] MASS_7.3-60.2 cli_3.6.3 ragg_1.3.3 generics_0.1.3
[33] RSpectra_0.16-2 ggforce_0.4.2 stringr_1.5.1 matrixStats_1.5.0
[37] vctrs_0.6.5 jsonlite_1.8.9 carData_3.0-5 cytolib_2.16.0
[41] car_3.1-3 S4Vectors_0.42.1 rstatix_0.7.2 ggrepel_0.9.6
[45] Formula_1.2-5 systemfonts_1.2.1 ggnewscale_0.5.0 tidyr_1.3.1
[49] glue_1.8.0 stringi_1.8.4 gtable_0.3.6 munsell_0.5.1
[53] tibble_3.2.1 pillar_1.10.1 openssl_2.3.2 R6_2.6.1
[57] textshaping_1.0.0 evaluate_1.0.3 lattice_0.22-6 png_0.1-8
[61] R.methodsS3_1.8.2 backports_1.5.0
Please let me know what you think.
Best wishes
Hefin
Hello gang!
I'm sure I've been able to do this in the past with no issue, but I now seem unable to specify different parameters for alignment and clustering with cytonorm. When I do so, the script errors at
train.cytonorm(). Here's an example that works when the same parameters are used forcellular.colsandcluster.cols, but fails when the latter is a subset of the former. I can provide the data too if you can't reproduce this.The final output is:
Here is my
sessionInfo(), with Spectre 1.2.0, CytoNorm 2.0.8, and FlowSOM 2.0.8:Please let me know what you think.
Best wishes
Hefin