Skip to content
Prev 19065 / 21307 Next

[Bioc-devel] BiocParallel and Shiny

I think it should be straight-forward to use bpiterate() where the REDUCE function is evaluated locally. It might take a bit of care to make sure that the progress bar is actually informative ? generally, increase the `tasks=` argument to the number of time you?d like the progress bar to be updated.

iter <- function(n) {
    ## return the numbers n, n-1, n-2, ? until n < 0, and then return NULL
    force(n)
    function() {
        if (n < 0)
            NULL
        else {
            n <<- n - 1
            n + 1
        }
    }
}

bpiterate(
    iter(10),
    function(i) { Sys.sleep(i/10); i },
    REDUCE = function(x, y) {
        message(y)
        c(x, y)
    },
    BPPARAM = SnowParam(workers = 2, tasks = 10)
)

Replace `message()` to do whatever is required to iterate the progress bar in shiny. There is a `reduce.in.order=` argument that might be necessary to obtain results in order; I?m not exactly sure how this would impact a progress bar when, for instance, the early tasks take a long time?

Martin


From: Bioc-devel <bioc-devel-bounces at r-project.org> on behalf of Giulia Pais <giuliapais1 at gmail.com>
Date: Thursday, July 7, 2022 at 6:11 AM
To: Henrik Bengtsson <henrik.bengtsson at gmail.com>
Cc: bioc-devel at r-project.org <bioc-devel at r-project.org>
Subject: Re: [Bioc-devel] BiocParallel and Shiny
Thank you so much! I'll look into it, have a nice day

Giulia Pais
Message-ID: <BN8PR04MB62419569D6109712A5D0350CF9839@BN8PR04MB6241.namprd04.prod.outlook.com>
In-Reply-To: <DBAPR04MB726938E2F993DA17792216CFAA839@DBAPR04MB7269.eurprd04.prod.outlook.com>