Search
Question: Gviz ChromHMM colouring for AnnotationTracks
1
gravatar for gammyknee
12 months ago by
gammyknee10
Australia/Adelaide
gammyknee10 wrote:

Hi guys,

Im looking for some specific help with the Gviz package and its ability to plot bed files with many features. Id like to colour each feature in an epigenomics roadmap 15 state chromHMM bed file for a figure im preparing but I can't seem to group the features to plot each colour (Rgb code is a column in the GRange object) on an AnnotationTrack. 

Here's some of the GRange object:

GRanges object with 11583 ranges and 4 metadata columns:
          seqnames                 ranges strand |        name     score     itemRgb
             <Rle>              <IRanges>  <Rle> | <character> <numeric> <character>
      [1]     chr3     [3151401, 3152200]      * |      1_TssA         0     #FF0000
      [2]     chr3     [3152201, 3152600]      * |       7_Enh         0     #FFFF00
      [3]     chr3     [3167601, 3168000]      * |       7_Enh         0     #FFFF00
      [4]     chr3     [3168001, 3168400]      * |  2_TssAFlnk         0     #FF4500
      [5]     chr3     [3168401, 3169400]      * |      1_TssA         0     #FF0000

I did notice a question answered thats fairly close to what im after, but unfortunately its dealing with the UCSCtrack functionality and downloaded tables (https://support.bioconductor.org/p/50192/). Unfortunately UCSC dont have the samples I need. Ive been reading up on how to change displayParams but im getting no-where fast

 

So far I've tried:

hmmTrack <- AnnotationTrack(Tcell_effmem_pblood, start = from,  end = to, chromosome = "chr3", id = Tcell_effmem_pblood$name, width = 10, genome="hg19", stacking = "dense", feature = Tcell_effmem_pblood$itemRgb, name = "Tcell effmem")
feat <- unique(feature(hmmTrack))
featCol <- setNames(as.list(rgb(t(sapply(strsplit(feat, " "), as.numeric)), maxColorValue=255)), feat)displayPars(hmmTrack) <- featCol
displayPars(hmmTrack) <- featCol

Which gives me the error:

> feat <- unique(feature(hmmTrack))
> featCol <- setNames(as.list(rgb(t(sapply(strsplit(feat, " "),
+                                          as.numeric)), maxColorValue=255)), feat)
Error in rgb(t(sapply(strsplit(feat, " "), as.numeric)), maxColorValue = 255) : 
  color intensity NA, not in 0:255
In addition: Warning messages:
1: In lapply(X = X, FUN = FUN, ...) : NAs introduced by coercion
2: In lapply(X = X, FUN = FUN, ...) : NAs introduced by coercion
3: In lapply(X = X, FUN = FUN, ...) : NAs introduced by coercion
4: In lapply(X = X, FUN = FUN, ...) : NAs introduced by coercion
5: In lapply(X = X, FUN = FUN, ...) : NAs introduced by coercion
6: In lapply(X = X, FUN = FUN, ...) : NAs introduced by coercion
7: In lapply(X = X, FUN = FUN, ...) : NAs introduced by coercion

Any help would be much appreciated.

Cheers,

JB

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin16.0.0 (64-bit)
Running under: OS X 10.12.1 (Sierra)

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

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

other attached packages:
 [1] coMET_1.6.0                             trackViewer_1.10.0                     
 [3] ggbio_1.22.0                            psych_1.6.9                            
 [5] biomaRt_2.30.0                          BiocInstaller_1.24.0                   
 [7] chromophobe_0.95                        fastcluster_1.1.21                     
 [9] reshape2_1.4.2                          devtools_1.12.0                        
[11] R.4Cker_0.0.0.9000                      TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2
[13] GenomicFeatures_1.26.0                  AnnotationDbi_1.36.0                   
[15] Biobase_2.34.0                          Gviz_1.18.0                            
[17] rtracklayer_1.34.1                      GenomicRanges_1.26.1                   
[19] GenomeInfoDb_1.10.1                     IRanges_2.8.1                          
[21] S4Vectors_0.12.0                        BiocGenerics_0.20.0                    
[23] pheatmap_1.0.8                          ggplot2_2.1.0                          

loaded via a namespace (and not attached):
 [1] bitops_1.0-6                  matrixStats_0.51.0            RColorBrewer_1.1-2           
 [4] httr_1.2.1                    tools_3.3.1                   R6_2.2.0                     
 [7] rpart_4.1-10                  Hmisc_4.0-0                   DBI_0.5-1                    
[10] colorspace_1.3-0              nnet_7.3-12                   withr_1.0.2                  
[13] gridExtra_2.2.1               GGally_1.2.0                  mnormt_1.5-5                 
[16] DESeq2_1.14.0                 curl_2.2                      git2r_0.15.0                 
[19] chron_2.3-47                  graph_1.52.0                  htmlTable_1.7                
[22] grImport_0.9-0                scales_0.4.1                  genefilter_1.56.0            
[25] pbapply_1.3-1                 RBGL_1.50.0                   stringr_1.1.0                
[28] digest_0.6.10                 Rsamtools_1.26.1              foreign_0.8-67               
[31] XVector_0.14.0                dichromat_2.0-0               htmltools_0.3.5              
[34] ensembldb_1.6.0               BSgenome_1.42.0               RSQLite_1.0.0                
[37] shiny_0.14.2                  BiocParallel_1.8.1            acepack_1.4.1                
[40] VariantAnnotation_1.20.0      RCurl_1.95-4.8                magrittr_1.5                 
[43] Formula_1.2-1                 Matrix_1.2-7.1                Rcpp_0.12.7                  
[46] munsell_0.4.3                 stringi_1.1.2                 MASS_7.3-45                  
[49] SummarizedExperiment_1.4.0    zlibbioc_1.20.0               plyr_1.8.4                   
[52] AnnotationHub_2.6.0           lattice_0.20-34               Biostrings_2.42.0            
[55] splines_3.3.1                 hash_2.2.6                    annotate_1.52.0              
[58] locfit_1.5-9.1                knitr_1.15                    geneplotter_1.52.0           
[61] XML_3.98-1.5                  biovizBase_1.22.0             latticeExtra_0.6-28          
[64] data.table_1.9.6              httpuv_1.3.3                  miscTools_0.6-16             
[67] gtable_0.2.0                  reshape_0.8.6                 mime_0.5                     
[70] xtable_1.8-2                  depmixS4_1.3-3                colortools_0.1.5             
[73] Rsolnp_1.16                   survival_2.40-1               truncnorm_1.0-7              
[76] OrganismDbi_1.16.0            GenomicAlignments_1.10.0      memoise_1.0.0                
[79] corrplot_0.77                 cluster_2.0.5                 interactiveDisplayBase_1.12.0

 

ADD COMMENTlink modified 14 days ago by Robert Ivanek350 • written 12 months ago by gammyknee10
0
gravatar for ta_awwad
14 days ago by
ta_awwad0
ta_awwad0 wrote:

Hi,

did you manage to solve this problem ?

ADD COMMENTlink written 14 days ago by ta_awwad0
0
gravatar for Robert Ivanek
14 days ago by
Robert Ivanek350
Switzerland
Robert Ivanek350 wrote:

Hi,

I can produce a colored plot  annotationTrack above:

Tcell_effmem_pblood <- data.frame(seqnames = c("chr3", "chr3", "chr3", "chr3", "chr3"),
           start = c(3151401L, 3152201L, 3167601L, 3168001L, 3168401L),
           end = c(3152200L, 3152600L, 3168000L, 3168400L, 3169400L), 
           strand = c("*", "*", "*", "*", "*"),
           name = c("1_TssA", "7_Enh", "7_Enh", "2_TssAFlnk", "1_TssA"),
           score = c(0L, 0L, 0L, 0L, 0L),
           itemRgb = c("#FF0000", "#FFFF00", "#FFFF00", "#FF4500", "#FF0000"))
Tcell_effmem_pblood <- as(D, "GRanges")

hmmTrack <- AnnotationTrack(Tcell_effmem_pblood, start = from,  end = to, chromosome = "chr3", id = Tcell_effmem_pblood$name, width = 10, genome="hg19", stacking = "dense", feature = Tcell_effmem_pblood$itemRgb, name = "Tcell effmem")

plotTracks(hmmTrack, groupAnnotation="feature", "#FF0000"="#FF0000", "#FFFF00"="#FFFF00", "#FF4500"="#FF4500")

 

Is that what do you want to achieve?

Best

Robert

ADD COMMENTlink modified 14 days ago • written 14 days ago by Robert Ivanek350
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: 159 users visited in the last hour