real_samples.html 71.6 KB
Newer Older
Olivier Rue's avatar
Olivier Rue committed
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />


<meta name="author" content="Olivier Rué" />

Olivier Rue's avatar
Olivier Rue committed
14
<meta name="date" content="2021-11-22" />
Olivier Rue's avatar
Olivier Rue committed
15
16
17
18
19
20
21
22
23

<title>Real samples analysis</title>

<script src="real_samples_files/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="real_samples_files/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="real_samples_files/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="real_samples_files/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="real_samples_files/bootstrap-3.3.5/shim/respond.min.js"></script>
Olivier Rue's avatar
Olivier Rue committed
24
25
26
27
28
29
30
31
32
<style>h1 {font-size: 34px;}
       h1.title {font-size: 38px;}
       h2 {font-size: 30px;}
       h3 {font-size: 24px;}
       h4 {font-size: 18px;}
       h5 {font-size: 16px;}
       h6 {font-size: 12px;}
       code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
       pre:not([class]) { background-color: white }</style>
Olivier Rue's avatar
Olivier Rue committed
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
<script src="real_samples_files/jqueryui-1.11.4/jquery-ui.min.js"></script>
<link href="real_samples_files/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="real_samples_files/tocify-1.9.1/jquery.tocify.js"></script>
<script src="real_samples_files/navigation-1.1/tabsets.js"></script>
<script src="real_samples_files/navigation-1.1/codefolding.js"></script>
<link href="real_samples_files/highlightjs-9.12.0/default.css" rel="stylesheet" />
<script src="real_samples_files/highlightjs-9.12.0/highlight.js"></script>

<style type="text/css">
  code{white-space: pre-wrap;}
  span.smallcaps{font-variant: small-caps;}
  span.underline{text-decoration: underline;}
  div.column{display: inline-block; vertical-align: top; width: 50%;}
  div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
  ul.task-list{list-style: none;}
    </style>

<style type="text/css">code{white-space: pre;}</style>
<script type="text/javascript">
if (window.hljs) {
  hljs.configure({languages: []});
  hljs.initHighlightingOnLoad();
  if (document.readyState && document.readyState === "complete") {
    window.setTimeout(function() { hljs.initHighlighting(); }, 0);
  }
}
</script>








<style type = "text/css">
.main-container {
  max-width: 940px;
  margin-left: auto;
  margin-right: auto;
}
img {
  max-width:100%;
}
.tabbed-pane {
  padding-top: 12px;
}
.html-widget {
  margin-bottom: 20px;
}
button.code-folding-btn:focus {
  outline: none;
}
summary {
  display: list-item;
}
Olivier Rue's avatar
Olivier Rue committed
89
90
91
pre code {
  padding: 0;
}
Olivier Rue's avatar
Olivier Rue committed
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
</style>



<!-- tabsets -->

<style type="text/css">
.tabset-dropdown > .nav-tabs {
  display: inline-table;
  max-height: 500px;
  min-height: 44px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.tabset-dropdown > .nav-tabs > li.active:before {
  content: "";
  font-family: 'Glyphicons Halflings';
  display: inline-block;
  padding: 10px;
  border-right: 1px solid #ddd;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
  content: "&#xe258;";
  border: none;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
  content: "";
  font-family: 'Glyphicons Halflings';
  display: inline-block;
  padding: 10px;
  border-right: 1px solid #ddd;
}

.tabset-dropdown > .nav-tabs > li.active {
  display: block;
}

.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
  border: none;
  display: inline-block;
  border-radius: 4px;
  background-color: transparent;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
  display: block;
  float: none;
}

.tabset-dropdown > .nav-tabs > li {
  display: none;
}
</style>

<!-- code folding -->
<style type="text/css">
.code-folding-btn { margin-bottom: 4px; }
</style>



<style type="text/css">

#TOC {
  margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
  position: relative;
  width: 100%;
}
}

@media print {
.toc-content {
  /* see https://github.com/w3c/csswg-drafts/issues/4434 */
  float: right;
}
}

.toc-content {
  padding-left: 30px;
  padding-right: 40px;
}

div.main-container {
  max-width: 1200px;
}

div.tocify {
  width: 20%;
  max-width: 260px;
  max-height: 85%;
}

@media (min-width: 768px) and (max-width: 991px) {
  div.tocify {
    width: 25%;
  }
}

@media (max-width: 767px) {
  div.tocify {
    width: 100%;
    max-width: none;
  }
}

.tocify ul, .tocify li {
  line-height: 20px;
}

.tocify-subheader .tocify-item {
  font-size: 0.90em;
}

.tocify .list-group-item {
  border-radius: 0px;
}


</style>



</head>

<body>


<div class="container-fluid main-container">


<!-- setup 3col/9col grid for toc_float and main content  -->
Olivier Rue's avatar
Olivier Rue committed
232
<div class="row">
Olivier Rue's avatar
Olivier Rue committed
233
234
235
236
237
238
239
240
241
242
<div class="col-xs-12 col-sm-4 col-md-3">
<div id="TOC" class="tocify">
</div>
</div>

<div class="toc-content col-xs-12 col-sm-8 col-md-9">




Olivier Rue's avatar
Olivier Rue committed
243
<div id="header">
Olivier Rue's avatar
Olivier Rue committed
244

Olivier Rue's avatar
Olivier Rue committed
245
246
247
<div class="btn-group pull-right float-right">
<button type="button" class="btn btn-default btn-xs btn-secondary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span>Code</span> <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right" style="min-width: 50px;">
Olivier Rue's avatar
Olivier Rue committed
248
249
250
251
252
253
254
255
256
<li><a id="rmd-show-all-code" href="#">Show All Code</a></li>
<li><a id="rmd-hide-all-code" href="#">Hide All Code</a></li>
</ul>
</div>



<h1 class="title toc-ignore">Real samples analysis</h1>
<h4 class="author">Olivier Rué</h4>
Olivier Rue's avatar
Olivier Rue committed
257
<h4 class="date">2021-11-22</h4>
Olivier Rue's avatar
Olivier Rue committed
258
259
260
261
262
263
264
265

</div>


<link href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/7.0.10/jquery.nouislider.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/7.0.10/jquery.nouislider.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.0/css/selectize.bootstrap3.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.0/js/standalone/selectize.min.js"></script>
Olivier Rue's avatar
Olivier Rue committed
266
<pre class="r"><code>source(&quot;curation.R&quot;)</code></pre>
Olivier Rue's avatar
Olivier Rue committed
267
268
269
<pre class="bash"><code># Genologin
cd /work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/scripts
sh dada2_frogs.sh</code></pre>
Olivier Rue's avatar
Olivier Rue committed
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<pre class="bash"><code>scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/results/DADA2_FROGS/ITS1/affiliation.biom REAL_MEAT/ITS1.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/results/DADA2_FROGS/ITS2/affiliation.biom REAL_MEAT/ITS2.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/results/DADA2_FROGS/D1D2/affiliation.biom REAL_MEAT/D1D2.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/results/DADA2_FROGS/RPB2/affiliation.biom REAL_MEAT/RPB2.biom

scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/results/DADA2_FROGS/ITS1/affiliation.tsv REAL_MEAT/ITS1.tsv
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/results/DADA2_FROGS/ITS2/affiliation.tsv REAL_MEAT/ITS2.tsv
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/results/DADA2_FROGS/D1D2/affiliation.tsv REAL_MEAT/D1D2.tsv
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/results/DADA2_FROGS/RPB2/affiliation.tsv REAL_MEAT/RPB2.tsv</code></pre>
<pre class="bash"><code>### GET DATA FROM GENOTOUL
scp orue@genotoul.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/results/DADA2_FROGS/RPB2/affiliation.biom .
scp orue@genotoul.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/REAL/results/DADA2_FROGS/RPB2/filters.fasta .
##########################

otu_filters.py --input-biom affiliation.biom --input-fasta filters.fasta --contaminant /db/frogs_databanks/assignation/Unite_Fungi_8.2_20200204/Unite_Fungi_8.2_20200204.fasta --output-biom 1.biom --output-fasta 1.fasta --nb-cpus 4
otu_filters.py --input-biom 1.biom --input-fasta 1.fasta --contaminant /db/frogs_databanks/assignation/SILVA_132_LSU/SILVA_132_LSU.fasta --nb-cpus 4 --output-biom 2.biom --output-fasta 2.fasta
otu_filters.py --input-biom 2.biom --input-fasta 2.fasta --contaminant /db/frogs_databanks/assignation/silva_138_SSU/silva_138_SSU.fasta --nb-cpus 4 --output-biom 3.biom --output-fasta 3.fasta 
otu_filters.py --input-biom 3.biom --input-fasta 3.fasta --contaminant /db/frogs_databanks/assignation/Unite_Euka_8.2_20200204/Unite_Euka_8.2_20200204.fasta --output-biom 4.biom --output-fasta 4.fasta --nb-cpus 4  
biom_to_tsv.py --input-biom 4.biom --output-tsv 4.tsv
head -n 1 4.tsv &gt; 4-2.tsv
sed &quot;s/no data/NA;NA;NA;NA;NA;NA;NA/&quot; 4.tsv |sed &quot;s/no data/0/g&quot; | grep  &#39;FROGS_combined&#39; &gt;&gt; 4-2.tsv
tsv_to_biom.py  --input-tsv 4-2.tsv --output-biom 4-2.biom
affiliation_filters.py  --input-fasta 4.fasta --input-biom 4-2.biom --min-blast-identity 0.1 --delete
biom_to_tsv.py --input-biom affiliation-filtered.biom --output-tsv affiliation-filtered.tsv
affiliation_OTU.py --input-fasta affiliation-filtered.fasta --input-biom affiliation-filtered.biom --nb-cpus 8 --output-biom affiliation.biom --summary affiliation.html --reference D1D2.fasta

biom_to_tsv.py --input-biom affiliation.biom --output-tsv affiliation.tsv

head -n 1 4.tsv &gt; final.tsv
awk -F&#39;\t&#39; &#39;{ if ($4 &lt; 80 &amp;&amp; $5 &gt; 95 &amp;&amp; length($8 &gt; 400)) { print } }&#39; affiliation.tsv &gt;&gt; final.tsv

