-
Notifications
You must be signed in to change notification settings - Fork 2
/
Setup.Rmd
135 lines (100 loc) · 4.5 KB
/
Setup.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
title: "Setup Instructions"
author: "David Levy-Booth"
date: "April 7 - 9, 2020"
output:
pdf_document:
fig_height: 6
html_document:
toc: yes
toc_float:
collapsed: no
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Setup Instructions
Please come to the workshop with your laptop setup with the required software and data files as described in our setup instructions.
# Making an RStudio Project
Projects allow you to divide your work into self-contained contexts.
Let's create a project to work in.
In the top-right corner of your RStudio window, click the "Project: (None)" button to show the projects
drop-down menu. Select "New Project." > "New Directory" > "New Project." Under directory name, input
"metagenomics" and choose a parent directory to contain this project on your computer.
### Installing Packages
Many R packages can be downloaded and installed from The Comprehensive R Archive Network (CRAN).
You can install each package with the following code:
```{r eval = FALSE}
install.packages("BiocManager",
"devtools",
"RColorBrewer",
"ape",
"tidyverse",
"ggplot2",
"phytools",
"stringr",
"reshape2",
"cowplot",
"grid",
"circlize",
"dplyr",
"aplot")
```
To make things a bit more difficult, there are other source of R packages, such as Bioconductor, which provides tools for the analysis and comprehension of high-throughput genomic data.
```{r eval = FALSE}
BiocManager::install("pathview")}
```
##Install ggtree
And finally, we have to install the developmental version of _ggtree_ from [GitHub](https://github.com/YuLab-SMU/ggtree). **This is very important to ensure colored ranges are applied correctly** (the Bioconductor version does not apply colors to trees correctly)
```{r eval = FALSE}
library(devtools)
install_github("YuLab-SMU/ggtree")
```
#Loading Packages
Next, we should check if all packages can be loaded properly. If a package does not load because of a missing package, please install the package (as shown above) and try again.
```{r, message=FALSE, warning=FALSE, eval = FALSE}
# Suite of packages for data manipulation and visualization
library(tidyverse)
# Working with trees
library(ape)
library(phytools)
# Plotting Grammar of Graphics
library(ggplot2)
# Tree visualization
library(ggtree)
# String manipulation
library(stringr)
# Data structure manipulation
library(reshape2)
# Multi-panel figure layouts
library(cowplot)
library(grid)
# Color maniputation
library(RColorBrewer)
# Pathway analysis with KEGG Orthologs
library(pathview)
#plot circular graphs and contig maps
library(circlize)
```
#Downloading Workshop Material
The material for this workshop is hosted on [GitHub](https://github.com/davidlevybooth/Metagenomics_Workshop).
Follow the above link and click the green "Clone or download"" button to download all files as a .zip archive. Unzip the archive to access files.
# Loading custom functions
I have written some helpful functions to replace some time-consuming workflows. Please load them from the source R script like this:
```{r}
#Custom functions for metagenomics and metatranscriptomics
source("scripts/metagenome.utilities.R")
```
Please ensure all packages are installed and up to date, and that you have all data downloaded prior to the start of the workshop. If you require any assistance, please contact David Levy-Booth (dlevyboo@mail.ubc.ca).
We will also spend a few minutes prior to the workshop ensuring that all attendees have completed setup and installation.
# Sanity Check
Because _ggtree_ is the main package that we will work with throughout the workshop, please ensure that you can reproduce a simple example plot using this package.
Please enter the following code in RStudio and ensure your output matches the plot provided:
```{r fig.height = 5, fig.align = "center", message=FALSE, warning=FALSE}
library(ape) #in case you did not load the package earlier.
library(ggtree)
set.seed(2020)
example.tree <- rtree(4)
ggtree(example.tree) + geom_balance(node=6)
```
If your plot **does not** look like this, you may have to re-install the _ggtree_ package from GitHub and any dependent packages. If it does, congratulations, we are ready to begin!