Getting Started with Travis Package

Intall Travis package and its dependencies

Install exomePeak, this will install a few useful packages from Bioconductor

source("http://bioconductor.org/biocLite.R")
biocLite("exomePeak")

Install ggplot2, devtools and then Travis package

install.packages("ggplot2")
install.packages("devtools")
library(devtools)
install_github('lzcyzm/Travis')

load Travis package

library(Travis)
## Loading required package: Rsamtools
## Loading required package: S4Vectors
## Loading required package: stats4
## Loading required package: BiocGenerics
## Loading required package: parallel
## 
## Attaching package: 'BiocGenerics'
## 
## The following objects are masked from 'package:parallel':
## 
##     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
##     clusterExport, clusterMap, parApply, parCapply, parLapply,
##     parLapplyLB, parRapply, parSapply, parSapplyLB
## 
## The following object is masked from 'package:stats':
## 
##     xtabs
## 
## The following objects are masked from 'package:base':
## 
##     anyDuplicated, append, as.data.frame, as.vector, cbind,
##     colnames, do.call, duplicated, eval, evalq, Filter, Find, get,
##     grep, grepl, intersect, is.unsorted, lapply, Map, mapply,
##     match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
##     Position, rank, rbind, Reduce, rep.int, rownames, sapply,
##     setdiff, sort, table, tapply, union, unique, unlist, unsplit
## 
## Loading required package: IRanges
## Loading required package: GenomeInfoDb
## Loading required package: GenomicRanges
## Loading required package: XVector
## Loading required package: Biostrings
## Loading required package: GenomicFeatures
## Loading required package: AnnotationDbi
## Loading required package: Biobase
## Welcome to Bioconductor
## 
##     Vignettes contain introductory material; view with
##     'browseVignettes()'. To cite Bioconductor, see
##     'citation("Biobase")', and for packages 'citation("pkgname")'.
## 
## Loading required package: rtracklayer
## Loading required package: GenomicAlignments
## Loading required package: SummarizedExperiment
## Loading required package: ggplot2

Read all the toy data files into a list with names

Find the toy data files came with Travis package

bed3=system.file("extdata", "H3K4me3_mm10_1000peaks.bed", package="Travis")
bed12=system.file("extdata", "m6A_mm10_exomePeak_1000peaks_bed12.bed", package="Travis")
bam1=system.file("extdata", "SRR568477_mm10_XIST.bam", package="Travis")
bam2=system.file("extdata", "SRR1768320_mm10_XIST.bam", package="Travis")

Read 4 different kinds of Genomic Features into R

H3K4me3 <- import.bed(bed3) # bed3 imported as GRanges
m6A <- BED12toGRangesList(bed12) # bed12 imported as GRangesList
## [1] "Converting BED12 to GRangesList"
## [1] "It may take a few minutes"
SRR568477 <- readGAlignments(bam1) # bam imported as GAlignments
SRR1768320 <- readGAlignments(bam2) # bam imported as GAlignments

Put everything in a list with names

peak <- list(H3K4me3,m6A,SRR568477,SRR1768320) 
names(peak) <- c("H3K4me3", "m6A", "BAM1", "BAM2")

TravisPlot

Show the transcriptomic view of 4 sets of genomic features

OPTION 1

TravisPlot(peak, 
           genome="mm10", 
           saveToPDFprefix = "Toy")

Gene annotation will be downloaded automatically, and two PDF figures with prefix “Toy” will be saved in the current working directory.

OPTION 2

It takes a few minutes to built TravisCoodinatesFromTxDb, so we may want to reuse it to save time.

txdb <- makeTxDbFromUCSC(genome="mm10") # Gene annotation downloaded from UCSC
TravisCoordsFromTxDb <- makeTravisCoordsFromTxDb(txdb) # TravisCoordinates generated
TravisPlot(peak[1:2], 
           TravisCoordsFromTxDb = TravisCoordsFromTxDb, 
           saveToPDFprefix = "Toy2")
TravisPlot(peak[3:4], 
           TravisCoordsFromTxDb = TravisCoordsFromTxDb, 
           saveToPDFprefix = "Toy3")

two PDF figures with prefix “Toy2” and “Toy3” will be saved in the current working directory.

OPTION 3

Alternatively, the function may return the figures if saveToPDFprefix is not set.

tp <- TravisPlot(peak, genome="mm10")
## [1] "Downloading Transcriptome Information from UCSC ..."
## [1] "Making Travis Coordinates ..."
## [1] "total 63244 transcripts extracted ..."
## [1] "total 49531 transcripts left after ambiguity filter ..."
## [1] "total 18997 mRNAs left after component length filter ..."
## [1] "total 7692 ncRNAs left after ncRNA length filter ..."
## [1] "Building Travis Coordinates. It may take a few minutes ..."
## [1] "Travis Coordinates Built ..."
## [1] "Figures returned as objects ..."
## [1] "Please check ..."
tp[[1]] # Please ignore the warning message
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density

tp[[2]] # Please ignore the warning message
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density

you may resize the Y-axis of the two figures with the rules in ggplot2 package.

tp[[1]] + ylim(-1,5) # reset the range of y axis. Please ignore the warning message
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density

tp[[2]] + ylim(-1,5) # reset the range of y axis. Please ignore the warning message
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density
## Warning in density.default(data$x, adjust = adjust, kernel = kernel, weight
## = data$weight, : sum(weights) != 1 -- will not get true density

Session Information

sessionInfo()
## R version 3.2.1 (2015-06-18)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 8 x64 (build 9200)
## 
## locale:
## [1] LC_COLLATE=English_United States.1252 
## [2] LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## 
## attached base packages:
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] Travis_0.1.0               ggplot2_1.0.1             
##  [3] GenomicAlignments_1.5.9    SummarizedExperiment_0.2.3
##  [5] rtracklayer_1.29.11        GenomicFeatures_1.21.13   
##  [7] AnnotationDbi_1.31.17      Biobase_2.29.1            
##  [9] Rsamtools_1.21.10          Biostrings_2.37.2         
## [11] XVector_0.9.1              GenomicRanges_1.21.15     
## [13] GenomeInfoDb_1.5.8         IRanges_2.3.12            
## [15] S4Vectors_0.7.7            BiocGenerics_0.15.2       
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.11.6          formatR_1.2          futile.logger_1.4.1 
##  [4] plyr_1.8.3           bitops_1.0-6         futile.options_1.0.0
##  [7] tools_3.2.1          zlibbioc_1.15.0      biomaRt_2.25.1      
## [10] digest_0.6.8         evaluate_0.7         RSQLite_1.0.0       
## [13] gtable_0.1.2         DBI_0.3.1            proto_0.3-10        
## [16] stringr_1.0.0        knitr_1.10.5         grid_3.2.1          
## [19] XML_3.98-1.2         BiocParallel_1.3.27  rmarkdown_0.7       
## [22] reshape2_1.4.1       lambda.r_1.1.7       magrittr_1.5        
## [25] MASS_7.3-41          scales_0.2.5         htmltools_0.2.6     
## [28] colorspace_1.2-6     labeling_0.3         stringi_0.5-5       
## [31] munsell_0.4.2        RCurl_1.95-4.6