awk -F&#39;\t&#39; &#39;{print $8}&#39; &lt;(grep -v &quot;^#&quot; final.tsv) &gt; to_keep.lst

head -n 1 4.tsv &gt; affiliation-filtered-final.tsv
grep -f to_keep.lst affiliation-filtered.tsv &gt;&gt; affiliation-filtered-final.tsv</code></pre>
<pre class="r"><code>raw_data &lt;- read.csv2(&quot;data/metadata_real_reads.tsv&quot; , sep = &quot;\t&quot;, stringsAsFactors = F) %&gt;% as_tibble()</code></pre>
<div id="meat" class="section level1">
<h1>MEAT</h1>
<div id="analysis-of-raw-biom-files" class="section level2 tabset">
Olivier Rue's avatar
Olivier Rue committed
309
<h2>Analysis of raw BIOM files</h2>
Olivier Rue's avatar
Olivier Rue committed
310
311
<pre class="r"><code>if (!file.exists(&quot;REAL_MEAT/ITS1.rds&quot;)) {
  biomfile &lt;- &quot;REAL_MEAT/ITS1.biom&quot;
Olivier Rue's avatar
Olivier Rue committed
312
  physeq_its1 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
Olivier Rue's avatar
Olivier Rue committed
313
314
  tax_table(physeq_its1) &lt;- gsub(tax_table(physeq_its1),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_MEAT/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
Olivier Rue's avatar
Olivier Rue committed
315
316
  sample_data(physeq_its1) &lt;- metadata
  sample_data(physeq_its1)$Marker &lt;- &quot;ITS1&quot;
Olivier Rue's avatar
Olivier Rue committed
317
318
319
  sample_data(physeq_its1)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;MEAT&quot;) %&gt;% filter(Marker == &quot;ITS1&quot;) %&gt;% pull(Reads)
  sample_names(physeq_its1) &lt;- glue::glue(paste(&quot;{sample_names(physeq_its1)}&quot;,&quot;ITS1&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_its1,&quot;REAL_MEAT/ITS1.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
320
} else {
Olivier Rue's avatar
Olivier Rue committed
321
  physeq_its1 &lt;- readRDS(&quot;REAL_MEAT/ITS1.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
322
323
}

Olivier Rue's avatar
Olivier Rue committed
324
325
if (!file.exists(&quot;REAL_MEAT/ITS2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_MEAT/ITS2.biom&quot;
Olivier Rue's avatar
Olivier Rue committed
326
  physeq_its2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
Olivier Rue's avatar
Olivier Rue committed
327
328
  tax_table(physeq_its2) &lt;- gsub(tax_table(physeq_its2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_MEAT/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
Olivier Rue's avatar
Olivier Rue committed
329
330
  sample_data(physeq_its2) &lt;- metadata
  sample_data(physeq_its2)$Marker &lt;- &quot;ITS2&quot;
Olivier Rue's avatar
Olivier Rue committed
331
332
333
  sample_data(physeq_its2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;MEAT&quot;) %&gt;% filter(Marker == &quot;ITS2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_its2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_its2)}&quot;,&quot;ITS2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_its2,&quot;REAL_MEAT/ITS2.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
334
} else {
Olivier Rue's avatar
Olivier Rue committed
335
  physeq_its2 &lt;- readRDS(&quot;REAL_MEAT/ITS2.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
336
337
}

Olivier Rue's avatar
Olivier Rue committed
338
339
if (!file.exists(&quot;REAL_MEAT/D1D2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_MEAT/D1D2.biom&quot;
Olivier Rue's avatar
Olivier Rue committed
340
  physeq_d1d2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
Olivier Rue's avatar
Olivier Rue committed
341
342
343
  tax_table(physeq_d1d2) &lt;- gsub(tax_table(physeq_d1d2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  tax_table(physeq_d1d2) &lt;- gsub(tax_table(physeq_d1d2),     pattern = &quot;Eukaryota&quot;, replacement = &quot;Fungi&quot;)
  metadata &lt;- read.table(&quot;REAL_MEAT/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
Olivier Rue's avatar
Olivier Rue committed
344
345
  sample_data(physeq_d1d2) &lt;- metadata
  sample_data(physeq_d1d2)$Marker &lt;- &quot;D1D2&quot;
Olivier Rue's avatar
Olivier Rue committed
346
347
348
  sample_data(physeq_d1d2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;MEAT&quot;) %&gt;% filter(Marker == &quot;D1D2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_d1d2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_d1d2)}&quot;,&quot;D1D2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_d1d2,&quot;REAL_MEAT/D1D2.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
349
} else {
Olivier Rue's avatar
Olivier Rue committed
350
  physeq_d1d2 &lt;- readRDS(&quot;REAL_MEAT/D1D2.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
351
352
}

Olivier Rue's avatar
Olivier Rue committed
353
354
if (!file.exists(&quot;REAL_MEAT/RPB2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_MEAT/RPB2.biom&quot;
Olivier Rue's avatar
Olivier Rue committed
355
  physeq_rpb2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
Olivier Rue's avatar
Olivier Rue committed
356
357
  tax_table(physeq_rpb2) &lt;- gsub(tax_table(physeq_rpb2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_MEAT/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
Olivier Rue's avatar
Olivier Rue committed
358
359
  sample_data(physeq_rpb2) &lt;- metadata
  sample_data(physeq_rpb2)$Marker &lt;- &quot;RPB2&quot;
Olivier Rue's avatar
Olivier Rue committed
360
361
362
  sample_data(physeq_rpb2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;MEAT&quot;) %&gt;% filter(Marker == &quot;RPB2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_rpb2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_rpb2)}&quot;,&quot;RPB2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_rpb2,&quot;REAL_MEAT/RPB2.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
363
} else {
Olivier Rue's avatar
Olivier Rue committed
364
  physeq_rpb2 &lt;- readRDS(&quot;REAL_MEAT/RPB2.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
365
}</code></pre>
Olivier Rue's avatar
Olivier Rue committed
366
367
368
369
370
371
<pre class="r"><code>if (!file.exists(&quot;REAL_MEAT/meat.rds&quot;)){
  meat_all &lt;- merge_phyloseq(physeq_its1, physeq_its2, physeq_d1d2, physeq_rpb2)
  sample_data(meat_all)$Marker &lt;- factor(sample_data(meat_all)$Marker, levels=c(&quot;ITS1&quot;,&quot;ITS2&quot;,&quot;D1D2&quot;,&quot;RPB2&quot;))  
  saveRDS(meat_all,&quot;REAL_MEAT/meat.rds&quot;)
}else{
  meat_all &lt;- readRDS(&quot;REAL_MEAT/meat.rds&quot;) 
Olivier Rue's avatar
Olivier Rue committed
372
}</code></pre>
Olivier Rue's avatar
Olivier Rue committed
373
<div id="sequencing-depth" class="section level3 tabset">
Olivier Rue's avatar
Olivier Rue committed
374
<h3>Sequencing depth</h3>
Olivier Rue's avatar
Olivier Rue committed
375
376
377
378
379
380
381
382
383
384
<pre class="r"><code>df &lt;- sample_data(meat_all) %&gt;% as(&quot;data.frame&quot;) %&gt;% 
  as_tibble(rownames = &quot;SampleID&quot;) %&gt;% 
  mutate(Final   = sample_sums(meat_all)) %&gt;% 
  rename(Initial = Reads)
ggplot(df %&gt;% pivot_longer(cols = c(Initial, Final), names_to = &quot;Step&quot;, values_to = &quot;Reads&quot;), 
       aes(x = SampleID, y = Reads, fill=Step)) + 
  geom_bar(stat=&#39;identity&#39;, position=&#39;identity&#39;) +
  facet_grid(~Marker, scales = &quot;free_x&quot;) +   
  scale_fill_brewer(palette = &quot;Reds&quot;, direction = -1) + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))</code></pre>
Olivier Rue's avatar
Olivier Rue committed
385
<p><img src="real_samples_files/figure-html/unnamed-chunk-8-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
386
387
388
389
390
</div>
<div id="compositions" class="section level3">
<h3>Compositions</h3>
<pre class="r"><code>p &lt;- plot_composition(physeq = meat_all, taxaRank1 = &quot;Kingdom&quot;, taxaSet1 = &quot;Fungi&quot;, taxaRank2 = &quot;Species&quot;, numberOfTaxa = 22, x = &quot;Sample&quot;)
p + facet_grid(&quot;. ~ Marker&quot;, scales = &quot;free_x&quot;, space = &quot;free&quot;)</code></pre>
Olivier Rue's avatar
Olivier Rue committed
391
<p><img src="real_samples_files/figure-html/unnamed-chunk-9-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
392
393
394
395
396
</div>
<div id="richness" class="section level3">
<h3>Richness</h3>
<pre class="r"><code>p &lt;- plot_richness(physeq = meat_all, x = &quot;Marker&quot;, color = &quot;Marker&quot;, shape = NULL, title = &quot;Alpha diversity graphics&quot;, measures = c(&quot;Observed&quot;, &quot;Chao1&quot;, &quot;ACE&quot;, &quot;Shannon&quot;, &quot;Simpson&quot;, &quot;InvSimpson&quot;, &quot;Fisher&quot;))
p + geom_boxplot() + NULL</code></pre>
Olivier Rue's avatar
Olivier Rue committed
397
<p><img src="real_samples_files/figure-html/unnamed-chunk-10-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
398
399
400
401
402
403
404
405
</div>
<div id="beta-diversity" class="section level3">
<h3><span class="math inline">\(\beta\)</span> diversity</h3>
<pre class="r"><code>beta.dist &lt;- distance(meat_all, method = &quot;bray&quot;)
ord &lt;- ordinate(meat_all, method = &quot;MDS&quot;, distance = beta.dist)
p &lt;- plot_ordination(physeq = meat_all, ordination = ord, type = &quot;samples&quot;, axes = c(1, 2), color = &quot;Marker&quot;, shape = NULL, label = NULL, title = &quot;Samples ordination graphic, bray-curtis distance&quot;)
p &lt;- p + stat_ellipse(aes_string(group = &quot;Marker&quot;))
p + theme_bw()</code></pre>
Olivier Rue's avatar
Olivier Rue committed
406
<p><img src="real_samples_files/figure-html/unnamed-chunk-11-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
407
408
409
410
411
412
413
414
415
416
417
</div>
<div id="common-families" class="section level3">
<h3>Common families</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1))$Family %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2))$Family %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2))$Family %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2))$Family %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
418
<p><img src="real_samples_files/figure-html/unnamed-chunk-12-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
419
420
421
422
423
424
425
426
427
428
429
</div>
<div id="common-genus" class="section level3">
<h3>Common genus</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1))$Genus %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2))$Genus %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2))$Genus %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2))$Genus %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
430
<p><img src="real_samples_files/figure-html/unnamed-chunk-13-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
431
432
433
</div>
</div>
<div id="manual-curation" class="section level2 tabset">
Olivier Rue's avatar
Olivier Rue committed
434
<h2>Manual curation</h2>
Olivier Rue's avatar
Olivier Rue committed
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
<pre class="r"><code>physeq_its1_final &lt;- curation_meat_its1(physeq_its1)
saveRDS(physeq_its1_final,&quot;REAL_MEAT/ITS1_final.rds&quot;)

