Hi,
I try to create PNG images of a certain size where each pixel
intensity corresponds to exactly one probe signal in an Affymetrix
array. I try to use png() and image() with zero margins to do this.
Example:
z <- matrix(1:15, nrow=45, ncol=30)
png("large.png", height=nrow(z), width=ncol(z), bg="red")
par(mar=c(0,0,0,0))
image(z, col=gray.colors(16), axes=FALSE)
dev.off()
z <- matrix(1:15, nrow=5, ncol=3)
png("tiny.png", height=nrow(z), width=ncol(z), bg="red")
par(mar=c(0,0,0,0))
image(z, col=gray.colors(16), axes=FALSE)
dev.off()
The problem is that on WinXP the very bottom row and the very right
column of pixels in red. Trying on Linux, it is only the very right
column that is red. See attached images (you might have to zoom in to
see it). I try to do this in R v2.3.1. The same effect is seen if
the jpeg() device is used.
When rescaling, the same effect is seen (the red border effect is one
pixel wide), e.g.
z <- matrix(1:15, nrow=45, ncol=30)
png("large5.png", height=5*nrow(z), width=5*ncol(z),
bg="red")
par(mar=c(0,0,0,0))
image(z, col=gray.colors(16), axes=FALSE)
dev.off()
I might be asking for something that is not supported, but is there a
way around this? It is a problem, because I wish to tile the images
in an HTML page.
Thanks
Henrik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WinXP-large.png
Type: image/png
Size: 141 bytes
Desc: not available
Url :
https://stat.ethz.ch/pipermail/r-devel/attachments/20060720/ca12637e/attachment.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WinXP-tiny.png
Type: image/png
Size: 113 bytes
Desc: not available
Url :
https://stat.ethz.ch/pipermail/r-devel/attachments/20060720/ca12637e/attachment-0001.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Linux-large.png
Type: image/png
Size: 148 bytes
Desc: not available
Url :
https://stat.ethz.ch/pipermail/r-devel/attachments/20060720/ca12637e/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Linux-tiny.png
Type: image/png
Size: 118 bytes
Desc: not available
Url :
https://stat.ethz.ch/pipermail/r-devel/attachments/20060720/ca12637e/attachment-0003.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WinXP-large5.png
Type: image/png
Size: 317 bytes
Desc: not available
Url :
https://stat.ethz.ch/pipermail/r-devel/attachments/20060720/ca12637e/attachment-0004.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WinXP-tiny5.png
Type: image/png
Size: 173 bytes
Desc: not available
Url :
https://stat.ethz.ch/pipermail/r-devel/attachments/20060720/ca12637e/attachment-0005.png
Hi Henrik, this does not directly answer your question, but you might be able to use the function write.image in the package EBImage (Bioconductor) to write matrices into image files (e.g. PNG or JPEG), this might be more flexible and also faster than what you're trying to do. Best wishes Wolfgang ------------------------------------------------------------------ Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber Henrik Bengtsson wrote:> Hi, > > I try to create PNG images of a certain size where each pixel > intensity corresponds to exactly one probe signal in an Affymetrix > array. I try to use png() and image() with zero margins to do this. > Example: > > z <- matrix(1:15, nrow=45, ncol=30) > png("large.png", height=nrow(z), width=ncol(z), bg="red") > par(mar=c(0,0,0,0)) > image(z, col=gray.colors(16), axes=FALSE) > dev.off() > > z <- matrix(1:15, nrow=5, ncol=3) > png("tiny.png", height=nrow(z), width=ncol(z), bg="red") > par(mar=c(0,0,0,0)) > image(z, col=gray.colors(16), axes=FALSE) > dev.off() > > The problem is that on WinXP the very bottom row and the very right > column of pixels in red. Trying on Linux, it is only the very right > column that is red. See attached images (you might have to zoom in to > see it). I try to do this in R v2.3.1. The same effect is seen if > the jpeg() device is used. > > When rescaling, the same effect is seen (the red border effect is one > pixel wide), e.g. > > z <- matrix(1:15, nrow=45, ncol=30) > png("large5.png", height=5*nrow(z), width=5*ncol(z), bg="red") > par(mar=c(0,0,0,0)) > image(z, col=gray.colors(16), axes=FALSE) > dev.off() > > I might be asking for something that is not supported, but is there a > way around this? It is a problem, because I wish to tile the images > in an HTML page. > > Thanks > > Henrik >
By changing
png("large.png", height=nrow(z), width=ncol(z), bg="red")
to
png("large.png", height=nrow(z), width=ncol(z),
bg="blue")
I can get the right column (on linux) to change to blue.
So it seems to be an alignment off-by-one error with the background
colour showing through, so you might be able to work around it
by changing the alignment of the margins.
Incidentally I am working on the AffyMetrix 500k chip as well
(http://www.wtccc.org.uk/) but I have already written a non-R C/C++
tool to dump all the probe signal of a whole array as an image
(not intended for html, obviously, for 6.5 million probes); and
another one for drawing the schematics of the locations of
probes associated with a specific snp as a postscript vector diagram.
I will probably be working on combining the two - i.e. overlaying
an image with a vector diagram next week. (which means I hope to get
an image of intensities with some cicles on top, highlighting the
effect on the intensities to a specific snp due to blemishes).
Hin-Tak Leung
Henrik Bengtsson wrote:> Hi,
>
> I try to create PNG images of a certain size where each pixel
> intensity corresponds to exactly one probe signal in an Affymetrix
> array. I try to use png() and image() with zero margins to do this.
> Example:
>
> z <- matrix(1:15, nrow=45, ncol=30)
> png("large.png", height=nrow(z), width=ncol(z),
bg="red")
> par(mar=c(0,0,0,0))
> image(z, col=gray.colors(16), axes=FALSE)
> dev.off()
>
> z <- matrix(1:15, nrow=5, ncol=3)
> png("tiny.png", height=nrow(z), width=ncol(z),
bg="red")
> par(mar=c(0,0,0,0))
> image(z, col=gray.colors(16), axes=FALSE)
> dev.off()
>
> The problem is that on WinXP the very bottom row and the very right
> column of pixels in red. Trying on Linux, it is only the very right
> column that is red. See attached images (you might have to zoom in to
> see it). I try to do this in R v2.3.1. The same effect is seen if
> the jpeg() device is used.
>
> When rescaling, the same effect is seen (the red border effect is one
> pixel wide), e.g.
>
> z <- matrix(1:15, nrow=45, ncol=30)
> png("large5.png", height=5*nrow(z), width=5*ncol(z),
bg="red")
> par(mar=c(0,0,0,0))
> image(z, col=gray.colors(16), axes=FALSE)
> dev.off()
>
> I might be asking for something that is not supported, but is there a
> way around this? It is a problem, because I wish to tile the images
> in an HTML page.
>
> Thanks
>
> Henrik
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel