Hello, thank you very much for developing the tool!
I am encountering an issue I cannot solve. On my local machine, I can effectively leverage the n_threads to speed up the computation. Here is a sample script I have used for the testing:
# AIM ---------------------------------------------------------------------
# quick testing of nnSVG for spatially variable genes
# libraries ---------------------------------------------------------------
library(SpatialExperiment)
library(STexampleData)
library(scran)
library(nnSVG)
library(ggplot2)
# read in the data --------------------------------------------------------
# load example dataset from STexampleData package
spe <- Visium_humanDLPFC()
dim(spe)
# preprocessing steps -----------------------------------------------------
# keep only spots over tissue
spe <- spe[, colData(spe)$in_tissue == 1]
dim(spe)
# filter low-expressed and mitochondrial genes
# using default filtering parameters
spe <- filter_genes(spe)
dim(spe)
# for a faster runtime reduce the size of the dataset
set.seed(123)
n <- 100
sub <- spe[, sample(ncol(spe), n)]
# using library size factors
sub <- computeLibraryFactors(sub)
sub <- logNormCounts(sub)
assayNames(sub)
# select small set of random genes and several known SVGs for faster runtime in this example
set.seed(123)
ix_random <- sample(seq_len(nrow(sub)), 10)
known_genes <- c("MOBP", "PCP4", "SNAP25", "HBB", "IGKC", "NPY")
ix_known <- which(rowData(sub)$gene_name %in% known_genes)
ix <- c(ix_known, ix_random)
sub <- sub[ix, ]
dim(sub)
# run nnSVG
# set seed for reproducibility
set.seed(123)
# using a single thread in this example
start_time <- Sys.time()
sub <- nnSVG(sub,
assay_name = "logcounts",
n_threads = 1,
verbose = F)
end_time <- Sys.time()
# Calculate difference
duration <- end_time - start_time
print(duration)
> Time difference of 15.05425 secs
# using a single thread in this example
start_time <- Sys.time()
sub <- nnSVG(sub,
assay_name = "logcounts",
n_threads = 8,
verbose = F)
end_time <- Sys.time()
# Calculate difference
duration <- end_time - start_time
print(duration)
> Time difference of 3.773179 secs
This is the sessionInfo from the local machine:
R version 4.5.1 (2025-06-13)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Rome
tzcode source: system (glibc)
attached base packages:
[1] stats4 stats graphics grDevices datasets utils methods base
other attached packages:
[1] ggplot2_4.0.0 nnSVG_1.14.0 scran_1.38.0 scuttle_1.20.0 STexampleData_1.18.0 ExperimentHub_3.0.0
[7] AnnotationHub_4.0.0 BiocFileCache_3.0.0 dbplyr_2.5.1 SpatialExperiment_1.20.0 SingleCellExperiment_1.32.0 SummarizedExperiment_1.40.0
[13] Biobase_2.70.0 GenomicRanges_1.62.0 Seqinfo_1.0.0 IRanges_2.44.0 S4Vectors_0.48.0 BiocGenerics_0.56.0
[19] generics_0.1.4 MatrixGenerics_1.22.0 matrixStats_1.5.0
loaded via a namespace (and not attached):
[1] tidyselect_1.2.1 farver_2.1.2 dplyr_1.1.4 blob_1.2.4 S7_0.2.0 filelock_1.0.3 BRISC_1.0.6 Biostrings_2.78.0
[9] fastmap_1.2.0 RANN_2.6.2 bluster_1.20.0 rsvd_1.0.5 lifecycle_1.0.4 cluster_2.1.8.1 statmod_1.5.1 KEGGREST_1.50.0
[17] RSQLite_2.4.3 magrittr_2.0.4 compiler_4.5.1 rlang_1.1.6 tools_4.5.1 igraph_2.2.1 yaml_2.3.10 S4Arrays_1.10.0
[25] dqrng_0.4.1 bit_4.6.0 curl_7.0.0 DelayedArray_0.36.0 RColorBrewer_1.1-3 rdist_0.0.5 abind_1.4-8 BiocParallel_1.44.0
[33] purrr_1.1.0 withr_3.0.2 grid_4.5.1 beachmat_2.26.0 edgeR_4.8.0 scales_1.4.0 dichromat_2.0-0.1 cli_3.6.5
[41] crayon_1.5.3 metapod_1.18.0 rstudioapi_0.17.1 httr_1.4.7 rjson_0.2.23 pbapply_1.7-4 DBI_1.2.3 cachem_1.1.0
[49] parallel_4.5.1 AnnotationDbi_1.72.0 BiocManager_1.30.26 XVector_0.50.0 vctrs_0.6.5 Matrix_1.7-3 BiocSingular_1.26.0 BiocNeighbors_2.4.0
[57] bit64_4.6.0-1 irlba_2.3.5.1 magick_2.9.0 locfit_1.5-9.12 limma_3.66.0 glue_1.8.0 codetools_0.2-20 gtable_0.3.6
[65] BiocVersion_3.22.0 ScaledMatrix_1.18.0 tibble_3.3.0 pillar_1.11.1 rappdirs_0.3.3 R6_2.6.1 httr2_1.2.1 lattice_0.22-7
[73] png_0.1-8 memoise_2.0.1 renv_1.1.5 Rcpp_1.1.0 SparseArray_1.10.1 pkgconfig_2.0.3
Now, if I try to run the same snippet on the HPC, it only runs if n_threads is set to 1. Any other value would just get stuck forever.
Here is the sessinInfo from the HPC
R version 4.5.1 (2025-06-13)
Platform: x86_64-conda-linux-gnu
Running under: Rocky Linux 9.5 (Blue Onyx)
Matrix products: default
BLAS/LAPACK: /home/pedrini.edoardo/miniconda3/envs/env_R45/lib/libopenblasp-r0.3.29.so; LAPACK version 3.12.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8
[8] LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Vatican
tzcode source: system (glibc)
attached base packages:
[1] stats4 stats graphics grDevices datasets utils methods base
other attached packages:
[1] ggplot2_4.0.0 nnSVG_1.14.0 scran_1.38.0 scuttle_1.20.0 STexampleData_1.18.0 ExperimentHub_3.0.0 AnnotationHub_4.0.0
[8] BiocFileCache_3.0.0 dbplyr_2.5.1 SpatialExperiment_1.20.0 SingleCellExperiment_1.32.0 SummarizedExperiment_1.40.0 Biobase_2.70.0 GenomicRanges_1.62.0
[15] Seqinfo_1.0.0 IRanges_2.44.0 S4Vectors_0.48.0 BiocGenerics_0.56.0 generics_0.1.4 MatrixGenerics_1.22.0 matrixStats_1.5.0
loaded via a namespace (and not attached):
[1] tidyselect_1.2.1 farver_2.1.2 dplyr_1.1.4 blob_1.2.4 S7_0.2.0 filelock_1.0.3 BRISC_1.0.6 Biostrings_2.78.0 fastmap_1.2.0 RANN_2.6.2
[11] bluster_1.20.0 rsvd_1.0.5 lifecycle_1.0.4 cluster_2.1.8.1 statmod_1.5.1 KEGGREST_1.50.0 RSQLite_2.4.3 magrittr_2.0.4 compiler_4.5.1 rlang_1.1.6
[21] tools_4.5.1 igraph_2.2.1 yaml_2.3.10 S4Arrays_1.10.0 dqrng_0.4.1 bit_4.6.0 curl_7.0.0 DelayedArray_0.36.0 RColorBrewer_1.1-3 rdist_0.0.5
[31] abind_1.4-8 BiocParallel_1.44.0 purrr_1.1.0 withr_3.0.2 grid_4.5.1 beachmat_2.26.0 edgeR_4.8.0 scales_1.4.0 dichromat_2.0-0.1 cli_3.6.5
[41] crayon_1.5.3 metapod_1.18.0 rstudioapi_0.17.1 httr_1.4.7 rjson_0.2.23 pbapply_1.7-4 DBI_1.2.3 cachem_1.1.0 parallel_4.5.1 AnnotationDbi_1.72.0
[51] BiocManager_1.30.26 XVector_0.50.0 vctrs_0.6.5 Matrix_1.7-4 BiocSingular_1.26.0 BiocNeighbors_2.4.0 bit64_4.6.0-1 irlba_2.3.5.1 magick_2.9.0 locfit_1.5-9.12
[61] limma_3.66.0 glue_1.8.0 codetools_0.2-20 gtable_0.3.6 BiocVersion_3.22.0 ScaledMatrix_1.18.0 tibble_3.3.0 pillar_1.11.1 rappdirs_0.3.3 R6_2.6.1
[71] httr2_1.2.1 lattice_0.22-7 png_0.1-8 memoise_2.0.1 renv_1.1.5 Rcpp_1.1.0 SparseArray_1.10.1 pkgconfig_2.0.3
Do you have any suggestions for fixing this issue?
Best regards,
edo
Hello, thank you very much for developing the tool!
I am encountering an issue I cannot solve. On my local machine, I can effectively leverage the
n_threadsto speed up the computation. Here is a sample script I have used for the testing:This is the
sessionInfofrom the local machine:Now, if I try to run the same snippet on the HPC, it only runs if
n_threadsis set to1. Any other value would just get stuck forever.Here is the
sessinInfofrom the HPCDo you have any suggestions for fixing this issue?
Best regards,
edo