physeq_its2_final &lt;- curation_meat_its2(physeq_its2)
saveRDS(physeq_its2_final,&quot;REAL_MEAT/ITS2_final.rds&quot;)

physeq_d1d2_final &lt;- curation_meat_d1d2(physeq_d1d2)
saveRDS(physeq_d1d2_final,&quot;REAL_MEAT/D1D2_final.rds&quot;)

physeq_rpb2_final &lt;- curation_meat_rpb2(physeq_rpb2)
saveRDS(physeq_rpb2_final,&quot;REAL_MEAT/RPB2_final.rds&quot;)</code></pre>
<pre class="r"><code>#if (!file.exists(&quot;REAL_MEAT/meat_final.rds&quot;)){
meat_all_final &lt;- merge_phyloseq(physeq_its1_final, physeq_its2_final, physeq_d1d2_final, physeq_rpb2_final)
sample_data(meat_all_final)$Marker &lt;- factor(sample_data(meat_all_final)$Marker, levels=c(&quot;ITS1&quot;,&quot;ITS2&quot;,&quot;D1D2&quot;,&quot;RPB2&quot;))  
saveRDS(meat_all_final,&quot;REAL_CHEESE/meat_final.rds&quot;)
#}else{
#  meat_all_final &lt;- readRDS(&quot;REAL_MEAT/meat_final.rds&quot;) 
#}</code></pre>
Olivier Rue's avatar
Olivier Rue committed
453
<div id="sequencing-depth-1" class="section level3 tabset">
Olivier Rue's avatar
Olivier Rue committed
454
<h3>Sequencing depth</h3>
Olivier Rue's avatar
Olivier Rue committed
455
456
457
458
459
460
461
462
463
464
<pre class="r"><code>df &lt;- sample_data(meat_all_final) %&gt;% as(&quot;data.frame&quot;) %&gt;% 
  as_tibble(rownames = &quot;SampleID&quot;) %&gt;% 
  mutate(Final   = sample_sums(meat_all_final)) %&gt;% 
  rename(Initial = Reads)
ggplot(df %&gt;% pivot_longer(cols = c(Initial, Final), names_to = &quot;Step&quot;, values_to = &quot;Reads&quot;), 
       aes(x = SampleID, y = Reads, fill=Step)) + 
  geom_bar(stat=&#39;identity&#39;, position=&#39;identity&#39;) +
  facet_grid(~Marker, scales = &quot;free_x&quot;) +   
  scale_fill_brewer(palette = &quot;Reds&quot;, direction = -1) + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))</code></pre>
Olivier Rue's avatar
Olivier Rue committed
465
<p><img src="real_samples_files/figure-html/unnamed-chunk-16-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
466
467
468
469
470
</div>
<div id="compositions-1" class="section level3">
<h3>Compositions</h3>
<pre class="r"><code>p &lt;- plot_composition(physeq = meat_all_final, taxaRank1 = &quot;Kingdom&quot;, taxaSet1 = &quot;Fungi&quot;, taxaRank2 = &quot;Species&quot;, numberOfTaxa = 22, x = &quot;Sample&quot;)
p + facet_grid(&quot;. ~ Marker&quot;, scales = &quot;free_x&quot;, space = &quot;free&quot;)</code></pre>
Olivier Rue's avatar
Olivier Rue committed
471
<p><img src="real_samples_files/figure-html/unnamed-chunk-17-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
472
473
474
475
476
</div>
<div id="richness-1" class="section level3">
<h3>Richness</h3>
<pre class="r"><code>p &lt;- plot_richness(physeq = meat_all_final, x = &quot;Marker&quot;, color = &quot;Marker&quot;, shape = NULL, title = &quot;Alpha diversity graphics&quot;, measures = c(&quot;Observed&quot;, &quot;Chao1&quot;, &quot;ACE&quot;, &quot;Shannon&quot;, &quot;Simpson&quot;, &quot;InvSimpson&quot;, &quot;Fisher&quot;))
p + geom_boxplot() + NULL</code></pre>
Olivier Rue's avatar
Olivier Rue committed
477
<p><img src="real_samples_files/figure-html/unnamed-chunk-18-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
478
479
480
481
482
483
484
485
</div>
<div id="beta-diversity-1" class="section level3">
<h3><span class="math inline">\(\beta\)</span> diversity</h3>
<pre class="r"><code>beta.dist &lt;- distance(meat_all_final, method = &quot;bray&quot;)
ord &lt;- ordinate(meat_all_final, method = &quot;MDS&quot;, distance = beta.dist)
p &lt;- plot_ordination(physeq = meat_all_final, ordination = ord, type = &quot;samples&quot;, axes = c(1, 2), color = &quot;Marker&quot;, shape = NULL, label = NULL, title = &quot;Samples ordination graphic, bray-curtis distance&quot;)
p &lt;- p + stat_ellipse(aes_string(group = &quot;Marker&quot;))
p + theme_bw()</code></pre>
Olivier Rue's avatar
Olivier Rue committed
486
<p><img src="real_samples_files/figure-html/unnamed-chunk-19-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
487
488
489
490
491
492
493
494
495
496
497
</div>
<div id="common-families-1" class="section level3">
<h3>Common families</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1_final))$Family %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2_final))$Family %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2_final))$Family %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2_final))$Family %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
498
<p><img src="real_samples_files/figure-html/unnamed-chunk-20-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
499
500
501
502
503
504
505
506
507
508
509
</div>
<div id="common-genus-1" class="section level3">
<h3>Common genus</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1_final))$Genus %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2_final))$Genus %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2_final))$Genus %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2_final))$Genus %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
510
<p><img src="real_samples_files/figure-html/unnamed-chunk-21-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
</div>
</div>
</div>
<div id="cheese" class="section level1">
<h1>CHEESE</h1>
<pre class="bash"><code># Genologin
cd /work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/scripts
sh dada2_frogs.sh</code></pre>
<pre class="bash"><code>scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/ITS1/affiliation.biom REAL_CHEESE/ITS1.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/ITS2/affiliation.biom REAL_CHEESE/ITS2.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/D1D2/affiliation.biom REAL_CHEESE/D1D2.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/RPB2/affiliation.biom REAL_CHEESE/RPB2.biom

scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/ITS1/affiliation.tsv REAL_CHEESE/ITS1.tsv
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/ITS2/affiliation.tsv REAL_CHEESE/ITS2.tsv
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/D1D2/affiliation.tsv REAL_CHEESE/D1D2.tsv
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/RPB2/affiliation.tsv REAL_CHEESE/RPB2.tsv

#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/ITS1/multiaff.tsv REAL_CHEESE/ITS1_multiaff.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/ITS2/multiaff.tsv REAL_CHEESE/ITS2_multiaff.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/D1D2/multiaff.tsv REAL_CHEESE/D1D2_multiaff.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/RPB2/multiaff.tsv REAL_CHEESE/RPB2_multiaff.tsv</code></pre>
<pre class="bash"><code>### GET DATA FROM GENOTOUL
scp orue@genotoul.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/RPB2/affiliation.biom .
scp orue@genotoul.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/RPB2/filters.fasta .
##########################

otu_filters.py --input-biom affiliation.biom --input-fasta filters.fasta --contaminant /db/frogs_databanks/assignation/Unite_Fungi_8.2_20200204/Unite_Fungi_8.2_20200204.fasta --output-biom 1.biom --output-fasta 1.fasta --nb-cpus 4
otu_filters.py --input-biom 1.biom --input-fasta 1.fasta --contaminant /db/frogs_databanks/assignation/SILVA_132_LSU/SILVA_132_LSU.fasta --nb-cpus 4 --output-biom 2.biom --output-fasta 2.fasta
otu_filters.py --input-biom 2.biom --input-fasta 2.fasta --contaminant /db/frogs_databanks/assignation/silva_138_SSU/silva_138_SSU.fasta --nb-cpus 4 --output-biom 3.biom --output-fasta 3.fasta 
otu_filters.py --input-biom 3.biom --input-fasta 3.fasta --contaminant /db/frogs_databanks/assignation/Unite_Euka_8.2_20200204/Unite_Euka_8.2_20200204.fasta --output-biom 4.biom --output-fasta 4.fasta --nb-cpus 4  
biom_to_tsv.py --input-biom 4.biom --output-tsv 4.tsv
head -n 1 4.tsv &gt; 4-2.tsv
sed &quot;s/no data/NA;NA;NA;NA;NA;NA;NA/&quot; 4.tsv |sed &quot;s/no data/0/g&quot; | grep  &#39;FROGS_combined&#39; &gt;&gt; 4-2.tsv
tsv_to_biom.py  --input-tsv 4-2.tsv --output-biom 4-2.biom
affiliation_filters.py  --input-fasta 4.fasta --input-biom 4-2.biom --min-blast-identity 0.1 --delete
biom_to_tsv.py --input-biom affiliation-filtered.biom --output-tsv affiliation-filtered.tsv
Olivier Rue's avatar
Olivier Rue committed
548
affiliation_OTU.py --input-fasta affiliation-filtered.fasta --input-biom affiliation-filtered.biom --nb-cpus 8 --output-biom affiliation.biom --summary affiliation.html --reference ~/work/D1D2.fasta
Olivier Rue's avatar
Olivier Rue committed
549
550
551
552
553
554
555
556
557
558
559

biom_to_tsv.py --input-biom affiliation.biom --output-tsv affiliation.tsv

head -n 1 4.tsv &gt; final.tsv
awk -F&#39;\t&#39; &#39;{ if ($4 &lt; 80 &amp;&amp; $5 &gt; 95 &amp;&amp; length($8 &gt; 400)) { print } }&#39; affiliation.tsv &gt;&gt; final.tsv

awk -F&#39;\t&#39; &#39;{print $8}&#39; &lt;(grep -v &quot;^#&quot; final.tsv) &gt; to_keep.lst

head -n 1 4.tsv &gt; affiliation-filtered-final.tsv
grep -f to_keep.lst affiliation-filtered.tsv &gt;&gt; affiliation-filtered-final.tsv</code></pre>
<div id="analysis-of-raw-biom-files-1" class="section level2 tabset">
Olivier Rue's avatar
Olivier Rue committed
560
<h2>Analysis of raw BIOM files</h2>
Olivier Rue's avatar
Olivier Rue committed
561
562
563
564
565
566
567
568
569
570
571
572
573
<pre class="r"><code>if (!file.exists(&quot;REAL_CHEESE/ITS1.rds&quot;)) {
  biomfile &lt;- &quot;REAL_CHEESE/ITS1.biom&quot;
  physeq_its1 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_its1) &lt;- gsub(tax_table(physeq_its1),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_CHEESE/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_its1) &lt;- metadata
  sample_data(physeq_its1)$Marker &lt;- &quot;ITS1&quot;
  sample_data(physeq_its1)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;CHEESE&quot;) %&gt;% filter(Marker == &quot;ITS1&quot;) %&gt;% pull(Reads)
  sample_names(physeq_its1) &lt;- glue::glue(paste(&quot;{sample_names(physeq_its1)}&quot;,&quot;ITS1&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_its1,&quot;REAL_CHEESE/ITS1.rds&quot;)
} else {
  physeq_its1 &lt;- readRDS(&quot;REAL_CHEESE/ITS1.rds&quot;)
}
Olivier Rue's avatar
Olivier Rue committed
574

Olivier Rue's avatar
Olivier Rue committed
575
576
577
578
579
580
581
582
583
584
585
586
587
if (!file.exists(&quot;REAL_CHEESE/ITS2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_CHEESE/ITS2.biom&quot;
  physeq_its2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_its2) &lt;- gsub(tax_table(physeq_its2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_CHEESE/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_its2) &lt;- metadata
  sample_data(physeq_its2)$Marker &lt;- &quot;ITS2&quot;
  sample_data(physeq_its2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;CHEESE&quot;) %&gt;% filter(Marker == &quot;ITS2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_its2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_its2)}&quot;,&quot;ITS2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_its2,&quot;REAL_CHEESE/ITS2.rds&quot;)
} else {
  physeq_its2 &lt;- readRDS(&quot;REAL_CHEESE/ITS2.rds&quot;)
}
Olivier Rue's avatar
Olivier Rue committed
588

Olivier Rue's avatar
Olivier Rue committed
589
590
591
592
593
594
595
596
597
598
599
600
601
602
if (!file.exists(&quot;REAL_CHEESE/D1D2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_CHEESE/D1D2.biom&quot;
  physeq_d1d2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_d1d2) &lt;- gsub(tax_table(physeq_d1d2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  tax_table(physeq_d1d2) &lt;- gsub(tax_table(physeq_d1d2),     pattern = &quot;Eukaryota&quot;, replacement = &quot;Fungi&quot;)
  metadata &lt;- read.table(&quot;REAL_CHEESE/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_d1d2) &lt;- metadata
  sample_data(physeq_d1d2)$Marker &lt;- &quot;D1D2&quot;
  sample_data(physeq_d1d2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;CHEESE&quot;) %&gt;% filter(Marker == &quot;D1D2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_d1d2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_d1d2)}&quot;,&quot;D1D2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_d1d2,&quot;REAL_CHEESE/D1D2.rds&quot;)
} else {
  physeq_d1d2 &lt;- readRDS(&quot;REAL_CHEESE/D1D2.rds&quot;)
}
Olivier Rue's avatar
Olivier Rue committed
603

Olivier Rue's avatar
Olivier Rue committed
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
if (!file.exists(&quot;REAL_CHEESE/RPB2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_CHEESE/RPB2.biom&quot;
  physeq_rpb2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_rpb2) &lt;- gsub(tax_table(physeq_rpb2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_CHEESE/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_rpb2) &lt;- metadata
  sample_data(physeq_rpb2)$Marker &lt;- &quot;RPB2&quot;
  sample_data(physeq_rpb2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;CHEESE&quot;) %&gt;% filter(Marker == &quot;RPB2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_rpb2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_rpb2)}&quot;,&quot;RPB2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_rpb2,&quot;REAL_CHEESE/RPB2.rds&quot;)
} else {
  physeq_rpb2 &lt;- readRDS(&quot;REAL_CHEESE/RPB2.rds&quot;)
}</code></pre>
<pre class="r"><code>if (!file.exists(&quot;REAL_CHEESE/cheese.rds&quot;)){
  cheese_all &lt;- merge_phyloseq(physeq_its1, physeq_its2, physeq_d1d2, physeq_rpb2)
  sample_data(cheese_all)$Marker &lt;- factor(sample_data(cheese_all)$Marker, levels=c(&quot;ITS1&quot;,&quot;ITS2&quot;,&quot;D1D2&quot;,&quot;RPB2&quot;))  
  saveRDS(cheese_all,&quot;REAL_CHEESE/cheese.rds&quot;)
}else{
  cheese_all &lt;- readRDS(&quot;REAL_CHEESE/cheese.rds&quot;) 
}</code></pre>
<div id="sequencing-depth-2" class="section level3 tabset">
Olivier Rue's avatar
Olivier Rue committed
625
<h3>Sequencing depth</h3>
Olivier Rue's avatar
Olivier Rue committed
626
627
628
629
630
631
632
633
634
635
<pre class="r"><code>df &lt;- sample_data(cheese_all) %&gt;% as(&quot;data.frame&quot;) %&gt;% 
  as_tibble(rownames = &quot;SampleID&quot;) %&gt;% 
  mutate(Final   = sample_sums(cheese_all)) %&gt;% 
  rename(Initial = Reads)
ggplot(df %&gt;% pivot_longer(cols = c(Initial, Final), names_to = &quot;Step&quot;, values_to = &quot;Reads&quot;), 
       aes(x = SampleID, y = Reads, fill=Step)) + 
  geom_bar(stat=&#39;identity&#39;, position=&#39;identity&#39;) +
  facet_grid(~Marker, scales = &quot;free_x&quot;) +   
  scale_fill_brewer(palette = &quot;Reds&quot;, direction = -1) + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))</code></pre>
