[BioC] Drawing multiple sequence logos with seqLogo?

Wolfgang Huber whuber at embl.de
Tue Sep 7 22:22:42 CEST 2010


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



More information about the Bioconductor mailing list