-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuppl1.Rmd
2173 lines (1940 loc) · 83.8 KB
/
suppl1.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
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
---
title: "Supplementary 1"
date: "`r Sys.Date()`"
author: "Ali Oghabian"
contact: "ali.oghabian@helsinki.fi"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Supplementary 1}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
---
Here we present supplementary data together with the scripts that were used to
generate the results mentioned in the paper. The document is comprised of the
following sections:
* [Differential intron retention analysis](#difIR)
+ [Mapping read sequences and intron retention analysis](#preprocessing)
+ [Building reference](#refbuild)
+ [Retention estimation of the introns](#irestimate)
+ [Discovering introns with strong increased/decreased retention](#DESeq2Ana)
+ [Filtering genes with low intron retention levels](#filtering)
* [Performance comparisons](#performance)
+ [Comparing IntEREst-DESeq2 to IntEREst-edgeR](#comglm)
+ [Comparing IntEREst-DESeq2 to IntEREst-DEXSeq](#comdexseq)
+ [Comparing IntEREst-DESeq2 results to the retained introns discovered by IRFInder](#comirfinder)
+ [Comparing IntEREst-DESeq2 results to the IRs reported in the MDS study](#commds)
* [Sensitivity analysis](#sensitivity)
+ [Sample size analysis](#samplesize)
+ [Read coverage analysis](#readsize)
* [Differential retention analysis of Maize data](#difMaizeIR)
Note that all scripts initiated with a `# Time demanding` comment are
time-demanding however, the results of these scripts are available as R data
objects in [GitHub](https://github.com/gacatag/IntEREst_suppl_data ).
Throughout this document, when you are running the other scripts which are not
time-consuming, if needed, these results would initially be loaded in R.
Also note that running the scripts requires that the working directory in R is
set to the path of the local copy of the GitHub repository. The working
directory in R can be changed with the `setwd()` command.
# Differential intron retention analysis {#difIR}
We compare the intron retention (IR) variations of U12 type introns to the U2
type (comparing ZRSR2mut samples vs controls), using the DESeq2 based function
of IntEREst (IntEREst-DESeq).
## Mapping read sequences and preprocessing {#preprocessing}
Here, we describe the preprocessing steps, *e.g.* mapping the sequence reads to
the genome and running the `interest()` function to measure the number of reads
that map to the introns of the genes. The `preprocessing.sh` file in the
`scripts` folder (in the GitHub repository) includes scripts that were
used to download and map the sequencing reads. It also changes the read names
with the intention that the paired reads be recognized as pairs when read in R;
**the read IDs of paired reads must be identical**. The `preprocessing.sh` file
can be run in Linux environment if `fastq-dump` (from the SRA Toolkit),
`Tophat2`, `Bowtie2`, `sed` and `samtools`are installed. If you intend to run
`preprocessing.sh`, before running you need to set the working directory to
the `scripts` folder and also set the following environmental
variables:
* `RAWDATAPATH`: Path to the folder containing all fastq files.
* `MAPPINGPATH`: Path to write and access all mapped sequence reads bam/sam
files.
* `indexPATH`: Path to the Bowtie2 index files including the genome name. If
the path to the index files is ~/bowtie2/indexes/hg19NoColor/ for hg19
(given that the necessary files are available in this path with hg19.*
filenames) set the indexPath as ~/bowtie2/indexes/hg19NoColor/hg19 .
Note that `Tophat2` and `samtools` were all run with their default parameters.
We ran all the analyses on a Linux (CentOS release 7.3.1611) server with 64 AMD
Opteron Processors (6274) and a total of ~528 GB memory capacity.
## Building reference {#refbuild}
First, a reference data-frame was built; The hg19 and UCSC was used. The exonic
regions were collapsed to prevent any biases in the intron retention level (IR)
calculation that may be introduced by the read counts of exons overlapping the
studied introns. Note that the following analyses are time demanding. You can
skip and continue from ['Discovering introns with strong increase/decrease in
retention'](#DESeq2Ana).
<br>
```{r buildingReference, out.width = 600, echo=TRUE, eval=FALSE }
# Time demanding
library(IntEREst)
refseqRef<- referencePrepare (sourceBuild="UCSC", ucscGenome="hg19",
addCollapsedTranscripts=TRUE, ignore.strand=FALSE)
```
<br>
After building the reference, the U12-type introns were annotated. If an intron
was not annotated as a U12-type or a U2-type we considered it as U2-type
(*i.e.* the parameter setting `setNaAs= "U2"` was used).
<br>
```{r annotateReference, out.width = 600, echo=TRUE, eval=FALSE }
# Time demanding
library(BSgenome.Hsapiens.UCSC.hg19)
refseqAnnoMat<- annotateU12(
pwmU12U2= list(
pwmU12db[[1]][,11:17],
pwmU12db[[2]],
pwmU12db[[3]][,38:40],
pwmU12db[[4]][,11:17],
pwmU12db[[5]][,38:40]),
pwmSsIndex= list(
indexDonU12=1,
indexBpU12=1,
indexAccU12=3,
indexDonU2=1,
indexAccU2=3),
referenceChr= refseqRef[,"chr"],
referenceBegin= as.numeric(refseqRef[,"begin"]),
referenceEnd= as.numeric(refseqRef[,"end"]),
referenceIntronExon= refseqRef[,"int_ex"],
intronExon= "intron",
matchWindowRelativeUpstreamPos= c(NA,-29,NA,NA,NA),
matchWindowRelativeDownstreamPos= c(NA,-9,NA,NA,NA),
minMatchScore= c( rep("80%", 2), "40%", "80%", "40%"),
refGenome= BSgenome.Hsapiens.UCSC.hg19,
setNaAs= "U2",
annotateU12Subtype= TRUE)
```
<br>
## Retention estimation of the introns {#irestimate}
To estimate the intron retention (IR) levels the `interest()` function was
used. We ran the analysis on 40 computing cores while at each attempt maximum
1 million paired reads were analyzed. For the normalization we scaled the
IR levels to the length of the introns and also the number of fragments mapped
to the gene.
<br>
```{r intronRetentionAnalysis, out.width = 600, echo=TRUE, eval=FALSE }
# Time demanding
outDir<-"/data1/ali/develop/sequencing/package/testInterestComplete/new/"
MDS_BAMFILES<- paste(
"/data1/ali/develop/sequencing/package/testInterestComplete/validation/",
c(
"SRR1691633/SRR1691633_ZRSR2Mut.bam",
"SRR1691634/SRR1691634_ZRSR2Mut.bam",
"SRR1691635/SRR1691635_ZRSR2Mut.bam",
"SRR1691636/SRR1691636_ZRSR2Mut.bam",
"SRR1691637/SRR1691637_ZRSR2Mut.bam",
"SRR1691638/SRR1691638_ZRSR2Mut.bam",
"SRR1691639/SRR1691639_ZRSR2Mut.bam",
"SRR1691640/SRR1691640_ZRSR2Mut.bam",
"SRR1691641/SRR1691641_WT.bam",
"SRR1691642/SRR1691642_WT.bam",
"SRR1691643/SRR1691643_WT.bam",
"SRR1691644/SRR1691644_WT.bam",
"SRR1691645/SRR1691645_Normal.bam",
"SRR1691646/SRR1691646_Normal.bam",
"SRR1691647/SRR1691647_Normal.bam",
"SRR1691648/SRR1691648_Normal.bam"
), sep="")
# Set sample names
names(MDS_BAMFILES)<- gsub(".bam","", gsub(".*/","", MDS_BAMFILES))
for(i in 1:length(MDS_BAMFILES)){
dir.create(paste(outDir, names(MDS_BAMFILES)[i],
sep="/"), recursive = TRUE)
interest(
bamFileYieldSize=1000000,
bamFile=MDS_BAMFILES[i],
isPaired=TRUE,
isPairedDuplicate=FALSE,
isSingleReadDuplicate=NA,
reference=refseqRef,
referenceGeneNames=refseqRef[,"collapsed_transcripts_id"],
referenceIntronExon=refseqRef[,"int_ex"],
repeatsTableToFilter= c(),
junctionReadsOnly=FALSE,
outFile=paste(outDir, names(MDS_BAMFILES)[i],
"interestRes.tsv", sep="/"),
logFile=paste(outDir, names(MDS_BAMFILES)[i],
"log.txt", sep="/"),
method=c"IntRet",
clusterNo=40,
returnObj=FALSE,
scaleLength= TRUE,
scaleFragment= TRUE
)
}
```
<br>
The running time for each sample (with 40 computing cores in use) was as
follows:
| Sample name | Running time (Secs) |
|:-------------:|:-------------:|
| SRR1691633_ZRSR2Mut | 11763.74 |
| SRR1691634_ZRSR2Mut | 11453.52 |
| SRR1691635_ZRSR2Mut | 11305.33 |
| SRR1691636_ZRSR2Mut | 11675.77 |
| SRR1691637_ZRSR2Mut | 11630.58 |
| SRR1691638_ZRSR2Mut | 11282.91 |
| SRR1691639_ZRSR2Mut | 12713.78 |
| SRR1691640_ZRSR2Mut | 11502.06 |
| SRR1691641_WT | 14215.48 |
| SRR1691642_WT | 12938.56 |
| SRR1691643_WT | 11699.02 |
| SRR1691644_WT | 12169.6 |
| SRR1691645_Normal | 11697.54 |
| SRR1691646_Normal | 11427.7 |
| SRR1691647_Normal | 11622.74 |
| SRR1691648_Normal | 11934.94 |
<center> **Table S1.** Running time of `interest()` function for each MDS
sample (Number of computing cores = 40). </center>
<br>
After the IR of all samples were estimated, we made an object of class
SummarizedExperiment that contains the IR results of all samples, and the
intron/exon and sample annotations.
<br>
```{r readingResults, out.width = 600, echo=TRUE, eval=FALSE }
# Read results and build SummarizedExperiment object
mdsRefObj<-readInterestResults(
resultFiles=paste(outDir, names(MDS_BAMFILES),
"interestRes.tsv", sep="/"),
sampleNames=names(MDS_BAMFILES),
sampleAnnotation=data.frame(
type=c(rep("ZRSR2mut",8), rep("ZRSR2wt",4), rep("HEALTHY",4)),
test_ctrl=c(rep("test",8), rep("ctrl",8))),
commonColumns=1:9, freqCol=10, scaledRetentionCol=11,
scaleLength=TRUE, scaleFragment=TRUE, reScale=TRUE,
geneIdCol="collapsed_transcripts_id")
# update the object with the intron type (U12- or U2-type) annotations
mdsRefObj<- updateRowDataCol(mdsRefObj, "intron_type", refseqAnnoMat[,1])
save(mdsRefObj, file="./mdsRefObj.rda")
```
<br>
The `mdsRefObj` object has been included in the GitHub repository.
In the next section, we will load and use it to make plots and perform
downstream analyses.
<br>
## Discovering introns with strong increase/decrease in retention {#DESeq2Ana}
We extract introns that featured strong differential IRs when comparing
ZRSR2mut to the controls, using the DESeq2 based function of IntEREst
(IntEREst-DESeq2). To carry out this analysis we extract the introns which
their retentions increase/decrease significantly compared to the decrease/
increase of the junction levels of their flanking exons. We initially, build a
reference data.frame from UCSC without collapsing the exons. Next, we keep a
single copy of each set of repeating exons. We run the IntEREst in the
exon-exon junction mode. and finally we merge the exon junction results to the
previously used intron retention results so that the resulting object would
include the retention level of the introns together with the mean of the
junction levels of their flanking exons. Finally we perform DESeq2 differential
test to get the relevant p values. The following runs are however time
demanding; You can skip this step and continue with the remaining analysis.
```{r UpDownRetInts, out.width = 600, echo=TRUE, eval=FALSE }
# Time demanding
library(BSgenome.Hsapiens.UCSC.hg19)
refseqUncollapsed<- referencePrepare (sourceBuild="UCSC", ucscGenome="hg19",
addCollapsedTranscripts=FALSE, collapseExons=FALSE, ignore.strand=FALSE)
# Union exons of transcripts with overlapping exons
# Keep one copy from each repeating set of exons, only
refExDf<- unionRefTr(referenceChr= refseqUncollapsed[,"chr"],
referenceBegin= as.numeric(refseqUncollapsed[,"begin"]),
referenceEnd= as.numeric(refseqUncollapsed[,"end"]),
referenceTr=as.character(refseqUncollapsed[,"transcript_id"]),
referenceIntronExon=refseqUncollapsed[,"int_ex"],
intronExon="exon",
silent=FALSE)
save(refExDf,file="./refExDf.rda")
outDir="/data1/ali/develop/sequencing/package/testInterestComplete/newEx/"
setwd(outDir)
MDS_BAMFILES<- paste(
"/data1/ali/develop/sequencing/package/testInterestComplete/validation/",
c(
"SRR1691633/SRR1691633_ZRSR2Mut.bam",
"SRR1691634/SRR1691634_ZRSR2Mut.bam",
"SRR1691635/SRR1691635_ZRSR2Mut.bam",
"SRR1691636/SRR1691636_ZRSR2Mut.bam",
"SRR1691637/SRR1691637_ZRSR2Mut.bam",
"SRR1691638/SRR1691638_ZRSR2Mut.bam",
"SRR1691639/SRR1691639_ZRSR2Mut.bam",
"SRR1691640/SRR1691640_ZRSR2Mut.bam",
"SRR1691641/SRR1691641_WT.bam",
"SRR1691642/SRR1691642_WT.bam",
"SRR1691643/SRR1691643_WT.bam",
"SRR1691644/SRR1691644_WT.bam",
"SRR1691645/SRR1691645_Normal.bam",
"SRR1691646/SRR1691646_Normal.bam",
"SRR1691647/SRR1691647_Normal.bam",
"SRR1691648/SRR1691648_Normal.bam"
), sep="")
# Set sample names
names(MDS_BAMFILES)<- gsub(".bam","", gsub(".*/","", MDS_BAMFILES))
for(i in 1:length(MDS_BAMFILES)){
dir.create(paste(outDir, names(MDS_BAMFILES)[i],
sep="/"), recursive = TRUE)
interest(
bamFileYieldSize=1000000,
bamFile=MDS_BAMFILES[i],
isPaired=TRUE,
isPairedDuplicate=FALSE,
isSingleReadDuplicate=NA,
reference=refExDf,
referenceGeneNames=refExDf[,"transcripts_id"],
referenceIntronExon=refExDf[,"int_ex"],
repeatsTableToFilter= c(),
junctionReadsOnly=TRUE,
outFile=paste(outDir, names(MDS_BAMFILES)[i],
"interestRes.tsv", sep="/"),
logFile=paste(outDir, names(MDS_BAMFILES)[i],
"log.txt", sep="/"),
method=c("ExEx"),
clusterNo=20,
returnObj=FALSE,
scaleLength= FALSE,
scaleFragment= TRUE,
bpparam= SnowParam(workers=25)
)
}
mdsExRefObj<-readInterestResults(
resultFiles=paste(outDir, names(MDS_BAMFILES),
"interestRes.tsv", sep="/"),
sampleNames=names(MDS_BAMFILES),
sampleAnnotation=data.frame(
type=c(rep("ZRSR2mut",8), rep("ZRSR2wt",4), rep("HEALTHY",4)),
test_ctrl=c(rep("test",8), rep("ctrl",8))),
commonColumns=1:5, freqCol=6, scaledRetentionCol=7,
scaleLength=FALSE, scaleFragment=TRUE, reScale=FALSE,
geneIdCol="transcripts_id")
save(mdsExRefObj,
file="./mdsExRefObj.rda")
load("./mdsRefObj.rda")
load("./mdsExRefObj.rda")
mdsRfObjIntBool<-rowData(mdsRefObj)$int_ex=="intron"
mdsRefObjInt<- mdsRefObj[mdsRfObjIntBool,]
mdsRefIntExObj<- interestResultIntEx(intObj=mdsRefObjInt, exObj=mdsExRefObj,
mean.na.rm=TRUE, postExName="ex_junc" )
save(mdsRefIntExObj,file="./mdsRefIntExObj.rda")
ddsDiff<- deseqInterest(mdsRefIntExObj,
design=~test_ctrl+test_ctrl:intronExon,
sizeFactor=rep(1,nrow(colData(mdsRefIntExObj))),
contrast=list("test_ctrltest.intronExonintron",
"test_ctrlctrl.intronExonintron"),
parallel=TRUE,
BPPARAM = SnowParam(workers=10))
save(ddsDiff, file="./ddsDiff.rda")
# Set adjusted p value threshold
pThresh<- 0.01
#get count data
cntMdsRefIntExObj<-counts(mdsRefIntExObj)
#Change colnames for more clarity
colnames(cntMdsRefIntExObj)[1:16]<-
paste(colnames(cntMdsRefIntExObj)[1:16], "IR", sep="_")
sigMoreOrLess<- rep(NA, nrow(ddsDiff))
sigMoreOrLess[which(ddsDiff$padj<pThresh & ddsDiff$log2FoldChange>0)]<- "more"
sigMoreOrLess[which(ddsDiff$padj<pThresh & ddsDiff$log2FoldChange<0)]<- "less"
# Annotate gene names of the collpased transcripts
library (RMySQL)
con <- dbConnect(
RMySQL::MySQL(),
host="genome-mysql.soe.ucsc.edu",
user="genome",
dbname="hg19")
genAnnoTabl<- dbGetQuery(
con,
"SELECT name,geneSymbol FROM knownGene,kgXref where kgID = name")
genAnno<- genAnnoTabl[,2]
names(genAnno)<- genAnnoTabl[,1]
# Annotate gene names of introns
library(GenomicRanges)
refseqUncollapsedInt<-
refseqUncollapsed[which(refseqUncollapsed$int_ex=="intron"),]
geneSymb<- rep(NA, nrow(rowData(mdsRefIntExObj)))
refseqUncollapsedIntGr<- GRanges(refseqUncollapsedInt$chr,
IRanges(refseqUncollapsedInt$begin,
refseqUncollapsedInt$end))
mdsRefIntExObjGr<- GRanges(rowData(mdsRefIntExObj)$chr,
IRanges(rowData(mdsRefIntExObj)$begin,
rowData(mdsRefIntExObj)$end))
intronsMatch<- suppressWarnings(
findOverlaps(mdsRefIntExObjGr, refseqUncollapsedIntGr, type="equal") )
tmpApply<- tapply(
subjectHits(intronsMatch),
queryHits(intronsMatch),
function(tmp)
paste(sort(unique(genAnno[refseqUncollapsedInt[tmp,"transcript_id"]]),
decreasing=FALSE), collapse=","))
geneSymb[as.numeric(names(tmpApply))]<- as.vector(tmpApply)
mdsRefIntExObjGenAnno<- sapply(
strsplit(rowData(mdsRefIntExObj)[,"collapsed_transcripts"], split=","),
function(tmp)
paste(sort(unique(genAnno[tmp]), decreasing=FALSE), collapse=","))
# Add delts psi values
psiMds<-psi(x=mdsRefIntExObj,
intCol= which(colData(mdsRefIntExObj)$intronExon=="intron"),
exCol=which(colData(mdsRefIntExObj)$intronExon=="exon"))
psiMdsTest<- psiMds[,which(colData(mdsRefIntExObj)$test_ctrl[
colData(mdsRefIntExObj)$intronExon=="intron"]=="test")]
psiMdsCtrl<- psiMds[,which(colData(mdsRefIntExObj)$test_ctrl[
colData(mdsRefIntExObj)$intronExon=="intron"]=="ctrl")]
difPsiAll<- (rowMeans(psiMdsTest)-rowMeans(psiMdsCtrl))
# Write differential IR data
write.table(
data.frame(
as.data.frame(rowData(mdsRefIntExObj))[,1:6],
gene_symbol= geneSymb,
as.data.frame(rowData(mdsRefIntExObj))[,7:8],
collapsed_gene_symbol= mdsRefIntExObjGenAnno,
as.data.frame(rowData(mdsRefIntExObj))[,9:10],
as.data.frame(cntMdsRefIntExObj),
as.data.frame(ddsDiff),
sig_more_or_less=sigMoreOrLess,
delta_psi=difPsiAll )[which(!is.na(sigMoreOrLess)),],
file="./differential-IR.tsv",
col.names=TRUE,
row.names=FALSE,
quote=FALSE,
sep='\t'
)
```
<br>
The following scripts load the required data (generated by the previous
scripts) and checks its contents:
<br>
```{r UpDownRetAnalysis, out.width = 600, echo=TRUE, eval=TRUE }
pThresh<- 0.01
load(file="./mdsRefIntExObj.rda")
load(file="./ddsDiff.rda")
# index of significantly more retained introns
indUpMdsRefDdsObjInt<- which(ddsDiff$padj<pThresh &
ddsDiff$log2FoldChange>0)
# index of significantly less retained introns
indDnMdsRefDdsObjInt<- which(ddsDiff$padj<pThresh &
ddsDiff$log2FoldChange<0)
# Type of significantly retained introns
table(rowData(mdsRefIntExObj)[indUpMdsRefDdsObjInt, "intron_type"])
# Type of significantly less retained introns
table(rowData(mdsRefIntExObj)[indDnMdsRefDdsObjInt, "intron_type"])
```
<br>
The following scripts initially loads the results of the previous scripts and
runs a statistical test to see whether the log FC of IR levels of U12 type
introns are higher than that of U2 type introns. Next suitable colours and
shapes of plot points (pch) are defined which will be used in the plot to
distinguish significantly more/less retained U12 type introns from the U2 type,
and from the introns that have not significantly varried across the studied
samples.
<br>
```{r downstreamDeseqanalysisFil, out.width = 600, echo=TRUE, eval=TRUE }
load("./ddsDiff.rda")
load("./mdsRefIntExObj.rda")
pThresh<- 0.01
mdsRefIntObj<- mdsRefIntExObj[,colData(mdsRefIntExObj)$intronExon=="intron"]
lfcRes<- lfc(mdsRefIntObj, fcType= "edgeR",
sampleAnnoCol="test_ctrl",sampleAnnotation=c("ctrl","test"))
# Build index for U2 introns
u2TF<- rep(FALSE,length(lfcRes))
u2TF[ which(rowData(mdsRefIntObj)[, "intron_type"]=="U2" &
rowData(mdsRefIntObj)[, "int_ex"]=="intron")]<- TRUE
u2TF[ which(rowData(mdsRefIntObj)[, "intron_type"]=="U12/U2" &
rowData(mdsRefIntObj)[, "int_ex"]=="intron")]<- FALSE
u2TF[u12Index(mdsRefIntObj, intExCol="int_ex",
intTypeCol="intron_type")]<- FALSE
#Check number of U2 introns
length(which(u2TF))
# Check if the FC retention increase is significant
lfcVec<- c(lfcRes[u2TF], lfcRes[u12Index(mdsRefIntObj, intExCol="int_ex",
intTypeCol="intron_type")])
ord<- c(rep(1, length(lfcRes[u2TF])),
rep(2, length(lfcRes[u12Index(mdsRefIntObj, intExCol="int_ex",
intTypeCol="intron_type")])))
table(ord)
library(clinfun)
jtRes<- jonckheere.test(lfcVec, ord, alternative = "increasing",
nperm=1000)
jtRes
# Set proper colours and point symbols (pch) for plotting to distinguish
# U12-type more/less retained introns from the U2-type more/less retained
cols<- rep("lightgrey", nrow(rowData(mdsRefIntExObj)))
cols[rowData(mdsRefIntExObj)[, "intron_type"]=="U12"]<- "black"
cols[rowData(mdsRefIntExObj)[, "intron_type"]=="U12" &
ddsDiff$padj<pThresh ]<- "red"
pchs=rep(21, nrow(rowData(mdsRefIntExObj)))
pchs[ddsDiff$padj<pThresh &
ddsDiff$log2FoldChange>0]<- 24
pchs[ddsDiff$padj<pThresh &
ddsDiff$log2FoldChange<0]<- 25
#Number of significantly more retained U12 introns
(u12UpNo<-length(which(pchs==24 & cols=="red")))
#Number of significantly lower retained U12 introns
(u12DnNo<-length(which(pchs==25 & cols=="red")))
#Number of U12 type introns
(u12No<- length(which(rowData(mdsRefIntExObj)[, "intron_type"]=="U12")))
#Number of U12 or U2 type introns
(u12u2No<- length(which(rowData(mdsRefIntExObj)[, "intron_type"]=="U12" |
rowData(mdsRefIntExObj)[, "intron_type"]=="U2")))
#Percentage of significantly more retained U12 introns
100*u12UpNo/u12No
#Percentage of significantly less retained U12 introns
100*u12DnNo/u12No
#Number of Significantly more retained introns (U12 and U2)
length(which(pchs==24))
#Number of Significantly less retained introns (U12 and U2)
length(which(pchs==25))
#Number of significantly more retained U2 introns
(u2UpNo<-length(which(pchs==24 & cols=="lightgrey")))
#Number of significantly less retained U2 introns
(u2DnNo<-length(which(pchs==25 & cols=="lightgrey")))
#Number of U2 type introns
(u2No<-length(which(rowData(mdsRefIntExObj)[, "intron_type"]=="U2")))
#Percentage of significantly more retained U2 introns
100*u2UpNo/u2No
#Percentage of significantly less retained U2 introns
100*u2DnNo/u2No
```
<br>
The following scripts, merge the information shown in Fig.1 A and B and
illustrate all in a single plot.
<br>
```{r plottingFigure1Fil, out.width = 600, echo=TRUE, eval=TRUE, message = FALSE, fig.width=6, fig.height=4, fig.align="center", fig.cap= "**Fig. S1.** The plot shows IR fold change (ZRSR2mut vs control) vs normalized retention levels of U12- and U2-type introns in the filtered data. Significantly higher and lower retained U12 and U2-type introns have been distinguished from the unchanged introns."}
ddsDiffBm<- log(ddsDiff$baseMean, base=10)
par(mar=c(4,4,2,1))
plot(ddsDiffBm, ddsDiff$log2FoldChange,
col=0, pch=16, xlab="", ylab=expression("fc (log"[2]*")"), mgp=c(2.9,1,0))
points(ddsDiffBm[cols=="lightgrey"&pchs==21],
ddsDiff$log2FoldChange[cols=="lightgrey"&pchs==21],
col="lightgrey", pch=21)
points(ddsDiffBm[cols=="lightgrey"&pchs==24],
ddsDiff$log2FoldChange[cols=="lightgrey"&pchs==24],
col="darkgrey", pch=24)
points(ddsDiffBm[cols=="lightgrey"&pchs==25],
ddsDiff$log2FoldChange[cols=="lightgrey"&pchs==25],
col="darkgrey", pch=25)
points(ddsDiffBm[cols=="black"&pchs==21],
ddsDiff$log2FoldChange[cols=="black"&pchs==21], col="black",
pch=21)
points(ddsDiffBm[cols=="red"&pchs==24],
ddsDiff$log2FoldChange[cols=="red"&pchs==24],
col="red", pch=24)
points(ddsDiffBm[cols=="red"&pchs==25],
ddsDiff$log2FoldChange[cols=="red"&pchs==25],
col="red", pch=25)
mtext(expression("cpm (log"[2]*")"), side=1, outer=F, line=2, cex=.7)
legend("bottomright",
legend=c("U2 NOT changed", "U2 significantly retained",
"U2 significantly LESS retained", "U12 NOT changed",
"U12 significantly retained", "U12 significantly LESS retained"),
col=c("lightgrey", "darkgrey", "darkgrey", "black", "red", "red"),
pch=c(21, 24, 25, 21, 24, 25), cex=.7 )
```
<br>
The following scripts generate the figures Fig. 1 and 2 in the paper.
<br>
```{r Fig1_2, out.width = 600, echo=TRUE, eval=FALSE }
library(grid)
# function to draw curly braces in red
# x1...y2 are the ends of the brace
# for upside down braces, x1 > x2 and y1 > y2
CurlyBraces <- function(x0, x1, y0, y1, pos = 1, direction = 1, depth = 1) {
a=c(1,2,3,48,50) # set flexion point for spline
b=c(0,.2,.28,.7,.8) # set depth for spline flexion point
curve = spline(a, b, n = 50, method = "natural")$y * depth
curve = c(curve,rev(curve))
if (pos == 1){
a_sequence = seq(x0,x1,length=100)
b_sequence = seq(y0,y1,length=100)
}
if (pos == 2){
b_sequence = seq(x0,x1,length=100)
a_sequence = seq(y0,y1,length=100)
}
# direction
if(direction==1)
a_sequence = a_sequence+curve
if(direction==2)
a_sequence = a_sequence-curve
# pos
if(pos==1)
lines(a_sequence,b_sequence, lwd=1.5, xpd=NA) # vertical
if(pos==2)
lines(b_sequence,a_sequence, lwd=1.5, xpd=NA) # horizontal
}
#Plotting
load("./ddsDiff.rda")
pThresh<- 0.01
cols<- rep("lightgrey", nrow(rowData(mdsRefIntExObj)))
cols[rowData(mdsRefIntExObj)[, "intron_type"]=="U12"]<- "black"
cols[rowData(mdsRefIntExObj)[, "intron_type"]=="U12" &
ddsDiff$padj<pThresh ]<- "red"
pchs=rep(21, nrow(rowData(mdsRefIntExObj)))
pchs[ddsDiff$padj<pThresh &
ddsDiff$log2FoldChange>0]<- 24
pchs[ddsDiff$padj<pThresh &
ddsDiff$log2FoldChange<0]<- 25
# Output figure
tiff("./figures/fig1.tif", width=1200, height=1200, res=300, pointsize=5)
par(lwd=1)
par(cex=1.1)
par(cex.axis=1.1)
par(mfrow=c(2,1))
par(mar=c(5,4.5,2,1))
logddsDiff<- log(ddsDiff$baseMean, base=10)
par(mar=c(5,4.5,2,1))
plot(logddsDiff,
ddsDiff$log2FoldChange, col=0, pch=16, xlab="", cex.lab=1.1,
ylab=expression("fc (log"[2]*")"), mgp=c(2.9,1,0))
points(logddsDiff[cols=="black"&pchs==21],
ddsDiff$log2FoldChange[cols=="black"&pchs==21], col="black",
pch=21)
points(logddsDiff[cols=="red"&pchs==24],
ddsDiff$log2FoldChange[cols=="red"&pchs==24], col="green",
pch=24)
points(logddsDiff[cols=="red"&pchs==25],
ddsDiff$log2FoldChange[cols=="red"&pchs==25], col="red",
pch=25)
mtext(expression("normalized retention levels (log"[10]*")"), side=1,
outer=FALSE, line=2.5, cex=1.1)
legend("bottomright", legend=c("U12 NOT changed", "U12 significantly retained",
"U12 significantly LESS retained"), col=c("black", "green", "red"),
pch=c(21, 24, 25), cex=1.1)
title(main = "(A)")
plot(logddsDiff, ddsDiff$log2FoldChange, cex.lab=1.1,
col=0, pch=16, xlab="", ylab=expression("fc (log"[2]*")"), mgp=c(2.9,1,0))
points(logddsDiff[cols=="lightgrey"&pchs==21],
ddsDiff$log2FoldChange[cols=="lightgrey"&pchs==21],
col="black", pch=21)
points(logddsDiff[cols=="lightgrey"&pchs==24],
ddsDiff$log2FoldChange[cols=="lightgrey"&pchs==24], col="green",
pch=24)
points(logddsDiff[cols=="lightgrey"&pchs==25],
ddsDiff$log2FoldChange[cols=="lightgrey"&pchs==25],
col="red", pch=25)
mtext(expression("normalized retention levels (log"[10]*")"), side=1, outer=F,
line=2.5, cex=1.1)
legend("bottomright", legend=c("U2 NOT changed", "U2 significantly retained",
"U2 significantly LESS retained"), col=c( "black", "green", "red"),
pch=c(21, 24, 25), cex=1.1 )
title(main = "(B)")
dev.off()
# filter transcripts with low number of reads mapped to all its introns
rlCntMdsRefObjInt<-
rowMeans(rlog(as.matrix(counts(mdsRefIntExObj))[,
colData(mdsRefIntExObj)$intronExon=="intron"]))
mdsMaxRetTr<- tapply(rlCntMdsRefObjInt,
as.character(rowData(mdsRefIntExObj)[,"collapsed_transcripts_id"]),
max)
inMdsTr<- names(mdsMaxRetTr)[which(as.numeric(mdsMaxRetTr)>1)]
mdsRowFilBool<-
rowData(mdsRefIntExObj)[,"collapsed_transcripts_id"] %in% inMdsTr
mdsRefIntExFilRowObj<- mdsRefIntExObj[mdsRowFilBool,]
save(mdsRefIntExFilRowObj,file="./mdsRefIntExFilRowObj.rda")
tiff("./figures/fig2.tif", width=1200, height=2400, res=300, pointsize=6)
par(lwd=1)
par(cex=1.5)
par(cex.axis=1.5)
par(cex.lab=1.5)
par(mfrow=c(4,1))
par(mar=c(5,5,2,1))
u12BoxplotNb(mdsRefIntExFilRowObj[,1:16], sampleAnnoCol="type", lasNames=1,
intExCol="int_ex", intTypeCol="intron_type", intronExon="intron",
boxplotNames=c(), outline=FALSE, plotLegend=TRUE,
geneIdCol="collapsed_transcripts_id", xLegend="topleft",
col=c("pink", "lightblue", "lightyellow"), ylim=c(0,700000),
ylab="FPKM", cex.axis=1.5, cex.lab=1.5, cexLegend=1.5, addGrid=TRUE,
xaxt='n')
axis(1, at=c(8.5, 25.5, 42.5),
labels=c("Upstream U2-type intron", "U12-type intron",
"Downstream U2-type intron"))
title(main = "(A)", cex.main=1.5)
par(mar=c(6.5,5,2,1))
u12Boxplot(mdsRefIntExFilRowObj[,1:16], sampleAnnoCol="type",
intExCol="int_ex", intTypeCol="intron_type",
col=rep(c("orange", "yellow"),3) , lasNames=1,
outline=FALSE, ylab="FPKM", cex.axis=1.5, intronExon="intron",
addGrid=TRUE, boxplotNames= rep(c("U12","U2"), 3))
c(rep("ZRSR2mut",2),
rep("ZRSR2wt",2), rep("HEALTHY", 2))
CurlyBraces(.7,2.3,-90000,-90000, pos = 2, direction = 2, depth=20000)
CurlyBraces(3.7,5.3,-90000,-90000, pos = 2, direction = 2, depth=20000)
CurlyBraces(6.7,8.3,-90000,-90000, pos = 2, direction = 2, depth=20000)
mtext(c("ZRSR2mut", "ZRSR2wt", "HEALTHY"), at=c(1.5, 4.5, 7.5), side=1,
line=4.2, cex=1.1)
title(main = "(B)", cex.main=1.5)
par(mar=c(5,5,2,1))
u12DensityPlotIntron(mdsRefIntExFilRowObj[,1:16],
type= c("U12", "U2Up", "U2Dn", "U2UpDn", "U2Rand"),
fcType= "edgeR", sampleAnnoCol="test_ctrl",
sampleAnnotation=c("ctrl","test"), intExCol="int_ex",
intTypeCol="intron_type", strandCol= "strand",
geneIdCol= "collapsed_transcripts_id", naUnstrand=FALSE, col=c(2,3,4,5,6),
lty=c(1,2,3,4,5), lwd=1, plotLegend=TRUE, cexLegend=1.5,
xLegend="topright", yLegend=NULL,
legend= c("U12-type intron (n=464)",
"U2-type upstream introns (n=266)",
"U2-type downstream introns (n=464)",
"U2-type up/down stream introns (n=730)",
"U2-type random introns (n=464)"),
randomSeed=10,
ylim=c(0,1), xlab=expression("log"[2]*" fold change FPKM"))
title(main = "(C)", cex.main=1.5)
# psi plot
psiMds<-psi(x=mdsRefIntExFilRowObj,
intCol= which(colData(mdsRefIntExFilRowObj)$intronExon=="intron"),
exCol=which(colData(mdsRefIntExFilRowObj)$intronExon=="exon"))
psiMdsTest<- psiMds[,which(colData(mdsRefIntExFilRowObj)$test_ctrl[
colData(mdsRefIntExFilRowObj)$intronExon=="intron"]=="test")]
psiMdsCtrl<- psiMds[,which(colData(mdsRefIntExFilRowObj)$test_ctrl[
colData(mdsRefIntExFilRowObj)$intronExon=="intron"]=="ctrl")]
difPsiAll<- (rowMeans(psiMdsTest)-rowMeans(psiMdsCtrl))
u12Ind<- u12Index(mdsRefIntExFilRowObj, intExCol="int_ex",
intTypeCol="intron_type")
plot(density(difPsiAll[-u12Ind], na.rm=TRUE), type='l', lwd=1, lty=2, main="",
xlab="ΔΨ")
points(density(difPsiAll[u12Ind], na.rm=TRUE), type='l', lwd=1, lty=1,
col="red")
text(x=0.05, y = 20, labels="U2", col="black")
text(x=0.4, y = 3, labels="U12", col="red")
title(main = "(D)", cex.main=1.5)
dev.off()
```
<br>
## Filtering genes with low intron retention levels {#filtering}
Here we plot density (the frequency distribution) of the log foldchange of
retention levels of various types of introns when comparing ZRSR2 mutated
samples to the ctrl samples. It shows the density plots of the full MDS data
(Fig. S2A) and the filtered data (Fig. S2B) that excludes genes which all of
their introns feature low (i.e. <=1) normalized retention. The filtered data
features less U12 and U2 type introns with log fold change IRs of ~0. These
excluded introns featured low log fold change IRs due to the low read coverage
(or possibly low expression of their transcripts).
<br>
```{r densityPlotCompare, out.width = 600, echo=TRUE, eval=TRUE, message = FALSE, fig.width=6, fig.height=8, fig.align="center", fig.cap="**Fig. S2.** Line plots showing the frequency (density) of the fold change of the FPKM normalized IR levels of U12-type introns when comparing ZRSR2mut vs controls for (A) the filtered data that lacks genes that all of its introns are low retained and (B) the complete data. As a control, density plots randomly selected U2-type introns and U2-type introns located in the U12-type intron-containing genes, either up- or downstream of the U12-type introns, are also included." }
library(IntEREst)
load(file="./mdsRefIntExObj.rda")
load(file="./mdsRefIntExFilRowObj.rda")
par(mfrow=c(2,1))
par(mar=c(5,4,2,1))
u12DensityPlotIntron(
mdsRefIntExObj[,colData(mdsRefIntExObj)$intronExon=="intron"],
type= c("U12", "U2Up", "U2Dn", "U2UpDn", "U2Rand"),
fcType= "edgeR", sampleAnnoCol="test_ctrl",
sampleAnnotation=c("ctrl","test"), intExCol="int_ex",
intTypeCol="intron_type", strandCol= "strand",
geneIdCol= "collapsed_transcripts_id", naUnstrand=FALSE, col=c(2,3,4,5,6),
lty=c(1,2,3,4,5), lwd=1, plotLegend=TRUE, cexLegend=0.7,
xLegend="topright", yLegend=NULL, legend=c(), randomSeed=10,
ylim=c(0,1), xlab=expression("log"[2]*" fold change FPKM"),
ylab="Density for the complete data")
title(main = "(A)")
par(mar=c(5,4,2,1))
u12DensityPlotIntron(
mdsRefIntExFilRowObj[,colData(mdsRefIntExObj)$intronExon=="intron"],
type= c("U12", "U2Up", "U2Dn", "U2UpDn", "U2Rand"),
fcType= "edgeR", sampleAnnoCol="test_ctrl",
sampleAnnotation=c("ctrl","test"), intExCol="int_ex",
intTypeCol="intron_type", strandCol= "strand",
geneIdCol= "collapsed_transcripts_id", naUnstrand=FALSE, col=c(2,3,4,5,6),
lty=c(1,2,3,4,5), lwd=1, plotLegend=TRUE, cexLegend=0.7,
xLegend="topright", yLegend=NULL, legend=c(), randomSeed=10,
ylim=c(0,1), xlab=expression("log"[2]*" fold change FPKM"),
ylab="Density for filtered data")
title(main = "(B)")
```
<br>
# Performance comparisons {#performance}
Here we compare the results obtained by IntEREst-DESeq2, i.e. to those
extracted from other methods.
## Comparing IntEREst-DESeq2 to IntEREst-edgeR {#comglm}
Here we compare the log foldchange and p-value results exracted from DESeq2
function of IntEREst to those resulted by the edgeR based function of
IntEREst.
<br>
```{r compareDeseq2ToEdgeR, out.width = 600, echo=TRUE, eval=TRUE, message = FALSE, fig.width=7, fig.height=14, fig.align="center", fig.cap= "**Fig. S3.** Volcano plots based on p-values and foldchange values obtained from (A) IntEREst-DESeq2 and (B) IntEREst-edgeR. The common and the unique discovered significantly more/less retained introns have been labeled and described in the legend."}
#Change this path if you prefer the temp files be copied elsewhere that the
# working directory
tmpPath<- "./"
library(DESeq2)
load(file="./ddsDiff.rda")
glmIntExRef<- glmInterest(mdsRefIntExObj,
sampleAnnoCol="test_ctrl", sampleAnnotation=c("ctrl","test"),
geneIdCol= "collapsed_transcripts_id", silent=TRUE, disp="common",
design=model.matrix(~test_ctrl+test_ctrl:intronExon,
data= colData(mdsRefIntExObj)),
contrast=c(0,0,-1,1)
)
save(glmIntExRef, file=paste(tmpPath, "glmIntExRef.rda", sep="/"))
padGlm<- p.adjust(glmIntExRef$table$PValue, method="BH")
length(padGlm)
pThresh<- 0.01
col1<-"green"
col2<-"lightblue"
col3<-"yellow2"
cols<- rep("black", length(ddsDiff$padj))
cols[which(ddsDiff$padj<pThresh&padGlm<pThresh)]<- col1
cols[which(ddsDiff$padj<pThresh&padGlm>=pThresh)]<- col2
cols[which(ddsDiff$padj>=pThresh&padGlm<pThresh)]<- col3
par(mfrow=c(2,1))
plot(ddsDiff$log2FoldChange, -1*log(ddsDiff$padj, base=10),
col=0, pch=16, xlab="FC (log2)", ylab="DESeq2 p-value (-log10)")
points(ddsDiff$log2FoldChange[cols=="black"],
-1*log(ddsDiff$padj[cols=="black"], base=10), col=cols[cols=="black"],
pch=16)
points(ddsDiff$log2FoldChange[cols==col1], -1*log(ddsDiff$padj[cols==col1],
base=10), col=cols[cols==col1], pch=16)
points(ddsDiff$log2FoldChange[cols==col2], -1*log(ddsDiff$padj[cols==col2],
base=10), col=cols[cols==col2], pch=16)
points(ddsDiff$log2FoldChange[cols==col3], -1*log(ddsDiff$padj[cols==col3],
base=10), col=cols[cols==col3], pch=16)
abline(h=2, col="red", lwd=2)
legend("topleft", legend=c("DESeq2 and GLM p-values < 0.01",
"Only DESeq2 p-value < 0.01", "Only GLM p-value < 0.01"),
fil=c(col1, col2, col3))
text(-8.5,0.8,"Y = 2",col="red", cex=1.5)
title(main = "(A)")
cols<- rep("black", length(ddsDiff$padj))
cols[which(ddsDiff$padj<pThresh&padGlm<pThresh)]<- col1
cols[which(ddsDiff$padj<pThresh&padGlm>=pThresh)]<- col2
cols[which(ddsDiff$padj>=pThresh&padGlm<pThresh)]<- col3
plot(glmIntExRef$table[,"logFC"], -1*log(padGlm, base=10), col=0, pch=16,
xlab="FC (log2)", ylab="GLM p-value (-log10)")
points(glmIntExRef$table[cols=="black","logFC"], -1*log(padGlm[cols=="black"],
base=10), col=cols[cols=="black"], pch=16)
points(glmIntExRef$table[cols==col1,"logFC"], -1*log(padGlm[cols==col1],
base=10), col=cols[cols==col1], pch=16)
points(glmIntExRef$table[cols==col2,"logFC"], -1*log(padGlm[cols==col2],
base=10), col=cols[cols==col2], pch=16)
points(glmIntExRef$table[cols==col3,"logFC"], -1*log(padGlm[cols==col3],
base=10), col=cols[cols==col3], pch=16)
abline(h=2, col="red", lwd=2)
legend("topleft", legend=c("DESeq2 and GLM p-values < 0.01",
"Only DESeq2 p-value < 0.01", "Only GLM p-value < 0.01"),
fil=c(col1, col2, col3))
text(-7.8,2.5,"Y = 2",col="red", cex=1.5)
title(main = "(B)")
```
<br>
## Comparing IntEREst-DESeq2 to IntEREst-DEXSeq {#comdexseq}
Here we compare the significantly more and less retained introns discovered by
running IntEREst-DEXSeq on the MDS data and compare to the results obtained
from IntEREst-DESeq2. Running the following script is however time consuming;
you can skip this script and continue.
```{r DEXSeqAnalysis, out.width = 600, echo=TRUE, eval=FALSE }
# Time demanding
library(BiocParallel)
library(DEXSeq)
load(file="./mdsRefObj.rda")
mdsRefObjInt<- mdsRefObj[rowData(mdsRefObj)[,"int_ex"]=="intron",]
dexObjMdsRefObjInt<- DEXSeqDataSet(
countData=counts(mdsRefObjInt),
sampleData=as.data.frame(colData(mdsRefObjInt)),
design= ~ sample + exon + test_ctrl:exon,
featureID=as.character(1:nrow(counts(mdsRefObjInt))),
groupID=as.character(rowData(mdsRefObjInt)[,"collapsed_transcripts_id"]))
save(dexObjMdsRefObjInt, file="dexObjMdsRefObjInt.rda")
#Filtering transcripts with introns that feature low read counts
sfMdsRefObjInt<- estimateSizeFactors(dexObjMdsRefObjInt)
feCntMdsRefObjInt<- rowMeans(featureCounts(sfMdsRefObjInt, TRUE))
maxRetTr<- tapply(feCntMdsRefObjInt,
as.character(rowData(mdsRefObjInt)[,"collapsed_transcripts_id"]),
max)
inTr<- names(maxRetTr)[which(as.numeric(maxRetTr)>1)]
mdsFilBool<- rowData(mdsRefObjInt)[,"collapsed_transcripts_id"] %in% inTr
mdsRefObjFilDsInt<- mdsRefObjInt[mdsFilBool,]
save(mdsRefObjFilDsInt, file="mdsRefObjFilDsInt.rda")
save(inTr, file="inTr.rda")
#DEXSeq test. Run silently
capture.output( dexseqFilIntRef<- DEXSeqIntEREst(x=mdsRefObjFilDsInt,
design= ~ sample + intron + test_ctrl:intron,
reducedModel = ~ sample + intron, fitExpToVar="test_ctrl",
intExCol="int_ex", geneIdCol="collapsed_transcripts", silent=TRUE,
bpparam=SnowParam(workers=30)), file='NUL')
save(dexseqFilIntRef, file="./dexseqFilIntRef.rda")
```
The following script plots the distributuion of pvalues to the log fold
change in the results obtained from IntEREst-DESeq2 and IntEREst-DEXSeq. It
also shows the overlapping and uniquely discovered differentialy reatined
introns by the two methods.
<br>
```{r compareDeseq2ToDEXSeq, out.width = 600, echo=TRUE, eval=TRUE, message = FALSE, fig.width=7, fig.height=14, fig.align="center", fig.cap= "**Fig. S4.** Volcano plots based on p-values and foldchange values obtained from (A) IntEREst-DESeq2 and (B) IntEREst-DEXSeq. The common and the unique discovered significantly more/less retained introns have been labeled and described in the legend."}
load(file="./mdsRefObj.rda")
load("./dexseqFilIntRef.rda")
load("./mdsRefObjFilDsInt.rda")
load("./inTr.rda")
# Get index of filtered data
mdsRefObjInt<- mdsRefObj[rowData(mdsRefObj)$int_ex=="intron",]
indDex<- which(rowData(mdsRefObjInt)[,"collapsed_transcripts_id"]
%in% inTr)
indDex<-indDex[which(rowData(mdsRefObjFilDsInt)[,"int_ex"]=="intron")]
indDds<- which(rowData(mdsRefIntExObj)[,"int_ex"]=="intron")
cols<- rep("black", length(indDex))
indSigDex<-indDex[which(dexseqFilIntRef$pvalue<pThresh)]
indSigDds<-indDds[which(ddsDiff$padj<pThresh)]
cols<- rep("black", length(indDex))
cols[which(dexseqFilIntRef$pvalue<pThresh)]<- col3
cols[which(indDex%in%indSigDds)]<- col1
cols[which(indDex %in% indSigDds[which(!(indSigDds%in%indSigDex))])]<- col2
par(mfrow=c(2,1))
pointsize=.7
plot(dexseqFilIntRef$log2fold_test_ctrl,
-1*log(dexseqFilIntRef$pvalue, base=10), col=0, pch=16, xlab="FC (log2)",
ylab="DEXSeq p-value (-log10)", cex=pointsize)
points(dexseqFilIntRef[which(cols=="black"),"log2fold_test_ctrl"],
-1*log(dexseqFilIntRef$pvalue[which(cols=="black")], base=10),
col=cols[which(cols=="black")], pch=16, cex=pointsize)
points(dexseqFilIntRef[which(cols==col1),"log2fold_test_ctrl"],
-1*log(dexseqFilIntRef$pvalue[which(cols==col1)], base=10),
col=cols[which(cols==col1)], pch=16, cex=pointsize)
points(dexseqFilIntRef[which(cols==col2),"log2fold_test_ctrl"],
-1*log(dexseqFilIntRef$pvalue[which(cols==col2)], base=10),
col=cols[which(cols==col2)], pch=16, cex=pointsize)
abline(h=2, col="red", lwd=2)
legend("topleft", legend=c("DESeq2 and DEXSeq p-values < 0.01",
"Only DESeq2 p-value < 0.01"),
fil=c(col1, col2))
text(38,6,"Y = 2",col="red", cex=1.5)
title(main = "(A)")
plot(dexseqFilIntRef$log2fold_test_ctrl,
-1*log(dexseqFilIntRef$pvalue, base=10), col=0, pch=16, xlab="FC (log2)",
ylab="DEXSeq p-value (-log10)", cex=pointsize)
points(dexseqFilIntRef[which(cols=="black"),"log2fold_test_ctrl"],
-1*log(dexseqFilIntRef$pvalue[which(cols=="black")], base=10),
col=cols[which(cols=="black")], pch=16, cex=pointsize)
points(dexseqFilIntRef[which(cols==col1),"log2fold_test_ctrl"],
-1*log(dexseqFilIntRef$pvalue[which(cols==col1)], base=10),
col=cols[which(cols==col1)], pch=16, cex=pointsize)
points(dexseqFilIntRef[which(cols==col3),"log2fold_test_ctrl"],
-1*log(dexseqFilIntRef$pvalue[which(cols==col3)], base=10),
col=cols[which(cols==col3)], pch=16, cex=pointsize)
abline(h=2, col="red", lwd=2)
legend("topleft", legend=c("DESeq2 and DEXSeq p-values < 0.01",
"Only DEXSeq p-value < 0.01"),