question regarding gviz
0
0
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 5.6 years ago
Switzerland
Hi Elmar, this is indeed a little tricky because the data in UCSC are spread across several tables. I think you will indeed have to fetch it for each of these tables individually. Looking at the table structure it seems that the data are stored in a BED-like structure, and the color is encoded in the itemRgb column. In your first attempt you didn't tell the UcscTrack constructor how to map the columns in the downloaded tables to the AnnotationTrack fields. You need to provide at least the mapping for the start and end coordinates ('chromStart' and 'chromEnd' columns) in the UCSC table, and to make use of the color information also the 'itemRgb' column. The item names may also be useful, and we can get those from the 'name' column. Below is how a call would look like: Broad1 <- UcscTrack(track='Broad ChromHMM', table="wgEncodeBroadHmmGm12878HMM", trackType="AnnotationTrack", genome='hg18', chromosome='chr18', name='12878', from=44675486, to=44679944, start="chromStart", end="chromEnd", feature="itemRgb", id="name", collapse=FALSE, stacking="dense") Note that I also turned off stacking for the track and collapsing, because we want to force all items to be on one line. Now we just need to tell the track how to color the items accordingly. That may look a bit exotic, in the ind it is rather simple: I define a bunch of display parameters with the same names as the features we downloaded from UCSC in the itemRgb column. The values of these parameters are the colors that have been stored as RGB values. feat <- unique(feature(Broad1)) featCol <- setNames(as.list(rgb(t(sapply(strsplit(feat, ","), as.numeric)), maxColorValue=255)), feat) displayPars(Broad1) <- featCol Now you would have to do the same for all your tables, so maybe sticking the whole thing into lapply will make sense: tracks <- lapply(c("wgEncodeBroadHmmGm12878HMM", "wgEncodeBroadHmmH1hescHMM", "wgEncodeBroadHmmK562HMM", "wgEncodeBroadHmmHepg2HMM", "wgEncodeBroadHmmHuvecHMM", "wgEncodeBroadHmmHmecHMM"), function(table){ track <- UcscTrack(track='Broad ChromHMM', table=table, trackType="AnnotationTrack", genome='hg18', chromosome='chr18', name=gsub("^wgEncodeBroadHmm|HMM$", "", table), from=44675486, to=44679944, start="chromStart", end="chromEnd", feature="itemRgb", id="name", collapse=FALSE, stacking="dense") feat <- unique(feature(track)) featCol <- setNames(as.list(rgb(t(sapply(strsplit(feat, ","), as.numeric)), maxColorValue=255)), feat) displayPars(track) <- featCol track }) plotTracks(tracks) Is that more or less what you were looking for? Florian PS: Please cc the bioconductor mailing list in order for this mail conversation to be searchable by others. -- From: "E.Tobi@lumc.nl" <e.tobi@lumc.nl> Date: Friday, January 11, 2013 3:03 PM To: NIBR <florian.hahne at="" novartis.com=""> Subject: question regarding gviz >Dear dr. Hahne, > >We are using your package Gviz more and more in our department. > >I am currently trying to use the ?Broad ChromHMM? track >(group=Regulation), which consists of 9 tables, in one panel using the >original colors of the items. >But I am having trouble recreating the following UCSC view: > > > > > > > > > > > > > >Somehow I am unable to 1. get it downloaded through the basic UcscTrack() >function (currently going via rtracklayer as a run around) 2. collapse >the different > tracks in one similarly styled track as above. > >Could you perhaps give me a pointer in the right direction to get this >interesting feature in my pictures? > >Broad1 <- UcscTrack(track='Broad ChromHMM',table = >"wgEncodeBroadHmmGm12878HMM", trackType="AnnotationTrack", genome='hg18', >chromosome='chr18', >name='12878', from=44675486, to=44679944) >Broad2 <- UcscTrack(track='Broad ChromHMM',table = >"wgEncodeBroadHmmH1hescHMM", trackType="AnnotationTrack", genome='hg18', >chromosome='chr18', >name='hESC', from=44675486, to=44679944) >Broad3 <- UcscTrack(track='Broad ChromHMM',table = >"wgEncodeBroadHmmK562HMM", trackType="AnnotationTrack", genome='hg18', >chromosome='chr18', >name='K562', from=44675486, to=44679944) >Broad4 <- UcscTrack(track='Broad ChromHMM',table = >"wgEncodeBroadHmmHepg2HMM", trackType="AnnotationTrack", genome='hg18', >chromosome='chr18', >name='Hepg2', from=44675486, to=44679944) >Broad5 <- UcscTrack(track='Broad ChromHMM',table = >"wgEncodeBroadHmmHuvecHMM", trackType="AnnotationTrack", genome='hg18', >chromosome='chr18', >name='Huvec', from=44675486, to=44679944) >Broad6 <- UcscTrack(track='Broad ChromHMM',table = >"wgEncodeBroadHmmHmecHMM", trackType="AnnotationTrack", genome='hg18', >chromosome='chr18', >name='Hmec', from=44675486, to=44679944) > > >Many thanks for any help or suggestion, > >Best wishes >Elmar Tobi > > > > > > >
rtracklayer Gviz rtracklayer Gviz • 1.3k views
ADD COMMENT

Login before adding your answer.

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