Skip to content

Commit 30ec71e

Browse files
Updated installing packages in GCP using bash script
1 parent 33c1f83 commit 30ec71e

File tree

4 files changed

+92
-63
lines changed

4 files changed

+92
-63
lines changed

GoogleCloud/01-RNA-Seq/RNA-seq.ipynb

+14-37
Original file line numberDiff line numberDiff line change
@@ -262,57 +262,34 @@
262262
]
263263
},
264264
{
265-
"cell_type": "code",
266-
"execution_count": null,
267-
"id": "75f2c0da-332b-4b12-8705-897a58fc0e9f",
265+
"cell_type": "markdown",
266+
"id": "b4788a28",
268267
"metadata": {},
269-
"outputs": [],
270268
"source": [
271-
"# Make installation paths writable so the packages install correctly.\n",
272-
"system(\"sudo chmod -R 777 /usr/lib/R/library\", intern=TRUE)\n",
273-
"system(\"sudo chmod -R 777 /usr/local/lib/R/site-library\", intern=TRUE)"
269+
"Run the following to create a Kernel with all required packaged installed. It will take about 10 minutes to install packages and create a kernel."
274270
]
275271
},
276272
{
277273
"cell_type": "code",
278274
"execution_count": null,
279-
"id": "4ea2df9e-b6c8-4da4-bbde-4659e28b42f7",
280-
"metadata": {},
275+
"id": "0a769bb6",
276+
"metadata": {
277+
"vscode": {
278+
"languageId": "r"
279+
}
280+
},
281281
"outputs": [],
282282
"source": [
283-
"# Intall r-base packages\n",
284-
"packages <- c(\"hexbin\", \"tidyverse\")\n",
285-
"\n",
286-
"if (!requireNamespace(\"Biobase\", quietly = TRUE))\n",
287-
" BiocManager::install(\"Biobase\")\n",
288-
"install.packages(\"NMF\")\n",
289-
"\n",
290-
"# Install packages not yet installed\n",
291-
"installed_packages <- packages %in% rownames(installed.packages())\n",
292-
"if (any(installed_packages == FALSE)) {\n",
293-
" install.packages(packages[!installed_packages])\n",
294-
"}"
283+
"system('chmod +x install_rna_seq_packages.sh' , intern=TRUE)\n",
284+
"system('bash install_rna_seq_packages.sh >> logs.txt' , intern=TRUE) # This creates \"R-RNA-Seq\" kernel"
295285
]
296286
},
297287
{
298-
"cell_type": "code",
299-
"execution_count": null,
300-
"id": "e84050fd-7b86-4d23-8d16-20479e6040e1",
288+
"cell_type": "markdown",
289+
"id": "bd70d6fe",
301290
"metadata": {},
302-
"outputs": [],
303291
"source": [
304-
"# Install BiocManager if not already installed\n",
305-
"if (!require(\"BiocManager\", quietly = TRUE))\n",
306-
" install.packages(\"BiocManager\")\n",
307-
"\n",
308-
"# Install Bioconductor packages.\n",
309-
"packages <- c(\"BSgenome\", \"DESeq2\", \"vsn\", \"genomation\")\n",
310-
"\n",
311-
"# Install packages not yet installed\n",
312-
"installed_packages <- packages %in% rownames(installed.packages())\n",
313-
"if (any(installed_packages == FALSE)) {\n",
314-
" BiocManager::install(packages[!installed_packages])\n",
315-
"}"
292+
"**Important: Choose \"R-RNA-Seq\" kernel for the rest of the notebook.**"
316293
]
317294
},
318295
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
conda update -n base -c defaults conda -y
4+
5+
# Create a conda environment
6+
conda create -n r-package-1 -y
7+
8+
# Consider addressing your conda initialization instead.
9+
source ~/.bashrc
10+
11+
# Activate the Conda Environment
12+
conda activate r-package-1
13+
14+
# Install packages
15+
conda install -c conda-forge -c bioconda bioconductor-deseq2 -y
16+
17+
conda install r-hexbin -y
18+
19+
conda install conda-forge::r-tidyverse -y
20+
21+
conda install bioconda::bioconductor-bsgenome -y
22+
23+
conda install bioconda::bioconductor-vsn -y
24+
25+
conda install bioconda::bioconductor-genomation -y
26+
27+
conda install bioconda::bioconductor-genomeinfodb -y
28+
29+
R -e 'install.packages(c("NMF","IRkernel"), repos="http://cran.rstudio.com/")'
30+
31+
32+
# Install the kernel specification for Jupyter
33+
R -e 'IRkernel::installspec(name = "R-RNA-Seq", displayname = "R-RNA-Seq")'

