Skip to content

processors arguments of kmFit() not working #81

@FerranLlobetC

Description

@FerranLlobetC

Describe the bug
Regardless of N of threads given to the processors arguments of kmFit() the function uses the total number of logical threads.

Expected behavior
Setting processors to N should cause the function to use N processors.

Code to Reproduce

library(devtools)
install_github("BIGslu/kimma")
example.voom <- kimma::example.voom
lm_virus <- kmFit(dat = example.voom, 
               model = "~ virus",
               run.lm = TRUE,
               processors = 4) -> **8 processors being used** (given that my computer has 8 processors). 

Software:

  • OS: Ubuntu 20.04.6 LTS
  • R session (from sessionInfo( )):
R version 4.2.3 (2023-03-15)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS/LAPACK: /opt/miniconda3/envs/R_env/lib/libopenblasp-r0.3.21.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
[1] stringr_1.5.0  kimma_1.4.4    edgeR_3.40.0   limma_3.54.0   optparse_1.7.1
[6] tidyr_1.3.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8.3     magrittr_2.0.3   tidyselect_1.2.0 getopt_1.20.3
 [5] lattice_0.20-45  R6_2.5.1         rlang_1.1.1      foreach_1.5.2
 [9] fansi_1.0.4      dplyr_1.1.2      tools_4.2.3      grid_4.2.3
[13] utf8_1.2.3       cli_3.6.1        iterators_1.0.14 tibble_3.2.1
[17] lifecycle_1.0.3  purrr_1.0.1      codetools_0.2-19 vctrs_0.6.2
[21] glue_1.6.2       stringi_1.7.12   compiler_4.2.3   pillar_1.9.0
[25] generics_0.1.3   locfit_1.5-9.5   pkgconfig_2.0.3

Additional context
Apparently the issue resides in the lines of code 104 to 115 of kmFit.R. While in the file here at GitHub the code looks perfect in the source of the kmFit function that I got there is an extra line break which does not allow the number of processors to be set:

if (nzchar(chk) && chk == "TRUE") {
    processors.to.use <- 2
  }
  else if (is.null(processors)) {
    processors.to.use <- parallel::detectCores() - 2
    if (processors.to.use == 0) {
      stop("Error processors: Default resulted in 0. Please correct.")
    }
  }
  else {
    processors.to.use <- processors
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions