Search
Question: Cannot specify groups when overlaying aligned read tracks
0
gravatar for JohnTownsend
12 months ago by
JohnTownsend20
JohnTownsend20 wrote:

I am trying to overlay two sets of read depth data on a single track in Gviz. As a minimal example, I can get this data plotted on two tracks:

library(Gviz)
set.seed(1)

coords <- seq(from=1000, to=5000, by=100)

starts1 <- sample(1500:4500, 10)
ends1 <- starts1 + 100
reads1 <- GRanges(Rle("chr1"), IRanges(starts1, ends1), strand = Rle("+"))

starts2 <- sample(1500:4500, 10)
ends2 <- starts2 + 100
reads2 <- GRanges(Rle("chr1"), IRanges(starts2, ends2), strand = Rle("+"))

ax <- GenomeAxisTrack()

T1 <- AlignedReadTrack(reads1)
T2 <- AlignedReadTrack(reads2)

plotTracks(list(ax, T1, T2))

I can also overlay these two tracks

ot <- OverlayTrack(list(T1, T2))

plotTracks(list(ax, ot))

However, this is not very useful as I cannot distinguish between the two datasets. So I've tried to specify each track as a separate group before overlaying them.

T1 <- AlignedReadTrack(reads1, groups = factor("sample 1", levels = c("sample 1", "sample 2")), legend = TRUE)
T2 <- AlignedReadTrack(reads2, groups = factor("sample 2", levels = c("sample 1", "sample 2")), legend = TRUE)

ot <- OverlayTrack(list(T1, T2))

plotTracks(list(ax, ot))

But this gives me the following error:

Error in rep(yy, nrow(valsS)) : invalid 'times' argument

Am I making a mistake somewhere? Or is this because the AlignedReadTrack is still in development, so there are still bugs like this coming up?

Many thanks!

John

PS. Here's my sessionInfo()

R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
 [1] grid      parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Gviz_1.20.0          GenomicRanges_1.28.3 GenomeInfoDb_1.12.1  IRanges_2.10.2      
[5] S4Vectors_0.14.7     BiocGenerics_0.22.0

loaded via a namespace (and not attached):
 [1] Biobase_2.36.2                httr_1.2.1                    bit64_0.9-7                  
 [4] AnnotationHub_2.8.2           splines_3.4.2                 shiny_1.0.3                  
 [7] Formula_1.2-2                 interactiveDisplayBase_1.14.0 latticeExtra_0.6-28          
[10] blob_1.1.0                    BSgenome_1.44.0               GenomeInfoDbData_0.99.0      
[13] Rsamtools_1.28.0              yaml_2.1.14                   RSQLite_2.0                  
[16] backports_1.1.0               lattice_0.20-35               biovizBase_1.24.0            
[19] digest_0.6.12                 RColorBrewer_1.1-2            XVector_0.16.0               
[22] checkmate_1.8.3               colorspace_1.3-2              httpuv_1.3.3                 
[25] htmltools_0.3.6               Matrix_1.2-11                 plyr_1.8.4                   
[28] XML_3.98-1.7                  biomaRt_2.32.1                zlibbioc_1.22.0              
[31] xtable_1.8-2                  scales_0.4.1                  BiocParallel_1.10.1          
[34] htmlTable_1.9                 tibble_1.3.4                  AnnotationFilter_1.0.0       
[37] ggplot2_2.2.1                 SummarizedExperiment_1.6.3    GenomicFeatures_1.28.5       
[40] nnet_7.3-12                   lazyeval_0.2.0                mime_0.5                     
[43] survival_2.41-3               magrittr_1.5                  memoise_1.1.0                
[46] foreign_0.8-69                BiocInstaller_1.26.1          tools_3.4.2                  
[49] data.table_1.10.4             matrixStats_0.52.2            stringr_1.2.0                
[52] munsell_0.4.3                 cluster_2.0.6                 DelayedArray_0.2.7           
[55] AnnotationDbi_1.38.1          ensembldb_2.0.4               Biostrings_2.44.1            
[58] compiler_3.4.2                rlang_0.1.2.9000              RCurl_1.95-4.8               
[61] dichromat_2.0-0               VariantAnnotation_1.22.1      htmlwidgets_0.9              
[64] bitops_1.0-6                  base64enc_0.1-3               gtable_0.2.0                 
[67] curl_2.8.1                    DBI_0.6-1                     R6_2.2.2                     
[70] GenomicAlignments_1.12.2      gridExtra_2.2.1               knitr_1.16                   
[73] rtracklayer_1.36.3            bit_1.1-12                    Hmisc_4.0-3                  
[76] ProtGenerics_1.8.0            stringi_1.1.5                 Rcpp_0.12.13                 
[79] rpart_4.1-11                  acepack_1.4.1 
ADD COMMENTlink modified 12 months ago by Robert Ivanek530 • written 12 months ago by JohnTownsend20
2
gravatar for Robert Ivanek
12 months ago by
Robert Ivanek530
Switzerland
Robert Ivanek530 wrote:

Hi John,

You can either use annotation tracks and then code similar to this one should work:

T1 <- AnnotationTrack(reads1, feature = factor(rep("sample 1",length(reads1)), levels = c("sample 1", "sample 2")), shape = "box", showId=FALSE)
T2 <- AnnotationTrack(reads2, feature = factor(rep("sample 2",length(reads2)), levels = c("sample 1", "sample 2")), shape = "box", showId=FALSE)

ot <- OverlayTrack(list(T1, T2))

plotTracks(list(ax, ot), groupAnnotation = "feature", `sample 1` = "darkred", `sample 2` = "darkgreen")

Or if you want to show legend then you need to use DataTrack and then you can follow the example in the vignette (chapter 5.2 Overlays)

Hope that helps

ADD COMMENTlink written 12 months ago by Robert Ivanek530
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 242 users visited in the last hour