Olivier Rue's avatar
Olivier Rue committed
636
<p><img src="real_samples_files/figure-html/unnamed-chunk-27-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
637
638
639
640
</div>
<div id="compositions-2" class="section level3">
<h3>Compositions</h3>
<pre class="r"><code>p &lt;- plot_composition(physeq = cheese_all, taxaRank1 = &quot;Kingdom&quot;, taxaSet1 = &quot;Fungi&quot;, taxaRank2 = &quot;Species&quot;, numberOfTaxa = 22, x = &quot;Sample&quot;)
Olivier Rue's avatar
Olivier Rue committed
641
p + facet_grid(&quot;. ~ Marker&quot;, scales = &quot;free_x&quot;, space = &quot;free&quot;)</code></pre>
Olivier Rue's avatar
Olivier Rue committed
642
<p><img src="real_samples_files/figure-html/unnamed-chunk-28-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
643
644
645
646
647
</div>
<div id="richness-2" class="section level3">
<h3>Richness</h3>
<pre class="r"><code>p &lt;- plot_richness(physeq = cheese_all, x = &quot;Marker&quot;, color = &quot;Marker&quot;, shape = NULL, title = &quot;Alpha diversity graphics&quot;, measures = c(&quot;Observed&quot;, &quot;Chao1&quot;, &quot;ACE&quot;, &quot;Shannon&quot;, &quot;Simpson&quot;, &quot;InvSimpson&quot;, &quot;Fisher&quot;))
p + geom_boxplot() + NULL</code></pre>
Olivier Rue's avatar
Olivier Rue committed
648
<p><img src="real_samples_files/figure-html/unnamed-chunk-29-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
649
650
651
652
653
654
655
656
</div>
<div id="beta-diversity-2" class="section level3">
<h3><span class="math inline">\(\beta\)</span> diversity</h3>
<pre class="r"><code>beta.dist &lt;- distance(cheese_all, method = &quot;bray&quot;)
ord &lt;- ordinate(cheese_all, method = &quot;MDS&quot;, distance = beta.dist)
p &lt;- plot_ordination(physeq = cheese_all, ordination = ord, type = &quot;samples&quot;, axes = c(1, 2), color = &quot;Marker&quot;, shape = NULL, label = NULL, title = &quot;Samples ordination graphic, bray-curtis distance&quot;)
p &lt;- p + stat_ellipse(aes_string(group = &quot;Marker&quot;))
p + theme_bw()</code></pre>
Olivier Rue's avatar
Olivier Rue committed
657
<p><img src="real_samples_files/figure-html/unnamed-chunk-30-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
658
659
660
661
662
663
664
665
666
667
668
</div>
<div id="common-families-2" class="section level3">
<h3>Common families</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1))$Family %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2))$Family %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2))$Family %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2))$Family %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
669
<p><img src="real_samples_files/figure-html/unnamed-chunk-31-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
670
671
672
673
674
675
676
677
678
679
680
</div>
<div id="common-genus-2" class="section level3">
<h3>Common genus</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1))$Genus %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2))$Genus %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2))$Genus %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2))$Genus %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
681
<p><img src="real_samples_files/figure-html/unnamed-chunk-32-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
682
</div>
Olivier Rue's avatar
Olivier Rue committed
683
684
685
686
687
688
689
690
691
692
<div id="common-species" class="section level3">
<h3>Common species</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1))$Species %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2))$Species %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2))$Species %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2))$Species %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
693
<p><img src="real_samples_files/figure-html/unnamed-chunk-33-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
694
</div>
Olivier Rue's avatar
Olivier Rue committed
695
696
</div>
<div id="manual-curation-1" class="section level2 tabset">
Olivier Rue's avatar
Olivier Rue committed
697
<h2>Manual curation</h2>
Olivier Rue's avatar
Olivier Rue committed
698
699
<pre class="r"><code>physeq_its1_final &lt;- curation_cheese_its1(physeq_its1)
saveRDS(physeq_its1_final,&quot;REAL_CHEESE/ITS1_final.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
700

Olivier Rue's avatar
Olivier Rue committed
701
702
physeq_its2_final &lt;- curation_cheese_its2(physeq_its2)
saveRDS(physeq_its2_final,&quot;REAL_CHEESE/ITS2_final.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
703

Olivier Rue's avatar
Olivier Rue committed
704
705
physeq_d1d2_final &lt;- curation_cheese_d1d2(physeq_d1d2)
saveRDS(physeq_d1d2_final,&quot;REAL_CHEESE/D1D2_final.rds&quot;)
Olivier Rue's avatar
Olivier Rue committed
706

Olivier Rue's avatar
Olivier Rue committed
707
708
physeq_rpb2_final &lt;- curation_cheese_rpb2(physeq_rpb2)
saveRDS(physeq_rpb2_final,&quot;REAL_CHEESE/RPB2_final.rds&quot;)</code></pre>
Olivier Rue's avatar
Olivier Rue committed
709
<pre class="r"><code>#if (!file.exists(&quot;REAL_CHEESE/cheese_final.rds&quot;)){
Olivier Rue's avatar
Olivier Rue committed
710
cheese_all_final &lt;- merge_phyloseq(physeq_its1_final, physeq_its2_final, physeq_d1d2_final, physeq_rpb2_final)
Olivier Rue's avatar
Olivier Rue committed
711
712
713
714
715
sample_data(cheese_all_final)$Marker &lt;- factor(sample_data(cheese_all_final)$Marker, levels=c(&quot;ITS1&quot;,&quot;ITS2&quot;,&quot;D1D2&quot;,&quot;RPB2&quot;))  
saveRDS(cheese_all_final,&quot;REAL_CHEESE/cheese_final.rds&quot;)
#}else{
#  cheese_all_final &lt;- readRDS(&quot;REAL_CHEESE/cheese_final.rds&quot;) 
#}</code></pre>
Olivier Rue's avatar
Olivier Rue committed
716
<div id="sequencing-depth-3" class="section level3 tabset">
Olivier Rue's avatar
Olivier Rue committed
717
<h3>Sequencing depth</h3>
Olivier Rue's avatar
Olivier Rue committed
718
719
720
721
722
723
724
725
726
727
<pre class="r"><code>df &lt;- sample_data(cheese_all_final) %&gt;% as(&quot;data.frame&quot;) %&gt;% 
  as_tibble(rownames = &quot;SampleID&quot;) %&gt;% 
  mutate(Final   = sample_sums(cheese_all_final)) %&gt;% 
  rename(Initial = Reads)
ggplot(df %&gt;% pivot_longer(cols = c(Initial, Final), names_to = &quot;Step&quot;, values_to = &quot;Reads&quot;), 
       aes(x = SampleID, y = Reads, fill=Step)) + 
  geom_bar(stat=&#39;identity&#39;, position=&#39;identity&#39;) +
  facet_grid(~Marker, scales = &quot;free_x&quot;) +   
  scale_fill_brewer(palette = &quot;Reds&quot;, direction = -1) + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))</code></pre>
Olivier Rue's avatar
Olivier Rue committed
728
<p><img src="real_samples_files/figure-html/unnamed-chunk-36-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
729
730
731
732
</div>
<div id="compositions-3" class="section level3">
<h3>Compositions</h3>
<pre class="r"><code>p &lt;- plot_composition(physeq = cheese_all_final, taxaRank1 = &quot;Kingdom&quot;, taxaSet1 = &quot;Fungi&quot;, taxaRank2 = &quot;Species&quot;, numberOfTaxa = 22, x = &quot;Sample&quot;)
Olivier Rue's avatar
Olivier Rue committed
733
p + facet_grid(&quot;. ~ Marker&quot;, scales = &quot;free_x&quot;, space = &quot;free&quot;)</code></pre>
Olivier Rue's avatar
Olivier Rue committed
734
<p><img src="real_samples_files/figure-html/unnamed-chunk-37-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
735
736
737
738
739
</div>
<div id="richness-3" class="section level3">
<h3>Richness</h3>
<pre class="r"><code>p &lt;- plot_richness(physeq = cheese_all_final, x = &quot;Marker&quot;, color = &quot;Marker&quot;, shape = NULL, title = &quot;Alpha diversity graphics&quot;, measures = c(&quot;Observed&quot;, &quot;Chao1&quot;, &quot;ACE&quot;, &quot;Shannon&quot;, &quot;Simpson&quot;, &quot;InvSimpson&quot;, &quot;Fisher&quot;))
p + geom_boxplot() + NULL</code></pre>
Olivier Rue's avatar
Olivier Rue committed
740
<p><img src="real_samples_files/figure-html/unnamed-chunk-38-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
741
742
743
744
745
746
747
748
</div>
<div id="beta-diversity-3" class="section level3">
<h3><span class="math inline">\(\beta\)</span> diversity</h3>
<pre class="r"><code>beta.dist &lt;- distance(cheese_all_final, method = &quot;bray&quot;)
ord &lt;- ordinate(cheese_all_final, method = &quot;MDS&quot;, distance = beta.dist)
p &lt;- plot_ordination(physeq = cheese_all_final, ordination = ord, type = &quot;samples&quot;, axes = c(1, 2), color = &quot;Marker&quot;, shape = NULL, label = NULL, title = &quot;Samples ordination graphic, bray-curtis distance&quot;)
p &lt;- p + stat_ellipse(aes_string(group = &quot;Marker&quot;))
p + theme_bw()</code></pre>
Olivier Rue's avatar
Olivier Rue committed
749
<p><img src="real_samples_files/figure-html/unnamed-chunk-39-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
750
751
752
753
754
</div>
<div id="common-families-3" class="section level3">
<h3>Common families</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1_final))$Family %&gt;% as.vector(), 
Olivier Rue's avatar
Olivier Rue committed
755
756
757
  ITS2 = as_tibble(tax_table(physeq_its2_final))$Family %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2_final))$Family %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2_final))$Family %&gt;% as.vector()
Olivier Rue's avatar
Olivier Rue committed
758
759
760
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
761
<p><img src="real_samples_files/figure-html/unnamed-chunk-40-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
762
763
764
765
766
</div>
<div id="common-genus-3" class="section level3">
<h3>Common genus</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1_final))$Genus %&gt;% as.vector(), 
Olivier Rue's avatar
Olivier Rue committed
767
  ITS2 = as_tibble(tax_table(physeq_its2_final))$Genus %&gt;% as.vector(),
Olivier Rue's avatar
Olivier Rue committed
768
769
  D1D2 = as_tibble(tax_table(physeq_d1d2_final))$Genus %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2_final))$Genus %&gt;% as.vector()
Olivier Rue's avatar
Olivier Rue committed
770
771
772
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
773
<p><img src="real_samples_files/figure-html/unnamed-chunk-41-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
774
775
776
777
778
779
</div>
<div id="common-species-1" class="section level3">
<h3>Common species</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1_final))$Species %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2_final))$Species %&gt;% as.vector(),
Olivier Rue's avatar
Olivier Rue committed
780
781
  D1D2 = as_tibble(tax_table(physeq_d1d2_final))$Species %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2_final))$Species %&gt;% as.vector()
Olivier Rue's avatar
Olivier Rue committed
782
783
784
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
785
<p><img src="real_samples_files/figure-html/unnamed-chunk-42-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
</div>
</div>
</div>
<div id="bread" class="section level1">
<h1>BREAD</h1>
<pre class="bash"><code>scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/ITS1/affiliation.biom REAL_BREAD/ITS1.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/ITS2/affiliation.biom REAL_BREAD/ITS2.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/D1D2/affiliation.biom REAL_BREAD/D1D2.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/RPB2/affiliation.biom REAL_BREAD/RPB2.biom

#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/ITS1/affiliation.tsv REAL_BREAD/ITS1.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/ITS2/affiliation.tsv REAL_BREAD/ITS2.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/D1D2/affiliation.tsv REAL_BREAD/D1D2.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/RPB2/affiliation.tsv REAL_BREAD/RPB2.tsv

#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/ITS1/multiaff.tsv REAL_CHEESE/ITS1_multiaff.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/ITS2/multiaff.tsv REAL_CHEESE/ITS2_multiaff.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/D1D2/multiaff.tsv REAL_CHEESE/D1D2_multiaff.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/RPB2/multiaff.tsv REAL_CHEESE/RPB2_multiaff.tsv</code></pre>
<div id="analysis-of-raw-biom-files-2" class="section level2 tabset">
Olivier Rue's avatar
Olivier Rue committed
806
<h2>Analysis of raw BIOM files</h2>
Olivier Rue's avatar
Olivier Rue committed
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
<pre class="r"><code>if (!file.exists(&quot;REAL_BREAD/ITS1.rds&quot;)) {
  biomfile &lt;- &quot;REAL_BREAD/ITS1.biom&quot;
  physeq_its1 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_its1) &lt;- gsub(tax_table(physeq_its1),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_BREAD/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_its1) &lt;- metadata
  sample_data(physeq_its1)$Marker &lt;- &quot;ITS1&quot;
  sample_data(physeq_its1)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;BREAD&quot;) %&gt;% filter(Marker == &quot;ITS1&quot;) %&gt;% pull(Reads)
  sample_names(physeq_its1) &lt;- glue::glue(paste(&quot;{sample_names(physeq_its1)}&quot;,&quot;ITS1&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_its1,&quot;REAL_BREAD/ITS1.rds&quot;)
} else {
  physeq_its1 &lt;- readRDS(&quot;REAL_BREAD/ITS1.rds&quot;)
}

