[Bioc-devel] loading database package changes random number

Martin Morgan mtmorg@n@b|oc @end|ng |rom gm@||@com
Fri Apr 12 00:25:03 CEST 2019


This is actually from a dependency DelayedArray which, on load, calls DelayedArray::setAutoBPPARAM, which calls BiocParallel::MulticoreParam(), which uses the random number generator to select a random port for connection.

A different approach would be for DelayedArray to respect the user's configuration and use bpparam(), or perhaps look at the class of bpparam() and tell the user they should, e.g., BiocParallel::register(SerialParam()) if that's appropriate, or use registered("MulticoreParam") or registered("SerialParam") if available (they are by default) rather than creating an ad-hoc instance.

Martin

On 4/11/19, 10:17 AM, "Bioc-devel on behalf of Steffi Grote" <bioc-devel-bounces using r-project.org on behalf of steffi_grote using eva.mpg.de> wrote:

    Hi all,
    I found out that example code for my package GOfuncR yields a different result the first time it's executed, despite setting a seed. All the following executions are identical.
    It turned out that loading the database package 'Homo.sapiens' changed the random numbers:
    
    set.seed(123)
    runif(1)
    # [1] 0.2875775
    
    set.seed(123)
    suppressWarnings(suppressMessages(require(Homo.sapiens)))
    runif(1)
    # [1] 0.7883051
    
    set.seed(123)
    runif(1)
    # [1] 0.2875775
    
    Is that known or expected behaviour?
    Should I not load a package inside a function that later uses random numbers?
    
    Thanks in advance,
    Steffi
    
    _______________________________________________
    Bioc-devel using r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/bioc-devel
    


More information about the Bioc-devel mailing list