-
Notifications
You must be signed in to change notification settings - Fork 1
/
b-figure-02.Rmd
236 lines (204 loc) · 11 KB
/
b-figure-02.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
---
title: "Panels of Figure 2: Phylogenetic relationship between the 21 de novo assembled non-redundant genomes and other Malacoherpesviridae"
author: "Delmotte jean"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
html_document:
toc: TRUE
code_folding: "hide"
theme: united
highlight: tango
number_sections: true
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
# Fonction to install / load package if it's not here
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
ipak(unique(
c("data.table", "tidyverse", "ape", "RColorBrewer", "pheatmap", "limma", "glue", "kableExtra", "plotly", "ape", "tidytree",
"hrbrthemes", "viridis", "ggsci", # palette
"cowplot", "scales", "maptools", "gggenes", "ggtree") # plot
) )
```
```{r Base_Path}
base_path <- "~/Documents/OshV-1-molepidemio" # Base location for the folder
```
```{r Color_analysis, echo=FALSE, warning = FALSE, message = FALSE}
## Convention
# Color Brest:blue | LT:Red | Thau:Green
# show_col(pal_aaas("default")(10))
Brest_color = pal_aaas("default")(10)[1]
LT_color = pal_aaas("default")(10)[2]
Thau_color = pal_aaas("default")(10)[3]
# Order
plot_order_samples <- tibble(ID_EXPERIMENT = c("Brest_2018_NSI_broyage_ind10_noPCR", "Brest_2018_NSI_broyage_ind2_noPCR", "Brest_2018_NSI_broyage_ind4_noPCR", "Brest_2018_NSI_broyage_ind6_noPCR", "Brest_2018_NSI_broyage_ind9_noPCR", "LT_2018_NSI_broyage_ind10_noPCR", "LT_2018_NSI_broyage_ind1_noPCR", "LT_2018_NSI_broyage_ind3_noPCR", "LT_2018_NSI_broyage_ind4_noPCR", "LT_2018_NSI_broyage_ind7_noPCR", "LT_2018_NSI_broyage_ind8_noPCR", "LT_2018_NSI_broyage_ind9_noPCR", "Thau_2018_NSI_broyage_ind10_noPCR", "Thau_2018_NSI_broyage_ind1_noPCR", "Thau_2018_NSI_broyage_ind3_noPCR", "Thau_2018_NSI_broyage_ind4_noPCR", "Thau_2018_NSI_broyage_ind5_noPCR", "Thau_2018_NSI_broyage_ind6_noPCR", "Thau_2018_NSI_broyage_ind7_noPCR", "Thau_2018_NSI_broyage_ind8_noPCR", "Thau_2018_NSI_broyage_ind9_noPCR") ) %>%
tidyr::separate(ID_EXPERIMENT, c("LOCATION","YEARS","FAM","TYPE","CONDITION","WGS_PCR")) %>%
tidyr::unite(LOCATION, CONDITION, col="Samples",sep="_",remove = FALSE) %>%
dplyr::left_join(., tibble(LOCATION = c("Brest","LT","Thau"),
ORDER= c(1,2,3))) %>%
dplyr::mutate(ORDER_samples = stringr::str_replace_all(CONDITION,"ind",""),
ORDER_samples = as.numeric(ORDER_samples)) %>%
arrange(ORDER, ORDER_samples)
```
## Figure 2 A Genome Drawing
The genome structure of OsHV-1 µVar A virus was represented based on the analyses of [Burioli et al., 2017](https://doi.org/10.1016/j.virol.2017.06.027) and confirmed on Ugene 1.30.0 [Okonechnikov et al., 2012](https://doi.org/10.1093/bioinformatics/bts091).
```{r Figure_02_A_genome_drawing, message=FALSE}
Unique_long=164268
Repeat_long=7338
X_region=1510
Repeat_short=9777
X_region=1510
Unique_short=3370
genome_size = 204886
nr_genoe_size = Unique_long+Repeat_long+X_region+Repeat_short+Unique_short
nr_genoe_size / genome_size
writeLines(glue::glue("Approximately {round((1-(nr_genoe_size)/genome_size)*100)}% of OsHV-1 genome consists of a set of repeats elements with 2 long repeat ({Repeat_long} nt), 2 short repeat ({Repeat_short} nt) and a X region ({X_region} nt)"))
# Genome drawing
OsHV_uVarA_scheme <- data.table::fread(glue::glue("{base_path}/raw/b-raw_metadatas/OsHV_uVarA_annotations.csv") ) %>%
dplyr::mutate(direction = if_else(strand == "forward",1,-1 ))
Figure_02_A_genome_drawing_p1 <- OsHV_uVarA_scheme %>%
ggplot(aes(xmin = start, xmax = end, y = direction, fill = `region :`, forward = direction, label = name)) +
facet_wrap(~ molecule, ncol = 1) +
geom_gene_label(align = "left") +
geom_gene_arrow(arrowhead_height = unit(16, "mm"),
arrowhead_width = unit(3, "mm"),
arrow_body_height= unit(16, "mm")) +
scale_fill_brewer(palette = "Set3") +
labs(x = "",
y = "") +
theme_classic()+
xlim(0, 204886) +
theme(axis.text.x = element_text(face="bold", size=14),
legend.position = "none") +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank())
# Non redondant
Figure_02_A_genome_drawing_p2 <- OsHV_uVarA_scheme %>%
dplyr::mutate(direction = if_else(strand == "forward",1,-1 )) %>%
filter(start >= 7339 & end < 193601) %>%
ggplot(aes(xmin = start, xmax = end, y = direction, fill = `region :`, forward = direction, label = name)) +
facet_wrap(~ molecule, ncol = 1) +
geom_gene_label(align = "left") +
geom_gene_arrow(arrowhead_height = unit(16, "mm"),
arrowhead_width = unit(3, "mm"),
arrow_body_height= unit(16, "mm")) +
scale_fill_brewer(palette = "Set3") +
theme_classic()+
labs(x = "",
y = "")+
xlim(0, 204886) +
theme(axis.text.x = element_text(face="bold", size=14),
legend.position = "bottom") +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank())
Figure_02_A_genome_drawing <- plot_grid(Figure_02_A_genome_drawing_p1, Figure_02_A_genome_drawing_p2,
labels = c('', ''),
ncol = 1)
Figure_02_A_genome_drawing
```
```{r Figure_02_A_genome_drawing_export, message=FALSE}
ggsave("Figure_02_A_genome_drawing.jpeg",
plot = Figure_02_A_genome_drawing,
device = "jpeg",
path = glue::glue("{base_path}/results/Figures/jpeg/Figure_2"),
width = 180, units = "mm", dpi = 300)
ggsave("Figure_02_A_genome_drawing.tiff",
plot = Figure_02_A_genome_drawing,
device = "tiff",
path = glue::glue("{base_path}/results/Figures/tiff/Figure_2"),
width = 180, units = "mm", dpi = 300)
ggsave("Figure_02_A_genome_drawing.eps",
plot = Figure_02_A_genome_drawing,
device = "eps",
path = glue::glue("{base_path}/results/Figures/eps_svg/Figure_2"),
width = 180, units = "mm", dpi = 300)
rm(Figure_02_A_genome_drawing)
```
## Figure 2 B Phylogenetique comparaison between all NR-genomes
The phylogenetic tree was obtained as described in the [README.md](https://github.com/propan2one/OshV-1-molepidemio#06-phylogenetic-analysis).
```{r Figure_02_A_phylogenetic_analysis}
iqtree <- treeio::read.newick(glue::glue("{base_path}/results/Phylogenetics_analysis/Fig2A_global_phylogeny.msa.treefile"))
# is.rooted(iqtree)
iqtree <- root(iqtree, "NR-genome_Abalone_herpesvirus_Taiwan_2005.fasta", resolve.root=TRUE)
iqtree$tip.label <- stringr::str_replace_all(iqtree$tip.label,"NR_genome_","")
iqtree$tip.label <- stringr::str_replace_all(iqtree$tip.label,"NR-genome_","")
iqtree$tip.label <- stringr::str_replace_all(iqtree$tip.label,"_2018_NSI_broyage_"," ")
iqtree$tip.label <- stringr::str_replace_all(iqtree$tip.label,"_noPCR","")
iqtree$tip.label <- stringr::str_replace_all(iqtree$tip.label,"Brest","Br")
iqtree$tip.label <- stringr::str_replace_all(iqtree$tip.label,"Thau","Th")
iqtree$tip.label <- stringr::str_replace_all(iqtree$tip.label,"LT","Lt")
iqtree$tip.label <- stringr::str_replace_all(iqtree$tip.label,"Ostreid_herpesvirus_1_strain_microVar_variant_A","OsHV-1 µVar A (KY242785.1)")
iqtree$tip.label <- stringr::str_replace(iqtree$tip.label,"Ostreid_herpesvirus_1_strain_microVar_variant_B","OsHV-1 µVar B (KY271630.1)")
iqtree$tip.label <- stringr::str_replace(iqtree$tip.label,'Ostreid_herpesvirus_1_isolate_ZK0118',"OsHV-1 ZK0118 (MF509813.1)")
iqtree$tip.label <- stringr::str_replace(iqtree$tip.label,"Chlamys_acute_necrobiotic_virus","AVNV (GQ153938.1)")
iqtree$tip.label <- stringr::str_replace(iqtree$tip.label,"Abalone_herpesvirus_Taiwan_2005\\.fasta","Abalone herpesvirus (KU096999.1)")
iqtree$tip.label <- stringr::str_replace(iqtree$tip.label,"Ostreid_herpesvirus_1_strain_CDSB2012\\.fasta","OsHV-1-SB (KP412538.1)")
iqtree$tip.label <- stringr::str_replace(iqtree$tip.label,"Ostreid_herpesvirus_1_2016_PT","OsHV-1 PT (MG561751.2)")
iqtree$tip.label <- stringr::str_replace(iqtree$tip.label,"Ostreid_herpesvirus_1","OsHV-1 (AY509253.2)")
PatristicDistMatrix<-cophenetic(iqtree)
# annotation to display color
annotation <- tibble(label = iqtree$tip.label) %>%
separate(label,
into = c("location", "individual"),
sep = " ",
remove = FALSE) %>%
dplyr::select(-individual) %>%
dplyr::mutate(location = str_replace(location, "-SB",""),
location = recode(location,
`OsHV-1` = "published",
`Abalone` = "published",
`Ostreid_herpesvirus_1` = "published"))
tree <- full_join(as_tibble(iqtree), annotation, by = 'label') %>%
as.treedata()
# solution from https://yulab-smu.github.io/treedata-book/faq.html part Bootstrap values from newick format
arbre_vide <- ggtree(iqtree)
data_arbre_vide <- arbre_vide$data
data_arbre_vide <- data_arbre_vide[!data_arbre_vide$isTip,]
data_arbre_vide$label <- as.numeric(data_arbre_vide$label)
data_arbre_vide <- data_arbre_vide[data_arbre_vide$label >= 70,]
# Change branch length of outgroup
as_tibble(iqtree) %>%
filter(str_detect(label, "KU096999\\.1"))
m <- MRCA(iqtree, 27,28)
iqtree_group_for_outgroup <- groupClade(iqtree, m)
y <- full_join(as_tibble(iqtree_group_for_outgroup), annotation, by = 'label') %>%
as.treedata()
p <- ggtree(y) +
theme(legend.position = 'none')
outgroup_info <- glue::glue("Transformation de la distance de l'outgroup de {median(p$data$x)} en prenant la median au lieu de {p$data[p$data$node %in% 27, 'x']} pour aider à la visualisation" )
writeLines(outgroup_info)
p$data[p$data$node %in% 27, "x"] <- median(p$data$x)
Figure_02_A_phylogenetic_analysis <- p + geom_treescale(x=0, y=10, color='black') +
geom_text(data=data_arbre_vide, aes(label=label), size = 4, vjust = -0.8, hjust=+1) +
geom_tiplab(size=3, aes(color=location)) +
scale_colour_manual(values=c(Brest_color, LT_color, "black", Thau_color))
Figure_02_A_phylogenetic_analysis
```
Note: As it was not possible to get the eps file directly, I had to create a PDF which I transformed into eps locally with the command `pdftops -eps Figure_02_A_phylogenetic_analysis.pdf` as observed `l230`.
```{r Figure_02_A_phylogenetic_analysis_export, message=FALSE}
ggsave("Figure_02_A_phylogenetic_analysis.jpeg",
plot = Figure_02_A_phylogenetic_analysis,
device = "jpeg",
path = glue::glue("{base_path}/results/Figures/jpeg/Figure_3"),
width = 180, units = "mm", dpi = 300)
ggsave("Figure_02_A_phylogenetic_analysis.tiff",
plot = Figure_02_A_phylogenetic_analysis,
device = "tiff",
path = glue::glue("{base_path}/results/Figures/tiff/Figure_3"),
width = 180, units = "mm", dpi = 300)
dev.copy2pdf(file=glue::glue("{base_path}/results/Figures/eps_svg/Figure_3/Figure_02_A_phylogenetic_analysis.pdf"),out.type="cairo", width=18)
writeLines(glue::glue("pdftops -eps {base_path}/results/Figures/eps_svg/Figure_3/Figure_02_A_phylogenetic_analysis.pdf"))
rm(Figure_02_A_phylogenetic_analysis)
```
```{r}
sessionInfo()
```