if (!file.exists(&quot;REAL_BREAD/ITS2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_BREAD/ITS2.biom&quot;
  physeq_its2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_its2) &lt;- gsub(tax_table(physeq_its2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_BREAD/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_its2) &lt;- metadata
  sample_data(physeq_its2)$Marker &lt;- &quot;ITS2&quot;
  sample_data(physeq_its2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;BREAD&quot;) %&gt;% filter(Marker == &quot;ITS2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_its2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_its2)}&quot;,&quot;ITS2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_its2,&quot;REAL_BREAD/ITS2.rds&quot;)
} else {
  physeq_its2 &lt;- readRDS(&quot;REAL_BREAD/ITS2.rds&quot;)
}

if (!file.exists(&quot;REAL_BREAD/D1D2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_BREAD/D1D2.biom&quot;
  physeq_d1d2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_d1d2) &lt;- gsub(tax_table(physeq_d1d2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  tax_table(physeq_d1d2) &lt;- gsub(tax_table(physeq_d1d2),     pattern = &quot;Eukaryota&quot;, replacement = &quot;Fungi&quot;)
  metadata &lt;- read.table(&quot;REAL_BREAD/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_d1d2) &lt;- metadata
  sample_data(physeq_d1d2)$Marker &lt;- &quot;D1D2&quot;
  sample_data(physeq_d1d2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;BREAD&quot;) %&gt;% filter(Marker == &quot;D1D2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_d1d2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_d1d2)}&quot;,&quot;D1D2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_d1d2,&quot;REAL_BREAD/D1D2.rds&quot;)
} else {
  physeq_d1d2 &lt;- readRDS(&quot;REAL_BREAD/D1D2.rds&quot;)
}

if (!file.exists(&quot;REAL_BREAD/RPB2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_BREAD/RPB2.biom&quot;
  physeq_rpb2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_rpb2) &lt;- gsub(tax_table(physeq_rpb2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_BREAD/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_rpb2) &lt;- metadata
  sample_data(physeq_rpb2)$Marker &lt;- &quot;RPB2&quot;
  sample_data(physeq_rpb2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;BREAD&quot;) %&gt;% filter(Marker == &quot;RPB2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_rpb2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_rpb2)}&quot;,&quot;RPB2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_rpb2,&quot;REAL_BREAD/RPB2.rds&quot;)
} else {
  physeq_rpb2 &lt;- readRDS(&quot;REAL_BREAD/RPB2.rds&quot;)
}</code></pre>
<pre class="r"><code>if (!file.exists(&quot;REAL_BREAD/bread.rds&quot;)){
  bread_all &lt;- merge_phyloseq(physeq_its1, physeq_its2, physeq_d1d2, physeq_rpb2)
  sample_data(bread_all)$Marker &lt;- factor(sample_data(bread_all)$Marker, levels=c(&quot;ITS1&quot;,&quot;ITS2&quot;,&quot;D1D2&quot;,&quot;RPB2&quot;))  
  saveRDS(bread_all,&quot;REAL_BREAD/bread.rds&quot;)
}else{
  bread_all &lt;- readRDS(&quot;REAL_BREAD/bread.rds&quot;) 
}</code></pre>
<div id="sequencing-depth-4" class="section level3 tabset">
Olivier Rue's avatar
Olivier Rue committed
871
<h3>Sequencing depth</h3>
Olivier Rue's avatar
Olivier Rue committed
872
873
874
875
876
877
878
879
880
881
<pre class="r"><code>df &lt;- sample_data(bread_all) %&gt;% as(&quot;data.frame&quot;) %&gt;% 
  as_tibble(rownames = &quot;SampleID&quot;) %&gt;% 
  mutate(Final   = sample_sums(bread_all)) %&gt;% 
  rename(Initial = Reads)
ggplot(df %&gt;% pivot_longer(cols = c(Initial, Final), names_to = &quot;Step&quot;, values_to = &quot;Reads&quot;), 
       aes(x = SampleID, y = Reads, fill=Step)) + 
  geom_bar(stat=&#39;identity&#39;, position=&#39;identity&#39;) +
  facet_grid(~Marker, scales = &quot;free_x&quot;) +   
  scale_fill_brewer(palette = &quot;Reds&quot;, direction = -1) + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))</code></pre>
Olivier Rue's avatar
Olivier Rue committed
882
<p><img src="real_samples_files/figure-html/unnamed-chunk-46-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
883
884
885
886
</div>
<div id="compositions-4" class="section level3">
<h3>Compositions</h3>
<pre class="r"><code>p &lt;- plot_composition(physeq = bread_all, taxaRank1 = &quot;Kingdom&quot;, taxaSet1 = &quot;Fungi&quot;, taxaRank2 = &quot;Species&quot;, numberOfTaxa = 22, x = &quot;Sample&quot;)
Olivier Rue's avatar
Olivier Rue committed
887
p + facet_grid(&quot;. ~ Marker&quot;, scales = &quot;free_x&quot;, space = &quot;free&quot;)</code></pre>
Olivier Rue's avatar
Olivier Rue committed
888
<p><img src="real_samples_files/figure-html/unnamed-chunk-47-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
889
890
891
892
893
</div>
<div id="richness-4" class="section level3">
<h3>Richness</h3>
<pre class="r"><code>p &lt;- plot_richness(physeq = bread_all, x = &quot;Marker&quot;, color = &quot;Marker&quot;, shape = NULL, title = &quot;Alpha diversity graphics&quot;, measures = c(&quot;Observed&quot;, &quot;Chao1&quot;, &quot;ACE&quot;, &quot;Shannon&quot;, &quot;Simpson&quot;, &quot;InvSimpson&quot;, &quot;Fisher&quot;))
p + geom_boxplot() + NULL</code></pre>
Olivier Rue's avatar
Olivier Rue committed
894
<p><img src="real_samples_files/figure-html/unnamed-chunk-48-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
895
896
897
898
899
900
901
902
</div>
<div id="beta-diversity-4" class="section level3">
<h3><span class="math inline">\(\beta\)</span> diversity</h3>
<pre class="r"><code>beta.dist &lt;- distance(bread_all, method = &quot;bray&quot;)
ord &lt;- ordinate(bread_all, method = &quot;MDS&quot;, distance = beta.dist)
p &lt;- plot_ordination(physeq = bread_all, ordination = ord, type = &quot;samples&quot;, axes = c(1, 2), color = &quot;Marker&quot;, shape = NULL, label = NULL, title = &quot;Samples ordination graphic, bray-curtis distance&quot;)
p &lt;- p + stat_ellipse(aes_string(group = &quot;Marker&quot;))
p + theme_bw()</code></pre>
Olivier Rue's avatar
Olivier Rue committed
903
<p><img src="real_samples_files/figure-html/unnamed-chunk-49-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
904
905
906
907
908
909
910
911
912
913
914
</div>
<div id="common-families-4" class="section level3">
<h3>Common families</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1))$Family %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2))$Family %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2))$Family %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2))$Family %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
915
<p><img src="real_samples_files/figure-html/unnamed-chunk-50-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
916
917
918
919
920
921
922
923
924
925
926
</div>
<div id="common-genus-4" class="section level3">
<h3>Common genus</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1))$Genus %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2))$Genus %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2))$Genus %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2))$Genus %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
927
<p><img src="real_samples_files/figure-html/unnamed-chunk-51-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
928
929
930
</div>
</div>
<div id="manual-curation-2" class="section level2 tabset">
Olivier Rue's avatar
Olivier Rue committed
931
<h2>Manual curation</h2>
Olivier Rue's avatar
Olivier Rue committed
932
933
934
935
936
937
938
939
940
941
942
943
<pre class="r"><code>tax_table(physeq_its1) &lt;- t
keptTaxa &lt;- setdiff(taxa_names(physeq_its1), to_remove)
physeq_its1_final &lt;- prune_taxa(keptTaxa, physeq_its1)
saveRDS(physeq_its1_final,&quot;REAL_BREAD/ITS1_final.rds&quot;)</code></pre>
<pre class="r"><code>if (!file.exists(&quot;REAL_MEAT/bread_final.rds&quot;)){
  bread_all_final &lt;- merge_phyloseq(physeq_its1_final, physeq_its2, physeq_d1d2, physeq_rpb2)
  sample_data(bread_all_final)$Marker &lt;- factor(sample_data(bread_all_final)$Marker, levels=c(&quot;ITS1&quot;,&quot;ITS2&quot;,&quot;D1D2&quot;,&quot;RPB2&quot;))  
  saveRDS(bread_all_final,&quot;REAL_MEAT/bread_final.rds&quot;)
}else{
  bread_all_final &lt;- readRDS(&quot;REAL_MEAT/bread_final.rds&quot;) 
}</code></pre>
<div id="sequencing-depth-5" class="section level3 tabset">
Olivier Rue's avatar
Olivier Rue committed
944
<h3>Sequencing depth</h3>
Olivier Rue's avatar
Olivier Rue committed
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
<pre class="r"><code>df &lt;- sample_data(bread_all_final) %&gt;% as(&quot;data.frame&quot;) %&gt;% 
  as_tibble(rownames = &quot;SampleID&quot;) %&gt;% 
  mutate(Final   = sample_sums(meat_all_final)) %&gt;% 
  rename(Initial = Reads)
