Gviz ChromHMM colouring for AnnotationTracks
4
1
Entering edit mode
gammyknee ▴ 10
@gammyknee-11838
Last seen 6.7 years ago
Australia/Adelaide

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

 

gviz chromHMM • 2.4k views
ADD COMMENT
2
Entering edit mode
Robert Ivanek ▴ 730
@robert-ivanek-5892
Last seen 4 months ago
Switzerland

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(Tcell_effmem_pblood, "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 COMMENT
1
Entering edit mode
@tiphaine-martin-6416
Last seen 5.5 years ago
France

Hi,

In my r package coMET, I allow user to visualise chrommHMM using Roadmap color or our color

https://bioconductor.org/packages/release/bioc/html/coMET.html, you have different color sets described in the vignette.  This was implemented in the function "chromHMM_RoadMap". Feel free to use it and if you have questions, feel free to ask . I wrapped other data with also some options for the colors.

Regards,

Tiphaine  

ADD COMMENT
0
Entering edit mode

Hi Tiphaine,

I already tried chromHMM_RoadMap to generate chromHMM15. there is no coloured features were shown only blue bar.

here is my bed file format:

chr1    75421401    75421600    TssBiv
chr1    75421601    75421800    TssBiv
chr1    75421801    75422000    TssBiv
chr1    75422001    75422200    TssBiv
chr1    75422201    75422400    TssBiv
chr1    75422401    75422600    TssBiv
chr1    75422601    75422800    TssBiv
chr1    75422801    75423000    TssBiv
chr1    75423001    75423200    TssBiv
chr1    75423201    75423400    TssBiv
chr1    75423401    75423600    TssBiv
chr1    75423601    75423800    HetFac
chr1    75423801    75424000    HetFac
chr1    75424001    75424200    HetFac
chr1    75424201    75424400    HetFac
chr1    75424401    75424600    HetFac
chr1    75424601    75424800    EnhPois2
chr1    75424801    75425000    EnhPois2
chr1    75425001    75425200    EnhPois2
chr1    75425201    75425400    EnhPois2
chr1    75425401    75425600    EnhPois2
chr1    75425601    75425800    EnhPois2
chr1    75425801    75426000    EnhPois2
chr1    75426001    75426200    EnhPois2
chr1    75426201    75426400    EnhPois2
chr1    75426401    75426600    EnhPois2
chr1    75426601    75426800    Tx1
chr1    75426801    75427000    Tx1
chr1    75427001    75427200    Tx2
chr1    75427201    75427400    Tx2
chr1    75427401    75427600    Tx2
chr1    75427601    75427800    Tx2
chr1    75427801    75428000    Tx2
chr1    75428001    75428200    Tx2
chr1    75428201    75428400    Tx2
chr1    75428401    75428600    Tx2
chr1    75428601    75428800    Tx2
chr1    75428801    75429000    Tx2
chr1    75429001    75429200    Tx2
chr1    75429201    75429400    Tx2
chr1    75429401    75429600    QuiesG
chr1    75429601    75429800    QuiesG
chr1    75429801    75430000    QuiesG
chr1    75430001    75430200    QuiesG
chr1    75430201    75430400    QuiesG
chr1    75430401    75430600    QuiesG
chr1    75430601    75430800    QuiesG
chr1    75430801    75431000    QuiesG
chr1    75431001    75431200    QuiesG
chr1    75431201    75431400    EnhPois2
chr1    75431401    75431600    EnhPois2
chr1    75431601    75431800    EnhPois2
chr1    75431801    75432000    EnhPois2
chr1    75432001    75432200    QuiesG
chr1    75432201    75432400    QuiesG
chr1    75432401    75432600    QuiesG
chr1    75432601    75432800    QuiesG
chr1    75432801    75433000    QuiesG
chr1    75433001    75433200    QuiesG​
ADD REPLY
0
Entering edit mode
ta_awwad ▴ 10
@ta_awwad-11382
Last seen 20 days ago
Frankfurt am Main

Hi,

did you manage to solve this problem ?

ADD COMMENT
0
Entering edit mode
ta_awwad ▴ 10
@ta_awwad-11382
Last seen 20 days ago
Frankfurt am Main

Hi Robert,

I did the same thing but still not working.

y <- import.bed("chromatin_stats.bed")

y

GRanges object with 13627678 ranges and 4 metadata columns:
             seqnames               ranges strand |        name     score     itemRgb                thick
                <Rle>            <IRanges>  <Rle> | <character> <numeric> <character>            <IRanges>
         [1]     chr1          [  1,  200]      * |       Quies       999     #DCDCDC          [  1,  200]
         [2]     chr1          [201,  400]      * |       Quies       999     #DCDCDC          [201,  400]
         [3]     chr1          [401,  600]      * |       Quies       998     #DCDCDC          [401,  600]
         [4]     chr1          [601,  800]      * |       Quies       998     #DCDCDC          [601,  800]
         [5]     chr1          [801, 1000]      * |       Quies       998     #DCDCDC          [801, 1000]
         ...      ...                  ...    ... .         ...       ...         ...                  ...
  [13627674]     chrY [91743601, 91743800]      * |       Quies       984     #DCDCDC [91743601, 91743800]
  [13627675]     chrY [91743801, 91744000]      * |       Quies       983     #DCDCDC [91743801, 91744000]
  [13627676]     chrY [91744001, 91744200]      * |       Quies       981     #DCDCDC [91744001, 91744200]
  [13627677]     chrY [91744201, 91744400]      * |       Quies       979     #DCDCDC [91744201, 91744400]
  [13627678]     chrY [91744401, 91744600]      * |       Quies       975     #DCDCDC [91744401, 91744600]
  -------
  seqinfo: 22 sequences from an unspecified genome; no seqlengths​

hmmTrack <- AnnotationTrack(y , start = from,  end = to, chromosome = chr, id = y$name, width = 10, genome= gen, stacking = "dense", feature = y$itemRgb, name = "chromHMM")

plotTracks(hmmTrack​)

but I am still missing the color code of my bed track

 

ADD COMMENT
0
Entering edit mode

You need to provide the specific colours as additional arguments to plotTracks function or to AnnotationTrack.

 

plotTracks(hmmTrack, "#FF0000"="#FF0000", "#FFFF00"="#FFFF00", "#FF4500"="#FF4500")
ADD REPLY
0
Entering edit mode

Thanks much Robert,

the colours should be automatically specified from itemRgb column ... am I getting this right?

 

ADD REPLY
1
Entering edit mode
Partially, the itemRgb column contains color definitions but they are not recognised as such by Gviz. In Gviz this columns simply represent grouping (features) and you need to define color for every group (feature). Hope that helps. Robert > On 6 Dec 2017, at 13:58, ta_awwad [bioc] <noreply@bioconductor.org> wrote: > > Activity on a post you are following on support.bioconductor.org > User ta_awwad wrote Comment: Gviz ChromHMM colouring for AnnotationTracks: > > > Thanks much Robert, > > the colours should specified from itemRgb column ... am I getting this wrong? > > > > Post tags: gviz, chromHMM > > You may reply via email or visit C: Gviz ChromHMM colouring for AnnotationTracks >
ADD REPLY
0
Entering edit mode

Thanks much Robert ... it worked pretty good now... 

TA

ADD REPLY
1
Entering edit mode

I hope I understood you correctly.  By setting argument col you can change the border color of all track items. see Gviz vignette, chapter AnnotationTrack.  So by setting it to  col="transparent" you can get rid of the lines:

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(Tcell_effmem_pblood, "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", col="transparent", groupAnnotation="feature", "#FF0000"="#FF0000", "#FFFF00"="#FFFF00", "#FF4500"="#FF4500")

plotTracks(hmmTrack)
ADD REPLY
0
Entering edit mode

thanks a ton .. I did it already .. 

ADD REPLY

Login before adding your answer.

Traffic: 695 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