OHDSI Home | Forums | Wiki | Github

Using renv to handle R package dependencies


(Jose Posada) #21

Hi @Chris_Knoll,

Below some answers to your questions:

We can host a docker repository here. Odysseus has been uploading already compiled images there. From there people will do a docker pull to get the image and run it.

The answer is yes. Almost everything if not all can be inside and you will run the study by executing a command-line argument. Here an example from AllenNlp that may give you an idea of how the dockers ar run for scientific packages.

The workflow you proposed is very close to what we should do, however, as anything goes we will need to test.


(Chris Knoll) #22

Thanks for the links, tho, I am not sure what I am seeing: none of the repositories I looked at (I viewed about 5) had any overview information on it; is odysseus/r-env different from the renv that @schuemie was referring to? there’s an r-java docker but isn’t r-java just an inner package of R, and not something you consume stand-alone? (do dockers ‘merge together’ to assemble a single r environment from a set of smaller dockers or is the primary use of dockers to produce a sort of ‘process image’ for specified functionality (such as a web server or J2EE WAR container)… Same with the AllenNlp, not sure what i’m looking at there.

But, I think the core of my 2 questions were answered: someone needs to host them (which we can use Docker Hub) and someone needs to load in the assets if we want a completely self-contained docker image.

So, I feel like the workflow I laid out above works for both contexts: the study designers and the study distributors: martijn doesn’t need to really know anything about docker in order to produce a new study implementation (less burden on the dev). He can load up all the necessary dependencies and then capture the versions of those dependencies via renv() or building a custom .lock file. For distribution, people have the choice of either initializing their environment using the .lock file, or pulling down an image from a docker repo (which someone must have initialized/published the image somehow, and the .lock file makes this very easy).


(Gowtham Rao) #23

image

renv is enabled in recent version of Rstudio wizard!.


(Martijn Schuemie) #24

Hi @Gowtham_Rao. Yes, it is integrated, but I see two issues with using the built-in functionality:

  1. By default, renv tries to infer what packages need to be included from the code in your RStudio project, rather than what is explicitly listed in the DESCRIPTION file of your study package. I found that this tends to include a lot of packages that aren’t needed for running the study, such as things I have my PackageMaintenance.R, like OhdsiRTools (with its many dependencies), pkgdown, and ROhdsiWebApi, as well as knitr, rmarkdown, etc. So the lock files becomes very ‘heavy’.

  2. renv doesn’t always get the installation details for the OHDSI R packages that come from GitHub correct.

I would therefore prefer to use the function I added to OhdsiRTools which solves these issues for you.


(Martijn Schuemie) #25

So the workflows would be:

When using ATLAS to design a study:

  1. Export study package from ATLAS. This would already have the appropriate lock file for all the dependencies. If we assume the study package name will be the same as the ohdsi-studies repo name, ATLAS / Hydra can already include the reference to that repo to install the study package itself.
  2. Post the study package on our ohdsi-studies GitHub.

When designing the study package in R:

  1. Develop the package.
  2. Run the new function in OhdsiRTools to generate the lock file.
  3. Post on ohdsi-studies.

From there the lock file can be used to reconstruct the R environment, for example in a Docker image.


(Konstantin Yaroshovets) #26

@schuemie

I can help with Docker and R environment.
Today we have already pre-build R-environment with all OHDSI packages available in Execution Engine and as separate image. We can use it as a base and extend it with “renv” or OhdsiRTools updates.

R-environment Docker image:
https://hub.docker.com/r/odysseusinc/r-env
Execution Engine Docker image (on top of R-environment): https://hub.docker.com/r/odysseusinc/execution_engine

You can find R environment build scripts here:

Nowadays Execution Engine could be used in combination with:

  • ATLAS
    This integration allows to create and execute Prediction and Estimation studies directly from ATLAS. But we are limited to these types of analysis here. Results of execution are available for download directly in ATLAS.

  • ARACHNE DataNode
    This integration allows to execute ANY type of analysis - this is suitable for ohdsi-studies repo. DataNode provides UI for datasource configuration and analysis execution for users who are not experienced with all technical details of R packages installation.

ATLAS screenshot:

DataNode screenshot:


t