\HeaderA{readCelRectangle}{Reads a spatial subset of probe-level data from Affymetrix CEL files}{readCelRectangle}
\keyword{file}{readCelRectangle}
\keyword{IO}{readCelRectangle}
\begin{Description}\relax
Reads a spatial subset of probe-level data from Affymetrix CEL files.
\end{Description}
\begin{Usage}
\begin{verbatim}readCelRectangle(filename, xrange=c(0, Inf), yrange=c(0, Inf), ..., asMatrix=TRUE)\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{filename}] The pathname of the CEL file.
\item[\code{xrange}] A \code{\LinkA{numeric}{numeric}} \code{\LinkA{vector}{vector}} of length two giving the left
and right coordinates of the cells to be returned.
\item[\code{yrange}] A \code{\LinkA{numeric}{numeric}} \code{\LinkA{vector}{vector}} of length two giving the top
and bottom coordinates of the cells to be returned.
\item[\code{...}] Additional arguments passed to \code{\LinkA{readCel}{readCel}}().
\item[\code{asMatrix}] If \code{\LinkA{TRUE}{TRUE}}, the CEL data fields are returned as
matrices with element (1,1) corresponding to cell
(xrange[1],yrange[1]).
\end{ldescription}
\end{Arguments}
\begin{Value}
A named \code{\LinkA{list}{list}} CEL structure similar to what \code{\LinkA{readCel}{readCel}}().
In addition, if \code{asMatrix} is \code{\LinkA{TRUE}{TRUE}}, the CEL data fields
are returned as matrices, otherwise not.
\end{Value}
\begin{Author}\relax
Henrik Bengtsson (\url{http://www.braju.com/R/})
\end{Author}
\begin{SeeAlso}\relax
The \code{\LinkA{readCel}{readCel}}() method is used internally.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

for (zzz in 0) {

rotate270 <- function(x, ...) {
  x <- t(x)
  nc <- ncol(x)
  if (nc < 2) return(x)
  x[,nc:1,drop=FALSE]
}

# Scan current directory for CEL files
files <- list.files(pattern="[.](c|C)(e|E)(l|L)$")
files <- files[!file.info(files)$isdir]
if (length(files) == 0)
  break

celFile <- files[1];

# Read CEL intensities in the upper left corner
cel <- readCelRectangle(celFile, xrange=c(0,250), yrange=c(0,250))
z <- rotate270(cel$intensities)
sub <- paste("Chip type:", cel$header$chiptype)
image(z, col=gray.colors(256), axes=FALSE, main=celFile, sub=sub)
text(x=0, y=1, labels="(0,0)", adj=c(0,-0.7), cex=0.8, xpd=TRUE)
text(x=1, y=0, labels="(250,250)", adj=c(1,1.2), cex=0.8, xpd=TRUE)

# Clean up
rm(rotate270, files, celFile, cel, z, sub)

} # for (zzz in 0)
\end{ExampleCode}
\end{Examples}

