Drawing multiple sequence logos with seqLogo?
2
1
Entering edit mode
@nenad-bartonicek-3293
Last seen 10.3 years ago
Hello, The seqLogo function is fast and useful, but has limited graphical options. For example, it is impossible to add a title to a graph. Furthermore, since it is uses "grid", it is also impossible to use par() if one wants to put multiple logos together. Does anyone have an idea what would be the fastest way to combine multiple logos into one pdf, without reediting the function itself? I would like to avoid usage of Imagemagick if possible... Thanks a bunch for any advice, Nenad Nenad Bartonicek PhD student, Enright group European Bioinformatics Institute Hinxton Cambridge CB10 1SD United Kingdom tel: +44-755-435-9057 [[alternative HTML version deleted]]
graph seqLogo graph seqLogo • 2.8k views
ADD COMMENT
1
Entering edit mode
@nenad-bartonicek-3293
Last seen 10.3 years ago
Hi Wolfgang, Thank you for the solutions! After my post I've gone through the grid vignettes and modified the function in a same manner, but with less elegant coding. Though it is trivial, I've added the modification for the defined dimensions of the tabular logo presentation... hopefully of use to someone in a rush. Cheers, Nenad library("seqLogo") #modify the seqLogo function mySeqLogo = seqLogo::seqLogo bad = (sapply( body(mySeqLogo), "==", "grid.newpage()") | sapply( body(mySeqLogo), "==", "par(ask = FALSE)")) body(mySeqLogo)[bad] = NULL #function for generation of pwms norm = function(x) scale(x, center=FALSE, scale=colSums(x)) #define dimensions ncol <- 2 nrow <- 3 #create plot grid.newpage() for(row in 1:nrow){ for(col in 1:ncol){ vp <- viewport(x = (col-1)/ncol, y = 1-(row-1)/nrow, w = 1/ncol, h = 1/nrow, just = c("left", "top")) pushViewport(vp) pwm = norm(matrix(runif(32), nrow=4)) mySeqLogo(pwm) grid.text(sprintf("Row %d, Column %d", row, col), x=0.5, y=0.9, just="top") upViewport() } } > sessionInfo() R version 2.11.1 (2010-05-31) i386-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] grid stats graphics grDevices datasets utils methods [8] base other attached packages: [1] seqLogo_1.14.0 Biobase_2.8.0 loaded via a namespace (and not attached): [1] tools_2.11.1 On 8 Sep 2010, at 11:00, bioconductor-request@stat.math.ethz.ch wrote: > Dear Nenad > > I need to correct my previous post: the function does in fact do a > number of odd things (such as calling 'grid.newpage()' and > 'par(ask=FALSE)') which prevent it from being used in combination with > other graphics elements. So you will need to edit the function for > your > use (and maybe the package maintainer can be enticed to bring some > changes back into a released version). Here is a code example that > produces multiple logos on one page, and titles: > > > library("seqLogo") > > mySeqLogo = seqLogo::seqLogo > > bad = (sapply( body(mySeqLogo), "==", "grid.newpage()") | > sapply( body(mySeqLogo), "==", "par(ask = FALSE)")) > body(mySeqLogo)[bad] = NULL > > > > norm = function(x) scale(x, center=FALSE, scale=colSums(x)) > > grid.newpage() > for(i in 0:3){ > > pwm = norm(matrix(runif(32), nrow=4)) > > pushViewport(viewport(x=0.2+0.55*(i%%2), > y=0.2+0.55*(i%/%2), > width=0.4, height=0.4, > angle=runif(1, min=-20, max=20))) > mySeqLogo(pwm) > grid.text(sprintf("Hi there %d", i), x=0.5, y=1, > hjust=0.5, vjust=1) > popViewport() > > } > > > >> sessionInfo() > R version 2.12.0 Under development (unstable) (2010-09-07 r52876) > Platform: x86_64-unknown-linux-gnu (64-bit) > > locale: > [1] C > > attached base packages: > [1] grid stats graphics grDevices utils datasets > methods > [8] base > > other attached packages: > [1] seqLogo_1.15.0 fortunes_1.3-7 > > loaded via a namespace (and not attached): > [1] tools_2.12.0 > > > > Enjoy, > Wolfgang Nenad Bartonicek PhD student, Enright group European Bioinformatics Institute Hinxton Cambridge CB10 1SD United Kingdom tel: +44-755-435-9057 [[alternative HTML version deleted]]
ADD COMMENT
0
Entering edit mode
@wolfgang-huber-3550
Last seen 4 months ago
EMBL European Molecular Biology Laborat…
Hi Nenad grid graphics, and in particular the "seqLogo" function, are in fact a lot more powerful for combining with other graphics elements (including a title, or multiple logos in one plot) than R's default graphics, "par", etc. The only possible drawback is that one needs to read the "grid" documentation to understand its viewport concept. Try: browseVignettes() and search for "Introduction to grid" and perhaps "Working with viewports". Best wishes Wolfgang PS: always remember to be specific about the name of the package (and version) that you refer to. PPS: nothing is impossible with R. Nenad Bartonicek scripsit 06/09/10 19:24: > Hello, > > The seqLogo function is fast and useful, but has limited graphical > options. For example, it is impossible to add a title to a graph. > Furthermore, since it is uses "grid", it is also impossible to use > par() if one wants to put multiple logos together. > Does anyone have an idea what would be the fastest way to combine > multiple logos into one pdf, without reediting the function itself? I > would like to avoid usage of Imagemagick if possible... > > Thanks a bunch for any advice, > > Nenad > > Nenad Bartonicek > PhD student, Enright group > European Bioinformatics Institute > Hinxton > Cambridge > CB10 1SD > United Kingdom > tel: +44-755-435-9057 > > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor -- Wolfgang Huber EMBL http://www.embl.de/research/units/genome_biology/huber
ADD COMMENT
1
Entering edit mode
Dear Nenad I need to correct my previous post: the function does in fact do a number of odd things (such as calling 'grid.newpage()' and 'par(ask=FALSE)') which prevent it from being used in combination with other graphics elements. So you will need to edit the function for your use (and maybe the package maintainer can be enticed to bring some changes back into a released version). Here is a code example that produces multiple logos on one page, and titles: library("seqLogo") mySeqLogo = seqLogo::seqLogo bad = (sapply( body(mySeqLogo), "==", "grid.newpage()") | sapply( body(mySeqLogo), "==", "par(ask = FALSE)")) body(mySeqLogo)[bad] = NULL norm = function(x) scale(x, center=FALSE, scale=colSums(x)) grid.newpage() for(i in 0:3){ pwm = norm(matrix(runif(32), nrow=4)) pushViewport(viewport(x=0.2+0.55*(i%%2), y=0.2+0.55*(i%/%2), width=0.4, height=0.4, angle=runif(1, min=-20, max=20))) mySeqLogo(pwm) grid.text(sprintf("Hi there %d", i), x=0.5, y=1, hjust=0.5, vjust=1) popViewport() } > sessionInfo() R version 2.12.0 Under development (unstable) (2010-09-07 r52876) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] C attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] seqLogo_1.15.0 fortunes_1.3-7 loaded via a namespace (and not attached): [1] tools_2.12.0 Enjoy, Wolfgang On 07/09/10 18:12, Wolfgang Huber wrote: > Hi Nenad > > grid graphics, and in particular the "seqLogo" function, are in fact a > lot more powerful for combining with other graphics elements (including > a title, or multiple logos in one plot) than R's default graphics, > "par", etc. The only possible drawback is that one needs to read the > "grid" documentation to understand its viewport concept. > > Try: > browseVignettes() > > and search for "Introduction to grid" and perhaps "Working with viewports". > > Best wishes > Wolfgang > > PS: always remember to be specific about the name of the package (and > version) that you refer to. > > PPS: nothing is impossible with R. > > > Nenad Bartonicek scripsit 06/09/10 19:24: >> Hello, >> >> The seqLogo function is fast and useful, but has limited graphical >> options. For example, it is impossible to add a title to a graph. >> Furthermore, since it is uses "grid", it is also impossible to use >> par() if one wants to put multiple logos together. >> Does anyone have an idea what would be the fastest way to combine >> multiple logos into one pdf, without reediting the function itself? I >> would like to avoid usage of Imagemagick if possible... >> >> Thanks a bunch for any advice, >> >> Nenad >> >> Nenad Bartonicek >> PhD student, Enright group >> European Bioinformatics Institute >> Hinxton >> Cambridge >> CB10 1SD >> United Kingdom >> tel: +44-755-435-9057 >> >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor at stat.math.ethz.ch >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: >> http://news.gmane.org/gmane.science.biology.informatics.conductor > > -- Wolfgang Huber EMBL http://www.embl.de/research/units/genome_biology/huber
ADD REPLY

Login before adding your answer.

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