[BioC] Gviz pacakge

Hahne, Florian florian.hahne at novartis.com
Mon Feb 3 15:49:43 CET 2014


Hi Sten, there is. Just set the ylim parameter to c(-1,1), or whatever your artificial plotting values are. This forces the same y limits on all tracks and thus a common gradient.
Florian

From: Sten Ilmjärv <sten.ilmjarv at gmail.com<mailto:sten.ilmjarv at gmail.com>>
Date: Monday, February 3, 2014 3:46 PM
To: Florian Hahne <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>>
Cc: "bioconductor at r-project.org<mailto:bioconductor at r-project.org>" <bioconductor at r-project.org<mailto:bioconductor at r-project.org>>
Subject: Re: Gviz pacakge

Hei Florian,

I managed to plot the picture I wanted with your approach (last picture). There is one thing however. On the first plot below there were no values for UP so the gradient for TP90 became different to the TP0 and the colors on two track are therefore different. The only way I could solve the problem (last picture) was to create an artificial position to the left where the values are predetermined with the values for UP, DOWN and EQUAL. That help to create the correct gradient for each track. I don't know if there is a better solution for that problem but it worked for me.

[Inline image 2]

[Inline image 1]

Thanks again for your help.

All the best,
Sten


On Thu, Jan 30, 2014 at 4:07 PM, Hahne, Florian <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>> wrote:
Hi Sten,
with AnnotationTracks you do not have that kind of control. The vertical stacking is really just optimised to make best use of the available space. You could however use a DataTrack object to archive that kind of plot. The heat map plotting type is what you want to go for. The only slight issue with this approach is that you would need to somewhat shoehorn your data into the matrix structure of the track. Not sure about the exact structure of your data, but the most generic way to do this is to  have individual values for each genomic position. The following is a quick example of what I mean:
dat <- matrix(NA, ncol=100, nrow=3)
dat[1, c(2:4, 40:46, 60:70, 90:92)] <- rep(c(1,0,-1,-1), c(3, 7, 11, 3))
dat[2, c(4:12, 22:28, 80:87)] <- rep(c(1,1,0), c(9, 7, 8))
dat[3, c(33:50, 70:84)] <- rep(c(1,-1), c(18, 15))
rownames(dat) <- c("TP0", "TP90", "TP300")
dt <- DataTrack(start=1:100, width=0, data=dat, name="TP0", genome="hg19", chromosome=1, type="heatmap", gradient=c("red", "gray", "blue"), showSampleNames=TRUE, showColorBar=FALSE, col.axis="transparent", separator=3)
plotTracks(dt)
It should be quite straight forward to create this matrix from Ranges objects. And it doesn't really matter too much that your data are categorical, the heat map will map the numeric values into discrete colors.
Please also CC the Bioconductor mailing list for further questions in order for others to also benefit from this.
Florian

[cid:82C4F714-4461-4736-84E8-971A67C5A21B]



From: Sten Ilmjärv <sten.ilmjarv at gmail.com<mailto:sten.ilmjarv at gmail.com>>
Date: Thursday, January 30, 2014 2:05 PM

To: Florian Hahne <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>>
Subject: Re: Gviz pacakge

Hello Florian,

sorry for bothering you again but reading the vignette I wasn't didn't really find out if I could do the following thing:

[Inline image 1]

As you can see from the picture above I currently have three TP0 layers of AnnotationTrack. What I would like to do is name each of the layers TP0 and then subname them either up, down or equal. The thing is that I will have other layers like this called TP90 and TP300. The colors just mean if the sequence was up, down or not regulated. Can you give me any hints on how to do it properly. For right now I have just made a different AnnotationTrack for each group. Ideally I would like it to look something like the picture below where instead of the three TP0 values there will be up, down or equal and to the left of them there will be TP0, TP90 and TP300:

[Inline image 2]

I noticed that with DataTrack I could present each sample on a different horizontal line, however these values are not numerical but categorical ("up","down","equal").

All the best and thanks again,
sten

On Tue, Jan 28, 2014 at 3:41 PM, Sten Ilmjärv <sten.ilmjarv at gmail.com<mailto:sten.ilmjarv at gmail.com>> wrote:
Thank you Florian. I got it working again. You have been a very big help.

Cheers,
Sten


On Tue, Jan 28, 2014 at 2:48 PM, Hahne, Florian <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>> wrote:
Sure, you can handle this through the 'feature' column in the definition of the GeneRegionTrack. If you pass on additional display parameters with the same names as the values in this column those will be used as plotting colors. So for instance you could pass in "protein_coding"="red" to the GeneRegionTrack constructor. Again, this is described in much more detail in the vignette in the AnnotationTrack section.

From: Sten Ilmjärv <sten.ilmjarv at gmail.com<mailto:sten.ilmjarv at gmail.com>>
Date: Tuesday, January 28, 2014 12:49 PM

To: Florian Hahne <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>>
Subject: Re: Gviz pacakge

Hei Florian,

I got it working with the substitution of the columns. Can you also tell me if there is a possibility for example to colour transcripts based on their biotype? For example to colour "protein coding" transcripts one color and "Retained intron" transcripts with another color?

Best,
Sten


On Tue, Jan 28, 2014 at 1:04 PM, Hahne, Florian <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>> wrote:
Yes, or simply use transcript ids as gene identifiers. E.g.,:
ensemblData$gene <- ensemblData$transcript

This will only cause harm if you want to use the collapseTranscript option. If you decide to upgrade to the devel version please be aware that I am currently actively working on it. I don't expect too many changes to the API, but I may introduce bugs at this stage that need to be ironed out later once the code has stabilised.


From: Sten Ilmjärv <sten.ilmjarv at gmail.com<mailto:sten.ilmjarv at gmail.com>>
Date: Tuesday, January 28, 2014 11:46 AM

