2
% NOTE -- ONLY EDIT THE .Rnw FILE!!! The .tex file is
3
% likely to be overwritten.
5
% \VignetteIndexEntry{esApply Introduction}
6
%\VignetteDepends{Biobase}
7
%\VignetteKeywords{Expression Analysis}
8
%\VignettePackage{Biobase}
9
\documentclass[12pt]{article}
11
\usepackage{amsmath,pstricks}
12
\usepackage[authoryear,round]{natbib}
23
\newcommand{\scscst}{\scriptscriptstyle}
24
\newcommand{\scst}{\scriptstyle}
26
\newcommand{\Rfunction}[1]{{\texttt{#1}}}
27
\newcommand{\Robject}[1]{{\texttt{#1}}}
28
\newcommand{\Rpackage}[1]{{\textit{#1}}}
29
\newcommand{\Rmethod}[1]{{\texttt{#1}}}
30
\newcommand{\Rfunarg}[1]{{\texttt{#1}}}
31
\newcommand{\Rclass}[1]{{\textit{#1}}}
35
\bibliographystyle{plainnat}
39
\section*{A note on {\tt esApply}}
41
{\tt exprSet}s are complex objects. We will think
42
of them as linked arrays: the \Robject{exprs} element
43
of an \Rclass{exprSet} is $G \times N$, where $G$ is
44
the number of genes on a chip and $N$ is the number
45
of tissues analyzed, and the \Robject{pData} element
46
of the associated \Robject{phenoData} element is $N \times p$,
47
where $p$ is the number of phenotypic or demographic, etc.,
50
Abstractly, we are often interested in evaluating
51
functions $f(y;x)$ where $y$ is an $N$-vector of
52
expression results for a specific gene and $x$ is
53
an $N$-dimensional structure, coordinated with $y$, that
54
distinguishes elements of $y$ for processing in the function $f$.
55
A basic problem is to guarantee that the $j$th element
56
of $y$ is correctly associated with the $j$th component of $x$.
58
<<R.hide, results=hide, echo=FALSE>>=
62
As an example, let's consider \Robject{eset} which is an %'
63
\Rclass{exprSet} supplied with Biobase. We will print
65
the first $N$-vector of gene expressions and
69
print(exprs(eset)[1,])
70
print(pData(eset)[1:2,1:3])
74
Now let's see how expressions %'
75
and a covariate are related:
78
print( rbind(exprs(eset[1,]),
79
cov1=t(pData(eset))[1,]))
81
A function that evaluates the difference in median expression across
82
strata defined using an abstract covariate \Robject{x} is
84
medContr <- function( y, x ) {
86
median(ys[[1]]) - median(ys[[2]])
89
We can apply this to a small
90
\Rclass{exprSet} that gives back the data listed above:
92
print(apply(exprs(eset[1,,drop=F]),1,
93
medContr, pData(eset)[["cov1"]]))
95
That's a bit clumsy. This is where %'
96
\Rfunction{esApply} comes in. We pay for some
97
simplicity by following a strict protocol
98
for the definition of the statistical
99
function to be applied.
101
medContr1 <- function(y) {
103
median(ys[[1]]) - median(ys[[2]])
106
print(esApply( eset, 1, medContr1 )[1])
108
The manual page on \Rfunction{esApply} has a number of
109
additional examples that show how applicable functions
110
can be constructed and used. The important thing to
111
note is that the applicable functions {\em know} the names of
112
the covariates in the \Robject{pData} dataframe.
114
This is achieved by having an environment populated with all the
115
variables in the \Robject{phenoData} component of the \Rclass{exprSet} put
116
in as the environment of the function that will be applied. If that
117
function already has an environment we retain that but in the second
118
position. Thus, there is some potential for variable shadowing.