GoogleCloud/02-RRBS/RRBS-downstream.ipynb

+19-26
Original file line numberDiff line numberDiff line change
@@ -198,41 +198,34 @@
198198
]
199199
},
200200
{
201-
"cell_type": "code",
202-
"execution_count": null,
203-
"id": "c0a10c0c-f13a-40e3-bd08-54529934e720",
201+
"cell_type": "markdown",
202+
"id": "47daed1e",
204203
"metadata": {},
205-
"outputs": [],
206204
"source": [
207-
"# Intall r-base packages\n",
208-
"packages <- c(\"ggplot2\", \"ggforce\", \"tidyverse\")\n",
209-
"\n",
210-
"# Install packages not yet installed\n",
211-
"installed_packages <- packages %in% rownames(installed.packages())\n",
212-
"if (any(installed_packages == FALSE)) {\n",
213-
" install.packages(packages[!installed_packages])\n",
214-
"}"
205+
"Run the following to create a Kernel with all required packaged installed. It will take about 10 minutes to install packages and create a kernel."
215206
]
216207
},
217208
{
218209
"cell_type": "code",
219210
"execution_count": null,
220-
"id": "f559b564-bf2a-416f-b7cf-71ef61c40d41",
221-
"metadata": {},
211+
"id": "786a0e20",
212+
"metadata": {
213+
"vscode": {
214+
"languageId": "r"
215+
}
216+
},
222217
"outputs": [],
223218
"source": [
224-
"# Install BiocManager if not already installed\n",
225-
"if (!require(\"BiocManager\", quietly = TRUE))\n",
226-
" install.packages(\"BiocManager\")\n",
227-
"\n",
228-
"## Install Bioconductor packages.\n",
229-
"packages <- c(\"methylKit\", \"GenomicRanges\", \"genomation\")\n",
230-
"\n",
231-
"# Install packages not yet installed\n",
232-
"installed_packages <- packages %in% rownames(installed.packages())\n",
233-
"if (any(installed_packages == FALSE)) {\n",
234-
" BiocManager::install(packages[!installed_packages])\n",
235-
"}"
219+
"system('chmod +x install_rrbs_packages.sh' , intern=TRUE)\n",
220+
"system('bash install_rrbs_packages.sh >> logs.txt' , intern=TRUE) # This creates \"R-RRBS\" kernel"
221+
]
222+
},
223+
{
224+
"cell_type": "markdown",
225+
"id": "6b15565e",
226+
"metadata": {},
227+
"source": [
228+
"**Important: Choose \"R-RRBS\" kernel for the rest of the notebook.**"
236229
]
237230
},
238231
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Create a conda environment
4+
conda create -n r-package-2 r-base=4.2.2 -y
5+
6+
# Consider addressing your conda initialization instead.
7+
source ~/.bashrc
8+
9+
# Activate the Conda Environment
10+
conda activate r-package-2
11+
12+
# Install packages
13+
conda install bioconda::bioconductor-methylkit -y
14+
15+
conda install bioconda::bioconductor-genomicranges -y
16+
17+
conda install bioconda::bioconductor-genomation -y
18+
19+
conda install conda-forge::r-ggforce -y
20+
21+
conda install conda-forge::r-tidyverse -y
22+
23+
R -e 'install.packages(c("IRkernel","ggplot2"), repos="http://cran.rstudio.com/")'
24+
25+
# Install the kernel specification for Jupyter
26+
R -e 'IRkernel::installspec(name = "R-RRBS", displayname = "R-RRBS")'

0 commit comments

Comments
 (0)