-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprepare-data_pavkovic_2019.html
1189 lines (1102 loc) · 67 KB
/
prepare-data_pavkovic_2019.html
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
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
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
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
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
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
<!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 Sand and Jacques van Helden" />
<meta name="date" content="2020-06-02" />
<title>DU-Bii Study cases - Mouse fibrotic kidney</title>
<script src="prepare-data_pavkovic_2019_files/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="prepare-data_pavkovic_2019_files/bootstrap-3.3.5/css/cerulean.min.css" rel="stylesheet" />
<script src="prepare-data_pavkovic_2019_files/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="prepare-data_pavkovic_2019_files/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="prepare-data_pavkovic_2019_files/bootstrap-3.3.5/shim/respond.min.js"></script>
<script src="prepare-data_pavkovic_2019_files/jqueryui-1.11.4/jquery-ui.min.js"></script>
<link href="prepare-data_pavkovic_2019_files/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="prepare-data_pavkovic_2019_files/tocify-1.9.1/jquery.tocify.js"></script>
<script src="prepare-data_pavkovic_2019_files/navigation-1.1/tabsets.js"></script>
<script src="prepare-data_pavkovic_2019_files/navigation-1.1/codefolding.js"></script>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css" data-origin="pandoc">
a.sourceLine { display: inline-block; line-height: 1.25; }
a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
a.sourceLine:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode { white-space: pre; position: relative; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
code.sourceCode { white-space: pre-wrap; }
a.sourceLine { text-indent: -1em; padding-left: 1em; }
}
pre.numberSource a.sourceLine
{ position: relative; left: -4em; }
pre.numberSource a.sourceLine::before
{ content: attr(data-line-number);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; pointer-events: all; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ color: #cccccc; background-color: #303030; }
@media screen {
a.sourceLine::before { text-decoration: underline; }
}
code span.al { color: #ffcfaf; } /* Alert */
code span.an { color: #7f9f7f; font-weight: bold; } /* Annotation */
code span.at { } /* Attribute */
code span.bn { color: #dca3a3; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #f0dfaf; } /* ControlFlow */
code span.ch { color: #dca3a3; } /* Char */
code span.cn { color: #dca3a3; font-weight: bold; } /* Constant */
code span.co { color: #7f9f7f; } /* Comment */
code span.cv { color: #7f9f7f; font-weight: bold; } /* CommentVar */
code span.do { color: #7f9f7f; } /* Documentation */
code span.dt { color: #dfdfbf; } /* DataType */
code span.dv { color: #dcdccc; } /* DecVal */
code span.er { color: #c3bf9f; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #c0bed1; } /* Float */
code span.fu { color: #efef8f; } /* Function */
code span.im { } /* Import */
code span.in { color: #7f9f7f; font-weight: bold; } /* Information */
code span.kw { color: #f0dfaf; } /* Keyword */
code span.op { color: #f0efd0; } /* Operator */
code span.ot { color: #efef8f; } /* Other */
code span.pp { color: #ffcfaf; font-weight: bold; } /* Preprocessor */
code span.sc { color: #dca3a3; } /* SpecialChar */
code span.ss { color: #cc9393; } /* SpecialString */
code span.st { color: #cc9393; } /* String */
code span.va { } /* Variable */
code span.vs { color: #cc9393; } /* VerbatimString */
code span.wa { color: #7f9f7f; font-weight: bold; } /* Warning */
.sourceCode .row {
width: 100%;
}
.sourceCode {
overflow-x: auto;
}
.code-folding-btn {
margin-right: -30px;
}
</style>
<script>
// apply pandoc div.sourceCode style to pre.sourceCode instead
(function() {
var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
for (var j = 0; j < rules.length; j++) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue;
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' && rule.style.backgroundColor === '') continue;
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
}
}
})();
</script>
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
<style type="text/css">
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;
}
.table th:not([align]) {
text-align: left;
}
</style>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
code {
color: inherit;
background-color: rgba(0, 0, 0, 0.04);
}
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;
}
</style>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
background: white;
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: "";
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 -->
<div class="row-fluid">
<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">
<div class="fluid-row" id="header">
<div class="btn-group pull-right">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span>Code</span> <span class="caret"></span></button>
<ul class="dropdown-menu" style="min-width: 50px;">
<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">DU-Bii Study cases - Mouse fibrotic kidney</h1>
<h3 class="subtitle">DUBii 2020</h3>
<h4 class="author">Olivier Sand and Jacques van Helden</h4>
<h4 class="date">2020-06-02</h4>
</div>
<div id="reference" class="section level2">
<h2>Reference</h2>
<p>Pavkovic, M., Pantano, L., Gerlach, C.V. et al. Multi omics analysis of fibrotic kidneys in two mouse models. Sci Data 6, 92 (2019).</p>
<ul>
<li><a href="https://doi.org/10.1038/s41597-019-0095-5" class="uri">https://doi.org/10.1038/s41597-019-0095-5</a></li>
<li><a href="https://www.nature.com/articles/s41597-019-0095-5#citeas" class="uri">https://www.nature.com/articles/s41597-019-0095-5#citeas</a></li>
<li>Mouse fibrotic kidney browser: <a href="http://hbcreports.med.harvard.edu/fmm/" class="uri">http://hbcreports.med.harvard.edu/fmm/</a></li>
<li>Data on Zenodo: <a href="https://zenodo.org/record/2592516" class="uri">https://zenodo.org/record/2592516</a></li>
</ul>
</div>
<div id="samples" class="section level2">
<h2>Samples</h2>
<blockquote>
<p>Samples from two mouse models were collected. The first one is a reversible chemical-induced injury model (folic acid (FA) induced nephropathy). The second one is an irreversible surgically-induced fibrosis model (unilateral ureteral obstruction (UUO)). mRNA and small RNA sequencing, as well as 10-plex tandem mass tag (TMT) proteomics were performed with kidney samples from different time points over the course of fibrosis development. In the FA model, mice were sacrificed before the treatment (day 0) and 1, 2, 7, and 14 days after a single injection of folic acid. For the UUO model, mice were sacrificed before obstruction (day 0) and 3, 7, and 14 days after the ureter of the left kidney was obstructed via ligation. For both studies, kidneys were removed at each time point for total RNA isolation and protein sample preparation.</p>
</blockquote>
<p>We will first explore the UUO transcriptome data.</p>
</div>
<div id="data-sources" class="section level2">
<h2>Data sources</h2>
<table>
<colgroup>
<col width="52%" />
<col width="47%" />
</colgroup>
<thead>
<tr class="header">
<th align="left">Doc</th>
<th align="left">URL</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">Total RNA for the experiment on Unilateral ureter obstruction (UUO) model</td>
<td align="left"><a href="https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE118339" class="uri">https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE118339</a></td>
</tr>
</tbody>
</table>
</div>
<div id="parameters" class="section level2">
<h2>Parameters</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="co">#### Define parameters for the analysis ####</span></a>
<a class="sourceLine" id="cb1-2" data-line-number="2"></a>
<a class="sourceLine" id="cb1-3" data-line-number="3"><span class="co">## Keep a trace of the original parameters</span></a>
<a class="sourceLine" id="cb1-4" data-line-number="4">par.ori <-<span class="st"> </span><span class="kw">par</span>(<span class="dt">no.readonly =</span> <span class="ot">TRUE</span>)</a>
<a class="sourceLine" id="cb1-5" data-line-number="5"></a>
<a class="sourceLine" id="cb1-6" data-line-number="6"><span class="co">## Analysis parameters</span></a>
<a class="sourceLine" id="cb1-7" data-line-number="7">parameters <-<span class="st"> </span><span class="kw">list</span>(</a>
<a class="sourceLine" id="cb1-8" data-line-number="8"> <span class="dt">dataset =</span> <span class="st">"uuo"</span>, <span class="co">## Supported: uuo, fa</span></a>
<a class="sourceLine" id="cb1-9" data-line-number="9"> <span class="dt">datatype =</span> <span class="st">"transcriptome"</span>,</a>
<a class="sourceLine" id="cb1-10" data-line-number="10"> <span class="dt">epsilon =</span> <span class="fl">0.1</span>,</a>
<a class="sourceLine" id="cb1-11" data-line-number="11"> <span class="dt">minCount =</span> <span class="dv">10</span>,</a>
<a class="sourceLine" id="cb1-12" data-line-number="12"> <span class="dt">forceDownload =</span> <span class="ot">FALSE</span>)</a>
<a class="sourceLine" id="cb1-13" data-line-number="13"></a>
<a class="sourceLine" id="cb1-14" data-line-number="14"><span class="kw">kable</span>(<span class="kw">as.data.frame</span>(parameters))</a></code></pre></div>
<table>
<thead>
<tr class="header">
<th align="left">dataset</th>
<th align="left">datatype</th>
<th align="right">epsilon</th>
<th align="right">minCount</th>
<th align="left">forceDownload</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">uuo</td>
<td align="left">transcriptome</td>
<td align="right">0.1</td>
<td align="right">10</td>
<td align="left">FALSE</td>
</tr>
</tbody>
</table>
</div>
<div id="output-directories" class="section level2">
<h2>Output directories</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" data-line-number="1"><span class="co">#### Output directories ####</span></a>
<a class="sourceLine" id="cb2-2" data-line-number="2">outdirs <-<span class="st"> </span><span class="kw">list</span>()</a>
<a class="sourceLine" id="cb2-3" data-line-number="3"><span class="co"># outdirs$main <- getwd()</span></a>
<a class="sourceLine" id="cb2-4" data-line-number="4">outdirs<span class="op">$</span>main <-<span class="st"> "."</span></a>
<a class="sourceLine" id="cb2-5" data-line-number="5"></a>
<a class="sourceLine" id="cb2-6" data-line-number="6"><span class="co">## Data directory, where the data will be downloaded and uncompressed</span></a>
<a class="sourceLine" id="cb2-7" data-line-number="7">outdirs<span class="op">$</span>data <-<span class="st"> </span><span class="kw">file.path</span>(outdirs<span class="op">$</span>main, <span class="st">"data"</span>)</a>
<a class="sourceLine" id="cb2-8" data-line-number="8"><span class="kw">dir.create</span>(outdirs<span class="op">$</span>data, <span class="dt">recursive =</span> <span class="ot">TRUE</span>, <span class="dt">showWarnings =</span> <span class="ot">FALSE</span>)</a>
<a class="sourceLine" id="cb2-9" data-line-number="9"></a>
<a class="sourceLine" id="cb2-10" data-line-number="10"><span class="co">## Main result directory</span></a>
<a class="sourceLine" id="cb2-11" data-line-number="11">outdirs<span class="op">$</span>results <-<span class="st"> </span><span class="kw">file.path</span>(outdirs<span class="op">$</span>main, <span class="st">"results"</span>)</a>
<a class="sourceLine" id="cb2-12" data-line-number="12"></a>
<a class="sourceLine" id="cb2-13" data-line-number="13"><span class="co"># Transcriptome results</span></a>
<a class="sourceLine" id="cb2-14" data-line-number="14">outdirs<span class="op">$</span>transcriptome <-<span class="st"> </span><span class="kw">file.path</span>(outdirs<span class="op">$</span>results, <span class="st">"transcriptome"</span>)</a>
<a class="sourceLine" id="cb2-15" data-line-number="15"><span class="kw">dir.create</span>(outdirs<span class="op">$</span>transcriptome, <span class="dt">recursive =</span> <span class="ot">TRUE</span>, <span class="dt">showWarnings =</span> <span class="ot">FALSE</span>)</a></code></pre></div>
</div>
<div id="download-transcriptome-data" class="section level2">
<h2>Download transcriptome data</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="co">#### Download transcriptome data ####</span></a>
<a class="sourceLine" id="cb3-2" data-line-number="2">archiveFile <-<span class="st"> "MouseKidneyFibrOmics-v1.0.zip"</span></a>
<a class="sourceLine" id="cb3-3" data-line-number="3">archiveURL <-<span class="st"> </span><span class="kw">file.path</span>(<span class="st">"https://zenodo.org/record/2592516/files/hbc"</span>, archiveFile)</a>
<a class="sourceLine" id="cb3-4" data-line-number="4">localDataArchive <-<span class="st"> </span><span class="kw">file.path</span>(outdirs<span class="op">$</span>data, archiveFile)</a>
<a class="sourceLine" id="cb3-5" data-line-number="5"></a>
<a class="sourceLine" id="cb3-6" data-line-number="6"><span class="cf">if</span> (<span class="kw">file.exists</span>(localDataArchive) <span class="op">&</span><span class="st"> </span><span class="op">!</span>parameters<span class="op">$</span>forceDownload) {</a>
<a class="sourceLine" id="cb3-7" data-line-number="7"> <span class="kw">message</span>(<span class="st">"Data archive already downloaded:</span><span class="ch">\n\t</span><span class="st">"</span>, localDataArchive)</a>
<a class="sourceLine" id="cb3-8" data-line-number="8">} <span class="cf">else</span> {</a>
<a class="sourceLine" id="cb3-9" data-line-number="9"> <span class="kw">message</span>(<span class="st">"Downloading data archive from zenodo: "</span>, archiveURL)</a>
<a class="sourceLine" id="cb3-10" data-line-number="10"> <span class="kw">download.file</span>(<span class="dt">url =</span> archiveURL, <span class="dt">destfile =</span> localDataArchive)</a>
<a class="sourceLine" id="cb3-11" data-line-number="11"> </a>
<a class="sourceLine" id="cb3-12" data-line-number="12"> <span class="co">## Uncompess the archive</span></a>
<a class="sourceLine" id="cb3-13" data-line-number="13"> <span class="kw">message</span>(<span class="st">"Uncompressing data archive"</span>)</a>
<a class="sourceLine" id="cb3-14" data-line-number="14"> <span class="kw">unzip</span>(<span class="dt">zipfile =</span> localDataArchive, <span class="dt">exdir =</span> outdirs<span class="op">$</span>data)</a>
<a class="sourceLine" id="cb3-15" data-line-number="15">}</a>
<a class="sourceLine" id="cb3-16" data-line-number="16"></a>
<a class="sourceLine" id="cb3-17" data-line-number="17"><span class="co">## Define destination directory</span></a>
<a class="sourceLine" id="cb3-18" data-line-number="18"><span class="co"># outdirs$csv <- file.path(outdirs$data, "CSV")</span></a>
<a class="sourceLine" id="cb3-19" data-line-number="19"><span class="co"># dir.create(outdirs$csv, showWarnings = FALSE, recursive = TRUE)</span></a></code></pre></div>
</div>
<div id="load-raw-counts" class="section level2">
<h2>Load raw counts</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1"><span class="co">#### Load raw counts data table ####</span></a>
<a class="sourceLine" id="cb4-2" data-line-number="2"></a>
<a class="sourceLine" id="cb4-3" data-line-number="3"></a>
<a class="sourceLine" id="cb4-4" data-line-number="4"><span class="co">## Note: the "raw" counts are decimal numbers, I suspect that they have been somewhat normalised. To check. </span></a>
<a class="sourceLine" id="cb4-5" data-line-number="5">rawCountFile <-<span class="st"> </span><span class="kw">file.path</span>(</a>
<a class="sourceLine" id="cb4-6" data-line-number="6"> outdirs<span class="op">$</span>data,</a>
<a class="sourceLine" id="cb4-7" data-line-number="7"> <span class="kw">paste0</span>(<span class="st">"hbc-MouseKidneyFibrOmics-a39e55a/tables/"</span>, </a>
<a class="sourceLine" id="cb4-8" data-line-number="8"> parameters<span class="op">$</span>dataset, </a>
<a class="sourceLine" id="cb4-9" data-line-number="9"> <span class="st">"/results/counts/raw_counts.csv.gz"</span>))</a>
<a class="sourceLine" id="cb4-10" data-line-number="10"> <span class="co"># "hbc-MouseKidneyFibrOmics-a39e55a/tables/fa/results/counts/raw_counts.csv.gz")</span></a>
<a class="sourceLine" id="cb4-11" data-line-number="11">rawValues <-<span class="st"> </span><span class="kw">read.csv</span>(<span class="dt">file =</span> rawCountFile, <span class="dt">header =</span> <span class="dv">1</span>, <span class="dt">row.names =</span> <span class="dv">1</span>)</a></code></pre></div>
<p>The RNA-seq transcriptome data was loaded as raw counts. This table contains 46679 rows (genes) and 15 columns (samples).</p>
</div>
<div id="build-metadata-table" class="section level2">
<h2>Build metadata table</h2>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="co">#### Build metadata table ####</span></a>
<a class="sourceLine" id="cb5-2" data-line-number="2">metadata <-<span class="st"> </span><span class="kw">data.frame</span>(</a>
<a class="sourceLine" id="cb5-3" data-line-number="3"> <span class="dt">dataType =</span> <span class="st">"transcriptome"</span>,</a>
<a class="sourceLine" id="cb5-4" data-line-number="4"> <span class="dt">sampleName =</span> <span class="kw">colnames</span>(rawValues))</a>
<a class="sourceLine" id="cb5-5" data-line-number="5">metadata[ , <span class="kw">c</span>(<span class="st">"condition"</span>, <span class="st">"sampleNumber"</span>)] <-<span class="st"> </span></a>
<a class="sourceLine" id="cb5-6" data-line-number="6"><span class="st"> </span><span class="kw">str_split_fixed</span>(<span class="dt">string =</span> metadata<span class="op">$</span>sampleName, <span class="dt">pattern =</span> <span class="st">"_"</span>, <span class="dt">n =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb5-7" data-line-number="7"></a>
<a class="sourceLine" id="cb5-8" data-line-number="8"><span class="co">## Colors per condition</span></a>
<a class="sourceLine" id="cb5-9" data-line-number="9">colPerCondition <-<span class="st"> </span><span class="kw">c</span>(<span class="dt">normal =</span> <span class="st">"#BBFFBB"</span>,</a>
<a class="sourceLine" id="cb5-10" data-line-number="10"> <span class="dt">day3 =</span> <span class="st">"#FFFFDD"</span>, </a>
<a class="sourceLine" id="cb5-11" data-line-number="11"> <span class="dt">day7 =</span> <span class="st">"#FFDD88"</span>,</a>
<a class="sourceLine" id="cb5-12" data-line-number="12"> <span class="dt">day14 =</span> <span class="st">"#FF4400"</span>)</a>
<a class="sourceLine" id="cb5-13" data-line-number="13">metadata<span class="op">$</span>color <-<span class="st"> </span>colPerCondition[metadata<span class="op">$</span>condition]</a></code></pre></div>
</div>
<div id="compute-sample-wise-statistics" class="section level2">
<h2>Compute sample-wise statistics</h2>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" data-line-number="1">sampleStat <-<span class="st"> </span>metadata</a>
<a class="sourceLine" id="cb6-2" data-line-number="2">sampleStat<span class="op">$</span>mean <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, mean)</a>
<a class="sourceLine" id="cb6-3" data-line-number="3">sampleStat<span class="op">$</span>median <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, median)</a>
<a class="sourceLine" id="cb6-4" data-line-number="4">sampleStat<span class="op">$</span>sd <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, sd)</a>
<a class="sourceLine" id="cb6-5" data-line-number="5">sampleStat<span class="op">$</span>min <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, min)</a>
<a class="sourceLine" id="cb6-6" data-line-number="6">sampleStat<span class="op">$</span>perc05 <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, quantile, <span class="dt">prob =</span> <span class="fl">0.05</span>)</a>
<a class="sourceLine" id="cb6-7" data-line-number="7">sampleStat<span class="op">$</span>Q1 <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, quantile, <span class="dt">prob =</span> <span class="fl">0.25</span>)</a>
<a class="sourceLine" id="cb6-8" data-line-number="8">sampleStat<span class="op">$</span>median <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, quantile, <span class="dt">prob =</span> <span class="fl">0.5</span>)</a>
<a class="sourceLine" id="cb6-9" data-line-number="9">sampleStat<span class="op">$</span>Q3 <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, quantile, <span class="dt">prob =</span> <span class="fl">0.75</span>)</a>
<a class="sourceLine" id="cb6-10" data-line-number="10">sampleStat<span class="op">$</span>perc95 <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, quantile, <span class="dt">prob =</span> <span class="fl">0.95</span>)</a>
<a class="sourceLine" id="cb6-11" data-line-number="11">sampleStat<span class="op">$</span>max <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, max)</a>
<a class="sourceLine" id="cb6-12" data-line-number="12">sampleStat<span class="op">$</span>iqr <-<span class="st"> </span><span class="kw">apply</span>(<span class="dt">X =</span> rawValues, <span class="dv">2</span>, IQR)</a>
<a class="sourceLine" id="cb6-13" data-line-number="13"></a>
<a class="sourceLine" id="cb6-14" data-line-number="14"><span class="co">## Print statistics per sample</span></a>
<a class="sourceLine" id="cb6-15" data-line-number="15"><span class="kw">kable</span>(<span class="kw">format</span>(<span class="dt">x =</span> <span class="kw">format</span>(<span class="dt">digits =</span> <span class="dv">5</span>, sampleStat)))</a></code></pre></div>
<table>
<thead>
<tr class="header">
<th align="left">dataType</th>
<th align="left">sampleName</th>
<th align="left">condition</th>
<th align="left">sampleNumber</th>
<th align="left">color</th>
<th align="left">mean</th>
<th align="left">median</th>
<th align="left">sd</th>
<th align="left">min</th>
<th align="left">perc05</th>
<th align="left">Q1</th>
<th align="left">Q3</th>
<th align="left">perc95</th>
<th align="left">max</th>
<th align="left">iqr</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">transcriptome</td>
<td align="left">day14_12</td>
<td align="left">day14</td>
<td align="left">12</td>
<td align="left">#FF4400</td>
<td align="left">577.40</td>
<td align="left">1.32543</td>
<td align="left">4020.5</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">227.855</td>
<td align="left">2563.5</td>
<td align="left">480841</td>
<td align="left">227.855</td>
</tr>
<tr class="even">
<td align="left">transcriptome</td>
<td align="left">day14_13</td>
<td align="left">day14</td>
<td align="left">13</td>
<td align="left">#FF4400</td>
<td align="left">317.42</td>
<td align="left">0.99779</td>
<td align="left">2538.1</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">130.509</td>
<td align="left">1371.5</td>
<td align="left">258977</td>
<td align="left">130.509</td>
</tr>
<tr class="odd">
<td align="left">transcriptome</td>
<td align="left">day14_14</td>
<td align="left">day14</td>
<td align="left">14</td>
<td align="left">#FF4400</td>
<td align="left">439.77</td>
<td align="left">1.19451</td>
<td align="left">2758.5</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">190.710</td>
<td align="left">2043.2</td>
<td align="left">280431</td>
<td align="left">190.710</td>
</tr>
<tr class="even">
<td align="left">transcriptome</td>
<td align="left">day14_15</td>
<td align="left">day14</td>
<td align="left">15</td>
<td align="left">#FF4400</td>
<td align="left">464.17</td>
<td align="left">1.24853</td>
<td align="left">5165.5</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">180.824</td>
<td align="left">1855.8</td>
<td align="left">693041</td>
<td align="left">180.824</td>
</tr>
<tr class="odd">
<td align="left">transcriptome</td>
<td align="left">day3_4</td>
<td align="left">day3</td>
<td align="left">4</td>
<td align="left">#FFFFDD</td>
<td align="left">736.30</td>
<td align="left">1.00880</td>
<td align="left">8571.4</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">197.157</td>
<td align="left">2901.5</td>
<td align="left">923949</td>
<td align="left">197.157</td>
</tr>
<tr class="even">
<td align="left">transcriptome</td>
<td align="left">day3_5</td>
<td align="left">day3</td>
<td align="left">5</td>
<td align="left">#FFFFDD</td>
<td align="left">670.62</td>
<td align="left">1.67158</td>
<td align="left">7646.5</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">222.837</td>
<td align="left">2687.5</td>
<td align="left">874143</td>
<td align="left">222.837</td>
</tr>
<tr class="odd">
<td align="left">transcriptome</td>
<td align="left">day3_6</td>
<td align="left">day3</td>
<td align="left">6</td>
<td align="left">#FFFFDD</td>
<td align="left">657.52</td>
<td align="left">1.02132</td>
<td align="left">8424.8</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">181.088</td>
<td align="left">2513.6</td>
<td align="left">987332</td>
<td align="left">181.088</td>
</tr>
<tr class="even">
<td align="left">transcriptome</td>
<td align="left">day3_7</td>
<td align="left">day3</td>
<td align="left">7</td>
<td align="left">#FFFFDD</td>
<td align="left">762.34</td>
<td align="left">1.20783</td>
<td align="left">11164.8</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">216.455</td>
<td align="left">2781.6</td>
<td align="left">1349892</td>
<td align="left">216.455</td>
</tr>
<tr class="odd">
<td align="left">transcriptome</td>
<td align="left">day7_10</td>
<td align="left">day7</td>
<td align="left">10</td>
<td align="left">#FFDD88</td>
<td align="left">747.06</td>
<td align="left">1.72124</td>
<td align="left">7495.7</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">242.263</td>
<td align="left">3132.0</td>
<td align="left">889506</td>
<td align="left">242.263</td>
</tr>
<tr class="even">
<td align="left">transcriptome</td>
<td align="left">day7_11</td>
<td align="left">day7</td>
<td align="left">11</td>
<td align="left">#FFDD88</td>
<td align="left">507.88</td>
<td align="left">1.01550</td>
<td align="left">4781.0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">185.765</td>
<td align="left">2135.0</td>
<td align="left">556133</td>
<td align="left">185.765</td>
</tr>
<tr class="odd">
<td align="left">transcriptome</td>
<td align="left">day7_8</td>
<td align="left">day7</td>
<td align="left">8</td>
<td align="left">#FFDD88</td>
<td align="left">724.46</td>
<td align="left">1.47772</td>
<td align="left">7201.4</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">236.473</td>
<td align="left">3005.6</td>
<td align="left">904431</td>
<td align="left">236.473</td>
</tr>
<tr class="even">
<td align="left">transcriptome</td>
<td align="left">day7_9</td>
<td align="left">day7</td>
<td align="left">9</td>
<td align="left">#FFDD88</td>
<td align="left">756.34</td>
<td align="left">1.99637</td>
<td align="left">6429.8</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">291.494</td>
<td align="left">3264.0</td>
<td align="left">733494</td>
<td align="left">291.494</td>
</tr>
<tr class="odd">
<td align="left">transcriptome</td>
<td align="left">normal_1</td>
<td align="left">normal</td>
<td align="left">1</td>
<td align="left">#BBFFBB</td>
<td align="left">801.47</td>
<td align="left">0.95108</td>
<td align="left">11585.8</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">123.308</td>
<td align="left">2740.6</td>
<td align="left">1259045</td>
<td align="left">123.308</td>
</tr>
<tr class="even">
<td align="left">transcriptome</td>
<td align="left">normal_2</td>
<td align="left">normal</td>
<td align="left">2</td>
<td align="left">#BBFFBB</td>
<td align="left">585.72</td>
<td align="left">0.00000</td>
<td align="left">8237.1</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">88.908</td>
<td align="left">2035.8</td>
<td align="left">912206</td>
<td align="left">88.908</td>
</tr>
<tr class="odd">
<td align="left">transcriptome</td>
<td align="left">normal_3</td>
<td align="left">normal</td>
<td align="left">3</td>
<td align="left">#BBFFBB</td>
<td align="left">638.52</td>
<td align="left">0.77229</td>
<td align="left">9846.7</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">0</td>
<td align="left">95.103</td>
<td align="left">2149.2</td>
<td align="left">1101035</td>
<td align="left">95.103</td>
</tr>
</tbody>
</table>
</div>
<div id="distribution-of-raw-counts" class="section level2">
<h2>Distribution of raw counts</h2>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1"><span class="kw">hist</span>(<span class="kw">unlist</span>(rawValues), <span class="dt">breaks =</span> <span class="dv">1000</span>, </a>
<a class="sourceLine" id="cb7-2" data-line-number="2"> <span class="dt">main =</span> <span class="st">"Raw count distribution"</span>, </a>
<a class="sourceLine" id="cb7-3" data-line-number="3"> <span class="dt">xlab =</span> <span class="st">"Raw counts"</span>, </a>
<a class="sourceLine" id="cb7-4" data-line-number="4"> <span class="dt">ylab =</span> <span class="st">"Number of genes (all samples)"</span>)</a></code></pre></div>
<div class="figure" style="text-align: center">
<img src="figures/mouse-kidney_RNA-seq_count_distrib-1.png" alt="Distribution of raw counts" width="70%" />
<p class="caption">
Distribution of raw counts
</p>
</div>
<p>The distribution of raw counts is not very informative, because the range is defined by some outlier, i.e. a gene having a huge number of reads. Even with strong zoom on the abcsissa range from 0 to 500, the histogram shows a steep drop in the first bins.</p>
</div>
<div id="distribution-of-raw-counts---truncated-abscissa" class="section level2">
<h2>Distribution of raw counts - truncated abscissa</h2>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" data-line-number="1"><span class="co">#### Count distrib - truncated abscissa ####</span></a>
<a class="sourceLine" id="cb8-2" data-line-number="2"><span class="kw">hist</span>(<span class="kw">unlist</span>(rawValues), <span class="dt">breaks =</span> <span class="dv">500000</span>, </a>
<a class="sourceLine" id="cb8-3" data-line-number="3"> <span class="dt">main =</span> <span class="st">"Raw count distribution"</span>, </a>
<a class="sourceLine" id="cb8-4" data-line-number="4"> <span class="dt">xlab =</span> <span class="st">"Raw counts (truncated abscissa"</span>, </a>
<a class="sourceLine" id="cb8-5" data-line-number="5"> <span class="dt">ylab =</span> <span class="st">"Number of genes (all samples)"</span>,</a>
<a class="sourceLine" id="cb8-6" data-line-number="6"> <span class="dt">xlim =</span> <span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">500</span>))</a></code></pre></div>
<div class="figure" style="text-align: center">
<img src="figures/mouse-kidney_RNA-seq_count_distrib_truncated-1.png" alt="Distribution of raw counts" width="70%" />
<p class="caption">
Distribution of raw counts
</p>
</div>
</div>
<div id="log2-transformed-counts" class="section level2">
<h2>Log2-transformed counts</h2>
<p>A typical approach is to normalise the counts by applying a log2 transformation . This however creates a problem when the counts of a given gene in a given sample is 0. To circumvent this, we can add an epsilon (<span class="math inline">\(\epsilon = 0.1\)</span>) before the log2 transformation.</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" data-line-number="1"><span class="co">#### Log2 transformatiojn of the counts ####</span></a>
<a class="sourceLine" id="cb9-2" data-line-number="2">log2Values <-<span class="st"> </span><span class="kw">log2</span>(rawValues <span class="op">+</span><span class="st"> </span>parameters<span class="op">$</span>epsilon)</a>
<a class="sourceLine" id="cb9-3" data-line-number="3"><span class="kw">hist</span>(<span class="kw">unlist</span>(log2Values), <span class="dt">breaks =</span> <span class="kw">seq</span>(<span class="dt">from =</span> <span class="dv">-5</span>, <span class="dt">to =</span> <span class="dv">22</span>, <span class="dt">by =</span> <span class="fl">0.1</span>),</a>
<a class="sourceLine" id="cb9-4" data-line-number="4"> <span class="dt">main =</span> <span class="st">"log2-counts distribution"</span>,</a>
<a class="sourceLine" id="cb9-5" data-line-number="5"> <span class="dt">xlab =</span> <span class="st">"log2(Counts + epsilon)"</span>, </a>
<a class="sourceLine" id="cb9-6" data-line-number="6"> <span class="dt">ylab =</span> <span class="st">"Number of genes"</span>, <span class="dt">col =</span> <span class="st">"#BBFFBB"</span>)</a></code></pre></div>
<p><img src="figures/mouse-kidney_log2_counts-1.png" width="70%" style="display: block; margin: auto;" /></p>
</div>
<div id="two-columns-test" class="section level2">
<h2>Two-columns test</h2>
<div class="columns">
<div class="column">
<p>contents 1 …</p>
</div><div class="column">
<p>pas l’air de marcher …</p>
</div>
</div>
</div>
<div id="box-plots" class="section level2">
<h2>Box plots</h2>
<p>We can now inspect the distribution of counts per sample with the <code>boxplot()</code> function.</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb10-1" data-line-number="1"><span class="co">#### Box plots ####</span></a>
<a class="sourceLine" id="cb10-2" data-line-number="2"><span class="kw">par</span>(<span class="dt">mar =</span> <span class="kw">c</span>(<span class="dv">4</span>, <span class="dv">6</span>, <span class="dv">5</span>, <span class="dv">1</span>))</a>
<a class="sourceLine" id="cb10-3" data-line-number="3"><span class="kw">boxplot</span>(log2Values, </a>
<a class="sourceLine" id="cb10-4" data-line-number="4"> <span class="dt">col =</span> metadata<span class="op">$</span>color,</a>
<a class="sourceLine" id="cb10-5" data-line-number="5"> <span class="dt">horizontal =</span> <span class="ot">TRUE</span>, </a>
<a class="sourceLine" id="cb10-6" data-line-number="6"> <span class="dt">las =</span> <span class="dv">1</span>, </a>
<a class="sourceLine" id="cb10-7" data-line-number="7"> <span class="dt">main =</span> <span class="st">"log2-transformed"</span>, </a>
<a class="sourceLine" id="cb10-8" data-line-number="8"> <span class="dt">xlab =</span> <span class="st">"log2(counts)"</span>)</a></code></pre></div>
<p><img src="figures/mouse-kidney_box%20plots-1.png" width="25%" style="display: block; margin: auto;" /></p>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb11-1" data-line-number="1"><span class="kw">par</span>(par.ori)</a></code></pre></div>
</div>
<div id="box-plot-comment" class="section level2">
<h2>Box plot comment</h2>
<p>We notice an obvious problem: the vast majority of counts is very small. This can result from different causes, which will not be investigated in this context.</p>
</div>
<div id="gene-filtering" class="section level2">
<h2>Gene filtering</h2>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" data-line-number="1"><span class="co">## Filter out the genes with very low counts in all conditions</span></a>
<a class="sourceLine" id="cb12-2" data-line-number="2">undetectedGenes <-<span class="st"> </span><span class="kw">apply</span>(rawValues, <span class="dt">MARGIN =</span> <span class="dv">1</span>, <span class="dt">FUN =</span> sum) <span class="op"><</span><span class="st"> </span>parameters<span class="op">$</span>minCount</a>
<a class="sourceLine" id="cb12-3" data-line-number="3"><span class="co"># table(undetectedGenes)</span></a>
<a class="sourceLine" id="cb12-4" data-line-number="4">log2Filtered <-<span class="st"> </span>log2Values[<span class="op">!</span>undetectedGenes, ]</a></code></pre></div>
<p>We filtered out all the genes whose maximal count value across all samples was lower than 10. Among the 46679 genes from the raw count table, 20851 were considered undetected according to this criterion. We use the remaining 25828 genes for the subsequent analyses.</p>
</div>
<div id="boxplot-after-gene-filtering" class="section level2">
<h2>Boxplot after gene filtering</h2>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb13-1" data-line-number="1"><span class="co">#### Box plots after filtering ####</span></a>
<a class="sourceLine" id="cb13-2" data-line-number="2"><span class="kw">par</span>(<span class="dt">mar =</span> <span class="kw">c</span>(<span class="dv">4</span>, <span class="dv">6</span>, <span class="dv">5</span>, <span class="dv">1</span>))</a>
<a class="sourceLine" id="cb13-3" data-line-number="3"><span class="kw">boxplot</span>(log2Filtered, </a>
<a class="sourceLine" id="cb13-4" data-line-number="4"> <span class="dt">col =</span> metadata<span class="op">$</span>color,</a>
<a class="sourceLine" id="cb13-5" data-line-number="5"> <span class="dt">horizontal =</span> <span class="ot">TRUE</span>, </a>
<a class="sourceLine" id="cb13-6" data-line-number="6"> <span class="dt">las =</span> <span class="dv">1</span>,</a>
<a class="sourceLine" id="cb13-7" data-line-number="7"> <span class="dt">main =</span> <span class="st">"Filtered genes"</span>, </a>
<a class="sourceLine" id="cb13-8" data-line-number="8"> <span class="dt">xlab =</span> <span class="st">"log2(counts)"</span>)</a></code></pre></div>
<p><img src="figures/mouse-kidney_boxplot_filtered-1.png" width="32%" style="display: block; margin: auto;" /></p>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb14-1" data-line-number="1"><span class="kw">par</span>(par.ori)</a></code></pre></div>
</div>
<div id="normalisation-more-precisely-scaling" class="section level2">
<h2>Normalisation (more precisely: scaling)</h2>
<p>Before going any further, it is important to ensure some normalisation of the counts, in order to correct for biases due to inter-sample differences in sequencing depth.</p>
<p>For the sake of simplicity, we will use here a very simple criterion: median-based normalisation. The principle is to multiply the counts of each sample by a scaling factor in order to bring each sample to the same median count.</p>
</div>
<div id="normalisation-code" class="section level2">
<h2>Normalisation code</h2>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb15-1" data-line-number="1"><span class="co">#### Median-based normalisation ####</span></a>
<a class="sourceLine" id="cb15-2" data-line-number="2">sampleMedians <-<span class="st"> </span><span class="kw">apply</span>(log2Filtered, <span class="dv">2</span>, median)</a>
<a class="sourceLine" id="cb15-3" data-line-number="3">seriesMedian <-<span class="st"> </span><span class="kw">median</span>(sampleMedians)</a>
<a class="sourceLine" id="cb15-4" data-line-number="4">scalingFactors <-<span class="st"> </span>seriesMedian <span class="op">/</span><span class="st"> </span>sampleMedians</a>
<a class="sourceLine" id="cb15-5" data-line-number="5"></a>
<a class="sourceLine" id="cb15-6" data-line-number="6">log2Standardised <-<span class="st"> </span><span class="kw">data.frame</span>(<span class="kw">matrix</span>(</a>
<a class="sourceLine" id="cb15-7" data-line-number="7"> <span class="dt">nrow =</span> <span class="kw">nrow</span>(log2Filtered),</a>
<a class="sourceLine" id="cb15-8" data-line-number="8"> <span class="dt">ncol =</span> <span class="kw">ncol</span>(log2Filtered)))</a>
<a class="sourceLine" id="cb15-9" data-line-number="9"><span class="kw">colnames</span>(log2Standardised) <-<span class="st"> </span><span class="kw">colnames</span>(log2Filtered)</a>
<a class="sourceLine" id="cb15-10" data-line-number="10"><span class="kw">rownames</span>(log2Standardised) <-<span class="st"> </span><span class="kw">rownames</span>(log2Filtered)</a>
<a class="sourceLine" id="cb15-11" data-line-number="11"><span class="cf">for</span> (j <span class="cf">in</span> <span class="dv">1</span><span class="op">:</span><span class="kw">ncol</span>(log2Filtered)) {</a>
<a class="sourceLine" id="cb15-12" data-line-number="12"> log2Standardised[, j] <-<span class="st"> </span>log2Filtered[, j] <span class="op">*</span><span class="st"> </span>scalingFactors[j]</a>
<a class="sourceLine" id="cb15-13" data-line-number="13">}</a>
<a class="sourceLine" id="cb15-14" data-line-number="14"></a>
<a class="sourceLine" id="cb15-15" data-line-number="15"><span class="co">## Check the remaining medians</span></a>
<a class="sourceLine" id="cb15-16" data-line-number="16"><span class="kw">apply</span>(log2Standardised, <span class="dv">2</span>, median)</a></code></pre></div>
<pre><code>day14_12 day14_13 day14_14 day14_15 day3_4 day3_5 day3_6 day3_7 day7_10 day7_11 day7_8 day7_9 normal_1 normal_2 normal_3
6.772065 6.772065 6.772065 6.772065 6.772065 6.772065 6.772065 6.772065 6.772065 6.772065 6.772065 6.772065 6.772065 6.772065 6.772065 </code></pre>
</div>
<div id="normalized-boxplot" class="section level2">
<h2>Normalized boxplot</h2>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-1" data-line-number="1"><span class="co">#### Box plots after scaling ####</span></a>
<a class="sourceLine" id="cb17-2" data-line-number="2"><span class="kw">par</span>(<span class="dt">mar =</span> <span class="kw">c</span>(<span class="dv">4</span>, <span class="dv">6</span>, <span class="dv">5</span>, <span class="dv">1</span>))</a>
<a class="sourceLine" id="cb17-3" data-line-number="3"><span class="kw">boxplot</span>(log2Standardised, </a>
<a class="sourceLine" id="cb17-4" data-line-number="4"> <span class="dt">col =</span> metadata<span class="op">$</span>color,</a>
<a class="sourceLine" id="cb17-5" data-line-number="5"> <span class="dt">horizontal =</span> <span class="ot">TRUE</span>, </a>
<a class="sourceLine" id="cb17-6" data-line-number="6"> <span class="dt">las =</span> <span class="dv">1</span>,</a>
<a class="sourceLine" id="cb17-7" data-line-number="7"> <span class="dt">main =</span> <span class="st">"Median-based scaled"</span>, </a>
<a class="sourceLine" id="cb17-8" data-line-number="8"> <span class="dt">xlab =</span> <span class="st">"log2(counts"</span>)</a></code></pre></div>
<p><img src="figures/mouse-kidney_median_normalisation_boxplot-1.png" width="32%" style="display: block; margin: auto;" /></p>
<div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb18-1" data-line-number="1"><span class="kw">par</span>(par.ori)</a></code></pre></div>
</div>
<div id="violin-plots" class="section level2">
<h2>Violin plots</h2>
<p>We can also inspect the distribution of counts per sample with the <code>vioplot()</code> function.</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb19-1" data-line-number="1"><span class="co">#### Violin plots ####</span></a>
<a class="sourceLine" id="cb19-2" data-line-number="2"><span class="kw">par</span>(<span class="dt">mar =</span> <span class="kw">c</span>(<span class="dv">4</span>, <span class="dv">6</span>, <span class="dv">5</span>, <span class="dv">1</span>))</a>
<a class="sourceLine" id="cb19-3" data-line-number="3">vioplot<span class="op">::</span><span class="kw">vioplot</span>(log2Values, </a>
<a class="sourceLine" id="cb19-4" data-line-number="4"> <span class="dt">col =</span> metadata<span class="op">$</span>color,</a>
<a class="sourceLine" id="cb19-5" data-line-number="5"> <span class="dt">horizontal =</span> <span class="ot">TRUE</span>, </a>
<a class="sourceLine" id="cb19-6" data-line-number="6"> <span class="dt">las =</span> <span class="dv">1</span>, </a>
<a class="sourceLine" id="cb19-7" data-line-number="7"> <span class="dt">main =</span> <span class="st">"log2-transformed"</span>, </a>
<a class="sourceLine" id="cb19-8" data-line-number="8"> <span class="dt">xlab =</span> <span class="st">"log2(counts)"</span>)</a></code></pre></div>
<p><img src="figures/mouse-kidney_violin%20plots-1.png" width="25%" style="display: block; margin: auto;" /></p>
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb20-1" data-line-number="1"><span class="kw">par</span>(par.ori)</a></code></pre></div>
</div>
<div id="scatter-plots" class="section level2">
<h2>Scatter plots</h2>
<p>We can also inspect the distribution of counts per sample with the <code>plot()</code> function.</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" data-line-number="1"><span class="co">#### Scatter plots ####</span></a>
<a class="sourceLine" id="cb21-2" data-line-number="2"><span class="co">#par(mar = c(4, 6, 5, 1))</span></a>
<a class="sourceLine" id="cb21-3" data-line-number="3"><span class="co">#plot(log2Values[,metadata$sampleName], </span></a>
<a class="sourceLine" id="cb21-4" data-line-number="4"><span class="co"># col = metadata$color)</span></a>
<a class="sourceLine" id="cb21-5" data-line-number="5"><span class="co">#par(par.ori)</span></a></code></pre></div>
</div>
<div id="combinations" class="section level2">
<h2>Combinations</h2>
</div>
<div id="exporting-the-result" class="section level2">
<h2>Exporting the result</h2>
<p>We export the pre-processed data in separate tables for further reuse.</p>
<div class="sourceCode" id="cb22"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb22-1" data-line-number="1"><span class="co">#### Save tables ####</span></a>
<a class="sourceLine" id="cb22-2" data-line-number="2"></a>
<a class="sourceLine" id="cb22-3" data-line-number="3">outfiles <-<span class="st"> </span><span class="kw">vector</span>()</a>
<a class="sourceLine" id="cb22-4" data-line-number="4"></a>
<a class="sourceLine" id="cb22-5" data-line-number="5"><span class="co">## Raw counts, all the variables</span></a>
<a class="sourceLine" id="cb22-6" data-line-number="6">outfiles[<span class="st">"raw"</span>] <-<span class="st"> </span><span class="kw">file.path</span>(outdirs[parameters<span class="op">$</span>datatype], </a>
<a class="sourceLine" id="cb22-7" data-line-number="7"> <span class="kw">paste0</span>(parameters<span class="op">$</span>dataset, </a>
<a class="sourceLine" id="cb22-8" data-line-number="8"> <span class="st">"_"</span>, parameters<span class="op">$</span>datatype, </a>
<a class="sourceLine" id="cb22-9" data-line-number="9"> <span class="st">"_raw.tsv.gz"</span>))</a>
<a class="sourceLine" id="cb22-10" data-line-number="10"><span class="kw">write.table</span>(<span class="dt">x =</span> <span class="kw">format</span>(<span class="dt">digits =</span> <span class="dv">3</span>, <span class="dt">big.mark =</span> <span class="st">""</span>, <span class="dt">decimal.mark =</span> <span class="st">"."</span>, rawValues), </a>
<a class="sourceLine" id="cb22-11" data-line-number="11"> <span class="dt">dec =</span> <span class="st">"."</span>, </a>
<a class="sourceLine" id="cb22-12" data-line-number="12"> <span class="dt">file =</span> <span class="kw">gzfile</span>(outfiles[<span class="st">"raw"</span>], <span class="st">"w"</span>), </a>
<a class="sourceLine" id="cb22-13" data-line-number="13"> <span class="dt">quote =</span> <span class="ot">FALSE</span>, <span class="dt">sep =</span> <span class="st">"</span><span class="ch">\t</span><span class="st">"</span>)</a>
<a class="sourceLine" id="cb22-14" data-line-number="14"></a>
<a class="sourceLine" id="cb22-15" data-line-number="15"><span class="co">## Log2-transformed counts, all the genes</span></a>
<a class="sourceLine" id="cb22-16" data-line-number="16">outfiles[<span class="st">"log2"</span>] <-<span class="st"> </span><span class="kw">file.path</span>(outdirs[parameters<span class="op">$</span>datatype], </a>
<a class="sourceLine" id="cb22-17" data-line-number="17"> <span class="kw">paste0</span>(parameters<span class="op">$</span>dataset, </a>
<a class="sourceLine" id="cb22-18" data-line-number="18"> <span class="st">"_"</span>, parameters<span class="op">$</span>datatype, </a>
<a class="sourceLine" id="cb22-19" data-line-number="19"> <span class="st">"_log2.tsv.gz"</span>))</a>
<a class="sourceLine" id="cb22-20" data-line-number="20"><span class="kw">write.table</span>(<span class="dt">x =</span> <span class="kw">format</span>(<span class="dt">digits =</span> <span class="dv">3</span>, <span class="dt">big.mark =</span> <span class="st">""</span>, <span class="dt">decimal.mark =</span> <span class="st">"."</span>, log2Values), </a>
<a class="sourceLine" id="cb22-21" data-line-number="21"> <span class="dt">dec =</span> <span class="st">"."</span>, </a>
<a class="sourceLine" id="cb22-22" data-line-number="22"> <span class="dt">file =</span> <span class="kw">gzfile</span>(outfiles[<span class="st">"log2"</span>], <span class="st">"w"</span>), </a>
<a class="sourceLine" id="cb22-23" data-line-number="23"> <span class="dt">quote =</span> <span class="ot">FALSE</span>, <span class="dt">sep =</span> <span class="st">"</span><span class="ch">\t</span><span class="st">"</span>)</a>
<a class="sourceLine" id="cb22-24" data-line-number="24"></a>
<a class="sourceLine" id="cb22-25" data-line-number="25"><span class="co">## Filtered genes only, log2-transformed counts</span></a>
<a class="sourceLine" id="cb22-26" data-line-number="26">outfiles[<span class="st">"filtered"</span>] <-<span class="st"> </span><span class="kw">file.path</span>(outdirs[parameters<span class="op">$</span>datatype], </a>
<a class="sourceLine" id="cb22-27" data-line-number="27"> <span class="kw">paste0</span>(parameters<span class="op">$</span>dataset, </a>
<a class="sourceLine" id="cb22-28" data-line-number="28"> <span class="st">"_"</span>, parameters<span class="op">$</span>datatype, </a>
<a class="sourceLine" id="cb22-29" data-line-number="29"> <span class="st">"_log2_filtered.tsv.gz"</span>))</a>
<a class="sourceLine" id="cb22-30" data-line-number="30"><span class="kw">write.table</span>(<span class="dt">x =</span> <span class="kw">format</span>(<span class="dt">digits =</span> <span class="dv">3</span>, <span class="dt">big.mark =</span> <span class="st">""</span>, <span class="dt">decimal.mark =</span> <span class="st">"."</span>, log2Filtered), </a>
<a class="sourceLine" id="cb22-31" data-line-number="31"> <span class="dt">dec =</span> <span class="st">"."</span>, </a>
<a class="sourceLine" id="cb22-32" data-line-number="32"> <span class="dt">file =</span> <span class="kw">gzfile</span>(outfiles[<span class="st">"filtered"</span>], <span class="st">"w"</span>), </a>
<a class="sourceLine" id="cb22-33" data-line-number="33"> <span class="dt">quote =</span> <span class="ot">FALSE</span>, <span class="dt">sep =</span> <span class="st">"</span><span class="ch">\t</span><span class="st">"</span>)</a>
<a class="sourceLine" id="cb22-34" data-line-number="34"></a>
<a class="sourceLine" id="cb22-35" data-line-number="35"><span class="co">## Filtered genes only, log2-transformed and standardized counts</span></a>
<a class="sourceLine" id="cb22-36" data-line-number="36">outfiles[<span class="st">"standardised"</span>] <-<span class="st"> </span><span class="kw">file.path</span>(outdirs[parameters<span class="op">$</span>datatype], </a>
<a class="sourceLine" id="cb22-37" data-line-number="37"> <span class="kw">paste0</span>(parameters<span class="op">$</span>dataset, </a>
<a class="sourceLine" id="cb22-38" data-line-number="38"> <span class="st">"_"</span>, parameters<span class="op">$</span>datatype, </a>
<a class="sourceLine" id="cb22-39" data-line-number="39"> <span class="st">"_log2_norm.tsv.gz"</span>))</a>
<a class="sourceLine" id="cb22-40" data-line-number="40"><span class="kw">write.table</span>(<span class="dt">x =</span> <span class="kw">format</span>(<span class="dt">digits =</span> <span class="dv">3</span>, <span class="dt">big.mark =</span> <span class="st">""</span>, <span class="dt">decimal.mark =</span> <span class="st">"."</span>, log2Standardised), </a>
<a class="sourceLine" id="cb22-41" data-line-number="41"> <span class="dt">dec =</span> <span class="st">"."</span>, </a>
<a class="sourceLine" id="cb22-42" data-line-number="42"> <span class="dt">file =</span> <span class="kw">gzfile</span>(outfiles[<span class="st">"standardised"</span>], <span class="st">"w"</span>), </a>
<a class="sourceLine" id="cb22-43" data-line-number="43"> <span class="dt">quote =</span> <span class="ot">FALSE</span>, <span class="dt">sep =</span> <span class="st">"</span><span class="ch">\t</span><span class="st">"</span>)</a>