EpiModel / EpiModeling

Tutorials for Using the EpiModel Software Platform for Research
4 stars 2 forks source link

Notes from Emeli (Windows) #4

Closed ejanderson1 closed 1 year ago

ejanderson1 commented 2 years ago

Notes on using R Studio's terminal

To login to Emory HPC in terminal before typing in the ssh command you must type this code: set DISPLAY=. Then log in as you normally would. Note that this command must be typed every time you start a new R Studio session before you can log in to the HPC.

ejanderson1 commented 2 years ago

Notes on step 2: Setting up your HPC environment

ejanderson1 commented 2 years ago

Using git pull

Git pull does not work in an interactive R session (i.e. when you are on a node to run code) unless you load git first.

To create an alias that does all 3 of the above steps use: alias lR='lspack; spack load git@2.35.1; spack load r@4.1.2; R

ejanderson1 commented 2 years ago

Creating and using a shell script

ejanderson1 commented 2 years ago

Using renv with your project on the HPC

Warning in install.packages("renv") : 'lib = "/projects/epimodel/spack/opt/spack/linux-centos8-cascadelake/gcc-11.2.0/r-4.1.3-gpyu76r3akwrtruy2syewy526o6d7ghy/rlib/R/library"' is not writable Would you like to use a personal library instead? (yes/No/cancel)

Select yes. This will install renv in your personal library on the HPC. All the other packages you use will be in your renv library.

REMINDER: you must run renv::restore() on HPC any time you make changes to your library locally and push those to GitHub

REMINDER 2: if you update your EpiModelHIV branch you have to renv::update() the package on the HPC as well

https://github.com/EpiModel/EmoryHPC/wiki/Using-Reproducible-R-Environments-with-the-%60renv%60-Package

ejanderson1 commented 2 years ago

Steps to start an interactive R session

Note: any output you generate will default save to your project directory on the HPC

ejanderson1 commented 2 years ago

slrum workflow

Link to vignette: https://github.com/EpiModel/EpiModelHPC/blob/main/vignettes/epimodelhiv-slurmworkflow.Rmd

ynchen08 commented 2 years ago

Side note on the use of renv: I previously ran into an issue in my local machine where renv::snapshot() was not updating the list of packages in my lockfile (i.e., newly installed packages were not found in my lockfile). I found running renv::settings$snapshot.type("all") helpful in my case. However, please note that running "all" option could include potentially undesired development dependencies in the lockfile.

AdrienLeGuillou commented 2 years ago

@ynchen08 this is by design, renv::snapshot() does not save all the installed packaged by default but only the ones that are used by the project.

For instance, most of my projects have languageserver and lintr installed but this is for my text editor and not the project itself. What renv does is looking for library, require or package::function calls on the scripts to find out what packages are actually necessary for the project. renv::settings$snapshot.type("all") should be used parsimoniously as it can lead to weird behavior or at least an imperinflated list of packages to be installed

ejanderson1 commented 2 years ago

Using EMHIV after making changes to your branch

Method 1:

  1. Make your changes to EMHIV
  2. Commit changes to GitHub
  3. Open your project in R studio (if already open, restart your session)
  4. Use renv::update() to pull the changes you made to EMHIV from GitHub
  5. Restart your session
  6. You can run your code now using the updated version of EMHIV
  7. NOTE: you will need to run renv::snpshot() to record the updated EMHIV to your renv.lock file

Method 2 (for quick development & testing locally):

  1. Make your changes to EMHIV
  2. Open your project in R studio (or start a new session if already open)
  3. Load EMHIV locally (i.e., from the location of you EMHIV folder on your laptop) by running the following code: pkgload::load_all(path/to/EpiModelHIV)
  4. Run your code to test the EMHIV changes

Note from Sam For quick development and testing locally, I always use the latter approach. For longer-term and bigger changes, including those that have to be tested against local versus HPC setups, I use the first approach. Here is an example:


# pkgload::load_all("~/git/EpiModelCOVID")
control <- [control.net](http://control.net/)(nsteps = 100,
                       nsims = 1,
                       ncores = 1,
                       [initialize.FUN](http://initialize.fun/) = init_covid_corporate,
                       [aging.FUN](http://aging.fun/) = aging_covid,
                       [departures.FUN](http://departures.fun/) = deaths_covid_corporate,
                       [arrivals.FUN](http://arrivals.fun/) = arrival_covid_corporate,
                       [resim_nets.FUN](http://resim_nets.fun/) = resim_nets_covid_corporate,
                       [infection.FUN](http://infection.fun/) = infect_covid_corporate,
                       [recovery.FUN](http://recovery.fun/) = progress_covid,
                       [dx.FUN](http://dx.fun/) = dx_covid,
                       [vax.FUN](http://vax.fun/) = vax_covid,
                       [prevalence.FUN](http://prevalence.fun/) = prevalence_covid_corporate,
                       module.order = c("[aging.FUN](http://aging.fun/)",
                                        "[departures.FUN](http://departures.fun/)",
                                        "[arrivals.FUN](http://arrivals.fun/)",
                                        "[resim_nets.FUN](http://resim_nets.fun/)",
                                        "[infection.FUN](http://infection.fun/)",
                                        "[recovery.FUN](http://recovery.fun/)",
                                        "[dx.FUN](http://dx.fun/)",
                                        "[vax.FUN](http://vax.fun/)",
                                        "[prevalence.FUN](http://prevalence.fun/)"),
                       resimulate.network = TRUE,
                       tergmLite = TRUE)

sim <- netsim(est, param, init, control)
smjenness commented 2 years ago

Notes on the issue directly above added to a new wiki page here: https://github.com/EpiModel/EpiModeling/wiki/Writing-and-Debugging-EpiModel-Code

smjenness commented 1 year ago

All of the windows-specific comments have been incorporated into the Wiki. Thanks @ejanderson1!