-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlibpackages.Rmd
113 lines (82 loc) · 2.97 KB
/
libpackages.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Library and packages
* **Packages** are collections of R functions, data, and compiled code in a well-defined format.
* The directory where packages are stored is called the **library**.
*Source of definitions: http://www.statmethods.net/interface/packages.html*
## R base
A set a standard packages which are supplied with R by default.<br>
Example: package base (write, table, rownames functions), package utils (read.table, str functions), package stats (var, na.omit, median functions).
## R contrib
All other packages:
* [CRAN](https://cran.r-project.org): Comprehensive R Archive Network
+ 13735<sup>*</sup> packages available
+ find packages in https://cran.r-project.org/web/packages/
<img src="images/cran_packages.png" width="550"/>
* [Bioconductor](https://www.bioconductor.org/):
+ 1649<sup>*</sup> packages available
+ find packages in https://bioconductor.org/packages
<img src="images/bioc_packages.png" width="550"/>
*<sup>*</sup>As of February 2019*
<h4>Bioconductor</h4>
Set of R packages specialized in the analysis of bioinformatics data.<br>
Bioconductor supports most types of **genomics and NGS data** (e.g. limma, DESeq2, BayesPeak) and integrates:
* Specific data classes (e.g. Granges from GenomicRanges)
* Integrates command line tools (e.g Rsamtools)
* Annotation tools (e.g. biomaRt)
There are different types of Bioconductor packages:
* **Software**: set of functions
+ e.g. DESeq2 (NGS data analysis)
* **Annotation**: annotation of specific arrays, organisms, events, etc.
+ e.g. BSgenome.Hsapiens.UCSC.hg38
* **Experiment**: data that can be loaded and used
+ e.g. ALL (acute lymphoblastic leukemia dataset)
## Install a package
* With RStudio:
<img src="images/bioc_install.png" width="550"/>
* From the console:
```{r, eval=F}
install.packages(pkgs="ggplot2")
```
* Install a bioconductor package:
+ For R version >= 3.5.0
```{r, eval=F}
# Install Bioconductor package manager
install.packages(pkgs="BiocManager")
# Install Bioconductor package
BiocManager::install("DESeq2")
```
+ For older R versions
```{r, eval=F}
# Source (load into environment) script containing biocLite function
source("http://www.bioconductor.org/biocLite.R")
# Use biocLite function to install Bioconductor package
biocLite("DESeq2")
```
## Load a package
* With RStudio:
<img src="images/bioc_load.png" width="450"/>
* From the console:
```{r}
library("ggplot2")
```
## Check what packages are currently loaded
```{r}
sessionInfo()
```
## List functions from a package
* With RStudio <br>
<img src="images/rstudio_ggplot2.png" width="450"/>
* From the console
```{r, eval=F}
ls("package:ggplot2")
```
## RStudio server at CRG
If you can't install packages (permission issues), you first need to specify a writeable directory to install the packages into.<br>
Follow the steps below:
```{r, eval=F}
# Go to your home directory
setwd("~")
# Create a directory where to store the packages
dir.create("R_packages")
# Add directory location to the library path
.libPaths("~/R_packages/")
```