To: Florian Hahne <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>>
Subject: Re: Gviz pacakge

Thank you Florian, I guess I have to upgrade my R then to use 1.7.4 version.

Thanks again,
Sten


On Tue, Jan 28, 2014 at 12:37 PM, Hahne, Florian <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>> wrote:
Thanks :-)
For R-3.0.1 you will need Gviz 1.6.0. However this is still the production version, and the changes I mentioned before are only available for now in the development version 1.7.4. They will move to production with the next release, together with a whole bunch of additional fixes and new features. For 1.6.0 you may want to create your GeneRegionTrack like this:
grtrack <- GeneRegionTrack( ensemblData, chromosome = 12, name = "Transcripts", showId = TRUE, background.title = "#40464C", cex.group = 0.7, cex.title = 0.8, geneSymbols = FALSE, fill = "salmon")
the geneSymbols parameter switches between plotting of symbols and gene ids. Transcript IDs are not supported there yet,.
Florian

From: Sten Ilmjärv <sten.ilmjarv at gmail.com<mailto:sten.ilmjarv at gmail.com>>
Date: Tuesday, January 28, 2014 11:27 AM
To: Florian Hahne <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>>
Subject: Re: Gviz pacakge

Hei Florian, thank you for your quick reply.

It is a good hint about the sessionInfo() and just in case I will include it now.


> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Estonian_Estonia.1257  LC_CTYPE=Estonian_Estonia.1257    LC_MONETARY=Estonian_Estonia.1257
[4] LC_NUMERIC=C                      LC_TIME=Estonian_Estonia.1257

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

other attached packages:
[1] biomaRt_2.16.0       GenomicRanges_1.12.5 IRanges_1.18.4       BiocGenerics_0.6.0   Gviz_1.4.5

loaded via a namespace (and not attached):
 [1] AnnotationDbi_1.22.6   Biobase_2.20.1         Biostrings_2.28.0      biovizBase_1.8.1       bitops_1.0-6
 [6] BSgenome_1.28.0        cluster_1.14.4         colorspace_1.2-4       DBI_0.2-7              dichromat_2.0-0
[11] Formula_1.1-1          GenomicFeatures_1.12.4 Hmisc_3.13-0           labeling_0.2           lattice_0.20-24
[16] munsell_0.4.2          plyr_1.8               RColorBrewer_1.0-5     RCurl_1.95-4.1         Rsamtools_1.12.4
[21] RSQLite_0.11.4         rtracklayer_1.20.4     scales_0.2.3           splines_3.0.1          stats4_3.0.1
[26] stringr_0.6.2          survival_2.37-6        zlibbioc_1.6.0         tools_3.0.1            XML_3.98-1.1

It seems that I am indeed using an old version and upgrading to a new one might do the trick. I will try to get it work and thank you again for your very quick reply. I find that your package is actually really really nice.

All the best,
Sten


On Tue, Jan 28, 2014 at 12:20 PM, Hahne, Florian <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>> wrote:
Hi Sten,
I am assuming that you are using the latest development version of the package since you are already setting the transcriptAnnotation parameter (hint: always include the output of sessionInfo() when asking for help). With this I tried to simplify the setting of labels for GeneRegionTracks, and the idea is quite trivial:
rather than having to play with showId and geneSymbols, you can now set everything with just one parameter, transcriptAnnotation. It can take one of the values "symbol", "transcript" or "gene", and will use the respective annotation for the labels. If not set at all , or if set to "none", no labels are printed. You may wan to create your GeneRegionTrack like this:
grtrack <- GeneRegionTrack(ensemblData, chromosome=12, name="Transcripts", transcriptAnnotation="transcript", background.title="#40464C", cex.group=0.7, cex.title=0.8, fill="salmon")
plotTracks(grtrack)

Check out how setting the transcriptAnnotation parameter has an effect on your plot:
plotTracks(grtrack, transcriptAnnotation="symbol")
plotTracks(grtrack, transcriptAnnotation="gene")

I will try to make this a bit clearer in the vignette. Btw, there are several other ways to create a GeneRegionTrack, also from Ensembl data. You may want to consult the vignette. Most of those assume that you want to fetch data for a particular genomic region, so I am not sure whether those make sense in your case.
Florian

From: Sten Ilmjärv <sten.ilmjarv at gmail.com<mailto:sten.ilmjarv at gmail.com>>
Date: Tuesday, January 28, 2014 11:00 AM
To: Florian Hahne <florian.hahne at novartis.com<mailto:florian.hahne at novartis.com>>
Subject: Gviz pacakge

plotTracks(list(itrack,gtrack,grtrack), from = min(ensemblData$start) - 20000, to = max(ensemblData$end) + 20000)






-------------- next part --------------
A non-text attachment was scrubbed...
Name: 82C4F714-4461-4736-84E8-971A67C5A21B.png
Type: image/png
Size: 30066 bytes
Desc: 82C4F714-4461-4736-84E8-971A67C5A21B.png
URL: <https://stat.ethz.ch/pipermail/bioconductor/attachments/20140203/8c37b96c/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 4768 bytes
Desc: image.png
URL: <https://stat.ethz.ch/pipermail/bioconductor/attachments/20140203/8c37b96c/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 7846 bytes
Desc: image.png
URL: <https://stat.ethz.ch/pipermail/bioconductor/attachments/20140203/8c37b96c/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 4825 bytes
Desc: image.png
URL: <https://stat.ethz.ch/pipermail/bioconductor/attachments/20140203/8c37b96c/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 7919 bytes
Desc: image.png
URL: <https://stat.ethz.ch/pipermail/bioconductor/attachments/20140203/8c37b96c/attachment-0004.png>


More information about the Bioconductor mailing list