Skip to content

Latest commit

 

History

History
172 lines (122 loc) · 3.95 KB

Rinstallation.org

File metadata and controls

172 lines (122 loc) · 3.95 KB

R installation

Introduction

I seem to keep having trouble with R installations on a number of my machines. Let’s try and fix this here.

Installing R locally

sudo dnf install readline-devel 

Get the R source

mkdir -p ~/local/R_libs
mkdir -p programs 
cd programs 
wget https://cran.r-project.org/src/base/R-3/R-3.6.3.tar.gz
tar -zxvf R-3.6.3.tar.gz  
cd R-3.6.3

Configure:

./configure --prefix ~/
make
make install

Some packages need a recent version of aclocal, part of automake.

cd programs 
wget https://ftp.gnu.org/gnu/automake/automake-1.16.tar.gz 
tar -zxvf automake-1.16.tar.gz
cd automake-1.16
./bootstrap
./configure --prefix ~/

Setup R environment

Renviron

Set the tmp + local lib directory:

R_LIBS_USER='~/local/R_libs'

Took this out: never works as expected.

Instead when installing big packages resize /tmp/.

TMP=’/home/user/tmp’ TEMP=’/home/user/tmp’ TMPDIR=’/home/user/tmp’

Rprofile

Make sure R knows about the user and base libraries:

set_lib_paths <- function(lib_vec) {
  lib_vec <- normalizePath(lib_vec, mustWork = TRUE)
  shim_fun <- .libPaths
  shim_env <- new.env(parent = environment(shim_fun))
  shim_env$.Library <- character()
  shim_env$.Library.site <- character()
  environment(shim_fun) <- shim_env
  shim_fun(lib_vec)
}
set_lib_paths(c("~/local/R_libs","~/lib64/R/library"))

Install packages

Install bioconductor etc…

NOTE: for larger packages it might be necessary to increase the size of /tmp :

sudo mount -o remount,size=5G /tmp/
packages = c("pheatmap",
             "seqinr",
             "httpuv",
             "cowplot",
             "tidyverse",
             "viridis",
             "ggplot2",
             "ggforce",
             "UpSetR",
             "MVA",
             "wesanderson",
             "xlsx",
             "randomForest",
             "extRemes");
## Now load or install&load all
package.check <- lapply(
  packages,
  FUN = function(x) {
    if (!require(x, character.only = TRUE)) {
      install.packages(x,Ncpus=8,clean=TRUE, dependencies = TRUE)
      library(x, character.only = TRUE)
    }
  }
)


if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")

BiocManager::install(c("BSgenome",
                       "tximport",
                       "biomaRt",
                       "DESeq2",
                       "rhdf5",
                       "CAGEr",
                       "tximportData",
                       "BiocParallel",
                       "apeglm",
                       "ReportingTools",
                       "AnnotationDbi",
                       "org.Hs.eg.db",
                       "org.Mm.eg.db",
                       "rtracklayer"))
BiocManager::install(c("BSgenome.Hsapiens.UCSC.hg38",
                       "BSgenome.Hsapiens.NCBI.GRCh38"))
BiocManager::install("BSgenome.Mmusculus.UCSC.mm10")

devtools::install_github("pachterlab/sleuth")