2007-09-07

The postscript problem in HW #1

The first part for reading in the dataset is fine, like this:

>library("arrayQuality")

>ArrayInfo <- read.marrayInfo("targetBeta7.txt")

>rawdata <- read.GenePix(target=ArrayInfo)
1) Loading the external package first
2) Read array layout into the customer variable "ArrayInfo"
3) Read in the raw data


then we can get MA plots as PNG or JPEG format,


>maQualityPlots(rawdata, dev="png")
or
>maQualityPlots(rawdata, dev="jpeg")

Either output as PNG or JPEG format

However, we can't get the output as postscript format expect some error messages,

> maQualityPlots(rawdata, dev="ps")
[1] "Format error, format will be set to PNG"
[1] TRUE
[1] TRUE
[1] TRUE
.
.
.

> maQualityPlots(rawdata, dev="postscript")
Error in frame() : figure margins too large

>postscript(
maQualityPlots(rawdata))


Basically, dev="ps" is not a right parameter in R 2.5.1 under win32. We checked the code for maQualityPlots(), and it actually recognizes "postscript".
If using dev="postscript", we got the error message.
But we did generate postscript ouptout by postscript(cmd), which can output the first plot from maQualityPlots() only (check the ps file here). (we didn't know why yet!)


We checked the manual for maQualityPlots (said nothing) and frame(), and found out frame() is an alias for plot.new(). Then we searched the R-help/discussion group, and it showed there are lots of such problems existed for plot.new() or frame() about "figure margins too large", and it said this problem came from the too small margins or too big/complicated figures, for example, too many points or lines.
People suggested to re-set the margins to resolve this problem. So first we check the margin set for postscript,

>ps.options()
.
$width
[1] 0
$height
[1] 0
.

>ps.options(width=1600, height=1200)
>ps.options()
.
$width
[1] 1600
$height
[1] 1200

.

it surprised us that both width and height are "ZERO".
So we tried to fix it by using ps.options(width=1600, height=1200), and the results look good.


However, after setting up the width and height, maQualityPlots still showed the error "Error in frame() : figure margins too large". Next we approached the issue by decreasing the margins.

>mai=c(0.2,0.2,0.2,0.2)
>mar=c(1,1,1,1)
>par()
.
.
$mai
[1] 0.612 0.492 0.492 0.252
$mar
[1] 5.1 4.1 4.1 2.1

.
.

>par(mai=c(0.2,0.2,0.2,0.2),mar=c(1,1,1,1))

After all, we still can't get the right results. It still showed "Error in frame() : figure margins too large"!

No comments: