[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
From: Henrik Bengtsson <henrik.bengtsson at gmail.com>
Sent: Thursday, July 7, 2022 11:59:36 AM
To: Giulia Pais <giuliapais1 at gmail.com>
Cc: Vincent Carey <stvjc at channing.harvard.edu>; bioc-devel at r-project.org <bioc-devel at r-project.org>
Subject: Re: [Bioc-devel] BiocParallel and Shiny
Sent: Thursday, July 7, 2022 11:59:36 AM
To: Giulia Pais <giuliapais1 at gmail.com>
Cc: Vincent Carey <stvjc at channing.harvard.edu>; bioc-devel at r-project.org <bioc-devel at r-project.org>
Subject: Re: [Bioc-devel] BiocParallel and Shiny
Hi. If you use the DoparParam backend for BiocParallel with doFuture::registerDoFuture(), then you have access to everything available in the 'future' ecosystem. This means you can use any of the available future parallel backends, plus near-live progress updates via the 'progressr' package. Progress signaled by 'progressr' can be rendered in Shiny. See https://progressr.futureverse.org/#biocparallelbplapply---parallel-lapply, for an example how to use BiocParallel on top of the future framework together with progress updates signaled by 'progressr'. See https://progressr.futureverse.org/reference/withProgressShiny.html for progressr::withProgressShiny(), which is a plug-in replacement for shiny::withProgress(). Run example("withProgressShiny", package = "progressr") for an example. I gave a short presentation on progressr, with a focus on its use together with future, at eRum 2020. The talk is available at https://www.jottr.org/2020/07/04/progressr-erum2020-slides/. It might give some more insight on how it all works. Hope this helps, Henrik On Thu, Jul 7, 2022 at 11:51 AM Giulia Pais <giuliapais1 at gmail.com> wrote: > > Hi, thanks for the reply. > Yes I?ve looked at this article, it seems to me like I have to access to the ?status? of a worker in order to do that, correct? > I mean, is there a way through BiocParallel interface in which I can receive a notification when a worker has finished a task? It is not clear to me how BiocParallel manages to update the progress bar internally ? I guess the mechanism is similar to the one I described: distribute workload ? when a worker has finished a task notify and update progress bar by one tick. > I?m honestly not too practical with asynch task management in R, sorry. > > Thank you > > From: Vincent Carey <stvjc at channing.harvard.edu> > Date: Thursday, July 7, 2022 at 11:40 > To: Giulia Pais <giuliapais1 at gmail.com> > Cc: bioc-devel at r-project.org <bioc-devel at r-project.org> > Subject: Re: [Bioc-devel] BiocParallel and Shiny > Interesting question. Have you looked at https://shiny.rstudio.com/articles/progress.html ...? There is > also a file called progress.R in BiocParallel/R folder. Probably some new code needs to be written > to connect information from the BiocParallel activities to the server so incProgress is run as needed. > > On Thu, Jul 7, 2022 at 4:48 AM Giulia Pais <giuliapais1 at gmail.com<mailto:giuliapais1 at gmail.com>> wrote: > Hello, > I have a question on the use of BiocParallel with Shiny: I would like to show a progress bar on the UI much like the standard progress bar that can be set in functions like bplapply() ? is it possible to do it and how? I haven?t found anything on the topic in the documentation unfortunately. > > Thanks in advance, > Giulia Pais > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioc-devel at r-project.org<mailto:Bioc-devel at r-project.org> mailing list > https://stat.ethz.ch/mailman/listinfo/bioc-devel > > The information in this e-mail is intended only for th...{{dropped:21}}