Skip to content
Permalink
Newer
Older
100755 63 lines (52 sloc) 1.54 KB
Aug 15, 2016
1
#!/bin/bash
2
3
r_pkgs=( DESeq2 grDevices genefilter biomaRt ggplot2 gplots RColorBrewer )
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
}
30
31
python_install_packages() {
32
apt-get -y install python-pip python-dev
Aug 15, 2016
33
pip install --upgrade ${pip_pkgs[@]}
34
}
35
36
r_install_packages() {
37
local pkgs=$@
38
pkgs=\"$(printf "\",\"%s" $pkgs)\"
39
Rscript --vanilla - <<EOF
40
options(echo = TRUE)
41
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)
42
.libPaths(Sys.getenv("R_LIBS_USER"))
43
setwd(paste(Sys.getenv("R_HOME")))
Aug 15, 2016
44
source("https://bioconductor.org/biocLite.R")
45
biocLite(c(${pkgs:3}))
Aug 15, 2016
46
EOF
47
}
48
49
main () {
50
ubuntu_update
51
ubuntu_install_r_cran
52
53
python_install_packages
54
55
# Install R libraries in the user home directory so that updating
56
# the libraries later on does not triggering the "unwritable
57
# directory" warning.
58
export -f r_install_packages
59
su cgi_user -c "bash -c \"r_install_packages ${r_pkgs[*]}\""
60
unset r_install_packages
Aug 15, 2016
61
}
62
63
main
You can’t perform that action at this time.