Gviz adding Custom Track
1
0
Entering edit mode
mviterson ▴ 10
@mviterson-6917
Last seen 6.5 years ago
Netherlands

Dear all,

I would like to create a custom track for Gviz. I found the CustomTrack class but didn't get it working properly. Plotting only the CustomTrack works as expected however, when plotting a tracklist the CustomTrack appears twice on different vertical locations.

Does anyone have experience using Gviz CustomTrack?

Kind regards,

Maarten van Iterson

The following minimal example shows the issue:

library(Gviz)
cTrack <- CustomTrack(plottingFunction = function(GdObject, prepare) {grid.text("customtrack"); return(invisible(GdObject))})
plotTracks(cTrack,  from = 1, to = 100) ##only CustomTrack

gtrack <- GenomeAxisTrack()                          
plotTracks(c(cTrack, gtrack),  from = 1, to = 100) ##Plotting two tracks

sessionInfo()
R Under development (unstable) (2014-07-22 r66228)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [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] parallel  grid      stats     graphics  grDevices utils     datasets
[8] methods   base     

other attached packages:
[1] Gviz_1.9.13           GenomicRanges_1.17.34 GenomeInfoDb_1.1.18  
[4] IRanges_1.99.24       S4Vectors_0.1.2       BiocGenerics_0.11.4  

loaded via a namespace (and not attached):
 [1] acepack_1.3-3.3           AnnotationDbi_1.27.9     
 [3] BatchJobs_1.3             BBmisc_1.7               
 [5] Biobase_2.25.0            BiocParallel_0.99.10     
 [7] biomaRt_2.21.1            Biostrings_2.33.13       
 [9] biovizBase_1.13.9         bitops_1.0-6             
[11] brew_1.0-6                BSgenome_1.33.8          
[13] checkmate_1.4             cluster_1.14.4           
[15] codetools_0.2-8           colorspace_1.2-4         
[17] DBI_0.3.0                 dichromat_2.0-0          
[19] digest_0.6.4              fail_1.2                 
[21] foreach_1.4.2             foreign_0.8-57           
[23] Formula_1.1-2             GenomicAlignments_1.1.24
[25] GenomicFeatures_1.17.14   Hmisc_3.14-5             
[27] iterators_1.0.7           lattice_0.20-24          
[29] latticeExtra_0.6-26       matrixStats_0.10.0       
[31] munsell_0.4.2             nnet_7.3-7               
[33] plyr_1.8.1                R.methodsS3_1.6.1        
[35] RColorBrewer_1.0-5        Rcpp_0.11.2              
[37] RCurl_1.95-4.3            rpart_4.1-3              
[39] Rsamtools_1.17.32         RSQLite_0.11.4           
[41] rtracklayer_1.25.13       scales_0.2.4             
[43] sendmailR_1.1-2           splines_3.2.0            
[45] stats4_3.2.0              stringr_0.6.2            
[47] survival_2.37-7           tools_3.2.0              
[49] VariantAnnotation_1.11.24 XML_3.98-1.1             
[51] XVector_0.5.7             zlibbioc_1.11.1         
gviz • 1.8k views
ADD COMMENT
2
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 5.5 years ago
Switzerland

Hi Maarten,

try this:

library(Gviz)
cTrack <- CustomTrack(plottingFunction = function(GdObject, prepare) {if(!prepare) grid.text("customtrack"); return(invisible(GdObject))})

gtrack <- GenomeAxisTrack()                          
plotTracks(c(cTrack, gtrack),  from = 1, to = 100) ##Plotting two tracks

 

Essentially the idea of the prepare parameter is that Gviz track plotting functions are called twice. Once in prepare mode to set up parameters like stacks or font sizes, and then a second time to do the actual plotting. 

I should probably hide this fact from the user in CustomTracks by not calling the plotting function in the preparation phase, and definitely should work on the documentation.

Florian

ADD COMMENT
0
Entering edit mode

Hi Florian,

Thanks for your help! This is exactly what I needed.

Cheers,

Maarten

 

ADD REPLY

Login before adding your answer.

Traffic: 582 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6