---
title: "00 - Environment setup"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(eval = FALSE) # setup steps run once, at the shell/console
```
# Software environment
This analysis uses R (>= 4.4; developed on 4.5.3) and Bioconductor (>= 3.20;
developed on 3.22). Core packages: **methylKit**, **DSS**, **bsseq**,
**GenomicRanges**, **genomation**, **rtracklayer**, plus **data.table**,
**ggplot2**, **patchwork**, **pheatmap**.
## Standard install (Linux, or macOS with binary packages available)
```{r}
install.packages("BiocManager")
BiocManager::install(c("methylKit", "DSS", "genomation",
"GenomicRanges", "rtracklayer"))
install.packages(c("data.table", "ggplot2", "patchwork", "pheatmap", "R.utils"))
```
## macOS / Apple Silicon (osx-arm64) note
bioconda has no osx-arm64 build of methylKit/DSS/genomation, so if you build a
conda R environment you must install these Bioconductor packages **from source**.
Source compilation of `locfit` (a DSS -> bsseq dependency) fails on the conda
toolchain with `C17 standard requested but CC17 is not defined`, because the
toolchain leaves `CC17` undefined. Fix by pointing R at a custom Makevars:
```{r}
# write a Makevars the current user can control, then export R_MAKEVARS_USER
dir.create(".rconfig", showWarnings = FALSE)
writeLines(c(
"CC17 = arm64-apple-darwin20.0.0-clang",
"CC17FLAGS = -mmacosx-version-min=11.0",
"CC23 = arm64-apple-darwin20.0.0-clang",
"CC23FLAGS = -mmacosx-version-min=11.0"
), ".rconfig/Makevars")
Sys.setenv(R_MAKEVARS_USER = file.path(getwd(), ".rconfig/Makevars"))
BiocManager::install(c("methylKit", "DSS", "genomation",
"GenomicRanges", "rtracklayer"),
update = FALSE, ask = FALSE, Ncpus = 8)
```
Set `R_MAKEVARS_USER` in every session that may compile a package. Adjust the
compiler name (`arm64-apple-darwin20.0.0-clang`) to whatever
`system("R CMD config CC")` reports on your machine.
## Session info
```{r, eval=TRUE}
sessionInfo()
```