17 Config files
Here are some of my configuration files for working R and JHPCE.
17.1 R setup
- RStudio Desktop Preview version: https://rstudio.com/products/rstudio/download/preview/
- R: latest versions that match Bioconductor release and devel
- macOS: you can download the latest “branch” and “devel” from https://mac.r-project.org/
- Windows: https://cran.r-project.org/, also needs Rtools42 https://cran.r-project.org/bin/windows/Rtools/
- RSwitch
- macOS: https://rud.is/rswitch/
- Windows: I install the R versions in two different folders and switch them using RStudio’s global configuration options https://cran.r-project.org/
- Bioconductor-devel docker image: http://bioconductor.org/help/docker/
Do you want to use @Bioconductor 3.15? That means that you’ll need to install R 4.2 on your computer from CRAN https://t.co/11yTIRMqlC
— 🇲🇽 Leonardo Collado-Torres (@lcolladotor) April 28, 2022
For macOS users, you might want to use to install 📦 deps for compiling
sudo R
source("https://t.co/ATL1ipla0M")
install.libs("all")#rstats https://t.co/EXUpWINy5T pic.twitter.com/X2HEbY1Znm
So in macOS I use:
- From https://mac.r-project.org/tools/, install
Xcode
developer tools +GNU Fortran compiler
. - From https://mac.r-project.org/bin/, install all binaries with the following commands:
## From https://mac.r-project.org/bin/
# sudo R
source("https://mac.R-project.org/bin/install.R")
install.libs("all")
On winOS I install Rtools (latest version) from https://cran.r-project.org/bin/windows/Rtools/.
Additional software:
- Both: Notion, Slack
- Windows: WinSCP, Git bash, PuTTY, Notepad++, NppToR
- macOS: Cyberduck, iTerm2, Alfred, TextMate2
You might also be interested in checking out our older onboarding setup materials.
17.1.1 R packages
The following R code installs all the packages I have installed currently as my base. Many of them are packages I have made or contributed to as you can see at lcolladotor.github.io/pkgs. As I explore packages, I might try new ones that are not in this list.
## Install from scratch
if (!requireNamespace("remotes", quietly = TRUE))
install.packages("remotes")
remotes::install_cran("BiocManager")
BiocManager::version()
## Rprofile packages
if (.Platform$OS.type != "windows") {
remotes::install_github(
"jalvesaq/colorout"
)
}
remotes::install_github("gaborcsardi/prompt")
remotes::install_cran(c(
"devtools",
"usethis"
))
## Laptop R profile packages (not needed at JHPCE)
remotes::install_github(c(
"gadenbuie/rsthemes"
))
remotes::install_cran("suncalc")
rsthemes::install_rsthemes(include_base16 = TRUE)
remotes::install_github("gadenbuie/xaringanExtra")
## JHPCE R profile packages
remotes::install_github("cloudyr/rmote")
## Main packages
BiocManager::install(c(
"biocthis",
"DeconvoBuddies", ## under review at BioC
"derfinder",
"derfinderPlot",
"GenomicState",
"megadepth",
"qsvaR",
"recount",
"recountWorkflow",
"recount3",
"regutools",
"regionReport",
"smokingMouse",
"spatialLIBD",
"TREG",
"visiumStitched" ## accepted at BioC but not yet available from it
), dependencies = TRUE, update = FALSE)
## LIBD packages
remotes::install_github(c(
"LieberInstitute/DeconvoBuddies",
"LieberInstitute/jaffelab",
# "LieberInstitute/recount.bwtool", ## Not really used anymore
"LieberInstitute/slurmjobs",
# "LieberInstitute/shinycsv", ## Not really used anymore
"LieberInstitute/visiumStitched"
), dependencies = TRUE)
## CRAN packages
remotes::install_cran(c(
"ari",
"available",
"bookdown",
"blogdown",
"clue",
"corrplot",
"emojifont",
"gapminder",
"getopt",
"ggpubr",
"ggrepel",
"ggthemes",
"googlesheets4",
"MatrixEQTL",
"pagedown",
"palmerpenguins",
"patchwork",
"Polychrome",
"postcards",
"reprex",
"rsconnect",
"rtweet",
"tidyverse",
"tidytuesdayR",
"xaringan",
"xaringanthemer",
"UpSetR",
"VennDiagram",
"wordcloud"
))
## Bioc packages
BiocManager::install(c(
"BayesSpace",
"BiocCheck",
"ComplexHeatmap",
"dreamlet",
"DO.db",
"EnhancedVolcano",
"ExploreModelMatrix",
"HubPub",
"iSEE",
"PCAtools",
"scater",
"scran",
"scry",
"sva",
"variancePartition"
), update = FALSE)
## GitHub packages
remotes::install_github(c(
"clauswilke/colorblindr",
"MatthewBJane/ThemePark",
## Install from GitHub due to https://github.com/immunogenomics/harmony/issues/145
"immunogenomics/harmony",
"satijalab/azimuth"
))
## Related to https://github.com/gusevlab/fusion_twas/issues/14
remotes::install_github(
"carbocation/plink2R/plink2R",
ref = "carbocation-permit-r361"
)
## Packages I only install at JHPCE
# remotes::install_github(c(
# "muschellij2/clusterRundown" ## this package was for JHPCE v2. Since 2023 we are using JHPCE v3.
# ))
17.1.1.1 Previously installed
As I described in my blog post on updating R, I also like to saved my list of currently installed packages.
## Save currently installed packages
installed_path <- ifelse(
.Platform$OS.type != "windows",
"~/Dropbox/Computing/R",
"C:/Users/fellg/Dropbox/Computing/R"
)
## At JHPCE I use:
# installed_path <- "~/R/update_R"
## Locate installed R packages
installed <- dir(.libPaths())
# For JHPCE
# installed <- dir(.libPaths()[1])
## Save list of installed packages for later use
save(installed, file = file.path(installed_path, paste0(Sys.Date(), '-installed.Rdata')))
## Load previous "installed" packages
previous <- dir(path = installed_path, pattern = 'installed.Rdata')
load(file.path(installed_path, previous[length(previous)]), verbose = TRUE)
## Locate current packages
current <- dir(.libPaths())
## Use the following at JHPCE:
current <- dir(.libPaths()[1])
## Missing ones
installed[!installed %in% current]
## Install missing packages
BiocManager::install(installed[!installed %in% current])
## List new R packages
current[!current %in% installed]
You might also benefit from watching this video and checking the companion notes.
If you want to install multiple R and Bioconductor versions, then you might find this second video and companion notes useful.
17.2 R config files
17.2.1 ~/.Rprofile
Edit it with usethis::edit_r_profile()
. Don’t add any analysis packages here as discussed in the “what they forgot to teach you about R” workshop.
## Change colors
# Source https://github.com/jalvesaq/colorout
if(Sys.getenv('TERM') %in% c("term", "xterm-256color", "cygwin", "screen")) {
if (!requireNamespace("colorout", quietly = TRUE) & .Platform$OS.type != 'windows') {
cat('To install colorout use: remotes::install_github("jalvesaq/colorout")\n')
} else {
require("colorout")
}
}
# https://bookdown.org/yihui/blogdown/global-options.html
options(blogdown.author = 'L. Collado-Torres')
options(blogdown.ext = '.Rmd')
options(blogdown.insertimage.usebaseurl = TRUE)
options(blogdown.method = "markdown")
## From RStudio::conf 2019 Building Tidy Tools
if (interactive()) {
suppressMessages(require("devtools"))
suppressMessages(require("usethis"))
suppressMessages(require("testthat"))
options(
warnPartialMatchArgs = TRUE,
warnPartialMatchDollar = TRUE,
warnPartialMatchAttr = TRUE
)
}
## https://blog.rstudio.com/2013/06/10/rstudio-cran-mirror/
options(repos = c(CRAN = "https://cloud.r-project.org/"))
## For usethis::use_git()
options(usethis.protocol = "ssh")
## For usethis
options(
usethis.full_name = "Leonardo Collado-Torres",
usethis.description = list(
`Authors@R` = 'c(
person("Leonardo", "Collado-Torres", role = c("aut", "cre"),
email = "lcolladotor@gmail.com", comment = c(ORCID = "0000-0003-2140-308X"))
)'
)
)
## For biocthis
options("biocthis.pkgdown" = TRUE)
options("biocthis.testthat" = TRUE)
## For the styler addin
# Affects the output of: styler:::get_addins_style_transformer_name()
# https://github.com/r-lib/styler/blob/acfb42acc2e558e7b57ef133f1470df78b5093fd/R/addins.R#L183
options("styler.addins_style_transformer" = "biocthis::bioc_style()")
## From https://www.garrickadenbuie.com/project/rsthemes/
if (interactive() && requireNamespace("rsthemes", quietly = TRUE)) {
# Set preferred themes if not handled elsewhere..
rsthemes::set_theme_light("base16 Monokai {rsthemes}") # light theme
rsthemes::set_theme_dark("base16 Pop {rsthemes}") # dark theme
rsthemes::set_theme_favorite(c(
"base16 Monokai {rsthemes}",
"base16 Pop {rsthemes}",
"base16 Brewer {rsthemes}",
"One Dark {rsthemes}",
"Solarized Light {rsthemes}"
))
# Whenever the R session restarts inside RStudio...
setHook("rstudio.sessionInit", function(isNewSession) {
# Automatically choose the correct theme based on time of day
## Used rsthemes::geolocate() once
rsthemes::use_theme_auto(lat = 39.2891, lon = -76.5583)
}, action = "append")
}
## From https://twitter.com/hadleywickham/status/1113542388033699840
if(interactive()) {
if (!requireNamespace("prompt", quietly = TRUE)) {
cat('To install prompt use: remotes::install_github("gaborcsardi/prompt")\n')
} else {
prompt::set_prompt(prompt::prompt_git)
}
}
17.3 Git config files
17.3.1 ~/.gitconfig
Edit it with usethis::edit_git_config()
.
[user]
name = lcolladotor
email = lcolladotor@gmail.com
[pull]
rebase = false
[alias]
co = checkout
br = branch
ci = commit
st = status
last = log -1 HEAD
[init]
defaultBranch = devel
[safe]
directory = *
[core]
ignorecase = true
On my laptop the end is a little different given that I do use a ~/.gitignore_global
file there and use TextMate as my text editor for commit messages.
[core]
ignorecase = true
excludesfile = ~/.gitignore_global
editor = mate -w
17.3.2 ~/.gitignore_global
Edit it with usethis::edit_git_ignore()
. These files are ignored by default by git on my computer.
I no longer have this file at JHPCE (though I have one on my laptop) since many people didn’t have it, so they would see files with git status
that I wouldn’t. To simplify things, I have deleted this (for now).
*~
## More at
## https://help.github.com/articles/ignoring-files
# R history #
#############
.Rapp.history
.Rhistory
# LaTeX stuff #
###############
*.aux
*.out
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
17.4 JHPCE files
To configure your computer with JHPCE, you might want to check this video and companion notes for macOS
or this other video and companion notes for winOS.
These videos also talk about GitHub and local git setup on your laptop.
17.4.1 ~/.slurm/defaults
This file configures the default SLURM requests under srun
and sbatch
. See this BitHelp thread for more details about this file.
17.4.2 ~/.bashrc
This is the main configuration file for JHPCE, but it’s really for any linux system. Some of the commands have to change when working on macOS.
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
## Team home directories
alias dcl02="cd /dcl02/lieber/lcolladotor"
alias dcs04="cd /dcs04/lieber/lcolladotor"
alias dcs05="cd /dcs05/lieber/lcolladotor"
## Creating modules
# https://lmod.readthedocs.io/en/latest/050_lua_modulefiles.html
# SLURM
alias modsrc="cd /jhpce/shared/libd/core"
alias modlua="cd /jhpce/shared/libd/modulefiles"
## To deal with running nextflow without requesting much more memory
## https://jhpce.jhu.edu/question/why-do-i-get-memory-errors-when-running-java/
# export _JAVA_OPTIONS="-Xms5g -Xmx6g"
## Disable for SPEAQeasy
## From https://twitter.com/lcolladotor/status/1258455434073124865?s=20
## and https://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html
umask u=rwx,g=rwx,o= ## equivalent to umask 007
# Exit for non-interactive shells
# Obtained this information from Geo Pertea
# as noted at https://lists.jh.edu/sympa/arc/bithelp/2024-04/msg00020.html.
[[ ${-#*i} != ${-} ]] || return
# User specific aliases and functions
# Auto-complete command from history
# http://lindesk.com/2009/04/customize-terminal-configuration-setting-bash-cli-power-user/
export INPUTRC=~/.inputrc
# http://www.biostat.jhsph.edu/~afisher/ComputingClub/webfiles/KasperHansenPres/IntermediateUnix.pdf
# https://unix.stackexchange.com/questions/48713/how-can-i-remove-duplicates-in-my-bash-history-preserving-order
export HISTCONTROL=ignoreboth:erasedups
export HISTSIZE=20000
shopt -s histappend
shopt -s cmdhist
# http://superuser.com/questions/384769/alias-rm-rm-i-considered-harmful
alias rmi='rm -i'
# colors
# http://norbauer.com/notebooks/code/notes/ls-colors-and-terminal-app
# used BSD pattern ExGxFxDxBxEgEdxbxgxhxd on http://geoff.greer.fm/lscolors/
# that tool does not specify the colors, which I did by looking manually at
# http://blog.twistedcode.org/2008/04/lscolors-explained.html
# and the norbauer.com site previously mentioned
alias ls="ls --color=auto"
#export LS_COLORS="di=1;34;40:ln=1;36;40:so=1;35;40:pi=1;93;40:ex=1;31;40:bd=1;34;46:cd=1;34;43:su=0;41:sg=0;46:tw=0;47:ow=0;43"
## After switching to RStudio:
# https://askubuntu.com/questions/466198/how-do-i-change-the-color-for-directories-with-ls-in-the-console
export LS_COLORS="di=0;32:ln=0;36:so=0;35:pi=0;93:ex=0;31:bd=0;34;46:cd=0;34;43:su=0;41:sg=0;46:tw=0;47:ow=0;43:fi=0;33"
# Uncomment below for Mac and comment the two previous commands
#export CLICOLOR=1
#export LSCOLORS="ExGxFxDxBxEgEdxbxgxhxd"
## For setup:
# http://erniemiller.org/2011/12/12/textmate-2-rmate-awesome/
## For laptop config:
# http://jonsimpson.co.uk/log/2011/rmate-ssh-remoteforward
## rmate port
# https://github.com/textmate/rmate
export RMATE_PORT="SOME_PORT_YOU_CHOOSE"
## Load commonly used modules by default when using srun/sbatch
## thanks to Jiong Yang and John Muschelli
if [[ $HOSTNAME == compute-* ]] || [[ $HOSTNAME == transfer-* ]]; then
# Load SLURM LIBD modules
## This command is not needed anymore, though you would need
## to use a similar command if you are loading private modules.
# module use /jhpce/shared/libd/modulefiles
module load git-status-size
module load git-lfs
module load rmate
module load conda_R/4.4.x ## for BioC 3.20
fi
## Set an alias to run JHPCE rsrun with X11 support
## Documented at https://jhpce.jhu.edu/slurm/interactive-jobs/#shortcuts
jsrun() { if [ -z ${DISPLAY} ]; then /usr/bin/srun --pty "$@" bash; else /usr/bin/srun --pty --x11 "$@" bash; fi }
# Change command prompt
# http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
# http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/
# https://bbs.archlinux.org/viewtopic.php?id=48910
# previous in enigma2: "[\u@\h \W]\$ "
# previously in mac: "\h:\W \u\$ "
export PS1="\[\e[0;33m\]\A \W \$ \[\e[m\]"
For more information on rmate
and rmote
and how it relates to these configuration files, check this video and companion notes.