-
Notifications
You must be signed in to change notification settings - Fork 1
/
libpackages.Rmd
124 lines (79 loc) · 3.22 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
113
114
115
116
117
118
119
120
# 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
+ 17318<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/):
+ 3372<sup>*</sup> packages available
+ find packages in https://bioconductor.org/packages
<img src="images/bioc_packages.png" width="550"/>
*<sup>*</sup>As of March 2021*
<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, from the bottom-right panel, "Packages" tab:
<img src="images/rstudio_installBiocManager_arrow.png" width="550"/>
* From the console:
```{r, eval=F}
install.packages(pkgs="BiocManager")
```
* Install a bioconductor package:
```{r, eval=F}
# Install Bioconductor package manager
install.packages(pkgs="BiocManager")
# Install Bioconductor package
BiocManager::install("DESeq2")
```
## Load a package
* With RStudio: tick the box.
<img src="images/rstudio_tick_BiocManager.png" width="450"/>
* From the console:
```{r}
library("BiocManager")
```
## Check what packages are currently loaded
```{r}
sessionInfo()
```
## List functions from a package
* With RStudio: click on the package name in the "Packages" tab: <br>
<img src="images/rstudio_list_biocmanager.png" width="450"/>
* From the console
```{r, eval=F}
ls("package:BiocManager")
```
<br>
**HANDS-ON**
1. Install and load package **WriteXLS** (using either the RStudio "Packages" panel, or the console)
2. Create a simple matrix (of your choice) with 6 rows and 4 columns!
3. Write matrix to a file using the **WriteXLS** function (from the package of the same name). Check the help page of the function!
## 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/")
```