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]]