-
Notifications
You must be signed in to change notification settings - Fork 0
/
Working_draft_cleanvirus.Rmd
180 lines (148 loc) · 4.48 KB
/
Working_draft_cleanvirus.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
title: 'Viral Comparison: Group Project'
author: "Aryss Hearne"
date: "3/6/2021"
output:
html_document:
keep_md: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Hypothesis: Viruses that target land plants will exhibit higher gene load and higher genome lengths than viruses that target humans.
### Load libraries for tidying
```{r}
library(tidyverse)
library(here)
library(janitor)
library(ggthemes)
library(paletteer)
```
### Load relevant csv
```{r}
virus<-readr::read_csv("data/viruses.csv")
```
### Inspect
```{r}
virus
```
### Are there any viruses which attack humans AND land plants?
```{r}
virus$Host<-as.factor(virus$Host)
levels(virus$Host)
```
### Fix the multiple hosts per host category nonsense.
```{r}
virus_c<-virus%>%
separate('Host', into=c("host_type_1", "host_type_2", "host_type_3", "host_type_4", "host_type_5"), sep=",")
virus_c
```
### Checking my work
```{r}
virus_c$host_type_1<-as.factor(virus_c$host_type_1)
virus_c$host_type_2<-as.factor(virus_c$host_type_2)
virus_c$host_type_3<-as.factor(virus_c$host_type_3)
virus_c$host_type_4<-as.factor(virus_c$host_type_4)
virus_c$host_type_5<-as.factor(virus_c$host_type_5)
levels(virus_c$host_type_1)
```
```{r}
levels(virus_c$host_type_2)
```
```{r}
levels(virus_c$host_type_3)
```
```{r}
levels(virus_c$host_type_4)
```
```{r}
levels(virus_c$host_type_5)
```
```{r}
virus_clong<-virus_c%>%
pivot_longer(host_type_1:host_type_3,
names_to="host_num",
values_to="host_type",
values_drop_na=T)
virus_clong
```
### Filter for only Complete Genome data, separate Organism Groups into difft columns, reorder, rename
```{r}
virus_clean<-virus_clong%>%
separate('Organism Groups', into=c("domain", "kingdom", "subgroup"), sep=";")%>%
filter(Level=="Complete" & (host_type=="human" | host_type=="land plants"))%>%
select('host_type', 'Organism Name', 'kingdom','subgroup', 'Size(Mb)', 'GC%', 'Genes','Level')%>%
rename(organism_name='Organism Name', kingdom=kingdom, subgroup=subgroup, level="Level", size_mb='Size(Mb)', perc_gc='GC%', host=host_type, genes_num='Genes')%>%
mutate(gene_to_genome_ratio=genes_num/size_mb)%>%
arrange(host)
virus_clean
```
#### Figuring out the limits of the data
```{r}
virus_clean%>%
select(size_mb)%>%
summary()
```
```{r}
virus_clean%>%
ggplot(aes(x=size_mb, fill=host, color=kingdom))+
geom_histogram(alpha=0.25)+
scale_y_log10()
```
```{r}
virus_clean%>%
ggplot(aes(x=size_mb, y=kingdom, color=host, size=perc_gc))+
geom_jitter(alpha=0.25)+
coord_flip()+
theme_solarized()+
scale_color_manual(values=colors)+
theme(legend.position="top",
axis.text.x=element_text(angle=60, hjust=1))
```
```{r}
virus_clean2<-virus%>%
separate('Host', into=c("host_type_1", "host_type_2", "host_type_3"), sep=",")%>%
pivot_longer(host_type_1:host_type_3,
names_to="host_num",
values_to="host_type",
values_drop_na=T)%>%
separate('Organism Groups', into=c("domain", "kingdom", "subgroup"), sep=";")%>%
filter(Level=="Complete" & (host_type=="human" | host_type=="land plants"))%>%
select('host_type', 'Organism Name', 'kingdom','subgroup', 'Size(Mb)', 'GC%', 'Genes','Level')%>%
rename(organism_name='Organism Name', kingdom=kingdom, subgroup=subgroup, level="Level", size_mb='Size(Mb)', perc_gc='GC%', host=host_type, genes_num='Genes')%>%
mutate(gene_to_genome_ratio=genes_num/size_mb)%>%
arrange(host)
virus_clean2
```
```{r}
virus_clean2%>%
group_by(host)%>%
ggplot(aes(x=host, y=gene_to_genome_ratio))+
geom_boxplot()
```
```{r}
devtools::install_github("johannesbjork/LaCroixColoR")
colors<- LaCroixColoR::lacroix_palette("Pamplemousse", type = "discrete")
```
```{r}
virus_clean2%>%
ggplot(aes(x=genes_num, y=size_mb, size=perc_gc, color=host, group=host))+
geom_jitter(alpha=0.25)+
facet_grid(. ~kingdom)+
#aesthetics
theme_solarized()+
theme(legend.position="top",
axis.text.x=element_text(angle=60, hjust=1))+
scale_size(range = c(0.1, 10),
guide = "none")+
scale_color_manual(values=colors)+
#labels
labs(x="Number of Genes",
y="Genome Size (Mb)",
size="Percent GC",
color="Host")+
#text
geom_text(aes(x = genes_num, y = + 3, label = organism_name),
color = "grey50",
data = filter(virus_clean2, size_mb > 100000 | organism_name %in% c("Zika virus", "West Nile virus", "Rabies lyssavirus")))
```