Plotting Alignments

Let’s take a look at the reads that overlap rs9536314 for sample NA12893 within the Illumina Platinum Genomes dataset. This SNP resides on chromosome 13 at position 33628137 in 0-based coordinates.

# Authenticated on package load from the env variable GOOGLE_API_KEY.
suppressPackageStartupMessages(library(GoogleGenomics))
## Configured public API key.
reads <- getReads(readGroupSetId="CMvnhpKTFhDyy__v0qfPpkw",
                  chromosome="chr13",
                  start=33628130,
                  end=33628145)
## Fetching reads page.
## Note: the specification for S3 class "AsIs" in package 'jsonlite' seems equivalent to one from package 'BiocGenerics': not turning on duplicate class definitions for this class.
## Reads are now available.
alignments <- readsToGAlignments(reads)

Display the basic alignments and coverage data:

suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(ggbio))
alignmentPlot <- autoplot(alignments, aes(color=strand, fill=strand))
## Scale for 'colour' is already present. Adding another scale for 'colour', which will replace the existing scale.
## Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale.
coveragePlot <- ggplot(as(alignments, "GRanges")) +
                stat_coverage(color="gray40", fill="skyblue")
tracks(alignmentPlot, coveragePlot,
       xlab="Reads overlapping rs9536314 for NA12893")

You could also display the spot on the chromosome these alignments came from:

ideogramPlot <- plotIdeogram(genome="hg19", subchr="chr13")
ideogramPlot + xlim(as(alignments, "GRanges"))

Provenance

Package versions used:

sessionInfo()
## R version 3.2.0 (2015-04-16)
## Platform: x86_64-unknown-linux-gnu (64-bit)
## Running under: Ubuntu 14.04.2 LTS
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats4    parallel  stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] ggbio_1.16.0             ggplot2_1.0.1           
##  [3] GoogleGenomics_1.0.0     VariantAnnotation_1.14.0
##  [5] GenomicAlignments_1.4.0  Rsamtools_1.20.0        
##  [7] Biostrings_2.36.0        XVector_0.8.0           
##  [9] GenomicRanges_1.20.0     GenomeInfoDb_1.4.0      
## [11] IRanges_2.2.0            S4Vectors_0.6.0         
## [13] BiocGenerics_0.14.0      BiocStyle_1.6.0         
## 
## loaded via a namespace (and not attached):
##  [1] reshape2_1.4.1         splines_3.2.0          lattice_0.20-31       
##  [4] colorspace_1.2-6       htmltools_0.2.6        rtracklayer_1.28.0    
##  [7] yaml_2.1.13            GenomicFeatures_1.20.0 RBGL_1.44.0           
## [10] XML_3.98-1.1           survival_2.38-1        foreign_0.8-63        
## [13] DBI_0.3.1              BiocParallel_1.2.0     RColorBrewer_1.1-2    
## [16] lambda.r_1.1.7         plyr_1.8.1             stringr_0.6.2         
## [19] zlibbioc_1.14.0        munsell_0.4.2          gtable_0.1.2          
## [22] futile.logger_1.4      OrganismDbi_1.10.0     evaluate_0.6          
## [25] labeling_0.3           latticeExtra_0.6-26    Biobase_2.28.0        
## [28] knitr_1.9              GGally_0.5.0           biomaRt_2.24.0        
## [31] AnnotationDbi_1.30.0   proto_0.3-10           Rcpp_0.11.5           
## [34] acepack_1.3-3.3        scales_0.2.4           BSgenome_1.36.0       
## [37] formatR_1.1            graph_1.46.0           Hmisc_3.15-0          
## [40] jsonlite_0.9.16        gridExtra_0.9.1        rjson_0.2.15          
## [43] digest_0.6.8           biovizBase_1.16.0      grid_3.2.0            
## [46] tools_3.2.0            bitops_1.0-6           RCurl_1.95-4.5        
## [49] RSQLite_1.0.0          dichromat_2.0-0        Formula_1.2-1         
## [52] cluster_2.0.1          futile.options_1.0.0   MASS_7.3-40           
## [55] rmarkdown_0.5.1        reshape_0.8.5          httr_0.6.1            
## [58] rpart_4.1-9            nnet_7.3-9