Skip to content
Permalink
Newer
Older
100755 65 lines (54 sloc) 1.61 KB
Aug 15, 2016
1
#!/bin/bash
2
3
r_pkgs=( DESeq2 genefilter biomaRt ggplot2 gplots RColorBrewer )
Aug 15, 2016
4
pip_pkgs=( biopython )
5
6
if [[ $(id -u) -ne 0 ]]; then
7
echo "Error: run this script as the root user, not EUID $(id -u)."
8
exit 1
9
fi
10
11
set -e # Make most errors fatal.
12
13
ubuntu_update () {
14
apt-get update
15
apt-get -y upgrade
16
}
17
18
ubuntu_install_r_cran () {
19
cat <<EOF > /etc/apt/sources.list.d/cgi-r-cran.list
20
# Newest R version from CRAN per
21
# https://cran.r-project.org/bin/linux/ubuntu/
22
deb https://cran.fhcrc.org/bin/linux/ubuntu $(lsb_release -cs)/
23
EOF
24
local key=E084DAB9
25
grep -q $key <( apt-key list ) ||
26
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key
Aug 15, 2016
27
apt-get update
28
apt-get -y install r-base-dev
29
# Dependencies of RCurl:
30
apt-get -y install libxml2-dev libcurl4-gnutls-dev
Aug 15, 2016
31
}
32
33
python_install_packages() {
34
apt-get -y install python-pip python-dev
Aug 15, 2016
35
pip install --upgrade ${pip_pkgs[@]}
36
}
37
38
r_install_packages() {
39
local pkgs=$@
40
pkgs=\"$(printf "\",\"%s" $pkgs)\"
41
Rscript --vanilla - <<EOF
42
options(echo = TRUE)
43
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)
44
.libPaths(Sys.getenv("R_LIBS_USER"))
45
setwd(paste(Sys.getenv("R_HOME")))
Aug 15, 2016
46
source("https://bioconductor.org/biocLite.R")
47
biocLite(c(${pkgs:3}))
Aug 15, 2016
48
EOF
49
}
50
51
main () {
52
ubuntu_update
53
ubuntu_install_r_cran
54
55
python_install_packages
56
57
# Install R libraries in the user home directory so that updating
58
# the libraries later on does not triggering the "unwritable
59
# directory" warning.
60
export -f r_install_packages
61
su cgi_user -c "bash -c \"r_install_packages ${r_pkgs[*]}\""
62
unset r_install_packages
Aug 15, 2016
63
}
64
65
main
You can’t perform that action at this time.