ggplot(df %&gt;% pivot_longer(cols = c(Initial, Final), names_to = &quot;Step&quot;, values_to = &quot;Reads&quot;), 
       aes(x = SampleID, y = Reads, fill=Step)) + 
  geom_bar(stat=&#39;identity&#39;, position=&#39;identity&#39;) +
  facet_grid(~Marker, scales = &quot;free_x&quot;) +   
  scale_fill_brewer(palette = &quot;Reds&quot;, direction = -1) + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))</code></pre>
</div>
<div id="compositions-5" class="section level3">
<h3>Compositions</h3>
<pre class="r"><code>p &lt;- plot_composition(physeq = bread_all_final, taxaRank1 = &quot;Kingdom&quot;, taxaSet1 = &quot;Fungi&quot;, taxaRank2 = &quot;Species&quot;, numberOfTaxa = 22, x = &quot;Sample&quot;)
p + facet_grid(&quot;. ~ Marker&quot;, scales = &quot;free_x&quot;, space = &quot;free&quot;)</code></pre>
</div>
<div id="richness-5" class="section level3">
<h3>Richness</h3>
<pre class="r"><code>p &lt;- plot_richness(physeq = bread_all_final, x = &quot;Marker&quot;, color = &quot;Marker&quot;, shape = NULL, title = &quot;Alpha diversity graphics&quot;, measures = c(&quot;Observed&quot;, &quot;Chao1&quot;, &quot;ACE&quot;, &quot;Shannon&quot;, &quot;Simpson&quot;, &quot;InvSimpson&quot;, &quot;Fisher&quot;))
p + geom_boxplot() + NULL</code></pre>
</div>
<div id="beta-diversity-5" class="section level3">
<h3><span class="math inline">\(\beta\)</span> diversity</h3>
<pre class="r"><code>beta.dist &lt;- distance(bread_all_final, method = &quot;bray&quot;)
ord &lt;- ordinate(bread_all_final, method = &quot;MDS&quot;, distance = beta.dist)
p &lt;- plot_ordination(physeq = bread_all_final, ordination = ord, type = &quot;samples&quot;, axes = c(1, 2), color = &quot;Marker&quot;, shape = NULL, label = NULL, title = &quot;Samples ordination graphic, bray-curtis distance&quot;)
p &lt;- p + stat_ellipse(aes_string(group = &quot;Marker&quot;))
p + theme_bw()</code></pre>
</div>
<div id="common-families-5" class="section level3">
<h3>Common families</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1_final))$Family %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2_final))$Family %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2_final))$Family %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2_final))$Family %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
</div>
<div id="common-genus-5" class="section level3">
<h3>Common genus</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1_final))$Genus %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2_final))$Genus %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2_final))$Genus %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2_final))$Genus %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
</div>
</div>
</div>
<div id="wine" class="section level1">
<h1>WINE</h1>
<pre class="bash"><code>scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/WINE_REAL/results/DADA2_FROGS/ITS1/affiliation.biom REAL_WINE/ITS1.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/WINE_REAL/results/DADA2_FROGS/ITS2/affiliation.biom REAL_WINE/ITS2.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/WINE_REAL/results/DADA2_FROGS/D1D2/affiliation.biom REAL_WINE/D1D2.biom
scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/WINE_REAL/results/DADA2_FROGS/RPB2/affiliation.biom REAL_WINE/RPB2.biom

#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/ITS1/affiliation.tsv REAL_BREAD/ITS1.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/ITS2/affiliation.tsv REAL_BREAD/ITS2.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/D1D2/affiliation.tsv REAL_BREAD/D1D2.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/BREAD_REAL/results/DADA2_FROGS/RPB2/affiliation.tsv REAL_BREAD/RPB2.tsv

#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/ITS1/multiaff.tsv REAL_CHEESE/ITS1_multiaff.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/ITS2/multiaff.tsv REAL_CHEESE/ITS2_multiaff.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/D1D2/multiaff.tsv REAL_CHEESE/D1D2_multiaff.tsv
#scp orue@genologin.toulouse.inra.fr:/work/frogsfungi/FungiPubli/Real_mock/METABARFOOD/CHEESE_REAL/results/DADA2_FROGS/RPB2/multiaff.tsv REAL_CHEESE/RPB2_multiaff.tsv</code></pre>
<div id="analysis-of-raw-biom-files-3" class="section level2 tabset">
Olivier Rue's avatar
Olivier Rue committed
1015
<h2>Analysis of raw BIOM files</h2>
Olivier Rue's avatar
Olivier Rue committed
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
<pre class="r"><code>if (!file.exists(&quot;REAL_WINE/ITS1.rds&quot;)) {
  biomfile &lt;- &quot;REAL_WINE/ITS1.biom&quot;
  physeq_its1 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_its1) &lt;- gsub(tax_table(physeq_its1),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_WINE/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_its1) &lt;- metadata
  sample_data(physeq_its1)$Marker &lt;- &quot;ITS1&quot;
  sample_data(physeq_its1)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;WINE&quot;) %&gt;% filter(Marker == &quot;ITS1&quot;) %&gt;% pull(Reads)
  sample_names(physeq_its1) &lt;- glue::glue(paste(&quot;{sample_names(physeq_its1)}&quot;,&quot;ITS1&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_its1,&quot;REAL_WINE/ITS1.rds&quot;)
} else {
  physeq_its1 &lt;- readRDS(&quot;REAL_WINE/ITS1.rds&quot;)
}

if (!file.exists(&quot;REAL_WINE/ITS2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_WINE/ITS2.biom&quot;
  physeq_its2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_its2) &lt;- gsub(tax_table(physeq_its2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_WINE/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_its2) &lt;- metadata
  sample_data(physeq_its2)$Marker &lt;- &quot;ITS2&quot;
  sample_data(physeq_its2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;WINE&quot;) %&gt;% filter(Marker == &quot;ITS2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_its2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_its2)}&quot;,&quot;ITS2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_its2,&quot;REAL_WINE/ITS2.rds&quot;)
} else {
  physeq_its2 &lt;- readRDS(&quot;REAL_WINE/ITS2.rds&quot;)
}

if (!file.exists(&quot;REAL_WINE/D1D2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_WINE/D1D2.biom&quot;
  physeq_d1d2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_d1d2) &lt;- gsub(tax_table(physeq_d1d2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  tax_table(physeq_d1d2) &lt;- gsub(tax_table(physeq_d1d2),     pattern = &quot;Eukaryota&quot;, replacement = &quot;Fungi&quot;)
  metadata &lt;- read.table(&quot;REAL_WINE/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_d1d2) &lt;- metadata
  sample_data(physeq_d1d2)$Marker &lt;- &quot;D1D2&quot;
  sample_data(physeq_d1d2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;WINE&quot;) %&gt;% filter(Marker == &quot;D1D2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_d1d2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_d1d2)}&quot;,&quot;D1D2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_d1d2,&quot;REAL_WINE/D1D2.rds&quot;)
} else {
  physeq_d1d2 &lt;- readRDS(&quot;REAL_WINE/D1D2.rds&quot;)
}

if (!file.exists(&quot;REAL_WINE/RPB2.rds&quot;)) {
  biomfile &lt;- &quot;REAL_WINE/RPB2.biom&quot;
  physeq_rpb2 &lt;- import_frogs(biomfile, taxMethod = &quot;blast&quot;)
  tax_table(physeq_rpb2) &lt;- gsub(tax_table(physeq_rpb2),     pattern = &quot;[a-z]__&quot;, replacement = &quot;&quot;)
  metadata &lt;- read.table(&quot;REAL_WINE/metadata.tsv&quot;, row.names = 1, header = TRUE, sep = &quot;\t&quot;, stringsAsFactors = FALSE)
  sample_data(physeq_rpb2) &lt;- metadata
  sample_data(physeq_rpb2)$Marker &lt;- &quot;RPB2&quot;
  sample_data(physeq_rpb2)$Reads &lt;- raw_data %&gt;% filter(Ecosystem == &quot;WINE&quot;) %&gt;% filter(Marker == &quot;RPB2&quot;) %&gt;% pull(Reads)
  sample_names(physeq_rpb2) &lt;- glue::glue(paste(&quot;{sample_names(physeq_rpb2)}&quot;,&quot;RPB2&quot;, sep=&quot;_&quot;))
  saveRDS(physeq_rpb2,&quot;REAL_WINE/RPB2.rds&quot;)
} else {
  physeq_rpb2 &lt;- readRDS(&quot;REAL_WINE/RPB2.rds&quot;)
}</code></pre>
<pre class="r"><code>if (!file.exists(&quot;REAL_WINE/wine.rds&quot;)){
  wine_all &lt;- merge_phyloseq(physeq_its1, physeq_its2, physeq_d1d2, physeq_rpb2)
  sample_data(wine_all)$Marker &lt;- factor(sample_data(wine_all)$Marker, levels=c(&quot;ITS1&quot;,&quot;ITS2&quot;,&quot;D1D2&quot;,&quot;RPB2&quot;))  
  saveRDS(wine_all,&quot;REAL_WINE/wine.rds&quot;)
}else{
  wine_all &lt;- readRDS(&quot;REAL_WINE/wine.rds&quot;) 
}</code></pre>
<div id="sequencing-depth-6" class="section level3 tabset">
Olivier Rue's avatar
Olivier Rue committed
1080
<h3>Sequencing depth</h3>
Olivier Rue's avatar
Olivier Rue committed
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
<pre class="r"><code>df &lt;- sample_data(wine_all) %&gt;% as(&quot;data.frame&quot;) %&gt;% 
  as_tibble(rownames = &quot;SampleID&quot;) %&gt;% 
  mutate(Final   = sample_sums(wine_all)) %&gt;% 
  rename(Initial = Reads)
ggplot(df %&gt;% pivot_longer(cols = c(Initial, Final), names_to = &quot;Step&quot;, values_to = &quot;Reads&quot;), 
       aes(x = SampleID, y = Reads, fill=Step)) + 
  geom_bar(stat=&#39;identity&#39;, position=&#39;identity&#39;) +
  facet_grid(~Marker, scales = &quot;free_x&quot;) +   
  scale_fill_brewer(palette = &quot;Reds&quot;, direction = -1) + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))</code></pre>
