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/bin/
# sudo R
source("https://mac.R-project.org/bin/install.R")
install.libs("all")
and 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")
::install_cran("BiocManager")
remotes::version()
BiocManager
## Rprofile packages
if (.Platform$OS.type != "windows") {
::install_github(
remotes"jalvesaq/colorout"
)
}::install_github("gaborcsardi/prompt")
remotes::install_cran(c(
remotes"devtools",
"usethis"
))
## Laptop R profile packages (not needed at JHPCE)
::install_github(c(
remotes"gadenbuie/rsthemes"
))::install_cran("suncalc")
remotes::install_rsthemes(include_base16 = TRUE)
rsthemes::install_github("gadenbuie/xaringanExtra")
remotes
## JHPCE R profile packages
::install_github("cloudyr/rmote")
remotes
## Main packages
::install(c(
BiocManager"biocthis",
"brainflowprobes",
"derfinder",
"derfinderPlot",
"GenomicState",
"megadepth",
"qsvaR",
"recount",
"recountWorkflow",
"recount3",
"regutools",
"regionReport",
"spatialLIBD",
"TREG"
dependencies = TRUE, update = FALSE)
),
## LIBD packages
::install_github(c(
remotes"LieberInstitute/DeconvoBuddies",
"LieberInstitute/jaffelab",
# "LieberInstitute/recount.bwtool", ## Not really used anymore
"LieberInstitute/sgejobs",
"LieberInstitute/shinycsv"
dependencies = TRUE)
),
## CRAN packages
::install_cran(c(
remotes"ari",
"bookdown",
"blogdown",
"clue",
"corrplot",
"getopt",
"ggpubr",
"ggrepel",
"ggthemes",
"googlesheets4",
"MatrixEQTL",
"pagedown",
"patchwork",
"postcards",
"reprex",
"rsconnect",
"rtweet",
"tidyverse",
"xaringan",
"xaringanthemer",
"UpSetR",
"VennDiagram"
))
## Bioc packages
::install(c(
BiocManager"BiocCheck",
"ComplexHeatmap",
"ExploreModelMatrix",
"iSEE",
"scater",
"scran",
"sva",
"variancePartition"
update = FALSE)
),
## GitHub packages
::install_github(c(
remotes"clauswilke/colorblindr",
## 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
::install_github(
remotes"carbocation/plink2R/plink2R",
ref = "carbocation-permit-r361"
)
## Packages I only install at JHPCE
::install_github(c(
remotes"muschellij2/clusterRundown"
))
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
<- ifelse(
installed_path $OS.type != "windows",
.Platform"~/Dropbox/Computing/R",
"C:/Users/fellg/Dropbox/Computing/R"
)
## At JHPCE I use:
<- "~/R/update_R"
installed_path
<- dir(.libPaths())
installed save(installed, file = file.path(installed_path, paste0(Sys.Date(), '-installed.Rdata')))
## Load previous "installed" packages
<- dir(path = installed_path, pattern = 'installed.Rdata')
previous load(file.path(installed_path, previous[length(previous)]), verbose = TRUE)
## Locate current packages
<- dir(.libPaths())
current ## Use the following at JHPCE:
<- dir(.libPaths()[1])
current
## Missing ones
!installed %in% current]
installed[
## Install missing packages
::install(installed[!installed %in% current])
BiocManager
## List new R packages
!current %in% installed] current[
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')
}
}
# https://bookdown.org/yihui/blogdown/global-options.html
options(blogdown.author = 'L. Collado-Torres')
options(blogdown.ext = '.Rmd')
options(blogdown.insertimage.usebaseurl = TRUE)
## 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..
::set_theme_light("base16 Monokai {rsthemes}") # light theme
rsthemes::set_theme_dark("base16 Pop {rsthemes}") # dark theme
rsthemes::set_theme_favorite(c(
rsthemes"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
::use_theme_auto(lat = 39.2891, lon = -76.5583)
rsthemesaction = "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 {
} ::set_prompt(prompt::prompt_git)
prompt
} }
17.3 Git config files
17.3.1 ~/.gitconfig
Edit it with usethis::edit_git_config()
. Note that my editor is TextMate2 on macOS which can be accessed through the mate -w
command.
[user]
name = Leonardo Collado Torres
email = lcolladotor@gmail.com
[core]
editor = mate -w
ignorecase = true
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[alias]
ci = commit
st = status
br = branch
co = checkout
last = log -1 HEAD
visual = gitk
[push]
default = simple
[svn]
rmdir = true
[commit]
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 ~/.sge_request
This file configures the default SGE requests under qsub
and qrsh
.
# Check http://www.biostat.jhsph.edu/bit/cluster-usage.html for more instructions
#
# Set defaults for mem_free and h_vmem
-l mem_free=12G,h_vmem=12G
#
# Set the standard value for stack size limit
# (needed for some programs to run properly when h_vmem is set)
-l h_stack=256M
#
# Set a default maximum file size that an SGE job can create
-l h_fsize=100G
# Define my email
-M YOUR_EMAIL@gmail.com
# To get an email on a job use -m e
# Keep in mind the limits with sending emails from
# https://jhpce.jhu.edu/email-qsub
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
# 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'
# 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\]"
# LIDB projects
alias labold="cd /dcl01/lieber/ajaffe/lab"
alias lab="cd /dcl01/ajaffe/data/lab"
## 10X genomics
alias single="cd /dcl01/ajaffe/data/lab/singleCell"
alias spatialold="cd /dcl02/lieber/ajaffe/SpatialTranscriptomics/HumanPilot"
alias spatial="cd /dcl02/lieber/ajaffe/SpatialTranscriptomics/LIBD"
alias matt="cd /dcl01/lieber/ajaffe/Matt/MNT_thesis/snRNAseq/10x_pilot_FINAL"
## Team home directories
alias dcl01="cd /dcl01/lieber/lcolladotor"
alias dcl02="cd /dcl02/lieber/lcolladotor"
alias dcs04="cd /dcs04/lieber/lcolladotor"
## Creating modules
# https://lmod.readthedocs.io/en/latest/050_lua_modulefiles.html
alias modsrc="cd /jhpce/shared/jhpce/libd"
alias modlua="cd /jhpce/shared/jhpce/modulefiles/libd"
# 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 the git module by default when qrsh/qsub
## thanks to Jiong Yang
if [[ $HOSTNAME == compute-* ]] || [[ $HOSTNAME == transfer-* ]]; then
echo "Adding LIBD modules"
module use /jhpce/shared/jhpce/modulefiles/libd
echo "Loading git"
module load git
module load git-status-size/github
module load git-lfs/2.8.0
module load rmate/1.5.10
module load conda_R/4.2.x
fi
## 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"
## From https://twitter.com/fellgernon/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
For more information on rmate
and rmote
and how it relates to these configuration files, check this video and companion notes.