1
### R code from vignette source 'cummeRbund-manual.Rnw'
3
###################################################
4
### code chunk number 1: init
5
###################################################
9
###################################################
10
### code chunk number 2: loadLib
11
###################################################
15
###################################################
16
### code chunk number 3: read
17
###################################################
18
myDir<-system.file("extdata", package="cummeRbund") #You can leave blank if cwd or replace with your own directory path.
19
gtfFile<-system.file("extdata/chr1_snippet.gtf",package="cummeRbund") #path to .gtf file used in cuffdiff analysis.
20
cuff <- readCufflinks(dir=myDir,gtfFile=gtfFile,genome="hg19",rebuild=T)
23
###################################################
24
### code chunk number 4: read2 (eval = FALSE)
25
###################################################
26
## cuff<-readCufflinks()
29
###################################################
30
### code chunk number 5: read3
31
###################################################
35
###################################################
36
### code chunk number 6: add_features
37
###################################################
38
#annot<-read.table("gene_annotation.tab",sep="\t",header=T,na.string="-")
39
#addFeatures(cuff,annot,level="genes")
42
###################################################
43
### code chunk number 7: global_dispersion
44
###################################################
45
disp<-dispersionPlot(genes(cuff))
49
###################################################
50
### code chunk number 8: global_dispersion_plot
51
###################################################
55
###################################################
56
### code chunk number 9: SCV_visualization
57
###################################################
58
genes.scv<-fpkmSCVPlot(genes(cuff))
59
isoforms.scv<-fpkmSCVPlot(isoforms(cuff))
62
###################################################
63
### code chunk number 10: global_plots_1
64
###################################################
65
dens<-csDensity(genes(cuff))
67
densRep<-csDensity(genes(cuff),replicates=T)
71
###################################################
72
### code chunk number 11: global_plots_dens
73
###################################################
74
dens<-csDensity(genes(cuff))
76
densRep<-csDensity(genes(cuff),replicates=T)
81
###################################################
82
### code chunk number 12: global_plots_dens_rep
83
###################################################
87
###################################################
88
### code chunk number 13: global_plots_2
89
###################################################
90
b<-csBoxplot(genes(cuff))
92
brep<-csBoxplot(genes(cuff),replicates=T)
96
###################################################
97
### code chunk number 14: global_plots_box
98
###################################################
99
b<-csBoxplot(genes(cuff))
101
brep<-csBoxplot(genes(cuff),replicates=T)
106
###################################################
107
### code chunk number 15: global_plots_box_rep
108
###################################################
112
###################################################
113
### code chunk number 16: global_plots_3.1
114
###################################################
115
s<-csScatterMatrix(genes(cuff))
119
###################################################
120
### code chunk number 17: global_plots_scatter_1
121
###################################################
122
s<-csScatterMatrix(genes(cuff))
127
###################################################
128
### code chunk number 18: global_plots_3.2
129
###################################################
130
s<-csScatter(genes(cuff),"hESC","Fibroblasts",smooth=T)
134
###################################################
135
### code chunk number 19: global_plots_scatter_2
136
###################################################
137
s<-csScatter(genes(cuff),"hESC","Fibroblasts",smooth=T)
142
###################################################
143
### code chunk number 20: global_plots_6
144
###################################################
145
dend<-csDendro(genes(cuff))
146
dend.rep<-csDendro(genes(cuff),replicates=T)
149
###################################################
150
### code chunk number 21: global_plots_dendro
151
###################################################
152
dend<-csDendro(genes(cuff))
153
dend.rep<-csDendro(genes(cuff),replicates=T)
157
###################################################
158
### code chunk number 22: global_plots_dendro_rep
159
###################################################
163
###################################################
164
### code chunk number 23: global_plots_4
165
###################################################
166
m<-MAplot(genes(cuff),"hESC","Fibroblasts")
168
mCount<-MAplot(genes(cuff),"hESC","Fibroblasts",useCount=T)
172
###################################################
173
### code chunk number 24: global_plots_MA
174
###################################################
175
m<-MAplot(genes(cuff),"hESC","Fibroblasts")
177
mCount<-MAplot(genes(cuff),"hESC","Fibroblasts",useCount=T)
182
###################################################
183
### code chunk number 25: global_plots_MA_count
184
###################################################
188
###################################################
189
### code chunk number 26: global_plots_5_1
190
###################################################
191
v<-csVolcanoMatrix(genes(cuff))
195
###################################################
196
### code chunk number 27: global_plots_volcano_1
197
###################################################
198
v<-csVolcanoMatrix(genes(cuff))
203
###################################################
204
### code chunk number 28: global_plots_5_2
205
###################################################
206
v<-csVolcano(genes(cuff),"hESC","Fibroblasts")
210
###################################################
211
### code chunk number 29: global_plots_volcano_2
212
###################################################
213
v<-csVolcano(genes(cuff),"hESC","Fibroblasts")
218
###################################################
219
### code chunk number 30: data_access_0
220
###################################################
225
###################################################
226
### code chunk number 31: data_access_1
227
###################################################
228
gene.features<-annotation(genes(cuff))
231
gene.fpkm<-fpkm(genes(cuff))
234
gene.repFpkm<-repFpkm(genes(cuff))
237
gene.counts<-count(genes(cuff))
240
isoform.fpkm<-fpkm(isoforms(cuff))
243
gene.diff<-diffData(genes(cuff))
247
###################################################
248
### code chunk number 32: data_access_2
249
###################################################
250
sample.names<-samples(genes(cuff))
252
gene.featurenames<-featureNames(genes(cuff))
253
head(gene.featurenames)
256
###################################################
257
### code chunk number 33: data_access_3
258
###################################################
259
gene.matrix<-fpkmMatrix(genes(cuff))
263
###################################################
264
### code chunk number 34: data_access_4
265
###################################################
266
gene.rep.matrix<-repFpkmMatrix(genes(cuff))
267
head(gene.rep.matrix)
270
###################################################
271
### code chunk number 35: data_access_5
272
###################################################
273
gene.count.matrix<-countMatrix(genes(cuff))
274
head(gene.count.matrix)
277
###################################################
278
### code chunk number 36: create_geneset_1
279
###################################################
283
myGenes<-getGenes(cuff,myGeneIds)
287
###################################################
288
### code chunk number 37: create_geneset_2
289
###################################################
290
#FPKM values for genes in gene set
293
#Isoform-level FPKMs for gene set
294
head(fpkm(isoforms(myGenes)))
296
#Replicate FPKMs for TSS groups within gene set
297
head(repFpkm(TSS(myGenes)))
301
###################################################
302
### code chunk number 38: geneset_plots_1
303
###################################################
304
h<-csHeatmap(myGenes,cluster='both')
306
h.rep<-csHeatmap(myGenes,cluster='both',replicates=T)
310
###################################################
311
### code chunk number 39: geneset_plots_heatmap
312
###################################################
313
h<-csHeatmap(myGenes,cluster='both')
315
h.rep<-csHeatmap(myGenes,cluster='both',replicates=T)
320
###################################################
321
### code chunk number 40: geneset_plots_heatmap_rep
322
###################################################
326
###################################################
327
### code chunk number 41: geneset_plots_1.5
328
###################################################
329
b<-expressionBarplot(myGenes)
333
###################################################
334
### code chunk number 42: geneset_plots_barplot
335
###################################################
336
b<-expressionBarplot(myGenes)
341
###################################################
342
### code chunk number 43: geneset_plots_2
343
###################################################
344
s<-csScatter(myGenes,"Fibroblasts","hESC",smooth=T)
348
###################################################
349
### code chunk number 44: geneset_plots_scatter
350
###################################################
351
s<-csScatter(myGenes,"Fibroblasts","hESC",smooth=T)
356
###################################################
357
### code chunk number 45: geneset_plots_3
358
###################################################
359
v<-csVolcano(myGenes,"Fibroblasts","hESC")
363
###################################################
364
### code chunk number 46: geneset_plots_volcano
365
###################################################
366
v<-csVolcano(myGenes,"Fibroblasts","hESC")
371
###################################################
372
### code chunk number 47: geneset_plots_4
373
###################################################
374
ih<-csHeatmap(isoforms(myGenes),cluster='both',labRow=F)
376
th<-csHeatmap(TSS(myGenes),cluster='both',labRow=F)
380
###################################################
381
### code chunk number 48: geneset_plots_isoform_heatmap
382
###################################################
383
ih<-csHeatmap(isoforms(myGenes),cluster='both',labRow=F)
385
th<-csHeatmap(TSS(myGenes),cluster='both',labRow=F)
390
###################################################
391
### code chunk number 49: geneset_plots_TSS_heatmap
392
###################################################
396
###################################################
397
### code chunk number 50: geneset_plots_5
398
###################################################
399
den<-csDendro(myGenes)
402
###################################################
403
### code chunk number 51: geneset_plots_dendro
404
###################################################
405
den<-csDendro(myGenes)
409
###################################################
410
### code chunk number 52: gene_level_1
411
###################################################
413
myGene<-getGene(cuff,myGeneId)
416
head(fpkm(isoforms(myGene)))
419
###################################################
420
### code chunk number 53: gene_plots_1
421
###################################################
422
gl<-expressionPlot(myGene)
425
gl.rep<-expressionPlot(myGene,replicates=TRUE)
428
gl.iso.rep<-expressionPlot(isoforms(myGene),replicates=T)
431
gl.cds.rep<-expressionPlot(CDS(myGene),replicates=T)
435
###################################################
436
### code chunk number 54: gene_plots_line
437
###################################################
438
gl<-expressionPlot(myGene)
441
gl.rep<-expressionPlot(myGene,replicates=TRUE)
444
gl.iso.rep<-expressionPlot(isoforms(myGene),replicates=T)
447
gl.cds.rep<-expressionPlot(CDS(myGene),replicates=T)
452
###################################################
453
### code chunk number 55: gene_plots_replicate_line
454
###################################################
459
###################################################
460
### code chunk number 56: gene_plots_iso_replicate_line
461
###################################################
466
###################################################
467
### code chunk number 57: gene_plots_cds_replicate_line
468
###################################################
473
###################################################
474
### code chunk number 58: gene_plots_2
475
###################################################
476
gb<-expressionBarplot(myGene)
478
gb.rep<-expressionBarplot(myGene,replicates=T)
482
###################################################
483
### code chunk number 59: gene_plots_bar
484
###################################################
485
gb<-expressionBarplot(myGene)
487
gb.rep<-expressionBarplot(myGene,replicates=T)
492
###################################################
493
### code chunk number 60: gene_plots_bar_rep
494
###################################################
498
###################################################
499
### code chunk number 61: gene_plots_3
500
###################################################
501
igb<-expressionBarplot(isoforms(myGene),replicates=T)
505
###################################################
506
### code chunk number 62: gene_plots_bar_isoforms
507
###################################################
508
igb<-expressionBarplot(isoforms(myGene),replicates=T)
513
###################################################
514
### code chunk number 63: features_1
515
###################################################
516
head(features(myGene))
519
###################################################
520
### code chunk number 64: features_2
521
###################################################
522
genetrack<-makeGeneRegionTrack(myGene)
523
plotTracks(genetrack)
526
###################################################
527
### code chunk number 65: features_3
528
###################################################
530
myStart<-min(features(myGene)$start)
531
myEnd<-max(features(myGene)$end)
532
myChr<-unique(features(myGene)$seqnames)
535
ideoTrack <- IdeogramTrack(genome = genome, chromosome = myChr)
536
trackList<-c(trackList,ideoTrack)
538
axtrack<-GenomeAxisTrack()
539
trackList<-c(trackList,axtrack)
541
genetrack<-makeGeneRegionTrack(myGene)
544
trackList<-c(trackList,genetrack)
546
biomTrack<-BiomartGeneRegionTrack(genome=genome,chromosome=as.character(myChr),
547
start=myStart,end=myEnd,name="ENSEMBL",showId=T)
549
trackList<-c(trackList,biomTrack)
551
conservation <- UcscTrack(genome = genome, chromosome = myChr,
552
track = "Conservation", table = "phyloP100wayAll",
553
from = myStart-2000, to = myEnd+2000, trackType = "DataTrack",
554
start = "start", end = "end", data = "score",
555
type = "hist", window = "auto", col.histogram = "darkblue",
556
fill.histogram = "darkblue", ylim = c(-3.7, 4),
557
name = "Conservation")
559
trackList<-c(trackList,conservation)
561
plotTracks(trackList,from=myStart-2000,to=myEnd+2000)
565
###################################################
566
### code chunk number 66: sig_mat_1
567
###################################################
568
mySigMat<-sigMatrix(cuff,level='genes',alpha=0.05)
572
###################################################
573
### code chunk number 67: sig_mat_plot_1
574
###################################################
575
mySigMat<-sigMatrix(cuff,level='genes',alpha=0.05)
580
###################################################
581
### code chunk number 68: get_sig_1
582
###################################################
583
mySigGeneIds<-getSig(cuff,alpha=0.05,level='genes')
588
###################################################
589
### code chunk number 69: get_sig_2
590
###################################################
591
hESC_vs_iPS.sigIsoformIds<-getSig(cuff,x='hESC',y='iPS',alpha=0.05,level='isoforms')
592
head(hESC_vs_iPS.sigIsoformIds)
593
length(hESC_vs_iPS.sigIsoformIds)
596
###################################################
597
### code chunk number 70: get_sig_3
598
###################################################
599
mySigGenes<-getGenes(cuff,mySigGeneIds)
604
###################################################
605
### code chunk number 71: get_sig_4
606
###################################################
607
mySigTable<-getSigTable(cuff,alpha=0.01,level='genes')
611
###################################################
612
### code chunk number 72: dist_heat_1
613
###################################################
614
myDistHeat<-csDistHeat(genes(cuff))
618
###################################################
619
### code chunk number 73: dist_heat_plot_1
620
###################################################
621
myDistHeat<-csDistHeat(genes(cuff))
626
###################################################
627
### code chunk number 74: dist_heat_2
628
###################################################
629
myRepDistHeat<-csDistHeat(genes(cuff),replicates=T)
633
###################################################
634
### code chunk number 75: dist_heat_plot_2
635
###################################################
636
myRepDistHeat<-csDistHeat(genes(cuff),replicates=T)
641
###################################################
642
### code chunk number 76: dim_reduction_1
643
###################################################
644
genes.PCA<-PCAplot(genes(cuff),"PC1","PC2")
645
genes.MDS<-MDSplot(genes(cuff))
647
genes.PCA.rep<-PCAplot(genes(cuff),"PC1","PC2",replicates=T)
648
genes.MDS.rep<-MDSplot(genes(cuff),replicates=T)
651
###################################################
652
### code chunk number 77: gene_PCA
653
###################################################
654
genes.PCA<-PCAplot(genes(cuff),"PC1","PC2")
655
genes.MDS<-MDSplot(genes(cuff))
657
genes.PCA.rep<-PCAplot(genes(cuff),"PC1","PC2",replicates=T)
658
genes.MDS.rep<-MDSplot(genes(cuff),replicates=T)
662
###################################################
663
### code chunk number 78: gene_MDS
664
###################################################
669
###################################################
670
### code chunk number 79: gene_PCA_rep
671
###################################################
676
###################################################
677
### code chunk number 80: gene_MDS_rep
678
###################################################
683
###################################################
684
### code chunk number 81: geneset_cluster_1
685
###################################################
686
ic<-csCluster(myGenes,k=4)
688
icp<-csClusterPlot(ic)
692
###################################################
693
### code chunk number 82: geneset_plots_cluster
694
###################################################
698
###################################################
699
### code chunk number 83: specificity_1
700
###################################################
701
myGenes.spec<-csSpecificity(myGenes)
705
###################################################
706
### code chunk number 84: similar_1
707
###################################################
708
mySimilar<-findSimilar(cuff,"PINK1",n=20)
709
mySimilar.expression<-expressionPlot(mySimilar,logMode=T,showErrorbars=F)
712
###################################################
713
### code chunk number 85: similar_plots_1
714
###################################################
715
mySimilar<-findSimilar(cuff,"PINK1",n=20)
716
mySimilar.expression<-expressionPlot(mySimilar,logMode=T,showErrorbars=F)
717
print(mySimilar.expression)
720
###################################################
721
### code chunk number 86: similar_2
722
###################################################
723
myProfile<-c(500,0,400)
724
mySimilar2<-findSimilar(cuff,myProfile,n=10)
725
mySimilar2.expression<-expressionPlot(mySimilar2,logMode=T,showErrorbars=F)
728
###################################################
729
### code chunk number 87: similar_plots_2
730
###################################################
731
myProfile<-c(500,0,400)
732
mySimilar2<-findSimilar(cuff,myProfile,n=10)
733
mySimilar2.expression<-expressionPlot(mySimilar2,logMode=T,showErrorbars=F)
734
print(mySimilar2.expression)
737
###################################################
738
### code chunk number 88: close_connection
739
###################################################
740
end<-sqliteCloseConnection(cuff@DB)
743
###################################################
744
### code chunk number 89: session
745
###################################################