Olivier Rue's avatar
Olivier Rue committed
1091
<p><img src="real_samples_files/figure-html/unnamed-chunk-63-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
1092
1093
1094
1095
1096
</div>
<div id="compositions-6" class="section level3">
<h3>Compositions</h3>
<pre class="r"><code>p &lt;- plot_composition(physeq = wine_all, taxaRank1 = &quot;Kingdom&quot;, taxaSet1 = &quot;Fungi&quot;, taxaRank2 = &quot;Species&quot;, numberOfTaxa = 22, x = &quot;Sample&quot;)
p + facet_grid(&quot;. ~ Marker&quot;, scales = &quot;free_x&quot;, space = &quot;free&quot;)</code></pre>
Olivier Rue's avatar
Olivier Rue committed
1097
<p><img src="real_samples_files/figure-html/unnamed-chunk-64-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
1098
1099
1100
1101
1102
</div>
<div id="richness-6" class="section level3">
<h3>Richness</h3>
<pre class="r"><code>p &lt;- plot_richness(physeq = wine_all, x = &quot;Marker&quot;, color = &quot;Marker&quot;, shape = NULL, title = &quot;Alpha diversity graphics&quot;, measures = c(&quot;Observed&quot;, &quot;Chao1&quot;, &quot;ACE&quot;, &quot;Shannon&quot;, &quot;Simpson&quot;, &quot;InvSimpson&quot;, &quot;Fisher&quot;))
p + geom_boxplot() + NULL</code></pre>
Olivier Rue's avatar
Olivier Rue committed
1103
<p><img src="real_samples_files/figure-html/unnamed-chunk-65-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
1104
1105
1106
1107
1108
1109
1110
1111
</div>
<div id="beta-diversity-6" class="section level3">
<h3><span class="math inline">\(\beta\)</span> diversity</h3>
<pre class="r"><code>beta.dist &lt;- distance(wine_all, method = &quot;bray&quot;)
ord &lt;- ordinate(wine_all, method = &quot;MDS&quot;, distance = beta.dist)
p &lt;- plot_ordination(physeq = wine_all, ordination = ord, type = &quot;samples&quot;, axes = c(1, 2), color = &quot;Marker&quot;, shape = NULL, label = NULL, title = &quot;Samples ordination graphic, bray-curtis distance&quot;)
p &lt;- p + stat_ellipse(aes_string(group = &quot;Marker&quot;))
p + theme_bw()</code></pre>
Olivier Rue's avatar
Olivier Rue committed
1112
<p><img src="real_samples_files/figure-html/unnamed-chunk-66-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
</div>
<div id="common-families-6" class="section level3">
<h3>Common families</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1))$Family %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2))$Family %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2))$Family %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2))$Family %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
1124
<p><img src="real_samples_files/figure-html/unnamed-chunk-67-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
</div>
<div id="common-genus-6" class="section level3">
<h3>Common genus</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1))$Genus %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2))$Genus %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2))$Genus %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2))$Genus %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
Olivier Rue's avatar
Olivier Rue committed
1136
<p><img src="real_samples_files/figure-html/unnamed-chunk-68-1.png" width="1008" /></p>
Olivier Rue's avatar
Olivier Rue committed
1137
1138
1139
</div>
</div>
<div id="manual-curation-3" class="section level2 tabset">
Olivier Rue's avatar
Olivier Rue committed
1140
<h2>Manual curation</h2>
Olivier Rue's avatar
Olivier Rue committed
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
<pre class="r"><code>tax_table(physeq_its1) &lt;- t
keptTaxa &lt;- setdiff(taxa_names(physeq_its1), to_remove)
physeq_its1_final &lt;- prune_taxa(keptTaxa, physeq_its1)
saveRDS(physeq_its1_final,&quot;REAL_BREAD/ITS1_final.rds&quot;)</code></pre>
<pre class="r"><code>if (!file.exists(&quot;REAL_MEAT/bread_final.rds&quot;)){
  bread_all_final &lt;- merge_phyloseq(physeq_its1_final, physeq_its2, physeq_d1d2, physeq_rpb2)
  sample_data(bread_all_final)$Marker &lt;- factor(sample_data(bread_all_final)$Marker, levels=c(&quot;ITS1&quot;,&quot;ITS2&quot;,&quot;D1D2&quot;,&quot;RPB2&quot;))  
  saveRDS(bread_all_final,&quot;REAL_MEAT/bread_final.rds&quot;)
}else{
  bread_all_final &lt;- readRDS(&quot;REAL_MEAT/bread_final.rds&quot;) 
}</code></pre>
<div id="sequencing-depth-7" class="section level3 tabset">
Olivier Rue's avatar
Olivier Rue committed
1153
<h3>Sequencing depth</h3>
Olivier Rue's avatar
Olivier Rue committed
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
<pre class="r"><code>df &lt;- sample_data(bread_all_final) %&gt;% as(&quot;data.frame&quot;) %&gt;% 
  as_tibble(rownames = &quot;SampleID&quot;) %&gt;% 
  mutate(Final   = sample_sums(meat_all_final)) %&gt;% 
  rename(Initial = Reads)
ggplot(df %&gt;% pivot_longer(cols = c(Initial, Final), names_to = &quot;Step&quot;, values_to = &quot;Reads&quot;), 
       aes(x = SampleID, y = Reads, fill=Step)) + 
  geom_bar(stat=&#39;identity&#39;, position=&#39;identity&#39;) +
  facet_grid(~Marker, scales = &quot;free_x&quot;) +   
  scale_fill_brewer(palette = &quot;Reds&quot;, direction = -1) + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))</code></pre>
</div>
<div id="compositions-7" class="section level3">
<h3>Compositions</h3>
<pre class="r"><code>p &lt;- plot_composition(physeq = bread_all_final, taxaRank1 = &quot;Kingdom&quot;, taxaSet1 = &quot;Fungi&quot;, taxaRank2 = &quot;Species&quot;, numberOfTaxa = 22, x = &quot;Sample&quot;)
p + facet_grid(&quot;. ~ Marker&quot;, scales = &quot;free_x&quot;, space = &quot;free&quot;)</code></pre>
</div>
<div id="richness-7" class="section level3">
<h3>Richness</h3>
<pre class="r"><code>p &lt;- plot_richness(physeq = bread_all_final, x = &quot;Marker&quot;, color = &quot;Marker&quot;, shape = NULL, title = &quot;Alpha diversity graphics&quot;, measures = c(&quot;Observed&quot;, &quot;Chao1&quot;, &quot;ACE&quot;, &quot;Shannon&quot;, &quot;Simpson&quot;, &quot;InvSimpson&quot;, &quot;Fisher&quot;))
p + geom_boxplot() + NULL</code></pre>
</div>
<div id="beta-diversity-7" class="section level3">
<h3><span class="math inline">\(\beta\)</span> diversity</h3>
<pre class="r"><code>beta.dist &lt;- distance(bread_all_final, method = &quot;bray&quot;)
ord &lt;- ordinate(bread_all_final, method = &quot;MDS&quot;, distance = beta.dist)
p &lt;- plot_ordination(physeq = bread_all_final, ordination = ord, type = &quot;samples&quot;, axes = c(1, 2), color = &quot;Marker&quot;, shape = NULL, label = NULL, title = &quot;Samples ordination graphic, bray-curtis distance&quot;)
p &lt;- p + stat_ellipse(aes_string(group = &quot;Marker&quot;))
p + theme_bw()</code></pre>
</div>
<div id="common-families-7" class="section level3">
<h3>Common families</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1_final))$Family %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2_final))$Family %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2_final))$Family %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2_final))$Family %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
</div>
<div id="common-genus-7" class="section level3">
<h3>Common genus</h3>
<pre class="r"><code>x &lt;- list(
  ITS1 = as_tibble(tax_table(physeq_its1_final))$Genus %&gt;% as.vector(), 
  ITS2 = as_tibble(tax_table(physeq_its2_final))$Genus %&gt;% as.vector(),
  D1D2 = as_tibble(tax_table(physeq_d1d2_final))$Genus %&gt;% as.vector(),
  RPB2 = as_tibble(tax_table(physeq_rpb2_final))$Genus %&gt;% as.vector()
  )
ggVennDiagram(x,label_alpha = 0) + 
  scale_fill_gradient(low = &quot;#F4FAFE&quot;, high = &quot;#4981BF&quot;) </code></pre>
</div>
</div>
</div>
Olivier Rue's avatar
Olivier Rue committed
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236



</div>
</div>

</div>

<script>

// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
  $('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
  bootstrapStylePandocTables();
});


</script>

<!-- tabsets -->

<script>
$(document).ready(function () {
  window.buildTabsets("TOC");
});

$(document).ready(function () {
  $('.tabset-dropdown > .nav-tabs > li').click(function () {
Olivier Rue's avatar
Olivier Rue committed
1237
    $(this).parent().toggleClass('nav-tabs-open');
Olivier Rue's avatar
Olivier Rue committed
1238
1239
1240
1241
1242
1243
1244
  });
});
</script>

<!-- code folding -->
<script>
$(document).ready(function () {
Olivier Rue's avatar
Olivier Rue committed
1245
  window.initializeCodeFolding("hide" === "show");
Olivier Rue's avatar
Olivier Rue committed
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
});
</script>

<script>
$(document).ready(function ()  {

    // move toc-ignore selectors from section div to header
    $('div.section.toc-ignore')
        .removeClass('toc-ignore')
        .children('h1,h2,h3,h4,h5').addClass('toc-ignore');

    // establish options
    var options = {
      selectors: "h1,h2,h3,h4,h5",
      theme: "bootstrap3",
      context: '.toc-content',
      hashGenerator: function (text) {
        return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
      },
      ignoreSelector: ".toc-ignore",
      scrollTo: 0
    };
    options.showAndHide = true;
    options.smoothScroll = true;

    // tocify
    var toc = $("#TOC").tocify(options).data("toc-tocify");
});
</script>

<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src  = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script>

</body>
</html>