Home
The Gviz User Guide
Contents
1. sample 1 sample 2 It is important to know that Gviz is fully unaware of the intention and any specifics of the track merging operation Any track type can be merged with any other track type and there are no limitations on the number of overlays It is totally up to the user to design reasonable merges and to control critical aspects of the plot like the y axis scaling or the grouping in the above example During rendering the software will only use the first track object in the trackList container of Overlay Tracks object to set up the track title Thus the ranges on the y axis are those that have been automatically determined for the first of our two Data Tracks Only by forcing a common y range for both objects do we actually plot the data from both tracks on a common scale Had we added another track object that is not a Data Track is the first element of our trackList there wouldn t even be an axis In a similar fashion by nicely setting up the group levels for the two Data Tracks we can even ask for a legend to be added On devices that support it alpha blending can be a useful tool to tease out even more information out of track overlays at least when comparing just a small number of samples The resulting transparancy effctively eliminates the probelm of overplotting The following example will only work if this vignette has been built on system with alpha blending support w gt displayPars dtrack lt list alpha ti
2. Logical scalar Always plot colored boxes for mismatch bases regardles of the available space Integer scalar The height of the sashimi part of the track Can either be a value between 0 and 1 in which case it is taken as a relative height or a positive value greater 1 in which case it is interpreted as pixels Integer scalar The minimum number of reads supporting the junction Integer scalar Only reads which have the specified strand are considered to count the junctions Logical scalar Add mismatch information either as individual base letters or us ing color coded bars This implies that the reference sequence has been provided either to the class constructor or as part of the track list Character vactor The type of information to plot For coverage a cover age plot potentially augmented by base mismatch information for sashimi a sashimi plot showing the juctions and for pileup the pileups of the individual reads Theese three can be combined The Gviz User Guide 65 4 10 Creating tracks from UCSC data The UCSC data bases contain a multitude of genome annotation data for dozents of different organisms Some of those data are very simple annotations like CpG island locations or SNP locations Others are more complicated gene models or even numeric annotations like conservation information In order to provide a unified interface to all this information the Gviz package defines a meta constructor function UcscTrack T
3. Conservation table phyloP30wayPlacental from from to to trackType DataTrack start start end end data score type hist window auto col histogram darkblue fill histogram darkblue ylim c 3 7 4 name Conservation gt gcContent lt UcscTrack genome mm9 chromosome chrX track GC Percent table gcbBase from from to to trackType DataTrack start start end end data score type hist window 1 windowSize 1500 fill histogram black col histogram black ylim c 30 70 name GC Percent To add some reference points we also need a genome axis and an Ideogram Track of the x chromosome gt axTrack lt GenomeAxisTrack gt idxTrack lt IdeogramTrack genome mm9 chromosome chrX And finally we can plot all of our tracks gt plotTracks list idxTrack axTrack knownGenes refGenes ensGenes cpgIslands gcContent conservation snpLocations from from to to showTitle FALSE The Gviz User Guide 68 65 93 mb 65 95 mb 65 97 mb 65 94 mb 65 96 mb E t tH B Hb E I H3 L E I H3 l ig i Hb H gt H H B ll HA H H 8 I L H 3 4 HAHAHA E En HAI HH Ht HA l H gt EHA H E HH l HHA E HH E a I H 3 E l HAI tI El I I H HAI A HHE I I H HHA Hork I I HHA tt 8 I l HAI Hr I HHA tt H H a I H
4. active chromosome chr1 referenced file tmp RtmpdVyvft Rinst615452e4743f Gviz extdata test bam Data transformations The Gviz package offers quite some flexibility to transform data on the fly This involves both rescaling operations each data point is transformed on the track s y axis by a transformation function as well as summarization and smoothing operations the values for several genomic locations are summarized into one The Gviz User Guide 26 derived value on the track s x axis To illustrate this let s create a significantly bigger Data Track than the one we used before containing purely syntetic data for only a single sample gt dat lt sin seq pi 10 pi len 500 gt dTrack big lt DataTrack start seg 1 100000 len 500 width 15 chromosome chrX genome hg19 name sinus data sin seq pi 5 pi len 500 runif 500 0 5 1 5 gt plotTracks dTrack big type hist Since the available resolution on our screen is limited we can no longer distinguish between individual coor dinate ranges The Gviz package tries to avoid overplotting by collapsing overlapping ranges assuming the collapseTracks parameter is set to TRUE However it is often desirable to summarize the data for instance by binning values into a fixed number of windows followe by the calculation of a meaningful summary statistic This can be archived by a combination of the window and aggregation display
5. GRanges Constructor or setAs method additional data in metadata columns GRangesList Constructor or setAs method additional data in metadata columns TxDb Constructor or setAs method DataTrack data frame Constructor IRanges Constructor additional data matrix GRanges Constructor or setAs method numeric data in metadata columns SequenceTrack DNAStringSet Constructor BSgenome Constructor The Gviz User Guide 15 We have seen in previous examples that the Gviz package supports quite a wide range of standard file types as inputs for the class constructor functions In this section we summarize the file support for the different track classes in one place Gviz class File type Extension Streaming Details Annotation Track BED GFF GFF2 GFF3 BAM bed gff gff1 gff2 gff3 bam Genomic locations from the manda tory chrom chromStart and chromEnd fields and optionally the strand from the strand field If present the information in the name field is mapped to track item ids and itemRgb is mapped to track item feature type All other fields are currently ignored Only the following basic GFF fields are recognized seqname start end end strand feature mapped to track item feature type and group to allow for track item grouping Same as above but feature grouping information may be provided either as Group or Parent attribute Feature ids are mapped to one of the ID
6. The font color for the group level annotation Integer scalar The font face for item identifiers Numeric scalar The font face for the group level annotation Character scalar The font family for item identifiers Character scalar The font family for the group level annotation Numeric scalar The font size for item identifiers Numeric scalar The font size for the group level annotation Logical scalar Use human readable gene symbols or gene IDs for the transcript annotation Numeric scalar The line expansion factor for all track items This is also used to connect grouped items See grouping for details Numeric scalar The font line height for item identifiers Character or integer scalar The line type for all track items This is also used to connect grouped items See grouping for details Integer scalar The line width for all track items This is also used to connect grouped items See grouping for details Numeric scalar The minimum pixel distance before collapsing range items only if collapse TRUE See collapsing for details Note that a value larger than 0 may lead to UTR regions being merged to CDS regions which in most cases is not particularly useful Numeric scalar The minimum range width in pixels to display All ranges are expanded to this size in order to avoid rendering issues See collapsing for details Numeric scalar The degree of text rotation for item identifiers Character scalar The shape in which
7. panel bwplot for details Numeric scalar Parameter controlling the boxplot appearance See panel bwplot for details Numeric scalar The default pixel size for plotting symbols Numeric scalar The size factor for the legend text Numeric scalar The size factor for the sample names text in heatmap or horizon plots Defaults to an automatic setting Numeric scalar Parameter controlling the boxplot appearance panel bwplot for details Character or integer vector The color used for all line and symbol elements unless there is a more specific control defined elsewhere Unless groups are specified only the first color in the vector is usually regarded Character scalar Color for the optional baseline defaults to the setting of col Character vector Border colors for the confidence intervals for confint type plots See The Gviz User Guide col confint col grid col histogram col horizon col line col mountain col sampleNames col symbol collapse degree do out evaluation factor family fill fill histogram fill horizon fill mountain fontcolor legend fontface legend fontfamily legend fontsize legend gradient grid groups Character vector Fill colors for the confidence intervals for confint type plots Integer scalar The line color for grid elements Character scalar Line color in histogram type plots The line color for the segments in the horizon type plot See horizonplot for details Charac
8. shape arrow transcriptAnnotation symbol The Gviz User Guide 41 KIAA0087 C7ort71 RPL7AP38 Aco049472 soo MI HMGB3P20 Collapsing down all the way to a gene is not always the desired oparation and the parameters offers a bit more control For instance we could decide to plot just the longest transcript by setting it to longest plotTracks grtrack collapseTranscripts longest shape arrow transcriptAnnotation symbol KlAA0087 C7ortz1 H SKAP2 Hl AC004947 2 HI RPL7AP38 HMGB3P20 Or we can plot the union of all the exons in some sort of meta transcript gt plotTracks grtrack collapseTranscripts meta shape arrow transcriptAnnotation symbol KIAA0087 c7orf71 H RPL7AP38 Ac004947 2 I skAP2 H HH IHIH HMGB3P20 Building GeneRegionTrack objects from TxDbs The GenomicFeatures packages provides an elegant framework to download gene model information from online sources and to store it locally in a SQLite data base Because these so called TxDb objects have become the de facto standard for genome annotation information in Bioconductor we tried to make it as simple as possible to convert them into GeneRegion Tracks Essentially one only has to call the constructor function with the TxDb object as a single argument We exemplify this on a small sample data set that comes with the GenomicFeatures package V library GenomicFeatures gt samplefile lt system
9. ENSMUST 66666127993 mea ENSMUST 66666158552 1 CpG Islands Islands lt 390 Bases are Light Green CpG Islands T9 a GC Percent in 5 Base Windows GC Percent Se 2 2 Placental Mammal Basewise Conservation by Phy loP Mammal Cons B URN A A A A A Jose hd NIU FA alli ll all e T CR Mr imple Nucleotide Polymorphisms dbSNP build 128 iA tT l ot Him Ill s SNPs ci255 p M BW 1 1 1 HWM LI ggg Figure 1 A screen shot of a UCSC genome browser view around the FMR1 locus on the mouse chromosome To start we first need to know about the available data in the UCSC data base and about their structure A good way to do this is to use the table browser on the UCSC web site http genome ucsc edu cgi bin hgTables command start Figure 4 10 shows the table structure for the first gene model track the known UCSC genes in the table browser We can see that there are multiple fields some with genomic locations other with additional data like labels or identifiers If we go back to the section about the GeneRegion Track class we remember that we need exactly this type of information for the constructor function So in order to take the UCSC data and build an object of class GeneRegion Track we need a way to map them to the individual constructor arguments This is exactly what the UcscTrack meta constructor is supposed to do for us The Gviz User Guide 66 Schema for UCSC Genes UCSC Genes Based on RefSeq UniProt GenBank C
10. FALSE just group Character scalar the justification of group labels Either left right above or below lex Numeric scalar The line expansion factor for all track items This is also used to connect grouped items See grouping for details The Gviz User Guide 39 lineheight Numeric scalar The font line height for item identifiers Ity Character or integer scalar The line type for all track items This is also used to connect grouped items See grouping for details lwd Integer scalar The line width for all track items This is also used to connect grouped items See grouping for details mergeGroups Logical scalar Merge fully overlapping groups if collapse TRUE min height Numeric scalar The minimum range height in pixels to display All ranges are expanded to this size in order to avoid rendering issues See collapsing for details For feathered bars indicating the strandedness of grouped items this also controls the height of the arrow feathers min width Numeric scalar The minimum range width in pixels to display All ranges are expanded to this size in order to avoid rendering issues See collapsing for details rotation group Numeric scalar The degree of text rotation for group labels rotation item Numeric scalar The degree of text rotation for item identifiers shape Character scalar The shape in which to display the track items Currently only box arrow fixedArrow ellipse and smallArrow are implemented showFeatureld Log
11. M TO 26 6 mb 26 8 mb 26 7 mb 26 9 mb Ideogram tracks are the one exception in all of Gviz s track objects in the sense that they are not really displayed on the same coordinate system like all the other tracks Instead the current genomic location is indicated on the chromosome by a red box or as in this case a red line if the width is too small to fit a box So far we have only looked at very basic annotation features and how to give a point of reference to our plots Naturally we also want to be able to handle more complex genomic features such as gene models One potential use case would be to utilize gene model information from an existing local source Alternatively we could dowload such data from one of the available online resources like UCSC or ENSEBML and there are constructor functions to handle these tasks For this example we are going to load gene model data from a stored data frame The track class of choice here is a GeneRegion Track object which can be created via the constructor function of the same name Similar to the Annotation Track constructor there are multiple possible ways to pass in the data The Gviz User Guide 5 gt data geneModels gt grtrack lt GeneRegionTrack geneModels genome gen chromosome chr name Gene Model gt plotTracks list itrack gtrack atrack grtrack Oc Ch a INT NT NM T 26 6 mb 26 8 mb 27 mb 26 7 mb 26 9 mb In all those previous examples the
12. Name or Alias attributes Same as above but feature grouping in formation has to be provided as the Par ent attribute Only start and end locations as well as the strand information for the reads are used Read identifiers are used for track item grouping GeneRegionTrack GTF GFF GFF2 GFF3 gtf gff gff1 gff2 gff3 A somewhat looser format definition for gtf files is applied here where gene transcript and exon identifiers and names can be parsed from the gene id gene name transcript id tran Script name exon id or exon id at tributes This only supports very limited item grouping and thus complete gene mod els can not be properly encoded In most instances this is identical to the GTF standard and it could make sense to rename the file accordingly The gene to transcript and transcript to exon relationships are encoded in the parent and type attributes and the parser tries to accomodate most of the exisiting GFF3 variants The Gviz User Guide 76 DataTrack BedGraph bedGraph x WIG wig BigWig bigWig bw y BAM bam y Read coverage only is extracted from the bam file SequenceTrack FASTA fa fasta Y Streaming only possible if an index file is found in the same directory as the origi nal fasta file 2Bit 2bit V AlignmentsTrack BAM bam y ALways needs an index file is found in the same directory as the original BAM file
13. The Gviz User Guide 51 Display Parameter Description details minWidth details ratio details size detailsBorder col detailsBorder fill detailsBorder ty detailsBorder lwd detailsConnector cex detailsConnector col detailsConnector Ity detailsConnector lwd detailsConnector pch detailsFunArgs groupDetails Numeric scalar The minium width in pixels for a details panel if less space is available no details are plotted Numeric scalar By default the plotting method tries to fill all available space of the details panel tiles Depending on the dimensions of your plot and the number of tiles this may lead to fairly stretched plots Restricting the ration of width over height can help to fine tune for somewhat more sane graphics in these cases Essentially this adds some white space in between individual tiles to force the desired ratio Together with the size and details size arguments which control the vertical extension of the whole track and of the details section this allows for some fairly generic resizing of the tiles Numeric scalar The fraction of vertical space of the track used for the details section Character or integer scalar Line color of the border Character or integer scalar Background color of the border Character or integer scalar Line type of the border around each details panel Integer scalar Line width of the border Numeric scalar Relative size of the connector s end poi
14. and build the gene model on the fly Please note that you will need an internet connection for this to work and that contacting Biomart can take a significant amount of time depending on usage and network traffic Hence the results are almost never going to be returned instantaniously gt biomTrack lt BiomartGeneRegionTrack genome hg19 chromosome chr start 20000000 end 21000000 name ENSEMBL gt plotTracks biomTrack MASH 71 0 n Di Il 50M Me Toe E O HH a pu iD m LET Ug D Hii 2 0 RDT E AA E 330 HH 0 O H odo i S H tf p D 1 pa pcs HID g Hi B8 B ge i i bi n i a HAH Do 00 O D H Cissa o D f ig You may have noticed in the above plot that the track includes feature information which is displayed by the different feature colors and box sizes This information has been automatically extracted from Biomart and the respective color coding is part of the class definition We can highlight the feature classes even more by using similarly colored bars to connect the grouped elements and by dropping the bounding boxes around the individual exon models gt plotTracks biomTrack col line NULL col NULL d e ERT qn H a RO E A t du uu Equi ga ERR E EA e Pam i m t le L D a E pr f E ese ist ba E HIETIEEH as mp For dense stacked plots like this it can sometimes be helpful to control the vertical spacing between the stacking rows A simple way to do this is available for eac
15. can be shown to the available device resolution By default this feature is turned on and the user does not have to worry too much about it However one should be aware of the consequences this may have on a given visualization If you absolutely do not want collapsing to take place you may completely turn it off by setting the display parameter collapse to FALSE Please note that by doing The Gviz User Guide 35 this the showOverplotting parameter will also stop working If you opt in there is some considerable amount of detailed control to fine tune the collapsing to your needs Let s start with a small example track for which element collapsing has been turned off and no adjustments to the ranges have been made We plot both the item identifiers and the group identifiers to exemplify what is going on gt data collapseTrack gt plotTracks ctrack group 1 a bo d g group 3 i group 2 Eh i group 4 cx The first thing to notice is that the for item d we do see the item identifier but not the range itself This is due to the fact that the width of the item is smaller than a single pixel and hence the graphics system can not display it Note that this is only true for certain devices The quartz device on the Mac seems to be a little smarter about this There are also the two items e and f which seem to overlay each other completely and another two items which appear to be just a single fused item k and 1 Again this is a resolution
16. chr1 referenced file tmp RtmpdVyvft Rinst615452e4743f Gviz extdata test bam mapping id id group id plotTracks aTrack3 from 189995000 to 190000000 Please note that if no metadata column can be mapped to the constructor arguments their values are assumed to be normal character scalars and they will be recycled accordingly to fill the track s slots One can ask for the package s default mappings by using the availableDefaultMapping function gt availableDefaultMapping bamFile AnnotationTrack id 1 id group 1 group We can now plot both the Data Track representation as well as the AnnotationTrack representation of the bam file together to prove that the underlying data are indeed identical plotTracks list dTrack4 aTrack2 from 189990000 to 190000000 The Gviz User Guide 38 Display parameters for AnnotationTrack objects For a complete listing of all the available display parameters please see the table below or the man page of the Annotation Track class by typing in AnnotationTrack on the Rcommand line Display Parameter Description alpha Numeric scalar between 0 and 1 The opacity of the plotting elements if sup ported by the device arrowHeadMaxWidth Numeric scalar The maximum width of the arrow head in pixels if shape is arrow arrowHeadWidth Numeric scalar The width of the arrow head in pixels if shape is fixedArrow cex Numeric scalar The font expansion factor for
17. chromosome or to show the measurement values of mapped probes from a micro array experiment This concludes our first introduction into the Gviz package The remainder of this vignette will deal in much more depth with the different concepts and the various track classes and plotting options 3 Plotting parameters 3 1 Setting parameters Although not implicitely mentioned before we have already made use of the plotting parameter facilities in the Gviz package or as we will call them from now on the display parameters Display parameters are properties of individual track objects i e of any object inheriting from the base GdObject class They can either be set during object instantiation as additional arguments to the constructor functions or for existing track objects using the displayPars replacement method In the former case all named arguments that can not be matched to any of the constructor s formal arguments are considered to be display parameters regardless of their type or whether they are defined for a particular track class or not The following code example rebuilds our GeneRegion Track object with a bunch of display parameters and demonstrates the use of the displayPars accessor and replacement methods gt grtrack GeneRegionTrack geneModels genome gen T chromosome chr name Gene Model transcriptAnnotation symbol background title brown gt head displayPars grtrack The Gviz User Guid
18. computed for each group separately and also indicated by two lines with similar color coding Grouping is not supported for all plotting types for example the mountain and polygon type already use color coding to convey a different message and for the gradient type the data are already collapsed to a single variable The following gives an overview over some of the other groupable Data Track types Please note that there are many more display parameters that control the layout of both grouped and of ungrouped DataTracks You may want to check the class help page for details Bess E E Maa A pele E If we need to display some additional information about the individual group levels we can make use of the legend display parameter to add a simple legend to the plot Depending on the plot type and on some of the other display parameters the look of this legend may vary slightly gt plotTracks dTrack groups rep c control treated each 3 type c a p legend TRUE A different data set is plotted for the horizon type for the sake of clarity The Gviz User Guide 23 control treated For a grouped horizon plot the group labels have to be shown in a similar fashion as for heatmaps i e by setting the showSampleNames argument to TRUE gt data dtHoriz gt dtHoriz lt dtHoriz 1 6 gt plotTracks dtHoriz type horiz groups rownames values dtHoriz showSampleNames TR
19. default type of all line elements Integer or character scalar The line type of the coverage profile Integer or character scalar The type of the line that is bridging the gap regions in gapped alignments Integer or character scalar The type of the line that is connecting two paired reads Integer or character scalar The box line type around mismatch bases Integer or character scalar The box line type around mismatch reads Integer scalar The default width of all line elements Integer or character scalar The line width of the coverage profile Integer scalar The width of the line that is bridging the gap regions in gapped alignments Integer scalar The width of the line that is connecting two paired reads Integer scalar The box line width around mismatch bases Integer scalar The box line width around reads Integer scalar The maximal width of the line in sashimi plots Integer scalar The maximum height of an individual read in pixels Can be used in combination with min height to control the read and stacking appearance Integer scalar The minimum height of an individual read in pixels Can be used in combination with max height to control the read and stacking appearance Integer scalar The minimum height of the coverage section Uselful in combi nation with a relative setting of coverageHeight Integer scalar The minimum height of the sashimi section Uselful in combina tion with a relative setting of sashimiHeight
20. depending on the zoom level This is a feature of the Gviz package which automatically tries to find the optimal visualization settings to make best use of the available space At the same time when features on a track are too close together to be plotted as separate items with the current device resolution the package will try to reasonably merge them in order to avoid overplotting Often individual ranges on a plot tend to grow quite narrow in particular when zooming far out and a couple of tweaks become helpful in order to get nice plots for instance to drop the bounding borders of the exons gt plotTracks list itrack gtrack atrack grtrack extend left 0 5 extend right 1000000 col NULL oco CNN i i gt i HEHEN IN IT E T 26 5 mb 27 5 mb 27 mb bo Ht H I i a HH H H H H H H i I H H Lj When zooming further in it may become interesting to take a look at the actual genomic sequence at a given position and the Gviz package provides the track class SequenceTrack that let s you do just that Among several other options it can draw the necessary sequence information from one of the BSgenome packages gt library BSgenome Hsapiens UCSC hgi9 gt strack SequenceTrack Hsapiens chromosome chr plotTracks list itrack gtrack atrack grtrack strack from 26591822 to 26591852 cex 0 8 The Gviz User Guide T Oo CN HNMEOENENEO HE HEHENM ENERO M TO 26 591825 mb 26 591835 mb 26 59
21. e e e i e oe e gt A D e xd m e e e e e o s e o e e e T P e s e se e ee ee e e e e o 3 A e e e s e e e e A e s s E 5 e e One can also build multiple Highlight Track collections to create gaps in the highlighting regions For Ideogram Tracks we never plot highlighting ranges because they do not live on the same x axis coordinate system like the other tracks gt hti HighlightTrack trackList list itrack gtrack atrack start c 26705000 26720000 width 7000 chromosome 7 gt ht2 lt HighlightTrack trackList dtrack start c 26705000 26720000 width 7000 chromosome 7 gt plotTracks list ht1 grtrack ht2 from lim 1 to lim 2 The Gviz User Guide 70 Ov MEN M gt a M 26 71 mb 26 73 mb 26 72 mb 26 74 mb EEH H Display parameters for HighlightTrack objects For a complete listing of all the available display parameters please see the table below or the man page of the Highlight Track class by typing in HighlightTrack on the Rcommand line Display Parameter Description col Integer or character scalar The boder color for the highlighting regions fill Integer or character scalar The fill color for the highlighting regions inBackground Logical scalar Place the box in the background or in the foreground 5 2 Overlays For certain applications it can make
22. file extdata hg19_knownGene_sample sqlite package GenomicFeatures gt txdb lt loadDb samplefile gt GeneRegionTrack txdb GeneRegionTrack GeneRegionTrack genome hg19 active chromosome chr1 annotation features 162 There are 1808 additional annotation features on 26 further chromosomes chr O 17 chrii 123 The Gviz User Guide 42 chr12 25 chr13 37 chri4 55 chr6_ssto_hap7 28 chr7 46 chr8 40 chr9 52 chrX 250 Call seqlevels obj to list all available chromosomes or seqinfo obj for more detailed output Call chromosome obj lt chrlId to change the active chromosome In this context the constructor s chromosome start and end argument take on a slightly differnt meaning in that they can be used to subset the data that is fetched from the TxDb object Please note that while the chromosome alone can be supplied providing start or end without the chromosome information will not work gt txTr lt GeneRegionTrack txdb chromosome chr6 start 35000000 end 40000000 A nice bonus when building GeneRegion Tracks from TxDb objects is that we get additional information about coding and non coding regions of the transcripts e coordinates of the 5 and 3 UTRs and of the CDS regions The class plotting method can use this inforamtion to distinguish between coding and non coding regions based on the shape of the feature All coding regions are plotted just as we have se
23. functions as well as a broad range of methods to interact with and to plot these tracks When combining multiple objects the individual tracks will always share the same genomic coordinate system thus taking the burden of aligning the plot elements from the user It is worth mentioning that at a given time tracks in the sense of the Gviz package are only defined for a single chromosome on a specific genome at least for the duration of a given plotting operation You will later see that a track may still contain information for multiple chromosomes however most of this is hidden except for the currently active chromosome and the user will have to explicitely switch the chromsome to access the inactive parts While the package in principle imposes no fixed structure on the chromosome or on the genome names it makes sense to stick to a standaradized naming paradigm in particular when fetching additional annotation information from online resources By default this is enforced by a global option ucscChromosomeNames which is set during package loading and which causes the package to check all supplied chromosome names for validity in the sense of the UCSC definition chromosomes have to start with the chr string You may decide to turn this feature off by calling options ucscChromosomeNames FALSE For the remainder of this vignette however we will make use of the UCSC genome and chromosome identifiers e g the chr7 chromosome on the mouse mm9 geno
24. hg19 chromosome chrX gt plotTracks ideoTrack from 85000000 to 129000000 ChomosomeX CE MEER NM gt a 7 MH EH E O We can turn off the explicit plotting of the chromosome name by setting the showld display parameter to FALSE plotTracks ideoTrack from 85000000 to 129000000 showId FALSE nnn E eee EM EH NUN O The chromosome bands in the ideogram come with a unique identifier and we can add this information to the plot at least for those bands that are wide enought to accomodate the text plotTracks ideoTrack from 85000000 to 129000000 T showId FALSE showBandId TRUE cex bands 0 5 Em I EZE Display parameters for IdeogramTrack objects For a complete listing of all the available display parameters please see the table below or the man page of the Ideogram Track class by typing in IdeogramTrack on the Rcommand line Display Parameter Description bevel Numeric scalar between 0 and 1 The level of smoothness for the two ends of the ideogram cex Numeric scalar The overall font expansion factor for the chromosome name text cex bands Numeric scalar The font expansion factor for the chromosome band identifier text The Gviz User Guide 18 col Character scalar The border color used for the highlighting of the currently displayed genomic region fill Character scalar The fill color used for the highlighting of the currently displayed genomic
25. import the data from the file into a GRanges object and then provided this object to the constructor The real power of the file support in the Gviz package comes with streaming from indexed files As mentioned before only the relevant part of the data has to be loaded during the plotting operation so the underlying data files may be quite large without decreasing the performance or causing too big of a memory footprint We will exemplify this feature here using a small bam file that is provided with the package bam files contain alignments of sequences typically from a next generation sequencing experiment to a common reference The most natural representation of such data in a DataTrack is to look at the alignment coverage at a given position only and to encode this in a single metadata column gt bamFile lt system file extdata test bam package Gviz gt dTrack4 lt DataTrack range bamFile genome hg19 type 1 name Coverage window 1 chromosome chr1 gt class dTrack4 1 ReferenceDataTrack attr package 1 Gviz gt dTrack4 ReferenceDataTrack Coverage genome hg19 The Gviz User Guide 25 active chromosome chr1 referenced file tmp RtmpdVyvft Rinst615452e4743f Gviz extdata test bam plotTracks dTrack4 from 189990000 to 190000000 As seen in the previous code chunk the dTrack4 object is now of class ReferenceData Track For the user this distinction is not part
26. meta item and hide all together disables the plotting of AnnotationTrack items Please note that adding identifiers to the plot only works for the squish option gt plotTracks aTrack stacked stacking dense In addition to annotation groups there is also the notion of a feature type in the Gviz package Feature types are simply different types of annotation regions e g mRNA transcripts miRNAs rRNAs etc that are indicated by different colors There is no limit on the number of different features however each element in a grouped annotation item needs to be of the same feature type We can query and set features using the feature and feature lt methods feature aTrack stacked 1 unknown unknown unknown unknown unknown unknown feature aTrack stacked c foo bar bar bar no no Features types can also be shown as either the group or the item annotation on the plot gt plotTracks aTrack stacked featureAnnotation feature groupAnnotation feature fontcolor feature 1 cex feature 0 7 foo foo bar bar bar bar no no no Unless we tell the Gviz package how to deal with the respective feature types they will all be treated in a similar fashion i e they will be plotted using the default color as defined by the fill display paramter To define colors The Gviz User Guide 34 for individual feature types we simply have to add them as additional display parameters where the
27. parameter name matches the feature type and ts value is supposed to be a valid R color qualifier Of course this implies that we can only use feature names that are not already occupied by other display parameters defined in the package gt plotTracks aTrack stacked groupAnnotation group foo darkred bar darkgreen Huey M Louie Dewey Mi A Stacking of annotation items to avoid overplotting only works as long as there is enough real estate on the plotting canvas to separate all items e we need all items to be at least a single pixel wide to correctly display them This limitation is automatically enforced by the Gviz package however it implies that unless neighbouring items are more than one pixel appart we can not distinguish between them and will inevitably introduce a certain amount of overplotting This means that on a common screen device we can only look at a very limited genomic region of a few kb in full resolution Given that an average chromosome is in the order of a few gb we still need a reasonable way to deal with the overplotting problem despite the item stacking functionality As default the Gviz package will merge all overlapping items into one unified meta item and only plot that see Collapse section below for details In order to indicate the amount of overplotting that was introduced by this process we can use the showOverplotting display parameter It uses a color scale based on the orginal colors d
28. plotted genomic range has been determined automatically from the input tracks Unless told otherwise the package will always display the region from the leftmost item to the rightmost item in any of the tracks Of course such a static view on a chromosomal region is of rather limited use We often want to zoom in or out on a particular plotting region to see more details or to get a broader overview To that end plotTracks supports the from and to arguments that let us choose an arbitrary genomic range to plot gt plotTracks list itrack gtrack atrack grtrack from 26700000 to 26750000 Chomosome7 CNEM MANR MO HN O INT IT A T 26 71 mb 26 73 mb 26 72 mb 26 74 mb EA Another pair of arguments that controls the zoom state are extend left and extend right Rather than from and to those arguments are relative to the currently displayed ranges and can be used to quickly extend the view on one or both ends of the plot In addition to positive or negative absolute integer values one can also provide a float value between 1 and 1 which will be interpreted as a zoom factor i e a value of 0 5 will cause zooming in to half the currently displayed range gt plotTracks list itrack gtrack atrack grtrack extend left 0 5 extend right 1000000 The Gviz User Guide chromosome i G gt IT IT O 26 5 mb 0 IHH Hit 27 5 mb 27 mb You may have noticed that the layout of the gene model track has changed
29. ranges gt detFun lt function identifier Gd bject original xad d plotTracks list GenomeAxisTrack scale 0 3 size 0 2 cex 0 7 Gd bject original group Gd bject original identifier add TRUE showTitle FALSE Finally we load some sample data turn it into a DetailsAnnotationTrack object and plot it gt data geneDetails gt deTrack2 lt AnnotationTrack geneDetails fun detFun selectFun selFun groupDetails TRUE details size 0 5 detailsConnector cex 0 5 detailsConnector lty dotted shape c smallArrow arrow groupAnnotation group gt plotTracks deTrack2 extend left 90000 anscript 2 anscript 3 anscript 4 transcript 1 transcript 2 transcript 4 transcript 3 Display parameters for DetailsAnnotationTrack objects In addtion to the display parameters for the Annotation Track class some additional parameters can be used to control the look and feel of the details sections For a complete listing of all the available display param eters please see the tables below and the one above in the Annotation Track section or the man page of the DetailsAnnotation Track class by typing in DetailsAnnotationTrack on the Rcommand line gt plotTracks deTrack details size 0 75 detailsConnector pch NA detailsConnector col darkred detailsBorder fill FFE3BF detailsBorder col darkred shape box detailsConnector lty dotted
30. the entrez argument In all of these cases the constructor will also fetch models for other genes that overlap the same region If that is not desired one needs to provide an explicit Biomart filter gt biomTrack BiomartGeneRegionTrack genome hg19 name ENSEMBL symbol ABCB5 gt plotTracks biomTrack ABCBS et HH HA LESE HH H H AC002486 3 ABCB5 HH ABCB5 HH ABCB5 HH ABCBS HHA I H HH FA H Using custom biomaRt objects for BiomartGeneRegionTracks Gviz tries hard to automatically set up the necessary connection to the Biomart service to retrieve the relevant data Sometimes however it can be advantagous to fully control the Biomart connector for instance when The Gviz User Guide 46 trying to retrieve data from an archived Ensembl version by default biomaRt will always link to the most recent version To that end the biomart parameter can be used to supply a biomaRt object Please note that a data set has to be selected in that object A second prerequesite for this to work is that Gviz is able to guess which of the values that are queried from the Ensembl data base represent which track feature If there were no changes in the schema of Ensembl or if the schema for all marts was similar this would not be an issue but that is not the case In the following example we show how to fetch data for the same region from the older version Ensembl version 47 The internal getBMFeatureMap is helpful to set up t
31. to display the track items Currently only box arrow ellipse and smallArrow are implemented Logical scalar Control whether to plot the individual exon identifiers Logical scalar Control whether to annotate individual groups Logical scalar Use a color gradient to show the amount of overplotting for collapsed items This implies that collapse TRUE Character vector A listing of feature types that should be drawn with thin boxes Typically those are non coding elements The Gviz User Guide 44 transcriptAnnotation Character scalar Add annotation information as transcript labels This can be a value in symbol gene transcript exon or feature Defaults to symbol Only works if showId is not FALSE 4 6 BiomartGeneRegionTrack As seen before it can be very useful to quickly download gene annotation information from an online repositry rather than having to construct it each time from scratch To this end the Gviz package also defines the BiomartGeneRegion Track class which directly extends GeneRegionTrack but provides a direct interface to the ENSEMBL Biomart service yet another interface to the UCSC data base content is highlighted in one of the next sections Rather than providing all the bits and pieces for the full gene model we just enter a genome chromosome and a start and end position on this chromosome and the constructor function BiomartGeneRegionTrack will automatically contact ENSEMBL fetch the necessary information
32. well as their default values in a list like structure The single The Gviz User Guide 12 argument to the function is either a class name of a track object class or the object itself in which case its class is automatically detected gt dp lt availableDisplayPars grtrack gt tail dp The following display parameters are available for GeneRegionTrack objects see GeneRegionTrack for details on their usage showAxis inherited from class Gd bject TRUE showExonld NULL showFeatureld inherited from class AnnotationTrack NULL showId inherited from class AnnotationTrack NULL show verplotting inherited from class AnnotationTrack FALSE showTitle inherited from class GdObject TRUE size inherited from class Gd bject 1 stackHeight inherited from class StackedTrack 0 75 thinBoxFeature utr ncRNA utr3 utr5 3UTR 5UTR miRNA lincRNA three prime UTR five prime UTR transcriptAnnotation NULL v inherited from class GdObject 1 As we can see display parameters can be inherited from parent classes For the regular user this is not important at all however it nicely exemplifies the structure of the class hierarchy in the Gviz package 3 2 Schemes Users might find themselves changing the same parameters over and over again and it would make sense to register these modifications in a central location once and for all To this end the Gviz package supports display parameter schemes A scheme is e
33. 1845 mb 26 59183 mb 26 59184 mb 26 59185 mb o 9 9 o v L4 G T G TT TC TG G G Cc C G G G G So far we have replicated the features of a whole bunch of other genome browser tools out there The real power of the package comes with a rather general track type the Data Track Data Track object are essentially run length encoded numeric vectors or matrices and we can use them to add all sorts of numeric data to our genomic coordinate plots There are a whole bunch of different visualization options for these tracks from dot plots to histograms to box and whisker plots The individual rows in a numeric matrix are considered to be different data groups or samples and the columns are the raster intervals in the genomic coordinates Of course the data points or rather the data ranges do not have to be evenly spaced each column is associated with a particular genomic location For demonstration purposes we can create a simple Data Track object from randomly sampled data set seed 255 lim lt c 26700000 26750000 coords lt sort c lim 1 sample seq from lim 1 to lim 2 99 lim 2 dat lt runif 100 min 10 max 10 dtrack lt DataTrack data dat start coords length coords end coords 1 chromosome chr genome gen name Uniform plotTracks list itrack gtrack atrack grtrack dtrack from lim 1 to lim 2 VvV VV VV Vv The Gviz User Guide 8 Ov NEM gt AAA M
34. 26 71 mb 26 73 mb 26 72 mb 26 74 mb n l l e e e P e e e z Ex a ha e d e e e e e o e i e e e e id e e wn P e s e se e e e eo e e e e o 3 e o A e e e e e e e e A s s i gt e e The first thing to notice is that the title panel to the right of the plot now contains a y axis indicating the range of the displayed data The default plotting type for numeric vectors is a simple dot plot This is by far not the only visualization option and in a sense it is waisting quite a lot of information because the run length encoded ranges are not immediately apparent We can change the plot type by supplying the type argument to plotTracks A complete description of the available plotting options is given in section Track classes and a more detailed treatment of the so called display parameters that control the look and feel of a track is given in the Plotting Parameters section plotTracks list itrack gtrack atrack grtrack dtrack from lim 1 to lim 2 type histogram The Gviz User Guide 9 Ov MEN M gt HEENM NT M 26 71 mb 26 73 mb 26 72 mb 26 74 mb Em H a I yall it MM 4 El i TT n p Rl i IM As we can see the data values in the numeric vector are indeed matched to the genomic coordinates of the Data Track object Such a visualization can be particularly helpful when displaying for instance the coverage of NGS reads along a
35. AI Hr METRE A NOT PRE N e 5 Track highlighting and overlays 5 1 Highlighting Some features of a typical genome browser plot are not specific for just a single track but instead span multiple tracks One prominent example are highlighting regions Assume you want to draw the attention on the plot to a particular genomic stretch where the visual clues across serveral or maybe even all tracks indicate a particular interesting behaviour Because the individual tracks in the Gviz package are all represented by individual objects there is no straight forward way to define such a region Here is where the Highlighting Track class comes into play Objects from this class are essentially just containers for one or several of the previously described track objects togehter with a very simple range definition that is to be superimposed over the individual tracks once they have been rendered Going back to our final example from the second chapter we could highlight two areas on the plot on the Annotation Track the GeneRegion Track and the Data Track using the HighlightTrack constructor in the following call gt ht HighlightTrack trackList list atrack grtrack T dtrack start c 26705000 26720000 width 7000 chromosome 7 gt plotTracks list itrack gtrack ht from lim 1 to lim 2 The Gviz User Guide 69 Ov CNENM A NI DI a M 26 71 mb 26 73 mb 26 72 mb 26 74 mb H
36. CDS and Comparative Genomics Database mm9 Primary Table knownGene Row Count 55 419 Format description Genes based on RefSeq GenBank and UniProt fed example SQLtype infol Werpkim pae __ ucdO7aet 1 __ varchar 25s falesNameofgen 1 pues fear e dsena 3195984 int 10 unsignedlrange Codingregionend S exonstarts 3195984 3203519 ongbiob Exon start positions gt ezonsnas 5197398 3208715 Jiongoros son end positions jproteintD vazchar s0 values UniProt display ID for Known Genes UniProt accession or RefSeq protein ID for UCSC Genes Unique identifier for each known gene alignment position pair Figure 2 A screen shot of a UCSC table browser view on the UCSC Known Genes track It needs to know about the track for which to extract the data and optionally one or several of the tables that make up the collective track data see UcscTrack for details about the genomic range including the chromosome for which to extract data about the type of Gviz track that we want to translate this data into and about the individual track columns and their counterparts in the respective track class constructor In our example the track is called knownGene the track type to construct is GeneRegionTrack and the relevant columns are exonStarts exonEnds n
37. Homo sapiens provider UCSC provider version hg19 release date Feb 2009 release name Genome Reference Consortium GRCh37 package name BSgenome Hsapiens UCSC hg19 Here we retain the same benefits as for regular BSgenome objects in that the actual sequence is only loaded into memory when a particular chromosome is first accessed Plotting the track yields the expected result a character representation of the genomic sequence in the current plot window lt may be worth noting that the color scheme that is used to encode the indvidual nucleotides is defined in the biovizBase package and the user is referred to its documentation for more details gt plotTracks sTrack chromosome 1 from 20000 to 20050 TCCTGGTGCTCCCAC GGAG GGGCTGATCACTC GTTGCG C Sometimes it may be too busy to plot both the sequence letters and the color coding and we can assign arbitrary colors by setting the fontcolor display parameter The convention here is that we need to supply a named vector with one entry for each of the five possible nucleotides A C T G and N If any of the entries is missing the respective letter will not be drawn at all gt fcol lt c A darkgray C darkgray T darkgray G darkgray gt plotTracks sTrack chromosome 1 from 20000 to 20050 fontcolor fcol In this case we are plotting the sequence on the forward strand and we may want to make this clear by adding direction indica
38. NST00000468712 lt il ENST00000495802 lt H HH tf L ENST00000487720 HH ENST00000441433 In order to make these settings persitant across R sessions one can create one or several schemes in the global environment in the special object GvizSchemes for instance by putting the necessary code in the Rprofile file This object needs to be a named list of schemes and it will be collected when the Gviz package loads lts content is then automatically added to the collection of available schemes The following pseudo code exemplifies this and could go into an Rprofile file gt GvizSchemes lt list myScheme list GeneRegionTrack list fill salmon col NULL transcriptAnnotation transcript Please note that because display parameters are stored with the track objects a scheme change only has an effect on those objects that are created after the change has taken place 3 3 Plotting direction By default all tracks will be plotted in a 5 gt 3 direction It sometimes can be useful to actually show the data relative to the opposite strand To this end one can use the reverseStrand display parameter which does just what its name suggests Since the combination of forward and reverse stranded tracks on a single plot does not make too much sense one should usually set this as a global display parameter in the plotTracks function The function will however cast a warning if a mixture of forward and reverse strand track
39. The Gviz User Guide Florian Hahne Edited January 2014 Compiled June 18 2015 Contents 1 Introduction 2 Basic Features 3 Plotting parameters 9 Setting parameters seo dope eom RR er ee ex dew dod dog se pede at S32 Schemes T 3 3 PlottinBdifECcton sg s gea edu a a ae ee we rd a 4 Track classes 4 1 GenomeAxisTrack lt lt s aiam eaga a a Boe es a a IE 42 Ideopramltack lt duc laa pee da a ee ee owe Pee we ee 49 Data WACK oe ganitas ho che BL we hhh eee ee es x ae Te Ba a a AA A ACK DT c 4 5 Genebeslon Track lt span a it Gi 2 4 6 BlomartGemeRegion Track i s dor 4 oe a a we PO ee Le eed e Ba ee 4 7 DetailsAnnotationTrack lt s coos lll s s ss ss s 4 8 SequenceTrack sl s s sso sas sss 4 9 AligenmentsTrack esos 203 eod Rock m3 wok Xx eae OR we dps moR ho a 4 10 Creating tracks from UCSC data s s c e sss bos ss caia a xe xx Rs 5 Track highlighting and overlays Biel Ig NtIAR lt lt ern eae See Sone ha oe ws ok eae a ina a a ee See de g 5 2 Overlays ccs ca data eedem Gee ce Om Bek ue od te ceed eed ee wupdbusoranth Gee 6 Composite plots for multiple chromosomes 7 Bioconductor integration and file support florian hahne novartis com 14 14 16 18 31 39 44 47 51 54 65 68 68 70 72 74 The Gviz User Guide 2 1 Introduction In order to make sense of genomic data one often aims to plot such data in a genome browser along with a variety of g
40. The Gviz User Guide Sessionlnfo The following is the session info that generated this vignette gt sessionInfo R version 3 2 1 2015 06 18 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 7 grid parallel stats4 stats graphics grDevices utils datasets methods base other attached packages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 lattice 0 20 31 biomaRt 2 24 0 GenomicFeatures 1 20 1 AnnotationDbi 1 30 1 Biobase 2 28 0 BSgenome Hsapiens UCSC hgi19 1 4 0 BSgenome 1 36 1 rtracklayer 1 28 5 Biostrings 2 36 1 XVector 0 8 0 Gviz 1 12 1 GenomicRanges 1 20 5 GenomeInfoDb 1 4 1 IRanges 2 2 4 SAVectors 0 6 0 BiocGenerics 0 14 0 xtable 1 7 4 loaded via a namespace and not attached 1 3 5 7 9 11 Rcpp 0 11 6 RColorBrewer 1 1 2 futile logger 1 4 1 plyr 1 8 3 bitops_1 0 6 futile options_1 0 0 tools_3 2 1 zlibbioc_1 14 0 rpart_4 1 9 digest_0 6 8 gtable_0 1 2 RSQLite_1 0 0 T7 The Gviz User Guide 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 biovizBase_1 16 0 proto_0 3 10 cluster
41. UE cex sampleNames 0 6 separator 1 Building DataTrack objects from files A number of standard file types exist that all store numeric data along genomic coordinates We have tried to make such files accessible in the Gviz package by providing additional options to the DataTrack constructor function In the previous examples the range argument was a GRanges object Instead we can also pass in the path to a file on disk by means of a character scalar The DataTrack class supports the most common file types like wig bigWig or bedGraph but also knows how to deal with bam files You may have realized that some of these files are indexed and we have taken the approach to stream the data from indexed files on the fly when it is needed for plotting However let s first start with the simple example of a bedGraph file These files support a single data sample and thus are equivalent to a GRanges object with a single numeric metadata column bedGraph files are not indexed so we have to load the whole file content when instantiating the object gt bgFile lt system file extdata test bedGraph package Gviz gt dTrack2 lt DataTrack range bgFile genome hgi9 type 1 chromosome chri19 name bedGraph gt class dTrack2 1 DataTrack attr package 1 Gviz gt plotTracks dTrack2 The Gviz User Guide 24 As we can see the constructor has returned a regular Data Track object The function t
42. _2 0 1 nnet_7 3 9 survival_2 38 2 foreign_0 8 63 latticeExtra_0 6 26 reshape2_1 4 1 lambda r_1 1 7 splines_3 2 1 scales_0 2 5 matrixStats_0 14 0 dichromat_2 0 0 colorspace_1 2 6 acepack_1 3 3 3 munsel1_0 4 2 DB1_0 3 1 gridExtra_0 9 1 stringr_1 0 0 XML_3 98 1 2 BiocParallel_1 2 4 Formula_1 2 1 magrittr_1 5 ggplot2_1 0 1 MASS_7 3 41 Rsamtools_1 20 4 Hmisc_3 16 0 GenomicAlignments_1 4 1 BiocStyle_1 6 0 stringi_0 4 1 RCur1_1 95 4 6 VariantAnnotation_1 14 3 78 The Gviz User Guide 79 References 1 Yarden Katz Eric T Wang Jacob Silterra Schraga Schwartz Bang Wong Helga Thorvaldsd ttir James T Robinson Jill P Mesirov Edoardo M Airoldi and Christopher B Burge Quantita tive visualization of alternative exon expression from rna seq data Bioinformatics 2015 URL http bioinformatics oxfordjournals org content early 2015 02 25 bioinformatics btv034 abstract arXiv http bioinformatics oxfordjournals org content early 2015 02 25 bioinformatics btv034 full pdf html doi 10 1093 bioinformatics btv034
43. a multitude of options to fine tune the track appearance which will be shown in the Plotting Parameters section Appart from the relative distance of the Cpg islands this visualization does not tell us much One obvious next step would be to indicate the genomic coordinates we are currently looking at in order to provide some reference For this purpose the Gviz package offers the GenomeAxisTrack class Objects from the class can be created using the constructor function of the same name gt gtrack GenomeAxisTrack Since a GenomeAxis Track object is always relative to the other tracks that are plotted there is little need for additional arguments Essentially the object just tells the plotTracks function to add a genomic axis to the plot Nonetheless it represent a separate annotation track just as the CpG island track does We can pass this additional track on to plotTracks in the form of a list The Gviz User Guide 4 gt plotTracks list gtrack atrack 26 6 mb 26 8 mb 26 7 mb 26 9 mb You may have realized that the genomic axis does not take up half of the available vertical plotting space but only uses the space necessary to fit the axis and labels Also the title region for this track is empty In general the Gviz package tries to find reasonable defaults for all the parameters controlling the look and feel of a plots so that appealing visualizations can be created without too much tinkering However all features on the p
44. ame and strand which we will use as the start and end coordinates of the ranges and for all the exon transcript and gene identifiers Here we make use of the high flexibility of the GeneRegionTrack constructor in the sense that the exon coordinates actually come in the form of a comma separated list combining all the information for one transcript in one row of the table The function is smart enough to detect this and to split the annotation regions accordingly The full function call to create the GeneRegion Track from the UCSC data looks like this gt from 65921878 to 65980988 gt knownGenes lt UcscTrack genome mm9 chromosome chrX T track knownGene from from to to trackType GeneRegionTrack T rstarts exonStarts rends exonEnds gene name T symbol name transcript name strand strand fill 8282d2 name UCSC Genes With a similar approach we can construct the next two gene model tracks based on the xenoRefGene and ensGene data tables gt refGenes lt UcscTrack genome mm9 chromosome chrX track xenoRefGene from from to to trackType GeneRegionTrack rstarts exonStarts rends exonEnds gene name symbol name2 transcript name strand strand fill 8282d2 stacking dense name Other RefSeq gt ensGenes lt UcscTrack genome mm9 chromosome chrX track ensGene from fro
45. average i e mean values stair steps horizontal first stair steps vertical first add grid lines add linear regression line histogram lines confint confidence intervals for average values smooth add loess curve histogram histogram bar width equal to range with mountain mountain type plot relative to a baseline polygon polygon type plot relative to a baseline boxplot box and whisker plot gradient false color image of the summarized values heatmap false color image of the individual values horizon Horizon plot indicating magnitude and direction of a change relative to a baseline Displayed below are the same sample data as before but plotted with the different type settings The Gviz User Guide 20 dl A A ALL d You will notice that some of the plot types work better for univariate data while others are clearly designed for multivariate inputs The a type for instance averages the values at each genomic location before plotting the derived values as a line The decision for a particular plot type is totally up to the user and one could even overlay multiple types by supplying a character vector rather than a character scalar as the type argument For example this will combine a boxplot with an average line and a data grid A different data set is plotted for the horizon type for the sake of clarity The Gviz User Guide 21 gt plotTracks dTrack type c boxplot a g For th
46. cations In our example those are considered to be probe locations from a methylation array gt library GenomicRanges gt probes lt GRanges seqnames chr7 ranges IRanges start c 2000000 2070000 2100000 2160000 end c 2050000 2130000 2150000 2170000 strand c ngu nom no For each of these probes we have methylation measurements from a large number of different samples in a numeric matrix and within the samples there are two treatment groups The aim is to compare the distribution of measurement values between these two groups at each probe locus gt methylation lt matrix c rgamma 400 1 ncol 100 dimnames list paste probe 1 4 sep NULL gt methylation 51 100 lt methylation 51 100 0 3 gt sgroups lt rep c grp1 grp2 each 50 Of course we could use a Data Track with the box plot representation for this task however we do have strand specific data here and some of the probes can be overlapping so all this information would be lost We are also interested in the particular shape of the data distribution so a density plot representation is what we really need Luckily the lattice package gives us a nice densityplot function that supports grouping so all that s left to do now is to write a little wrapper that handles the extraction of the relevant data from the matrix This is easily archieved by using the range identifiers which convenientl
47. dense We can create a first plot of our read alignments data from a birds eye perspecive say a range of 20 000 nucleotides gt plotTracks c bmt alTrack from afrom to ato chromosome chr12 HH I H HH B HHH H X gt 25000 y I Now this already shows us the general layout of the track on top we have a panel with the read coverage information in the form of a histogram and below that a pile up view of the individual reads There is only a certain amount of vertical space available for the plotting and not the whole depth of the pile up can be displayed here This fact is indicated by the white downward pointing arrows in the title panel We could address this issue by playing around with the max height min height or stackHeight display parameters which all control the height or the vertical spacing of the stacked reads Or we could reduce the size of the coverage section by setting the coverageHeight or the minCoverageHeight parameters Please see the class documentation for more details gt plotTracks c bmt alTrack from afrom to ato chromosome chri2 min height 0 coverageHeight 0 08 minCoverageHeight 0 The Gviz User Guide 56 gt E b TT al AUT E a Ll HEEE u __ ttt HL Ir I ea From that far out the pile ups are not particlularly useful and we can turn those off by setting the type display parameter accordingly gt plotTracks c alT
48. e Character or integer scalar Fill color for type snRNA Character or integer scalar Fill color for type snRNA pseudogene Character or integer scalar Fill color for type snoRNA Character or integer scalar Fill color for type snoRNA pseudogene Character or integer scalar Fill color for type tRNA pseudogene Logical scalar retrieval from cache annotation annotation annotation annotation annotation annotation annotation annotation annotation annotation annotation annotation annotation annotation annotation annotation annotation annotation objects objects objects objects objects objects objects objects objects objects objects objects objects objects objects objects objects objects Report data loading events from Bioamart of of of of of of of of of of of of of of of of of of or 4T darkgoldenrod1 aquamarine cornflowerblue cornsilk cornsilk3 cornsilk4 orange brown1 darkolivegreen1 darkolivegreen blueviolet gold4 darkorange2 coral coral3 cyan cyan2 antiquewhite3 FALSE 4 7 JDetailsAnnotation Track It is sometimes desirable to add more detailed information to particular ranges in an Gviz plot for which the notion of genomic coordinates no longer makes sense For instance the ranges in an Annotation Track may represent probe locations on a genome and for each of the
49. e arrowHeadWidth 1 10 arrowHeadMaxWidth 1 20 col 1 darkgray collapseTranscripts 1 FALSE exonAnnotation NULL fill 1 FFD58A gt displayPars grtrack lt list background panel FFFEDB col NULL gt head displayPars grtrack arrowHeadWidth 1 10 arrowHeadMaxWidth 1 20 col NULL collapseTranscripts 1 FALSE exonAnnotation NULL fill 1 FFD58A plotTracks list itrack gtrack atrack grtrack The Gviz User Guide 11 Ov CNNEN MO INR DIE IT IT O 26 6 mb 26 8 mb 27 mb 26 7 mb 26 9 mb KIAA0087 C7ort71 H SKAP2 lt i SKAP2 lt RPL7AP38 HMGB3P20 AC004947 2 H SKAP2 m e _ AC004947 2 H SKAP2 lt kH 3 Ac004947 2 H SKAP2 e SS z SKAP2 lt lt eee S SKAP2 jke 1 o SKAP2 k c SKAP2 H skaP2 HHH For our gene model track we have now added the gene symbols of the different transcripts to the plot removed the gray border around the individual exons models and changed the background color of both the title and the data panel to a yellowish hue There is a third option to set display parameters for a single plotting operation rather than the permanent setting in the track object by passing in additional arguments to the plotTracks function We have already made use of this feature for instance in the previous data plotting type example It is worth mentioning that all disp
50. e also the two items b and c have been merged and all ranges are now at least 3 pixels wide Depending on the density of items on the plot even this reduction can be insufficient Because we did not merge complete groups we might still end up with quite a lot of stacks to accomodate all the information To this end the display parameter mergeGroups can be used to disable absolute group separation Rather than blindly merging all groups as it is done when stacking dense however the software will only join those overlapping group ranges for which all items are already merged into a single meta item gt plotTracks ctrack min width 3 min distance 5 collapse TRUE mergeGroups TRUE extend left 0 1 2 d 2 d group 1 a features 4 Teatres 9 2 merged groups SOR group 2 5 i Building AnnotationTrack objects from files Just like we showed before for DataTrack objects it is possible to stream the data for an Annotation Track object off the file system We will again use the bam file as an example This time the default import function reads the coordinates of all the sequence alignments from the file and even knows how to deal with grouped elements gt aTrack2 lt AnnotationTrack range bamFile genome hg19 name Reads chromosome chr1 gt class aTrack2 1 ReferenceAnnotationTrack attr package 1 Gviz gt aTrack2 ReferenceAnnotationTrack Reads genome hg19 active chromosome c
51. e fine grained axis annotation plotTracks axisTrack from 1000000 to 9000000 add53 TRUE add35 TRUE littleTicks TRUE 1 6mb 17 24mb 28mb 32mb 3 6mb T 44mb 48mb 52mb 5 6mb 64mb 68mb 2mb 6mb 84mb i 1 4mb 18mb 22mb 26mb 34mb 38mb 42mb 46mb 54mb 58mb 62mb 66mb 74mb 78mb 82mb 86mb The Gviz package tries to come up with reasonable defaults for the axis annotation In our previous example the genomic coordinates are indicated in megabases We can control this via the exponent parameter which takes an integer value greater then zero The location of the tick marks are displayed as a fraction of 1067P0nent gt plotTracks axisTrack from 1000000 to 9000000 exponent 4 2UU 1U 4UU 1U 6UU 1U BUU 1U ann ant Enn ant 7nn ant Another useful parameter labelPos controls the arrangement of the tick marks It takes one of the values alternating revAlternating above or below For instance we could aline all tick marks underneath the axis gt plotTracks axisTrack from 1000000 to 9000000 labelPos below 2 mh 2 mh A mh R mh amp mh 7 mh 2 mh Sometimes a full blown axis is just too much and all we really need in the plot is a small scale indicator We can change the appearance of the GenomeAxisTrack object to such a limited representation by setting the scale display parameter Typically this will be a numeric value between 0 and 1 which is interpreted as the fraction of the plott
52. e heatmap plotting type we arrange all the data in a well structured two dimensional matrix which gives us the oportunity to add a little extra information about the individual samples Depending on how the Data Track was created in the first place we can choose to display the sample names which in our case correspond to the column names of the input GRanges object The plot also highlights another feature of the heatmap type the y axis now shows a mapping of the numeric values into the color range gt colnames mcols twoGroups 1 control control 1 control 2 treated treated 1 6 treated 2 gt plotTracks dTrack type c heatmap showSampleNames TRUE cex sampleNames 0 6 E E E E An additional layer of flexibility is added by making use of Gviz s grouping functionality The individual samples i e rows in the data matrix can be grouped together using a factor variable and if reasonable this grouping is reflected in the layout of the respective track types For instance our example data could be derived from two different sample groups with three replicates each and we could easily integrate this information into our plot Data Grouping gt plotTracks dTrack groups rep c control treated each 3 type c a p confint The Gviz User Guide 22 For the dot plot representation the individual group levels are indicated by color coding For the a type the averages are now
53. ee horizonplot for details The scale for each of the segments in the horizon type plot Defaults to 1 3 of the absolute data range See horizonplot for details Logical scalar Toggle on jittering on the x axis in xy type plots See panel xyplot for details Logical scalar Toggle off jittering on the y axis in xy type plots See panel xyplot for details Boolean triggering the addition of a legend to the track to indicate groups This only has an effect if at least two groups are presen Numeric scalar Parameter controlling the boxplot appearance panel bwplot for details Numeric scalar The line height for the legend text Character or integer scalar The type for all line elements unless there is a more specific control defined elsewhere Character or numeric scalar Line type of the optional baseline defaults to the setting of 1ty Integer scalar The line type for grid elements Defaults to the setting of 1ty Character or numeric scalar Line type in mountain type and polygon type plots defaults to the setting of 1ty Integer scalar The line width for all line elements unless there is a more specific control defined elsewhere Numeric scalar Line width of the optional baseline defaults to the setting of lwd Integer scalar The line width for grid elements Defaults to the setting of 1wd Numeric scalar Line width in mountain type and polygon type plots defaults to the setting of 1wd Numeric scalar The mimimum dis
54. efined for the track with lighter colors indicating areas of low or no overplotting and more saturated colors indicating areas of high overplotting density We exemplify this feature on an Annotation Track object that represents a good portion of a real human chromosome gt data denseAnnTrack gt plotTracks denseAnnTrack show verplotting TRUE gt gt lt MP mm mm m pm Sse m gt a gt z om r 1 n Collapsing All track types that inherit from class AnnotationTrack support the collapsing of overlapping track items either because they have initially been defined as overlapping coordinates or because the current device resolution does not allow to sufficiently separate them For instance two elements of a feature group may be separated by 100 base pairs on the genomic scale however when plotted to the screen those 100 base pairs translate to a distance of less than one pixel In this case we can no longer show the items as two separate entitites One solution to this problem would be to allow for arbitrary overplotting in which case the last one of the overlapping items that is drawn on the device wins This is not optimal in many ways and it also poses a significant burden on the graphical engine because a lot of stuff has to be drawn which no one will ever see To this end the Gviz package provides an infrastructure to reasonably collapse overlappig items thereby adjusting the information content that
55. en in the previous examples whereas the non coding regions are drawn as slighly thinner boxes The distinction between coding and non coding is made on the basis of the object s feature values in combination with a special display parameter thinBoxFeature that enumerates all feature types that are to be treated as non coding Obviously this feature is available to all GeneRegion Tracks not only the ones that were build from TxDb objects However the coding information has to be added manually and the default value of the thinBoxFeature parameter may not be sufficient to cover all possible cases It is up to the user to come up with a complete list of non coding feature types depending on the source of the data gt feature txTr gt plotTracks txTr Display parameters for GeneRegionTrack objects For a complete listing of all the available display parameters please see the table below or the man page of the GeneRegion Track class by typing in GeneRegionTrack on the Rcommand line Display Parameter Description alpha Numeric scalar between 0 and 1 The opacity of the plotting elements if sup ported by the device arrowHeadMaxWidth Numeric scalar The maximum width of the arrow head in pixels if shape is arrow arrowHeadWidth Numeric scalar The width of the arrow head in pixels if shape is fixedArrow cex Numeric scalar The font expansion factor for item identifiers cex group Numeric scalar The font expansion factor for the group
56. enomic annotation features such as gene or transcript models CpG island repeat regions and so on These features may either be extracted from public data bases like ENSEMBL or UCSC or they may be generated or curated in house Many of the currently available genome browsers do a reasonable job in displaying genome annotation data and there are options to connect to some of them from within R e g using the rtracklayer package However none of these solutions offer the flexibility of the full Rgraphics system to display large numeric data in a multitude of different ways The Gviz package aims to close this gap by providing a structured visualization framework to plot any type of data along genomic coordinates It is loosely based on the GenomeGraphs package by Steffen Durinck and James Bullard however the complete class hierarchy as well as all the plotting methods have been restructured in order to increase performance and flexibility All plotting is done using the grid graphics system and several specialized annotation classes allow to integrate publicly available genomic annotation data from sources like UCSC or ENSEMBL 2 Basic Features The fundamental concept behind the Gviz package is similar to the approach taken by most genome browsers in that individual types of genomic features or data are represented by separate tracks Within the package each track constitutes a single object inheriting from class GdObject and there are constructor
57. entical dimensionality as the input data type Character vector The plot type one or several in c p 1 b a a_confint s g r S smooth histogram mountain polygon h boxplot gradient heatmap horizon See Details section in Data Track for more information on the individual plotting types v Integer scalar Parameter controlling the number of vertical grid lines see panel grid for details varwidth Logical scalar Parameter controlling the boxplot appearance See panel bwplot for details window Numeric or character scalar Aggregate the rows values of the data matrix to window equally sized slices on the data range using the method defined in aggregation If negative apply a running window of size windowSize using the same aggregation method Alternatively the special value auto causes the function to determine the optimal window size to avoid overplotting windowSize Numeric scalar The size of the running window when the value of window is negative ylim Numeric vector of length 2 The range of the y axis scale 4 4 AnnotationTrack Annotation Track objects are the multi purpose tracks in the Gviz package Essentially they consist of one or several genomic ranges that can be grouped into composite annotation elements if needed In principle this would be enough to represent everything from CpG islands to complex gene models however for the latter the packge defines the specialized GeneReg
58. er Guide 58 to afrom 15200 chromosome chri2 reverseStacking TRUE col mates purple col gap orange type pileup A En E As mentioned before we can control whether the data should be treated as paired end or single end data by setting the isPaired argument in the constructor Here is how we could take a look at the data in the same file but in single end mode gt alTrack lt AlignmentsTrack system file package Gviz extdata gapped bam isPaired FALSE gt plotTracks c bmt alTrack from afrom 12700 to afrom 15200 chromosome chri2 The Gviz User Guide 59 EI So far we did not look at the individual read sequences at all Even though they are contained in the BAM file their value is fairly limited without the reference sequence against which the reads have initially been aligned Typically the mismatch positions and the variant bases are not included Please note that this is not entirely true for all BAM files One can store base mismatch positions in the CIGAR string or even the full variant description in the non standard MD field However very few aligners currently make use of these features We may implement support for those later if found necessary To better show the features of the AlignmentsTrack for sequence variants we wi
59. eter It can also be helpful to add the names for the individual features to the plot This can be archived by setting the featureAnnotation parameter to id gt plotTracks aTrack shape box featureAnnotation id gt plotTracks aTrack shape ellipse featureAnnotation id fontcolor feature darkblue Huey Dewey Louie In this very simplistic example each annotation feature consisted of a single range In real life the genomic annotation features that we encounter often consists of several sub units We can create such composite Annotation Track objects by providing a grouping factor to the constructor It needs to be of similar length as the total number of atomic features in the track i e the number of genomic ranges that are passed to the constructor The levels of the this factor will be used as internal identifiers for the individual composite feature groups and we can toggle on their printing by setting groupAnnotation to group gt aTrack groups lt AnnotationTrack start c 50 180 260 460 860 1240 width c 15 20 40 100 200 20 chromosome chrX strand rep c x c 1 3 2 group rep c Huey Dewey Louie c 1 3 2 genome hgi9 name foo gt plotTracks aTrack groups groupAnnotation group Huey Louie Dewey We can control the placement of the group labels through the just group parameter gt plotTracks aTrack groups groupA
60. f all the available display parameters please see the table below or the man page of the Data Track class by typing in DataTrack on the Rcommand line Display Parameter Description aggregateGroups aggregation alpha alpha confint amount baseline box legend box ratio box width cex cex legend cex sampleNames coef col col baseline col confint Logical scalar Aggregate the values within a sample group using the aggregation funnction specified in the aggregation parameter Function or character scalar Used to aggregate values in windows or for col lapsing overlapping items The function has to accept a numeric vector as a single input parameter and has to return a numeric scalar with the aggregated value Alternatively one of the predefined options mean median sum min max or extreme can be supplied as a character scalar Defaults to mean Numeric scalar between 0 and 1 The opacity of the plotting elements if sup ported by the device Numeric scalar The tranasparency for the confidence intervalls in confint type plots Numeric scalar Amount of jittering in xy type plots See panel xyplot for details Numeric scalar Y axis position of an optional baseline This parameter has a special meaning for mountain type and polygon type plots see the Details section in DataTrack for more information Logical scalar Draw a box around a legend Numeric scalar Parameter controlling the boxplot appearance See
61. h object inheriting form the StackedTrack class by means of the stackHeight display parameter It takes a value between 0 and 1 that controls which fraction of the available vertical space on a stacking line should be used to draw the feature glyphs The Gviz User Guide 45 gt plotTracks biomTrack col line NULL col NULL stackHeight 0 3 11111 ns Tur pr The filter argument to the BiomartGeneRegionTrack constructor can be used to pass on arbitratry additional filters to the Biomart query We could for instance limit the returned gene models to RefSeq models only Please see the documentation in the biomaRt package for details gt biomTrack lt BiomartGeneRegionTrack genome hg19 chromosome chr start 20000000 end 21000000 name ENSEMBL filter list with ox refseq mrna TRUE gt plotTracks biomTrack col line NULL col NULL stackHeight 0 3 gt gt gt H gt H on nH La ean H ae ERE Lem Sometimes it can be more convenient to get a model for a particular gene rather than defining a genomic range One could use the filter mechanisms as described before for this purpose however the BiomartGeneRegion Track implements a more generic way By providing the gene symbol as the symbol argument the track will be initialized around the locus for this gene if it can be found Alternatively one can provide the Ensembl trancript or gene id via the transcript or gene arguments or an Entrez id via
62. have to be a BAM file the automatic import will only work for those For all other file representations of alignments a user will have to provide their own import function and this topic is further discussed in the class documentation For this demonstation let s use a small BAM file for which paired NGS reads have been mapped to an extract of the human hg19 genome The data originate from an RNASeq experiment and the alignements have been performed using the STAR aligner allowing for gaps We also download some gene annotation data for that region from Biomart Again creating the AlignmentsTrack object is as simple as calling the constructor function of the same name We set the isPaired argument to TRUE in order to tell the constructor that it should expect paired reads Please note that TRUE is the default value for this parameter and usually things will still work even if the reads do not originate from a paired end library In other words the default setting could be used as a poor man s autodetection however it make more sense to supply the argument explicitely if you know what type of data to expect gt afrom 2960000 ato 3160000 gt alTrack AlignmentsTrack system file package Gviz extdata gapped bam isPaired TRUE gt bmt lt BiomartGeneRegionTrack genome hg19 chromosome chri2 The Gviz User Guide 55 start afrom end ato filter list with_ox_refseq_mrna TRUE stacking
63. he feature mapping which is necessary because Esembl used to call the gene symbol field external_gene_id in that release gt library biomaRt gt bm lt useMart host oct2012 archive ensembl org biomart ENSEMBL_MART_ENSEMBL dataset hsapiens_gene_ensembl gt fm lt Gviz getBMFeatureMap gt fm symbol lt external_gene_id gt biomTrack lt BiomartGeneRegionTrack genome hg19 chromosome chr7 start 20000000 end 21000000 name ENSEMBL featureMap fm biomart bm gt plotTracks biomTrack col line NULL col NULL stackHeight 0 3 mtr Display parameters for BiomartGeneRegionTrack objects For a complete listing of all the available display parameters please see the table above in the previous GeneRe gion Track section or the man page of the BiomartGeneRegion Track class by typing in BiomartGeneRegion Track on the Rcommand line As mentioned above one additional benefit when fetching the data through Biomart is that we also receive some information about the annotation feature types which is automatically used for the color coding of the track The following table shows the available feature types Display Parameter Description Color C segment Character or integer scalar Fill color for annotation objects of burlywood4 type C segment D segment Character or integer scalar Fill color for annotation objects of lightblue type C segment J_segme
64. he idea here is that we can express all of the available Ucsc data in one of the package s track types We use the functionality provided in the rtracklayer package to connect to UCSC and to download the relevant information As a little illustrative example let s reproduce a view from the famous UCSC genome browser using the Gviz package As a final result we want to show something similar to Figure 4 10 UCSC Genome Browser on Mouse July 2007 NCBI37 mm9 Assembly move lt lt lt lt lt lt gt gt gt gt gt zoom in 1 5x 3x 10x base zoom out 1 5x 3x 10x position search chrx 65 921 878 65 980 988 gene Gump clear size 59 111 bp configure chrx 447 1 EUEN 3602 MAS Eee ane Scale 88 a chrxt esaseeee 65935009 65946600 65945990 65950006 esossese 659600900 65965000 ES97GGG0 c5975606 65950090 UCSC Genes Based on RefSeq UniProt GenBank CCDS and Comparative Genomics GM1 0474 mpjeccnn nae dices Enri B329329 539 94 Fmri s Fite ono 9 Fmri m3 Fnridp J aaa 993 99 499 Fmt a A o pp pas Fmri x i Non Mouse RefSeq Genes Other RefSeq Hb H H H 1 H HHH Ensembl Gene Predictions Ensembl 62 NSMUST 66666161526 mr ENSMUST 66696142584 RRHH ENSMUST 66666655546 ENSMUST 888881 81518 ess po eiii ii miii ENSMUST 66666114651 ENSMUST 66666133327 a ENSMUST 66666141725 m
65. hr1 referenced file tmp RtmpdVyvft Rinst615452e4743f Gviz extdata test bam mapping id id group group gt plotTracks aTrack2 from 189995000 to 190000000 Since AnnotationTrack objects are somewhat more complicated than DataTrack objects the constructor pro vides another level of flexibility when reading the data from a file More specifically the user has the ability The Gviz User Guide 37 to map the provided metadata columns of the GRanges object that is returned by the import function to the respective columns in the final Annotation Track object If no explicit mapping is provided the package will try to find a default mapping based on the input file type and the desired track type The current mapping of a track is displayed by its show method as can be seen above The mechanism for changing this default mapping is quite straight forward if the values in the relevant constructor arguments in this case group id and feature are character scalars the metadata columns of the GRanges object that is returned by the import function are mapped against their values For instance we can map the id column to the group attribute and thus suppress the grouping of sequence alignments that originate from the same sequencing read gt aTrack3 lt AnnotationTrack range bamFile genome hg19 name Reads chromosome chri group id gt aTrack3 ReferenceAnnotationTrack Reads genome hg19 active chromosome
66. ical scalar Control whether to plot the individual track item identifiers showld Logical scalar Control whether to annotate individual groups showOverplotting Logical scalar Use a color gradient to show the amount of overplotting for collapsed items This implies that collapse TRUE 4 5 GeneRegionTrack GeneRegion Track objects are in principle very similar to AnnotationTrack objects The only difference is that they are a little more gene transcript centric both in terms of plotting layout and user interaction and that they may define a global start and end position a feature which is not particularly relevant for the normal user The constructor function of the same name is a convenient tool to instantiate the object from a variety of different sources In a nutshell we need to pass start and end positions or the width of each annotation feature in the track and also supply the exon transcript and gene identifiers for each item which will be used to create the transcript groupings A somewhat special case is to build a GeneRegionTrack object directly from one of the popular TxDb objects an option that is treated in more detail below For more information about all the available options see the class s manual page GeneRegionTrack There are a number of accessor methods that make it easy to query and replace for instance exon transcript or gene assignments There is also some support for gene aliases or gene symbols which are often
67. icularly relevant with the exception that the length method for this class almost always returns O because the content of the object is only realized during the plotting operation Obviously streaming from the disk comes with a price in that file access is much slower than accessing RAM however the file indexing allows for fairly rapid data retrieval and other processes during the plotting operation tend to be much more costly anyways It is woth mentioning however that each plotting operation will cause reading off the file and there are currently no caching mechanisms in place to avoid that Nevertheless plotting a larger chunk of the bam file still finishes in a reasonable time gt plotTracks dTrack4 chromosome chri from 189891483 to 190087517 Of course users can provided their own file parsing function just like we showed in the previous example The import function now needs to be able to deal with a second mandatory argument selection which is a GRanges object giving the genomic interval that has to be imported from the file In addition one needs to tell the DataTrack constructor that data should be streamed off a file by setting the stream argument to TRUE gt myImportFun lt function file selection 1 gt DataTrack range bamFile genome hg19 type 1 name Coverage window 1 chromosome chr1 importFunction myImportFun stream TRUE ReferenceDataTrack Coverage genome hg19
68. ing region used for the scale The plotting method will apply some rounding to come up with reasonable and human readable values For even more control we can pass in a value larger than 1 which is considered to be an absolute range length In this case the user is responsible for the scale to actually fit in the current plotting range gt plotTracks axisTrack from 1000000 to 9000000 scale 0 5 The Gviz User Guide 16 We still have control over the placement of the scale label via the labelPos parameter which now takes the values above below and beside gt plotTracks axisTrack from 1000000 to scale 0 5 labelPos below 9000000 For a complete listing of all the available display parameters please see the table below or the man page of the GenomeAxis Track class by typing in GenomeAxisTrack on the Rcommand line Display Parameter Description add35 Logical scalar Add 3 to 5 direction indicators add53 Logical scalar Add 5 to 3 direction indicators cex Numeric scalar The overall font expansion factor for the axis annotation text cex id Numeric scalar The text size for the optional range annotation col Character scalar The color for the axis lines and tickmarks col id Character scalar The text color for the optional range annotation col range Character scalar The border color for highlighted regions on the axis distFromAxis Numeric scalar Control the distance of the axis annotati
69. ing the data on the x axis we can also apply arbitrary transformation functions on the y axis One obvious use case would be to log transform the data prior to plotting The framework is flexible enough however to allow for arbitrary transformation operations The mechanism works by providing a function as the transformation display parameter which takes as input a numeric vector and returns a transformed numeric vector of the same length The following code for instance truncates the plotted data to values greater than zero gt plotTracks dTrack big type 1 transformation function x Te O As seen before the a type allows to plot average values for each of the separate groups There is however an additional parameter aggregateGroups that generalizes group value aggregations In the following example we display for each group and at each position the average values in the form of a dot and lines plot xiz lt 0 lt 0 x J gt plotTracks dTrack groups rep c control treated each 3 type c b aggregateGroups TRUE This functionality again also relies on the setting of the aggregation parameter and we can easily change it to display the maximum group values instead gt plotTracks dTrack groups rep c control treated each 3 type c b aggregateGroups TRUE aggregation max The Gviz User Guide Display parameters for DataTrack objects For a complete listing o
70. ion Track class which will be highlighted in a separate section Most of the features discussed here will also apply to GeneRegionTrack objects though As a matter of fact the GeneRegion Track class inherits directly from class Annotation Track Annotation Track objects are easily instantiated using the constructor function of the same name The necessary building blocks are the range coordinates a chromosome and a genome identifier Again we try to be flexible in the way this information can be passed to the function either in the form of separate function arguments as IRanges GRanges or data frame objects Optionally we can pass in the strand information for the annotation features and some useful identifiers A somewhat special case is to build the object from a GRangesList object which will automatically preserve the element grouping information contained in the list structure For the full details on the constructor function and the accepted arguments see AnnotationTrack Let s take a look at a very simple track gt aTrack lt AnnotationTrack start c 10 40 120 width 15 chromosome chrX strand c MM Hal id c Huey Dewey Louie genome hgi9 name foo gt plotTracks aTrack The Gviz User Guide 32 The ranges are plotted as simple boxes if no strand information is available or as arrows to indicate their direction We can change the range item shapes by setting the shape display param
71. issue as their relative distance is smaller than a single pixel so all we see is a single range and some ugly overplotted identifiers We can control the first issue by setting the minimum pixel width of a plotted item to be one pixel using the min width display parameter gt plotTracks ctrack min width 1 group 1 Ha bo d g group 3 i group 2 Eh i group 4 Ska Now the item d has a plotable size and can be drawn to the device The overplotted items are still rather anoying but the only way to get rid of those is to turn item collapsing back on gt plotTracks ctrack min width 1 collapse TRUE group 1 ma be ee g group 3 i group 2 Eh i 2 merged g rou p 4 features Now all items that could not be separated by at least one pixel have been merged into a single meta item and the software has taken care of the identifiers for you too The merging operation is aware of the grouping information so no two groups where joint together Sometimes a single pixel width or a single pixel distance is not enough to get a good visualization In these cases one could decide to enforce even larger values We can do this not only for the minimum width but also for the minimum distance by setting the min distance parameter gt plotTracks ctrack min width 3 min distance 5 collapse TRUE The Gviz User Guide 36 2 merged 2 merged group 1 a features Y features z group 3 i group 2 M i 2 merged g rou p 4 features This tim
72. item identifiers cex group Numeric scalar The font expansion factor for the group level annotation col Character or integer scalar The border color for all track items col line Character scalar The color used for connecting lines between grouped items featureAnnotation Defaults to a light gray but if set to NULL the same color as for the first item in the group is used Character scalar Add annotation information to the individual track elements This can be a value in id group or feature Defaults to id Only works if showFeatureld is not FALSE fill Character or integer scalar The fill color for untyped items This is also used to connect grouped items See grouping for details fontcolor Character or integer scalar The font color for item identifiers fontcolor group Character or integer scalar The font color for the group level annotation fontface Integer scalar The font face for item identifiers fontface group Numeric scalar The font face for the group level annotation fontfamily Character scalar The font family for item identifiers fontfamily group Character scalar The font family for the group level annotation fontsize Numeric scalar The font size for item identifiers fontsize group groupAnnotation Numeric scalar The font size for the group level annotation Character scalar Add annotation information as group labels This can be a value in id group or feature Defaults to group Only works if showId is not
73. l of plotable details Iwd Numeric scalar The width of the line when no indiviual letters can be plotted due to size limitations min width Numeric scalar The minimum width in pixels of the colored boxes that are drawn when no indiviual letters can be plotted due to size limitations If the horizontal space that a single base occupies is smaller than this value only a horizontal line is drawn to indicate the presence of a sequence noLetters Logical scalar Always plot colored boxes or a line regardles of the available space rotation Numeric scalar The rotation angle for each individual letter in the sequence 4 9 AlignmentsTrack Plots of aligned sequences typically from next generation sequencing experiments can be quite helpful for instance when visually inspecting the validity of a called SNP Those alignments are usually stored in BAM files As shown in some of the previous section we can deal with these files in a fairly crude way by coupling them to either an AnnotationTrack or a DataTrack The utility of the generated plots however is fairly limited and we want in particular support for gapped and paired aligments and show differences of the individual read sequences to a reference The AlignmentsTrack class is designed to help in exactly these tasks In its typical manifestation it is also a member of the ReferenceTrack class enabling memory efficient streaming directly off a file Even though this file does not necessarily
74. lay parameters which are passed along with the plotTracks function apply to all track objects in the plot For some objects classes a particular display parameter may not make any sense and in that case it is simply ignored Also the settings only apply for one single plotting operation and will not be retained in the plotted track objects They do however get precedence over the object internal parameters The following line of code exemplifies this behaviour gt plotTracks list itrack gtrack atrack grtrack background panel FFFEDB background title darkblue E Chromosome CNN ANM NE NN OC a NN NR OUS NE 26 6 mb 26 8 mb 27 mb 26 7 mb 26 9 mb KIAA0087 C7ort71 H SKAP2 il SKAP2 Hj RPL7AP38 HMGB3P20 AC004947 2 Hi skap2 L H lt lt _ AC004947 2 H SKAP2 lt lt lt lt e lt lt kH 3 AC004947 2 H SKAP2 H n HI SKAP2 H S SKAP2 lt e 6 SKAP2 SKAP2 lt HH skAP2 HHH In order to make full use of the flexible parameter system we need to know which display parameters control which aspect of which track class The obvious source for this information are the man pages of the respective track classes which list all available parameters along with a short description of their effect and default values in the Display Parameters section Alternatively we can use the availableDisplayPars function which prints out the available parameters for a class as
75. level annotation The Gviz User Guide col collapse Transcripts exonAnnotation fill fontcolor fontcolor group fontface fontface group fontfamily fontfamily group fontsize fontsize group geneSymbols lex lineheight Ity Iwd min distance min width rotation shape showExonld showld showOverplotting thinBoxFeature 43 Character or integer scalar The border color for all track items Defaults to using the same color as in fill also taking into account different track features Logical or character scalar Can be one in gene longest shortest or meta Merge all transcripts of the same gene into one single gene model In the case of gene or TRUE this will only keep the start location of the first exon and the end location of the last exon from all transcripts of the gene For shortest and longest only the longest or shortest transcript model is retained For meta a meta transcript containing the union of all exons is formed essentially identical to the operation reduce geneModel Character scalar Add annotation information to the individual exon models This can be a value in symbol gene transcript exon or feature Defaults to exon Only works if showExonId is not FALSE Character or integer scalar The fill color for untyped items This is also used to connect grouped items See grouping for details Character or integer scalar The font color for item identifiers Character or integer scalar
76. ll load a different data set this time from a whole genome DNASeq SNP calling experiment Again the reference genome is hg19 and the alignments have been performed using Bowtie2 gt afrom 44945200 ato 44947200 gt alTrack AlignmentsTrack system file package Gviz extdata snps bam isPaired TRUE gt plotTracks alTrack chromosome chr21 from afrom to ato The Gviz User Guide 60 Track E E E E ay a Somehow we need to tell the AlignmentsTrack about the reference genome and there are two ways to archive this Either we provide a SequenceTrack object with the reference to the constructor function via the refer enceSequence argument or we stick it into the track list that is provided to the plotTrack which is smart enough to detect it there For this example we chose the second option and re use the SequenceTrack object from the previous section gt plotTracks c alTrack sTrack chromosome chr21 from afrom to ato 61 j i ra 5 f hal n mpi gt zo dace coverage plot in the form of a stacked histogram When zooming in to one of the obvious heterozygous SNP The mismatched bases are now indicated on both the individual reads in the pileup section and also in the positions we can reveal even more details The Gviz User Guide chr21 gt plotTracks c alTrack sTrack chromoso
77. lot including the relative track sizes can also be adjusted manually As mentioned before in the beginning of this vignette a plotted track is always defined for exactly one chromosome on a particular genome We can include this information in our plot by means of a chromosome ideogram An ideogram is a simplified visual representation of a chromosome with the different chromosomal staining bands indicated by color and the centromer if present indicated by the shape The necessary information to produce this visualization is stored in online data repositories for instance at UCSC The Gviz package offers very convenient connections to some of these repositories and the deogram Track constructor function is one example for such a connection With just the information about a valid UCSC genome and chromosome we can directly fetch the chromosome ideogram information and construct a dedicated track object that can be visualized by plotTracks Please not that you will need an established internet connection for this to work and that fetching data from UCSC can take quite a long time depending on the server load The Gviz package tries to cache as much data as possible to reduce the bandwidth in future queries gt itrack lt IdeogramTrack genome gen chromosome chr Similar to the previous examples we stick the additional track object into a list in order to plot it gt plotTracks list itrack gtrack atrack Ov CNNEN MI MA HI DI IT IT
78. m to to trackType GeneRegionTrack rstarts exonStarts rends exonEnds gene name symbol name2 transcript name strand strand The Gviz User Guide 67 fill 960000 name Ensembl Genes The CpG and SNP tracks are slightly different since a GeneRegion Track representation would not be particularly useful Instead we can use AnnotationTrack objects as containers The overall process using the UcscTrack meta constructor remains the same gt cpgIslands lt UcscTrack genome mm9 chromosome chrX track cpgIslandExt from from to to trackType AnnotationTrack start chromStart end chromEnd id name shape box fill 006400 name CpG Islands gt snpLocations lt UcscTrack genome mm9 chromosome chrX track snp128 from from to to trackType AnnotationTrack start chromStart end chromEnd id name feature func strand strand shape box stacking dense fill black name SNPs Most of UCSC s Data Track like tracks are a little more complex and represent a collection of several sub tracks with data originating from multiple tables To make sure that we get the correct information we have to be a little bit more specific here and also define the particular table on the UCSC data base to use gt conservation lt UcscTrack genome mm9 chromosome chrX track
79. me The different track classes will be described in more detail in the Track classes section further below For now let s just take a look at a typical Gviz session to get an idea of what this is all about We begin our presentation of the available functionality by loading the package gt library Gviz The most simple genomic features consist of start and stop coordinates possibly overlapping each other CpG islands or microarray probes are real life examples for this class of features In the Bioconductor world those are most often represented as run length encoded vectors for instance in the Ranges and GRanges classes To seamlessly integrate with other Bioconductor packages we can use the same data structures to generate our track objects A sample set of CpG island coordinates has been saved in the cpgIslands object and we The Gviz User Guide 3 can use that for our first annotation track object The constructor function AnnotationTrack is a convenient helper to create the object gt library GenomicRanges gt data cpgIslands gt class cpgIslands 1 GRanges attr package 1 GenomicRanges gt chr lt as character unique seqnames cpgIslands gt gen lt genome cpglslands gt atrack lt AnnotationTrack cpgIslands name CpG Please note that the AnnotationTrack constructor as most constructors in this package is fairly flexible and can accomodate many different types of inputs For insta
80. me from 44946590 to 44946660 The Gviz User Guide 62 AlignmentsTrack v THT mum mu mu sg mum m 3 1 Just like shown before in the SequenceTrack we can even show individual letters here as long as there is enough space to fit them This can be controlled using the display parameters min height max height and cex plotTracks c alTrack sTrack chromosome chr21 from 44946590 to 44946660 cex 0 5 min height 8 The Gviz User Guide 63 A G A A A A A a A a A A A El IE TE AJ 3 a Era ATAI a IA TJ du En A A A A GGGGTGAGGAAGGAGGGAGTCAAGTCTGACGTCGGGCCTGCCAGGTTTCACACCTTTACATAC cT Display parameters for AlignmentsTrack objects For a complete listing of all the available display parameters please see the table below or the man page of the Alignments Track class by typing in AlignmentsTrack on the Rcommand line Display Parameter Description alpha mismatch Numeric scalar between 0 and 1 The transparency of the mismatch base infor mation alpha reads Numeric scalar between 0 and 1 The transparency of the individual read icons Can be used to indicate overlapping regions in read pairs Only on supported devices cex mismatch Numeric Scalar The character expansion factor for the mismatch base letters col Integer or character scalar The default color of all line elements col coverage Integer or character scalar The line colo
81. names chroms ranges IRanges start 1 width c 100 400 200 1000 strand c mq genome mm9 chromosome chr1 name foo gt mdTrack DataTrack range GRanges seqnames rep chroms c 10 40 20 100 ranges IRanges start c seq 1 100 len 10 seq 1 400 len 40 seq 1 200 len 20 seq 1 1000 len 100 width 9 values runif 170 data values chromosome chri genome mm9 name bar Now we also want a genome axis and an deogram Track object to indicate the genomic context gt mgTrack GenomeAxisTrack scale 50 labelPos below exponent 3 gt chromosome itrack lt chri Finaly we build a layout in which the plots for each chromosome are placed in a rectangular grid and repeatedly call plotTracks for each chromosome The Gviz User Guide 13 gt ncols lt 2 gt nrows lt length chroms 4ncols gt grid newpage gt pushViewport viewport layout grid layout nrows ncols gt for i in seq_along chroms pushViewport viewport layout pos col i 1 ncols 1 layout pos row i 1 4 4ncols 1 plotTracks list itrack maTrack mdTrack mgTrack chromosome chroms i add TRUE popViewport 1 Chromosome ETTITA ITI obvomesome2 OOOO e e e e x a ig e id ee e n ee e e e e e e e Cromosomeo gt IMITA c
82. nce the start and end coordinates of the annotation features could be passed in as individual arguments start and end as a data frame or even as an lRanges or GRangesList object Furthermore a whole bunch of coercion methods are available for those package users that prefer the more traditional R coding paradigm and they should allow operations along the lines of as obj AnnotationTrack You may want to consult the class manual page for more information or take a look at the Bioconductor integration section for a listing of the most common data structures and their respective counterparts in the Gviz package With our first track object being created we may now proceed to the plotting There is a single function plotTracks that handles all of this As we will learn in the remainder of this vignette plotTracks is quite powerful and has a number of very useful additional arguments For now we will keep things very simple and just plot the single CpG islands annotation track gt plotTracks atrack As you can see the resulting graph is not particularly spectacular There is a title region showing the track s name on a gray background on the left side of the plot and a data region showing the seven individual CpG islands on the right This structure is similar for all the available track objects classes and it somewhat mimicks the layout of the popular UCSC Genome Browser If you are not happy with the default settings the Gviz package offers
83. nd how much of the complete chromosome is covered in our plot To that end the Gviz package defines the deogram Track class which is an idealized representation of a single chromosome When plotted these track objects will always show the whole chromosome regardless of the The Gviz User Guide 17 selected genomic region However the displayed coordinates are indicated by a box that sits on the ideogram image The chromosomal data necessary to draw the ideogram is not part of the Gviz package itself instead it is downloaded from an online source UCSC Thus it is important to use both chromosome and genome names that are recognizable in the UCSC data base when dealing with deogram Track objects You might want to consult the UCSC webpage http genome ucsc edu or use the ucscGenomes function in the rtracklayer package for a listing of available genomes Assuming the chromosome data are available online a simple call to the IdeogramTrack constructor function including the desired genome and chromosome name are enough to instantiate the object Since the connection to UCSC can be slow the package tries to cache data that has already been downloaded for the duration of the Rsession If needed the user can manually clear the cache by calling the clearSessionCache function Of course it is also possible to construct deogram Track objects from local data Please see the class man page for details gt ideoTrack lt IdeogramTrack genome
84. nnotation group just group right Huey Louie Dewey gt plotTracks aTrack groups groupAnnotation group just group above Huey Dewey Louie The Gviz User Guide 33 Arranging items on the plotting canvas is relatively straight forward as long as there are no overlaps between invidiual regions or groups of regions Those inevitably cause overplotting which could seriously obfuscate the information on the plot A logical solution to this problem is to stack overlapping items in separate horizon tal lines to accomodate all of them This involves some optimization and the Gviz package automatically tries to come up with the most compact arrangement Let s exemplify this feature with a slightly modified Annotation Track object gt aTrack stacked lt AnnotationTrack start c 50 180 260 800 600 1240 width c 15 20 40 100 500 20 chromosome chrX strand group rep c Huey Dewey Louie c 1 3 2 genome hg19 name foo gt plotTracks aTrack stacked groupAnnotation group Huey Louie Dewey We now have our three annotation feature groups distributed over two horizontal lines One can control the stacking of overlapping items using the stacking display parameter Currently the three values squish dense and hide are supported Horizontal stacking is enabled via the squish option which also is the default The dense setting forces overlapping items to be joined in one
85. nt Character or integer scalar Fill color for annotation objects of dodgerblue2 type C_segment Mt rRNA Character or integer scalar Fill color for annotation objects of yellow type Mt rRNA Mt tRNA Character or integer scalar Fill color for annotation objects of darkgoldenrod type Mt tRNA The Gviz User Guide Mt_tRNA_pseudogene V_segment miRNA miRNA_pseudogene misc_RNA misc_RNA_pseudogene protein_coding pseudogene rRNA rRNA_pseudogene retrotransposed scRNA scRNA_pseudogene snRNA snRNA_pseudogene snoRNA snoRNA_pseudogene tRNA_pseudogene verbose Character or integer scalar Fill color for type Mt tRNA pseudogene Character or integer scalar Fill color for type V_segment Character or integer scalar Fill color for type L segment Character or integer scalar Fill color for type miRNA pseudogene Character or integer scalar Fill color for type misc RNA Character or integer scalar Fill color for type misc RNA pseudogene Character or integer scalar Fill color for type protein coding Character or integer scalar Fill color for type pseudogene Character or integer scalar Fill color for type rRNA Character or integer scalar Fill color for type rRNA pseudogene Character or integer scalar Fill color for type retrotransposed Character or integer scalar Fill color for type scRNA Character or integer scalar Fill color for type scRNA pseudogen
86. nts Character or integer scalar Color of the line connecting the AnnotstionTrack item with its details panel Character or integer scalar Type of connecting line Integer scalar Line width of the connector Integer scalar Type of the connector s ends List Additional arguments that get passed on the the details plotting function Logial scalar Plot details for feature groups rather than for individual features 4 8 SequenceTrack So far we have displayed all kinds of ranges on a genome but never really looked at the underlying genomic sequence To that end the Gviz package defines the SequenceTrack class which can hold genomic sequence information derived from either a DNAStringSet object of even more convenient from one of the BSgenome packages There is not formal checking of the track s genome so it is up to the user to provide reasonable The Gviz User Guide 52 inputs to the class constructor As with all the other track types the constructor has the same name as the class In this example we build a SequenceTrack from the human hg19 UCSC genome gt library BSgenome Hsapiens UCSC hg19 gt sTrack lt SequenceTrack Hsapiens gt sTrack Sequence track SequenceTrack genome hg19 chromosomes 93 active chromosome chri 249250621 nulceotides Call seqnames to list all available chromosomes Call chromosome to change the active chromosome Parent BSgenome object organism Homo sapiens
87. o be used in order to read the data off the file has been automatically choosen by the package based on the file extension of the input file Of course the number of these supported standard file types is limited and a user may want to import a non standard file through the same mechanism To this end the DataTrack constructor defines an additional argument called importFunction As the name suggests the value of this argument is a function which needs to handle the mandatory file argument Upon evaluation this argument will be filled in with the path to the data file and the user defined function needs to provide all logic necessary to parse that file into a valid GRanges object From this point on everything will happen just as if the range argument had been this GRanges object In other words numeric metadata columns will be shown as individual samples and non numeric columns will be silently ignored We can exemplify this in the next code chunk Note that the Gviz package is using functionality from the rtracklayer package for most of the file import operations just as we do here in a more explicit way gt library rtracklayer gt dTrack3 DataTrack range bgFile genome hg19 type 1 chromosome chri9 name bedGraph importFunction function file import con file asRangedData FALSE gt identical dTrack2 dTrack3 1 TRUE So far one could have easily done the whole process in two separate steps first
88. on from the tick marks exponent Numeric scalar The exponent for the axis coordinates e g 3 means mb 6 means gb etc The default is to automatically determine the optimal exponent fill range Character scalar The fill color for highlighted regions on the axis fontcolor Character scalar The font color for the axis annotation text fontface Character scalar The font face for the axis annotation text fontfamily Character scalar The font family for the axis annotation text fontsize Numeric scalar Font size for the axis annotation text in points labelPos Character vector one in alternating revAlternating above or below The vertical positioning of the axis labels If scale is not NULL the possible values are above below and beside littleTicks Logical scalar Add more fine grained tick marks Iwd Numeric scalar The line width for the axis elementes scale Numeric scalar If not NULL a small scale is drawn instead of the full axis if the value is between 0 and 1 it is interpreted as a fraction of the current plotting region otherwise as an absolute length value in genomic coordinates showld Logical scalar Show the optional range highlighting annotation 4 2 IdeogramTrack While a genomic axis provides helpful points of reference to a plot it is sometimes important to show the currently displayed region in the broader context of the whole chromosme Are we looking at distal regions or somewhere close to the centromer A
89. parameters The former can be an integer value greater than zero giving the number of evenly sized bins to aggregate the data in The latter is supposed to be a user supplied function that accepts a numeric vector as a single input parameter and returns a single aggregated numerical value For simplicity the most obvious aggregation functions can be selected by passing in a character scalar rather than a function Possible values are mean median extreme sum min and max These presets are also much faster because they have been optimized to operate on large numeric matrices The default is to compute the mean value of all the binned data points gt plotTracks dTrack big type hist window 50 Instead of binning the data in fixed width bins one can also use the window parameter to perform more elaborate running window operations For this to happen the parameter value has to be smaller than zero and the addtional display parameter windowSize can be used to control the size of the running window This operation does not change the number of coordinate ranges on the plot but instead the original value at a particular position is replaced by the respective sliding window value at the same position A common use case for sliding windows on genomic ranges is to introduce a certain degree of smoothing to the data gt plotTracks dTrack big type hist window 1 windowSize 2500 The Gviz User Guide 27 In addition to transform
90. r for the coverage profile col gap Integer or character scalar The color of the line that is bridging the gap regions in gapped alignments col mates Integer or character scalar The color of the line that is connecting two paired reads col mismatch Integer or character scalar The box color around mismatch bases col reads Integer or character scalar The box color around reads col sashimi Integer or character scalar The line color for sashimi plots collapse Logical scalar Do not perform any collapsing of overlapping elements Currently not supported The Gviz User Guide coverageHeight fill fill coverage fill reads fontface mismatch Ity Ity coverage Ity gap Ity mates Ity mismatch Ity reads lwd Iwd coverage Iwd gap Iwd mates Iwd mismatch Iwd reads Iwd sashimiMax max height min height minCoverageHeight minSashimi noLetters sashimiHeight sashimiScore sashimiStrand showMismatches type 64 Numeric scalar The height of the coverage region of the track Can either be a value between 0 and 1 in which case it is taken as a relative height or a positive value greater 1 in which case it is interpreted as pixels Integer or character scalar The default fill color of all plot elements Integer or character scalar The fill color for the coverage profile Integer or character scalar The fill color for the read icons Integer scalar The font face for mismatch bases Integer or character scalar The
91. r large genomic region containing one big transcript with many widely spaced exons and a bunch of smaller more compact transcripts In this case it would be helpful to provide a zoomed in version of those smaller transcripts In order to achieve this we can make use of the class groupDetails display parameter which applies the detail plotting function over each range group rather than over individual range items First we define a function that selects those groups with a plotted size smaller than 10 pixels We make use of the unexported function pxResolution here to come up with the mapping between pixel coordinates and genomic coordinates selFun function identifier start end track GdObject 1 gcount lt table group Gd bject pxRange lt Gviz pxResolution min width 20 coord x The Gviz User Guide 50 return end start lt pxRange amp amp gcount identifier 1 The actual detail plotting function is fairly trivial In the details viewport we simply call plotTracks function on the subset of items from each group that has been selected before without plotting the track titles and also add a scale indicator for some reference lt is worth mentioning however that we need to extract the ranges of the zoomed in track items from the unmodified track object the Gdobject original argument in the details function because the object that is plotted in the lower panel contains only the collapsed
92. rack bmt from afrom to ato chromosome chr12 type coverage JA aN sal nAn A so pod iba HIHHH H 3H E18 z t HHH H Let s zoom in a bit further to check out the details of the pile ups section gt plotTracks c bmt alTrack from afrom 12700 to afrom 15200 chromosome chr12 The Gviz User Guide 57 TT anal Ill The direction of the individual reads is indicated by the arrow head and read pairs are connected by a bright gray line Gaps in the alignments are show by the connecting dark gray lines Numbers of reads supporting each gap can be visualized as sashimi plot 1 by adding sashimi as an additional agument to the type display parameter gt plotTracks c bmt alTrack from afrom 12700 T to afrom 15200 chromosome chr12 type c coverage sashimi Da ZNA On devices that support transparancy we can also see that some of the read pairs are actually overlapping Like before we can not display the full depth of the pile up and the clipping that takes place hides a lot of the reads from the view Another way of getting to see at least some of them is by reversing the stacking order We can also play around with some of the other display parameters that control the look and feel of the reads AI AAA AA gt plotTracks c bmt alTrack from afrom 12700 The Gviz Us
93. region fontcolor Character scalar The font color for the chromosome name text fontface Character scalar The font face for the chromosome name text fontfamily Character scalar The font family for the chromosome name text fontsize Numeric scalar The font size for the chromosome name text lty Character or integer scalar The line type used for the highlighting of the cur rently displayed genomic region Iwd Numeric scalar The line width used for the highlighting of the currently dis played genomic region outline Logical scalar Add borders to the individual chromosome staining bands showBandld Logical scalar Show the identifier for the chromosome bands if there is space for it showld Logical scalar Indicate the chromosome name next to the ideogram 4 3 DataTrack Probably the most powerfull of all the track classes in the Gviz package are DataTracks Essentially they constitute run length encoded numeric vectors or matrices meaning that one or several numeric values are associated to a particular genomic coordinate range These ranges may even be overlapping for instance when looking at results from a running window operation There can be multiple samples in a single data set in which case the ranges are associated to the columns of a numeric matrix rather than a numeric vector and the plotting method provides tools to incoorporate sample group information Thus the starting point for creating DataTrack objects will always be a
94. romosome N MTC s I e Ts ee EL E E P e e e e e e e e 9 9 9 o e e e e e e e e Le e ts s 4 A t e oe S e e e e 4 k lt aia x e ni gt e 3 Maybe an even more compact version of this would be to use the lattice package for building the actual trellis with plotTracks as the panel function gt library lattice gt chroms lt data frame chromosome chroms gt xyplot 1 chromosome chromosome data chroms panel function x 1 plotTracks list itrack maTrack mdTrack mgTrack chromosome x add TRUE showId FALSE scales list draw FALSE xlab NULL ylab NULL ttt The Gviz User Guide 74 chr3 chr4 7 Bioconductor integration and file support This short section is supposed to give a very brief overview over the different track classes in the Gviz package and how those can be constructed from the typical Bioconductor classes that deal with genomic data The list ist by no means complete and a closer look at a track class documentation should provide all the possible options Gviz class Bioconductor class Method AnnotationTrack data frame Constructor IRanges Constructor 4 additional arguments GRanges Constructor or setAs method additional data in metadata columns GRangesList Constructor or setAs method GeneRegionTrack data frame Constructor IRanges Constructor 4 additonal arguments
95. s has been passed in for plotting gt plotTracks list itrack gtrack atrack grtrack reverseStrand TRUE Oo a a a gt IT IN IT NN 27 mb 26 8 mb 26 6 mb 26 9 mb 26 7 mb HMGB3P20 RPL7AP38 SKAP2 C7ort71 Hj KIAA0087 skAP2 gt l H AC004947 2 H SKAP2 HH HA AC004947 2 H skaP2 H skap2 jH AC004947 2 H SKAP2 SKAP2 skAP2 SKAP2 sKAP2 The Gviz User Guide 14 As you can see the fact that the data has been plotted on the reverse strand is also reflected in the GenomeAxis track 4 Track classes In this section we will highlight all of the available annotation track classes in the Gviz package For the complete reference of all the nuts and bolts including all the avaialable methods please see the respective class man pages We will try to keep this vignette up to date but in cases of discrepancies between here and the man pages you should assume the latter to be correct 4 1 GenomeAxisTrack GenomeAxis Track objects can be used to add some reference to the currently displayed genomic location to a Gviz plot In their most basic form they are really just a horizontal axis with genomic coordinate tickmarks Using the GenomeAxisTrack constructor function is the recommended way to instantiate objects from the class There is no need to know in advance about a particular genomic location when constructing the object Instead the displayed coordinates will be determined from the con
96. se probes a number of measurements from multiple samples and from different sample groups are available To this end the DetailsAnnotation Track provides a flexible interface to further annotate genomic regions with arbitrary additional information This is archived by splitting the Annotation Track plotting region into two horizontal sections the lower section containing the The Gviz User Guide 48 range data in genomic coordinates and the upper one containing the additional data for each of the displayed ranges in verticaly tiled panels of equal size The connection between a range item and its details panel is indicated by connecting lines The content of the individual details panels has to be filled in by a user defined plotting function that uses grid or lattice plotting commands This function has to accept a number of mandatory parameters notably the start end strand chromosome and identifier information for the genomic range as well as an integer counter indicating the index of the currently plotted details tile This information can be used to fetch abtritray details e g from a list and environement or even from a GRanges object which will then be processed and visualized within the plotting function This may sound rather abstract and for more details please refer to the class help page For now we just want to demonstrate the functionality in a simple little example We begin by defining a GRanges object containing 4 genomic lo
97. sense to overlay multiple tracks on the same area of the plot For instance when dealing with multiple data sets that do not necessarily share the same genomic coordinates for their data points the design of the Data Track class is not optimal To contrast these two data sets an overlay of two separate Data Track objects however can be quite powerful The Gviz package allows for such overlay operations by means of the Overlay Track class Similar to the Highlight Track class from the previous section this is merely a container for an arbitrary number of other Gviz track objects For the purpose of an instructive example we will generate a second Data Track object and combine it with the existing one from the second chapter gt dat runif 100 min 2 max 22 gt dtrack2 DataTrack data dat start coords length coords T end coords 1 chromosome chr genome gen name Uniform2 groups factor sample 2 levels c sample 1 sample 2 legend TRUE gt displayPars dtrack lt list groups factor sample 1 levels c sample 1 sample 2 legend TRUE The Gviz User Guide 71 gt ot lt OverlayTrack trackList list dtrack2 dtrack gt ylims lt extendrange range c values dtrack values dtrack2 gt plotTracks list itrack gtrack ot from lim 1 to lim 2 ylim ylims type c smooth p Chomosome7 CNN gt IN HIT TEN NO 26 71 mb 26 73 mb 26 72 mb 26 74 mb
98. set of ranges either in the form of an Ranges or GRanges object or individually as start and end coordinates or widths The second ingredient is a numeric vector of the same length as the number of ranges or a numeric matrix with the same number of columns Those may even already be part of the input GRanges object as elemenMetadata values For a complete description of all the possible inputs please see the class online documentation We can pass all this information to the DataTrack constructor function to instantiate an object We will load our sample data from an GRanges object that comes as part of the Gviz package gt data twoGroups gt dTrack lt DataTrack twoGroups name uniform gt plotTracks dTrack e d 8 e e a e e M i e e e 8 e e e e gt gt tos e 3 e s 8 3 8 e 8 e e L i 3 3 6 8 c6 To ts 3 3 95 t Tox Y a ios The default visualization for our very simplistic sample DataTrack is a rather unispiring dot plot The track comes with a scale to indicate the range of the numeric values on the y axis appart from that it looks very much like the previous examples A whole battery of display parameters is to our disposal to control the track s The Gviz User Guide 19 look and feel The most important one is the type parameter It determines the type of plot to use and takes one or several of the following values Value Type dot plot lines plot dot and lines plot lines plot of
99. ssentially just a bunch of nested named lists where the names on the first level of nesting should correspond to track class names and the names on the second level to the display parameters to set The currently active schmeme can be changed by setting the global option Gviz scheme and a new scheme can be registered by using the addScheme function providing both the list and the name for the new scheme The getScheme function is useful to get the current scheme as a list structure for instance to use as a skeleton for your own custom scheme gt get ption Gviz scheme 1 default gt scheme getScheme gt scheme GeneRegionTrack fill salmon gt scheme GeneRegionTrack col NULL gt scheme GeneRegionTrack transcriptAnnotation lt transcript gt addScheme scheme myScheme gt options Gviz scheme myScheme gt grtrack lt GeneRegionTrack geneModels genome gen T chromosome chr name Gene Model gt plotTracks grtrack gt options Gviz scheme default The Gviz User Guide 13 gt grtrack lt GeneRegionTrack geneModels genome gen chromosome chr name Gene Model transcriptAnnotation symbol ENST00000242109 M ENST00000409974 H ENST00000497511 ENST00000417997 ENST00000432747 ENST00000490456 H ENST00000420912 Hi ENST00000345317 B H 1 3 i ENSTO00000457000 n ENST00000539623 H Keo 1 81 ENST00000430426 H ENST00000489977 BI ENST00000481204 Hd E
100. tance in pixel below which to collapse ranges Numeric scalar The mimimum horizontal size of a plotted object in pixels Boolean controlling whether to discard all NA values when plotting or to keep empty spaces for NAs Integer scalar The number of colors for the gradient plotting type See Logical scalar Parameter controlling the boxplot appearance See panel bwplot for details Numeric scalar Parameter controlling the boxplot appearance See panel bwplot for details Integer scalar The type of glyph used for plotting symbols Numeric scalar Number of pixels used to separate individual samples in heatmap and horizon type plots Boolean Indicate the data range color mapping in the axis for heatmap or gradient types Boolean Display the names of the individual samples in a heatmap or a horizon plot Numeric scalar Parameter controlling the loess calculation for smooth and mountain type plots See panel loess for details Logical scalar When there are several data groups draw the histogram type plots as stacked barplots or grouped side by side 30 The Gviz User Guide 31 stats Function Parameter controlling the boxplot appearance See panel bwplot for details transformation Function Applied to the data matrix prior to plotting or when calling the score method The function should accept exactly one input argument and its return value needs to be a numeric vector which can be coerced back into a data matrix of id
101. ter or integer scalar The color used for line elements Defaults to the setting of col Character scalar Line color in mountain type and polygon type plots defaults to the setting of col Character or integer scalar The color used for the sample names in heatmap plots Character or integer scalar The color used for symbol elements Defaults to the setting of col Logical scalar Collapse overlapping ranges and aggregate the underlying data Numeric scalar Parameter controlling the loess calculation for smooth and mountain type plots See panel loess for details Logical scalar Parameter controlling the boxplot appearance panel bwplot for details Numeric scalar Parameter controlling the loess calculation for smooth and mountain type plots See panel loess for details Numeric scalar Factor to control amount of jittering in xy type plots panel xyplot for details Character scalar Parameter controlling the loess calculation for smooth and mountain type plots See panel loess for details Character scalar The fill color for area elements unless there is a more specific control defined elsewhere Character scalar Fill color in histogram type plots defaults to the setting of fill The fill colors for the segments in the horizon type plot This should be a vector of length six where the first three entries are the colors for positive changes and the latter three entries are the colors for negative changes Defaults to a red bl
102. text e g from the from and to arguments of the plotTracks function or when plotted together with other track objects from their genomic locations gt axisTrack lt GenomeAxisTrack gt plotTracks axisTrack from 1000000 to 9000000 mp 4 mo o mp Oo mo 2 mh 5 mh 7 mh As an optional feature one can highlight particular regions on the axis for instance to indicated stretches of N nucleotides or gaps in genomic alignments Such regions have to be supplied to the optional range argument of the constructor function as either an GRanges or an IRanges object gt axisTrack lt GenomeAxisTrack range IRanges start c 2000000 4000000 end c 3000000 7000000 names rep N stretch 2 gt plotTracks axisTrack from 1000000 to 9000000 E R mh EIE If names have been supplied with the range argument those can also be added to the plot gt plotTracks axisTrack from 1000000 to 9000000 showId TRUE The Gviz User Guide 15 Display parameters for GenomeAxisTrack objects There are a whole bunch of display parameters to alter the appearance of GenomeAxis Track plots For instance one could add directional indicators to the axis using the add53 and add35 parameters gt plotTracks axisTrack from 1000000 to 9000000 add53 TRUE add35 TRUE 2 mh E mh 7 mh Sometimes the resolution of the tick marks is not sufficient in which case the ittleTicks argument can be used to have a mor
103. times more useful than cryptic data base gene identifiers The following code that re uses the GeneRegion Track object from the first section exemplifies some of these features gt data geneModels gt grtrack lt GeneRegionTrack geneModels genome gen T chromosome chr name foo gt head gene grtrack gt head transcript grtrack gt head exon grtrack gt head symbol grtrack gt plotTracks grtrack The Gviz User Guide 40 Both exon and transcript centric annotation can be added to the plot using the transcriptAnnotation and exonAnnotation display parameters gt plotTracks grtrack transcriptAnnotation symbol KIAA0087 C7ort71 H SKAP2 SKAP2 RPL7AP38 HMGB3P20 ACO04947 2 H SKAP2 H AC004947 2 SKAP2 H AC004947 2 H SKAP2 lt SkAP2 lt SKAP2 SKAP2 SKAP2 SKAP2 gt plotTracks grtrack transcriptAnnotation transcript ENSE0000160 ENSE00001592282 ENSE00001769159 gt plotTracks grtrack exonAnnotation exon extend left 0 8 fontcolor exon 1 ENSE0000160 ENSE00001592282 ENSE00001 769159 Since we have the gene and trancript level information as part of our GeneRegion Track objects we can ask the package to collapse all of our gene models from individual exons and transcripts down to gene body locations by setting the collapseTranscripts display parameter to TRUE gt plotTracks grtrack collapseTranscripts TRUE
104. tle 1 alpha 0 5 gt displayPars dtrack2 lt list alpha title 1 alpha 0 5 gt ot lt OverlayTrack trackList list dtrack dtrack2 gt plotTracks list itrack gtrack ot from lim 1 to lim 2 ylim ylims type c hist window 30 The Gviz User Guide 72 Os CNEN gt IN IT M 26 71 mb 26 73 mb 26 72 mb 26 74 mb 6 Composite plots for multiple chromosomes As mentioned in the introduction section a set of Gviz tracks has to share the same chromosome when plotted i e only a single chromosome can be active during a given plotting operation Consequently we can not directly create plots for multiple chromosomes in a single call to the plotTracks function However since the underlying graphical infrastructure of the Gviz package uses grid graphics we can build our own composite plot using multiple consecutive plotTracks calls All we need to take care of is an adequate layout structure to plot into and we also need to tell plotTracks not to clear the graphics device before plotting which can be archieved by setting the function s add argument to FALSE For details on how to create a layout structure in the grid graphics system please see the help page at grid layout We start by creating an Annotation Track objects and a Data Track object which both contain data for several chromosomes gt chroms lt c chr1 chr2 chr3 chr4 gt maTrack lt AnnotationTrack range GRanges seq
105. tors gt plotTracks sTrack chromosome 1 from 20000 to 20050 add53 TRUE The Gviz User Guide 53 5CCTGGTGCTCCCAC GGAG GGGCTGATCACTC GTTGCG c3 If instead we plot the complement sequence on the reverse strand the indicators are automatically adjusted gt plotTracks sTrack chromosome 1 from 20000 T to 20050 add53 TRUE complement TRUE 3 GGACCACGAGGGTGTTTCCTCTTCCCGACTAGTGAGTTTC CGCTTGS So far we have been able to fit the sequence onto our plotting device without overplotting l e all the letters nicely fit in to their respective position in the genomic coordinate system However this restricts us to very small windows which we can reasonably display A much more compact version of the same information is to use colored boxes rather than individual letters Those boxes can be stacked much closer together which increases the possible window size quite a bit The user does not really need to worry about this as the plotting method will automatically make a reasonable decision based on the available space gt plotTracks sTrack chromosome 1 from 20000 to 20100 A A AA Tt A AA A AA S SOC A A TT TT HEN RETRETTI For added flexibility one can set the noLetters display paramter to TRUE to always force the drawing of boxes Of course also the colored box represenation of a sequence has its limits and if we cross the threshold when individual boxes can not be separated anymore the plo
106. tting method falls back to drawing a single line indicating the presence of a sequence at the given position plotTracks sTrack chromosome 1 from 20000 T to 201000 Finally the selected font size is also contributing to the available space and we can cram a little more sequence into a given window by decreasing it gt plotTracks sTrack chromosome 1 from 20000 to 20100 cex 0 5 TCCTGGTGCTCCCAC GGAG GGGCTGATCACTC GTTGCG CACC GCTC c TGAGCCCTGG TTTCTGG TGGATTATT c Display parameters for SequenceTrack objects For a complete listing of all the available display parameters please see the table below or the man page of the SequenceTrack class by typing in SequenceTrack on the Rcommand line Display Parameter Description add53 Logical scalar Add a direction indicator cex The character expansion factor for the size of the sequence letters Together with fontsize this determines the final font size and thus the level of plotable details The Gviz User Guide 54 col Character scalar The color of the line when no indiviual letters can be plotted due to size limitations complement Logical scalar Plot the sequence complement fontcolor Character vector The colors used for the 5 possible nucleotides G A T C N Defaults to use colors as defined in the biovizBase package fontface Numeric scalar The face of the font fontsize Numeric scalar Controls the size of the sequence letters and thus also the leve
107. ue color scheme See horizonplot for details Character vector of length 2 Fill color in mountain type and polygon type plots Integer or character scalar The font color for the legend text Integer or character scalar The font face for the legend text Integer or character scalar The font family for the legend text Numeric scalar The pixel size for the legend text Character vector The base colors for the gradient plotting type or the heatmap type with a single group When plotting heatmaps with more than one group the col parameter can be used to control the group color scheme however the gradient will always be from white to col and thus does not offer as much flexibility as this gradient parameter Logical vector Draw a line grid under the track content Vector coercable to a factor Optional sample grouping See Details section in DataTrack for further information Integer scalar Parameter controlling the number of vertical grid lines see panel grid for details See See 29 The Gviz User Guide horizon origin horizon scale jitter x jitter y legend levels fos lineheight legend Ity Ity baseline Ity grid Ity mountain Iwd Iwd baseline lwd grid Iwd mountain min distance min width na rm ncolor notch notch frac pch separator showColorBar showSampleNames span stackedBars The baseline relative to which changes are indicated on the horizon type plot S
108. y map to the row names of the data matrix gt library lattice gt details lt function identifier d lt data frame signal methylation identifier J group sgroups print densityplot signal group group data d main list label identifier cex 0 7 scales list draw FALSE x list draw TRUE ylab xlab newpage FALSE prefix plot Finaly it is as simple as calling the Annotation Track constructor passing along the wrapper function and The Gviz User Guide 49 calling plotTracks gt deTrack lt AnnotationTrack range probes genome hg19 chromosome 7 id rownames methylation name probe details stacking squish fun details gt plotTracks deTrack probe1 probe2 probe3 probe4 NN I O 0 2 4 6 8 0 2 4 6 0 2 4 6 024 6 8 It should be noted here that in our little example we rely on the methylation data matrix and the grouping vector to be present in the working environment This is not necessarily the cleanest solution and one should consider storing additional data in an evironment passing it along using the detailFunArgs parameter or making it part of the details function in form of a closure The class help page provides further instructions Another use case for the DetailsAnnotation Track class is to deal with the problem of very different feature sizes within a single track For instance we may be looking at a rathe
Download Pdf Manuals
Related Search
Related Contents
Mode d`emploi Dépoussiéreur mobile ArbiTER: a Flexible Eigenvalue Solver for Edge Fusion Plasma Swisher Mower T-40 User's Manual Manual de utilização rápida TED Pro Manual - Actoolsupply.com body beautiful.qxd Aucun titre de diapositive Emerson MS9904TTC Stereo System User Manual Copyright © All rights reserved.
Failed to retrieve file