Skip to content

Instantly share code, notes, and snippets.

@omsai
Last active September 14, 2017 20:37
Show Gist options
  • Save omsai/546efbb0336f844e283e80d559c0336c to your computer and use it in GitHub Desktop.
Save omsai/546efbb0336f844e283e80d559c0336c to your computer and use it in GitHub Desktop.
Install and run R package grantfigs201710 on SLURM cluster
#!/bin/bash
#SBATCH -o sense-pat.out
set -e
# Globals
repo="grantfigs201710"
main() {
test -n "$SLURM_JOB_ID" && echo "Job $SLURM_JOB_ID" >> sense-pat.out
module purge
bootstrap
update
run
}
# Install R and Bioconductor installer.
bootstrap() {
conda install -y -c r r-essentials r-xml r-devtools
Rscript -e 'source("https://bioconductor.org/biocLite.R")'
}
# Update our package.
update() {
local github git
github="CoreLab/$repo"
module load git
if ! [[ -d "$repo" ]]; then
git clone git@github.uconn.edu:${github}.git
fi
(
# Old versions of git do not support --git-dir=$repo/.git
# --work-tree=$repo
cd $repo
git pull
R -q --vanilla <<EOF
devtools::install(
dependencies = c("Imports", "Suggests"),
repos = BiocInstaller::biocinstallRepos())
EOF
)
}
# Run vignette.
run() {
R -q --vanilla <<EOF
setwd("$repo/vignettes")
library(BiocParallel)
register(MulticoreParam($SLURM_JOB_CPUS_PER_NODE))
devtools::build_vignettes()
EOF
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment