├── demo
├── 00Index
└── affy.tour.R
├── TITLE
├── cleanup
├── .Rbuildignore
├── data
├── SpikeIn.rda
├── mapCdfName.rda
└── cdfenv.example.rda
├── src
├── Makevars.in
├── rma_common.h
├── Makevars.win
├── getall_locations.c
└── rma_common.c
├── vignettes
├── image.png
├── EWSnap.png
├── widgetfilechooser.png
└── vim.Rnw
├── R
├── generateExprVal.method.medianpolish.R
├── ppset.ttest.R
├── generateExprVal.method.avgdiff.R
├── generateExprVal.method.liwong.R
├── plot.ProbeSet.R
├── hlog.R
├── tukey.biweight.R
├── avdiff.R
├── plotLocation.R
├── generateExprVal.method.mas.R
├── normalize.constant.R
├── ppsetApply.R
├── barplot.ProbeSet.R
├── pmcorrect.mas.R
├── normalize.contrasts.R
├── generateExprVal.method.playerout.R
├── pairs.AffyBatch.R
├── whatcdf.R
├── merge.AffyBatch.R
├── bg.Affy.chipwide.R
├── plot.density.R
├── loess.normalize.R
├── summary.R
├── bg.R
├── xy2indices.R
├── rma.R
├── normalize.loess.R
├── ProgressBarText.R
├── AffyRNAdeg.R
├── zzz.R
├── normalize.quantiles.R
├── expresso.R
├── expressoWidget.R
├── normalize.qspline.R
├── ProbeSet.R
├── justrma.R
└── normalize.invariantset.R
├── man
├── debug.affy123.Rd
├── cdfenv.example.Rd
├── summary.Rd
├── list.celfiles.Rd
├── probeNames-methods.Rd
├── probeMatch-methods.Rd
├── affy-deprecated.Rd
├── whatcdf.Rd
├── setAffyOptions.Rd
├── tukey.biweight.Rd
├── plot.ProbeSet.Rd
├── hlog.Rd
├── merge.AffyBatch.Rd
├── bg.adjust.Rd
├── maffy.subset.Rd
├── cdfFromBioC.Rd
├── barplot.ProbeSet.Rd
├── affy.scalevalue.exprSet.Rd
├── normalize.constant.Rd
├── normalize.contrast.Rd
├── mva.pairs.Rd
├── plotLocation.Rd
├── generateExprVal.method.playerout.Rd
├── cleancdfname.Rd
├── pmcorrect.Rd
├── SpikeIn.Rd
├── ppsetApply.Rd
├── generateExprVal-methods.Rd
├── normalize.quantiles.Rd
├── affy-options.Rd
├── read.probematrix.Rd
├── pairs.AffyBatch.Rd
├── mas5.Rd
├── ProbeSet-class.Rd
├── MAplot.Rd
├── plot.density.Rd
├── generateExprVal.method.avgdiff.Rd
├── normalize.loess.Rd
├── AffyRNAdeg.Rd
├── expressoWidget.Rd
├── bgc.Rd
├── generateExprSet-methods.Rd
├── normalize.invariantset.Rd
├── ProgressBarText-class.Rd
├── normalize.quantiles.robust.Rd
├── normalize-methods.Rd
├── rma.Rd
├── expresso.Rd
├── normalize.qspline.Rd
├── xy2indices.Rd
├── fit.li.wong.Rd
├── read.affybatch.Rd
└── justrma.Rd
├── .gitignore
├── inst
├── tests
│ ├── bg.correct.R
│ ├── normalize.methods.R
│ ├── expression.values.R
│ └── affybatch.R
└── CITATION
├── README.md
├── configure.in
├── aclocal.m4
├── changelog
├── DESCRIPTION
├── NAMESPACE
└── NEWS
/demo/00Index:
--------------------------------------------------------------------------------
1 | affy.tour A tour of the affy package
2 |
--------------------------------------------------------------------------------
/TITLE:
--------------------------------------------------------------------------------
1 | affy Methods for Affymetrix Oligonucleotide Arrays
2 |
--------------------------------------------------------------------------------
/cleanup:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 |
3 | rm -f config.* src/Makevars
4 |
--------------------------------------------------------------------------------
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | debian
2 | ^.*\.Rproj$
3 | ^\.Rproj\.user$
4 | ^doc$
5 | ^Meta$
6 |
--------------------------------------------------------------------------------
/data/SpikeIn.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bioconductor/affy/devel/data/SpikeIn.rda
--------------------------------------------------------------------------------
/data/mapCdfName.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bioconductor/affy/devel/data/mapCdfName.rda
--------------------------------------------------------------------------------
/src/Makevars.in:
--------------------------------------------------------------------------------
1 | PKG_CFLAGS = @CFLAGS@
2 | PKG_LIBS = @LIBS@
3 | PKG_CPPFLAGS = @DEFS@
4 |
--------------------------------------------------------------------------------
/vignettes/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bioconductor/affy/devel/vignettes/image.png
--------------------------------------------------------------------------------
/vignettes/EWSnap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bioconductor/affy/devel/vignettes/EWSnap.png
--------------------------------------------------------------------------------
/data/cdfenv.example.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bioconductor/affy/devel/data/cdfenv.example.rda
--------------------------------------------------------------------------------
/vignettes/widgetfilechooser.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bioconductor/affy/devel/vignettes/widgetfilechooser.png
--------------------------------------------------------------------------------
/R/generateExprVal.method.medianpolish.R:
--------------------------------------------------------------------------------
1 | generateExprVal.method.medianpolish <- function(probes, ...)
2 | medianpolish(probes, ...)
3 |
4 |
--------------------------------------------------------------------------------
/man/debug.affy123.Rd:
--------------------------------------------------------------------------------
1 | \name{debug.affy123}
2 | \docType{methods}
3 | \alias{debug.affy123}
4 | \title{Debugging Flag}
5 | \description{
6 | For developmental use only
7 | }
8 | \keyword{methods}
9 |
--------------------------------------------------------------------------------
/src/rma_common.h:
--------------------------------------------------------------------------------
1 | #ifndef RMA_COMMON
2 | #define RMA_COMMON 1
3 |
4 | int sort_double(const double *a1,const double *a2);
5 | double median(double *x, int length);
6 | double median_nocopy(double *x, int length);
7 |
8 |
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.cache
2 | *.log
3 | ..Rcheck/
4 | .DS_Store
5 | .RData
6 | .Rhistory
7 | .Rproj.user
8 | .Ruserdata
9 | /Meta/
10 | /doc/
11 | affy.Rproj
12 | config.status
13 | src/*.dll
14 | src/*.o
15 | src/*.so
16 | src/Makevars*
17 | src/symbols.rds
18 |
--------------------------------------------------------------------------------
/inst/tests/bg.correct.R:
--------------------------------------------------------------------------------
1 | library(affy)
2 | library(affydata)
3 |
4 | data(Dilution)
5 |
6 | meth <- bgcorrect.methods()
7 |
8 | cat("background correction:\n")
9 |
10 | for (m in meth) {
11 | cat(m,"...")
12 | abatch.bgc <- bg.correct(Dilution, method=m)
13 | cat("done.\n")
14 | }
15 |
--------------------------------------------------------------------------------
/R/ppset.ttest.R:
--------------------------------------------------------------------------------
1 | ppset.ttest <- function(ppset, covariate, pmcorrect.fun = pmcorrect.pmonly, ...) {
2 | probes <- do.call(pmcorrect.fun, list(ppset))
3 | my.ttest <- function(x) {
4 | y <- split(x, get(covariate))
5 | t.test(y[[1]], y[[2]])$p.value
6 | }
7 | r <- apply(probes, 1, my.ttest)
8 | return(r)
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/src/Makevars.win:
--------------------------------------------------------------------------------
1 | PKG_CPPFLAGS += -DHAVE_ZLIB
2 | ZLIB_CFLAGS+=$(shell echo 'zlibbioc::pkgconfig("PKG_CFLAGS")'|\
3 | "${R_HOME}/bin/R" --vanilla --slave)
4 | PKG_LIBS+=$(shell echo 'zlibbioc::pkgconfig("PKG_LIBS_shared")' |\
5 | "${R_HOME}/bin/R" --vanilla --slave)
6 | %.o: %.c
7 | $(CC) $(ZLIB_CFLAGS) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
8 |
--------------------------------------------------------------------------------
/R/generateExprVal.method.avgdiff.R:
--------------------------------------------------------------------------------
1 | ## Currently, the input is a 2 matrices a pm and a mm
2 |
3 | ##avdiff is more like median than mean, it would be nice to actually have
4 | ##avfif
5 | ##added typical se of the mean as returned se
6 | generateExprVal.method.avgdiff <- function(probes, ...) {
7 | list(exprs=apply(probes, 2, median),se.exprs=apply(probes,2,sd)/sqrt(nrow(probes)))
8 | }
9 |
--------------------------------------------------------------------------------
/man/cdfenv.example.Rd:
--------------------------------------------------------------------------------
1 | \name{cdfenv.example}
2 | \alias{cdfenv.example}
3 | \title{Example cdfenv}
4 | \description{
5 | Example cdfenv (environment containing the probe locations).
6 | }
7 | \usage{data(cdfenv.example)}
8 | \format{ An
9 | \code{\link{environment}} \code{cdfenv.example} containing the probe
10 | locations}
11 | \source{Affymetrix CDF file for the array Hu6800}
12 | \keyword{datasets}
13 |
--------------------------------------------------------------------------------
/R/generateExprVal.method.liwong.R:
--------------------------------------------------------------------------------
1 | generateExprVal.method.liwong <- function(probes, ...) {
2 | probes <- t(probes)
3 | if (ncol(probes) == 1) {
4 | warning("method liwong unsuitable when only one probe pair")
5 | list(exprs=as.vector(probes),se.exprs=rep(NA,length(probes)))
6 | }
7 | else {
8 | tmp <- fit.li.wong(probes, ...)
9 | list(exprs=tmp$theta,se.exprs=tmp$sigma.theta)
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/inst/tests/normalize.methods.R:
--------------------------------------------------------------------------------
1 | ## routine tests for the normalization methods
2 | library(affy)
3 | library(affydata)
4 |
5 | data(Dilution)
6 |
7 | n.meth <- normalize.methods(Dilution)
8 |
9 | ## remove qspline
10 | ##n.meth <- n.meth[ ! (n.meth %in% c("qspline"))]
11 |
12 | for (m in n.meth) {
13 | cat("-->method=", m, "...")
14 | Dilution.n <- normalize(Dilution, method=m)
15 | cat("done.\n")
16 | }
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [
](https://bioconductor.org/)
2 |
3 | **affy** is an R/Bioconductor package conaining methods for Affymetrix oligonucleotide arrays.
4 |
5 | See https://bioconductor.org/packages/affy for more information including how to install the release version of the package (please refrain from installing directly from GitHub).
6 |
--------------------------------------------------------------------------------
/man/summary.Rd:
--------------------------------------------------------------------------------
1 | \name{summary}
2 | \alias{summary}
3 | \alias{medianpolish}
4 | \alias{tukeybiweight}
5 | \alias{avdiff}
6 | \title{Probe Set Summarizing Functions}
7 | \description{
8 | These were used with the function \code{express}, which is no longer part
9 | of the package. Some are still used by the generateExprVal functions, but
10 | you should avoid using them directly.
11 | }
12 | \seealso{\code{\link[affy]{expresso}}}
13 | \keyword{manip}
14 |
--------------------------------------------------------------------------------
/R/plot.ProbeSet.R:
--------------------------------------------------------------------------------
1 | plot.ProbeSet <- function(x, which=c("pm", "mm"), xlab="probes", type="l", ylim=NULL, ...) {
2 |
3 | which <- match.arg(which)
4 | if (which == "pm")
5 | f <- getMethod("pm", "ProbeSet")
6 | else
7 | f <- getMethod("mm", "ProbeSet")
8 |
9 | if (is.null(ylim))
10 | ylim = range(c(f(x)), na.rm=TRUE)
11 |
12 | if (is.na(xlab))
13 | xlab="probes"
14 |
15 | matplot(f(x), xlab=xlab, type=type, ylim=ylim, ...)
16 | }
17 |
--------------------------------------------------------------------------------
/R/hlog.R:
--------------------------------------------------------------------------------
1 |
2 | hlog <- function(x,constant=1){ #constant is where the change occurs
3 | if(constant<=0){
4 | warning("constant less than or equal to 0. Returning log(x)\n")
5 | return(log(x))
6 | }
7 | else{
8 | if(constant==Inf)
9 | return(x)
10 | else{
11 | aux <- (abs(x)=constant)*(sign(x)*(constant*log(abs(x/constant))+constant))
13 | aux[x==0] <- 0
14 | return(aux)
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/R/tukey.biweight.R:
--------------------------------------------------------------------------------
1 | tukey.biweight <- function(x, c=5, epsilon=0.0001)
2 | {
3 | m <- median(x)
4 | s <- median(abs(x - m))
5 | u <- (x - m) / (c * s + epsilon)
6 | w <- rep(0, length(x))
7 | i <- abs(u) <= 1
8 | w[i] <- ((1 - u^2)^2)[i]
9 | t.bi <- sum(w * x) / sum(w)
10 | return(t.bi)
11 | }
12 |
13 | tukeybiweight <- function(x, c=5, epsilon=0.0001)
14 | list(exprs=apply(x,2,tukey.biweight,c=c,epsilon=epsilon),se.exprs=rep(NA,ncol(x)))
15 |
16 |
17 |
--------------------------------------------------------------------------------
/R/avdiff.R:
--------------------------------------------------------------------------------
1 | avdiff <- function(x,verbose=FALSE){
2 | if(missing(x)) stop("Argument x missing, with no default\n")
3 | cat("Computing average difference for",dim(x$pm)[2],"columns")
4 | avdiff <- apply(x$pm-x$mm,2,function(y){
5 | cat(".")
6 | tapply(y,x$name,function(z){
7 | o <- order(z)
8 | zz <- z[-c(o[1],o[length(z)])] #take out biggest and smallest
9 | mean(z[abs(z-mean(zz))<3*sd(zz)])
10 | })
11 | })
12 | colnames(avdiff) <- x$chip.names
13 | return(avdiff)
14 | }
15 |
--------------------------------------------------------------------------------
/man/list.celfiles.Rd:
--------------------------------------------------------------------------------
1 | \name{list.celfiles}
2 | \alias{list.celfiles}
3 | \title{List the Cel Files in a Directory/Folder}
4 | \description{
5 | This function produces a vector containing the names of files in the
6 | named directory/folder ending in .cel or .CEL.
7 | }
8 | \usage{
9 | list.celfiles(...)
10 | }
11 | \arguments{
12 | \item{\dots}{arguments to pass along to
13 | \code{\link[base]{list.files}}}
14 | }
15 | \value{
16 | A character vector of file names.
17 | }
18 | \seealso{list.files}
19 | \examples{
20 | list.celfiles()
21 | }
22 | \keyword{character}
23 |
--------------------------------------------------------------------------------
/man/probeNames-methods.Rd:
--------------------------------------------------------------------------------
1 | \name{probeNames-methods}
2 | \docType{methods}
3 | \title{Methods for accessing the Probe Names}
4 | \alias{probeNames-methods}
5 | \alias{probeNames}
6 | \alias{probeNames<-}
7 | %\alias{probeName}
8 | %\alias{probeName<-}
9 | \description{Methods for accessing Probe Names}
10 | \section{Methods}{\describe{
11 | \item{object = Cdf}{an accessor function for the \code{name} slot.}
12 | \item{object = probeNames}{returns the probe names associated with the
13 | rownames of the intensity matrices one gets with the \code{pm} and
14 | \code{mm} methods.}
15 | }}
16 | \keyword{methods}
17 |
--------------------------------------------------------------------------------
/man/probeMatch-methods.Rd:
--------------------------------------------------------------------------------
1 | \name{probeMatch-methods}
2 | \docType{methods}
3 | \title{Methods for accessing perfect matches and mismatches}
4 | \alias{probeMatch-methods}
5 | \alias{probeMatch}
6 | \alias{pm}
7 | \alias{pm<-}
8 | \alias{mm}
9 | \alias{mm<-}
10 | \description{Methods for perfect matches and mismatches probes}
11 | \section{Methods}{\describe{
12 | \item{object = AffyBatch}{All the \emph{perfect match} (pm) or
13 | \emph{mismatch} (mm) probes on the arrays the object represents
14 | are returned.}
15 | \item{object = ProbeSet}{The \code{pm} or \code{mm} of the object
16 | are returned.}
17 | }
18 | }
19 | \keyword{methods}
20 |
--------------------------------------------------------------------------------
/R/plotLocation.R:
--------------------------------------------------------------------------------
1 | plotLocation <- function(x, col="green", pch=22, ...) {
2 | if (is.list(x)) {
3 | x <- cbind(unlist(lapply(x, function(x) x[,1])),
4 | unlist(lapply(x, function(x) x[,2])))
5 | }
6 | ## need to use nrow - x[,2] for correct y position.
7 | ## use image width to get nrow, which isn't ideal
8 | ## but follows assumption for this function that an
9 | ## image already exists
10 | nrow <- ceiling(par("usr")[4])
11 | if(nrow == 1) stop(paste("\nYou must first generate an image of an array",
12 | "for this function to work!\n\n"), call. = FALSE)
13 | points(x[,1], nrow - x[,2]
14 | , pch=pch, col=col, ...)
15 | }
16 |
--------------------------------------------------------------------------------
/configure.in:
--------------------------------------------------------------------------------
1 | dnl
2 | dnl Configuration things for affyR.
3 | dnl (http://www.cbs.dtu.dk/laurent/download/affyR/
4 | dnl What is below (and in the other configuration fiels
5 | dnl was taken from different configuration scripts for R version 1.3.0.
6 | dnl
7 | dnl Acknowledgments: The author(s) of the R configure scripts, Kurt Hornik for the tip with autoconf.
8 | dnl
9 | dnl Laurent 2001
10 |
11 |
12 | AC_INIT("DESCRIPTION")
13 |
14 | dnl
15 | dnl Are things (still) the same ?
16 | dnl (taken from the 'writing R extensions manual')
17 |
18 |
19 | dnl
20 | dnl tests the zlib.h
21 | dnl (the test is found in 'acinclude.m4')
22 | dnl
23 |
24 | R_ZLIB
25 |
26 |
27 | AC_OUTPUT(src/Makevars)
28 |
--------------------------------------------------------------------------------
/man/affy-deprecated.Rd:
--------------------------------------------------------------------------------
1 | \name{affy-deprecated}
2 | \alias{loess.normalize}
3 | \alias{maffy.normalize}
4 | \alias{multiloess}
5 | \alias{simplemultiLoess}
6 | \title{Deprecated functions in package \sQuote{affy}}
7 | \description{
8 | These functions are provided for compatibility with older versions
9 | of affy only, and will be defunct at the next release.
10 | }
11 | \details{
12 |
13 | The following functions are deprecated and will be made defunct; use
14 | the replacement indicated below:
15 | \itemize{
16 |
17 | \item{loess.normalize: \code{\link{normalize.loess}}}
18 |
19 | \item{maffy.normalize}
20 | \item{multiloess}
21 | \item{simplemultiLoess}
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/man/whatcdf.Rd:
--------------------------------------------------------------------------------
1 | \name{whatcdf}
2 | \alias{whatcdf}
3 | \title{Find which CDF corresponds}
4 | \description{
5 | Find which kind of CDF corresponds to a CEL file.
6 | }
7 | \usage{
8 | whatcdf(filename, compress = getOption("BioC")$affy$compress.cel)
9 | }
10 | \arguments{
11 | \item{filename}{a '.CEL' file name.}
12 | \item{compress}{logical (file compressed or not).}
13 | }
14 | \details{
15 | Information concerning the corresponding CDF file seems to be found in
16 | CEL files. This allows us to try to link CDF information automatically.
17 | }
18 | \value{
19 | a \code{character} with the name of the CDF.
20 | }
21 | \seealso{\code{getInfoInAffyFile}, \code{read.celfile}}
22 | \keyword{manip}
23 |
--------------------------------------------------------------------------------
/man/setAffyOptions.Rd:
--------------------------------------------------------------------------------
1 | \name{.setAffyOptions}
2 | \alias{.setAffyOptions}
3 | \title{ ~~function to set options ~~ }
4 | \description{
5 | ~~ Set the options for the package
6 | }
7 | \usage{
8 | .setAffyOptions(affy.opt = NA)
9 | }
10 | \arguments{
11 | \item{affy.opt}{ A list structure of options. If \code{NA}, the
12 | default options are set.}
13 | }
14 | \details{
15 | See the vignettes to know more. This function could disappear in favor
16 | of a more general one the package Biobase.
17 | }
18 | \value{
19 | The function is used for its side effect. Nothing is returned.
20 | }
21 | \author{ Laurent }
22 | \examples{
23 | affy.opt <- getOption("BioC")$affy
24 |
25 | .setAffyOptions(affy.opt)
26 | }
27 | \keyword{manip}
28 |
--------------------------------------------------------------------------------
/aclocal.m4:
--------------------------------------------------------------------------------
1 | ##
2 | ## Try finding zlib library and headers
3 | ##
4 | ## R_ZLIB()
5 | ##
6 | AC_DEFUN([R_ZLIB], [
7 | have_zlib=no
8 | AC_CHECK_LIB(z, main, [
9 | AC_CHECK_HEADER(zlib.h, [
10 | AC_MSG_CHECKING([if zlib version >= 1.1.3])
11 | AC_TRY_RUN([
12 | #include "confdefs.h"
13 | #include
14 | #include
15 | int main() {
16 | #ifdef ZLIB_VERSION
17 | return(strcmp(ZLIB_VERSION, "1.1.3") < 0);
18 | #else
19 | return(1);
20 | #endif
21 | }], [AC_MSG_RESULT([yes])
22 | have_zlib=yes],
23 | AC_MSG_RESULT([no]),
24 | AC_MSG_RESULT([no]))
25 | ])
26 | ])
27 | if test "${have_zlib}" = yes; then
28 | AC_DEFINE(HAVE_ZLIB)
29 | LIBS='-lz '$LIBS
30 | fi
31 | ])
32 |
33 |
--------------------------------------------------------------------------------
/inst/CITATION:
--------------------------------------------------------------------------------
1 | citEntry(entry = "Article",
2 | "author" = "Laurent Gautier and Leslie Cope and Benjamin M. Bolstad and Rafael A. Irizarry",
3 | "title" = "affy---analysis of Affymetrix GeneChip data at the probe level",
4 | journal = "Bioinformatics",
5 | volume = "20",
6 | number = "3",
7 | year = "2004",
8 | issn = "1367-4803",
9 | pages = "307--315",
10 | doi = "10.1093/bioinformatics/btg405",
11 | publisher = "Oxford University Press",
12 | address = "Oxford, UK",
13 | textVersion = "Gautier, L., Cope, L., Bolstad, B. M., and Irizarry, R. A. 2004. affy---analysis of Affymetrix GeneChip data at the probe level. Bioinformatics 20, 3 (Feb. 2004), 307-315."
14 | )
15 |
--------------------------------------------------------------------------------
/man/tukey.biweight.Rd:
--------------------------------------------------------------------------------
1 | \name{tukey.biweight}
2 | \alias{tukey.biweight}
3 | \title{One-step Tukey's biweight}
4 | \description{
5 | One-step Tukey's biweight on a matrix.
6 | }
7 | \usage{
8 | tukey.biweight(x, c = 5, epsilon = 1e-04)
9 | }
10 | \arguments{
11 | \item{x}{a matrix.}
12 | \item{c}{tuning constant (see details).}
13 | \item{epsilon}{fuzzy value to avoid division by zero (see details).}
14 | }
15 | \details{
16 | The details can be found in the given reference.
17 | }
18 | \value{
19 | a vector of values (one value per column in the input matrix).
20 | }
21 | \references{Statistical Algorithms Description Document, 2002, Affymetrix.}
22 | \seealso{
23 | \code{\link{pmcorrect.mas}} and \code{\link{generateExprVal.method.mas}}
24 | }
25 | \keyword{manip}
26 |
--------------------------------------------------------------------------------
/man/plot.ProbeSet.Rd:
--------------------------------------------------------------------------------
1 | \name{plot.ProbeSet}
2 | \alias{plot.ProbeSet}
3 | \title{plot a probe set}
4 | \description{
5 | Plot intensities by probe set.
6 | }
7 | \usage{
8 | \method{plot}{ProbeSet}(x, which=c("pm", "mm"), xlab = "probes", type = "l", ylim = NULL, ...)
9 | }
10 | \arguments{
11 | \item{x}{a \code{ProbeSet} object.}
12 | \item{which}{get the PM or the MM.}
13 | \item{xlab}{x-axis label.}
14 | \item{type}{plot type.}
15 | \item{ylim}{range of the y-axis.}
16 | \item{\dots}{optional arguments to be passed to \code{matplot}.}
17 | }
18 | \value{
19 | This function is only used for its (graphical) side-effect.
20 | }
21 | \seealso{\code{\link[affy:ProbeSet-class]{ProbeSet}}}
22 | \examples{
23 | data(SpikeIn)
24 | plot(SpikeIn)
25 | }
26 | \keyword{hplot}
27 |
--------------------------------------------------------------------------------
/man/hlog.Rd:
--------------------------------------------------------------------------------
1 | \name{hlog}
2 | \alias{hlog}
3 | \title{Hybrid Log}
4 | \description{Given a constant \code{c} this function returns
5 | \code{x} if \code{x} is less than \code{c} and \code{sign(x)*(c*log(abs(x)/c)
6 | + c)} if its not. Notice this is a continuous odd ( f(-x)=-f(x) )
7 | function with continuous first derivative. The main purpose is to perform log
8 | transformation when one has negative numbers, for example for PM-MM.}
9 | \usage{
10 | hlog(x, constant=1)
11 | }
12 | \arguments{
13 | \item{x}{a number.}
14 | \item{constant}{the constant c (see description).}
15 | }
16 | \details{
17 | If \code{constant} is less than or equal to 0 \code{log(x)} is
18 | returned for all \code{x}. If \code{constant} is infinity \code{x} is
19 | returned for all \code{x}.
20 | }
21 | \author{Rafael A. Irizarry}
22 | \keyword{math}
23 |
--------------------------------------------------------------------------------
/R/generateExprVal.method.mas.R:
--------------------------------------------------------------------------------
1 | generateExprVal.method.mas <- function(probes, ...)
2 | {
3 |
4 | probes <- log2(probes)
5 | M <- ncol(probes)
6 | slg <- rep(NA,M)
7 |
8 | for (i in 1:ncol(probes)) {
9 |
10 | slg[i] <- tukey.biweight(probes[ ,i], ...)
11 |
12 | }
13 |
14 | return(list(exprs=2^slg,se.exprs=rep(NA,M)))
15 |
16 | }
17 |
18 | affy.scalevalue.exprSet <- function(eset, sc=500, analysis="absolute")
19 | {
20 |
21 | analysis <- match(analysis, c("absolute", "comparison"))
22 |
23 | if(analysis == 1)
24 | nf <- 1
25 | else
26 | stop("sorry! comparison not implemented.")
27 | for (i in 1:ncol(exprs(eset))) {
28 | slg <- exprs(eset)[, i]
29 | sf <- sc / mean(slg, trim=0.02)
30 | reported.value <- nf * sf * slg
31 | exprs(eset)[, i] <- reported.value
32 | }
33 |
34 | return(eset)
35 | }
36 |
--------------------------------------------------------------------------------
/man/merge.AffyBatch.Rd:
--------------------------------------------------------------------------------
1 | \name{merge.AffyBatch}
2 | \alias{merge.AffyBatch}
3 | \title{merge two AffyBatch objects}
4 | \description{
5 | merge two AffyBatch objects into one.
6 | }
7 | \usage{
8 | \method{merge}{AffyBatch}(x, y, annotation = paste(annotation(x),
9 | annotation(y)), description = NULL, notes =
10 | character(0), ...)
11 | }
12 | \arguments{
13 | \item{x}{an \code{AffyBatch} object.}
14 | \item{y}{an \code{AffyBatch} object.}
15 | \item{annotation}{a \code{character} vector.}
16 | \item{description}{a \code{characterORmiame}, eventually \code{NULL}.}
17 | \item{notes}{a \code{character} vector.}
18 | \item{\dots}{additional arguments.}
19 | }
20 | \details{
21 | To be done.
22 | }
23 | \value{
24 | A object if class \code{\link[affy:AffyBatch-class]{AffyBatch}}.
25 | }
26 | \seealso{\code{\link{AffyBatch-class}}}
27 | \keyword{manip}
28 |
--------------------------------------------------------------------------------
/man/bg.adjust.Rd:
--------------------------------------------------------------------------------
1 | \name{bg.adjust}
2 | \alias{bg.adjust}
3 | \alias{bg.parameters}
4 | \title{Background adjustment (internal function)}
5 | \description{
6 | An internal function to be used by \code{\link{bg.correct.rma}}.
7 | }
8 | \usage{
9 | bg.adjust(pm, n.pts = 2^14, ...)
10 | bg.parameters(pm, n.pts = 2^14)
11 | }
12 | \arguments{
13 | \item{pm}{a pm matrix}
14 | \item{n.pts}{number of points to use in call to \code{density}.}
15 | \item{\dots}{extra arguments to pass to bg.adjust.}
16 | }
17 | \details{Assumes PMs are a convolution of normal and exponential. So we
18 | observe X+Y where X is background and Y is signal. \code{bg.adjust}
19 | returns E[Y|X+Y, Y>0] as our background corrected PM.
20 | \code{bg.parameters} provides ad hoc estimates of the parameters of the
21 | normal and exponential distributions.}
22 | \value{a matrix}
23 | \seealso{\code{\link{bg.correct.rma}}}
24 | \keyword{manip}
25 |
--------------------------------------------------------------------------------
/inst/tests/expression.values.R:
--------------------------------------------------------------------------------
1 | ## -------------------------------------------
2 | ## routine tests for expression values methods
3 | ## -------------------------------------------
4 |
5 | library(affy)
6 | library(affydata)
7 |
8 | data(Dilution)
9 |
10 | essm = express.summary.stat.methods()
11 | i <- match("playerout", essm)
12 | meths <- essm[-i]
13 |
14 | for (m in meths) {
15 | for (mbc in pmcorrect.methods()) {
16 | cat("expression value with method=", m, "bg correct=", mbc, "...")
17 | computeExprSet(Dilution, pmcorrect.method=mbc, summary.method=m)
18 | cat("done.\n")
19 | }
20 | }
21 |
22 | ## playerout alone 'cause very slow
23 | m <- "playerout"
24 | for (mbc in pmcorrect.methods()) {
25 | cat("expression value with method=", m, "bg correct=", mbc, "...")
26 | computeExprSet(Dilution, pmcorrect.method=mbc, summary.method=m,
27 | ids=geneNames(Dilution)[1:3])
28 | cat("done.\n")
29 | }
30 |
31 |
32 |
--------------------------------------------------------------------------------
/man/maffy.subset.Rd:
--------------------------------------------------------------------------------
1 | \name{maffy.subset}
2 | \alias{maffy.subset}
3 | \title{Select Subset}
4 | \description{Select a subset of rows with small rank-range over columns.}
5 | \usage{
6 | maffy.subset(data,subset.size=5000,maxit=100,
7 | subset.delta=max(round(subset.size/100),25),verbose=FALSE)}
8 | \arguments{
9 | \item{data}{a matrix}
10 | \item{subset.size}{desired size of subset}
11 | \item{maxit}{maximum number of iterations}
12 | \item{subset.delta}{maximum deviation from subset.size}
13 | \item{verbose}{logical value.}
14 | }
15 | \details{
16 | Please refer to references.
17 | }
18 | \value{
19 | A list with component \code{subset}, the indexes for subset.
20 | }
21 | \references{Astrand, M. (2001) \url{http://www.math.chalmers.se/~magnusaa/maffy/}}
22 | \author{Magnus Astrand}
23 | \seealso{ \code{\link{maffy.normalize}}}
24 | \examples{
25 | if (require(affydata)) {
26 | #data(Dilution)
27 | #x <- log2(pm(Dilution)[,1:3])
28 | #Index <- maffy.subset(x,subset.size=100)$subset
29 | #mva.pairs(x[Index,])
30 | }
31 | }
32 | \keyword{internal}
33 |
--------------------------------------------------------------------------------
/R/normalize.constant.R:
--------------------------------------------------------------------------------
1 | normalize.AffyBatch.constant <- function(abatch, refindex=1, FUN=mean, na.rm=TRUE) {
2 |
3 | n <- length( abatch )
4 |
5 | if (! (refindex %in% 1:n)) stop("invalid reference index for normalization")
6 | refconstant <- FUN(intensity(abatch)[,refindex], na.rm=na.rm)
7 |
8 | #set.na.spotsd(abatch)
9 |
10 | normhisto <- vector("list", length=n)
11 | for (i in (1:n)[-refindex]) {
12 | m <- normalize.constant(intensity(abatch)[,i], refconstant, FUN=FUN, na.rm=na.rm)
13 | myhistory <- list(name="normalized by constant",
14 | constant=attr(m,"constant"))
15 | attr(m,"constant") <- NULL
16 | intensity(abatch)[, i] <- m
17 | normhisto[[i]] <- myhistory
18 | }
19 | attr(abatch, "normalization") <- normhisto
20 | return(abatch)
21 | }
22 |
23 |
24 | normalize.constant <- function(x, refconstant, FUN=mean, na.rm=TRUE) {
25 | thisconstant <- FUN(x, na.rm=na.rm)
26 | r <- x / thisconstant * refconstant
27 | attr(r,"constant") <- refconstant / thisconstant
28 | return(r)
29 | }
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/R/ppsetApply.R:
--------------------------------------------------------------------------------
1 | ppsetApply <- function(abatch, FUN, genenames=NULL, ...) {
2 |
3 | if (! is(abatch, "AffyBatch"))
4 | stop("abatch must be inheriting from class AffyBatch")
5 |
6 | if (! is(FUN, "function"))
7 | stop("FUN must be a function")
8 |
9 | cdfenv <- getCdfInfo(abatch)
10 |
11 | if (is.null(genenames))
12 | genenames <- ls(cdfenv)
13 |
14 | ##
15 | e1 <- new.env(parent = environment(FUN))
16 | multiassign(names(pData(abatch)), pData(abatch), e1)
17 | environment(FUN) <- e1
18 |
19 | ppset <- new("ProbeSet", pm=matrix(), mm=matrix())
20 |
21 | r <- vector("list", length=length(genenames))
22 | names(r) <- genenames
23 |
24 | for (i in seq(along=genenames)) {
25 | ## use mget to get NA when genenames[i] not found
26 | probes.i <- mget(genenames[i], envir = cdfenv, ifnotfound = NA)[[1]]
27 | if (all(is.na(probes.i)))
28 | next
29 | ppset@pm <- intensity(abatch)[probes.i[, 1], , drop=FALSE]
30 | ppset@mm <- intensity(abatch)[probes.i[, 2], , drop=FALSE]
31 | ppset@id <- genenames[i]
32 | r[[i]] <- FUN(ppset, ...)
33 | }
34 |
35 | return(r)
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/man/cdfFromBioC.Rd:
--------------------------------------------------------------------------------
1 | \name{cdfFromBioC}
2 | \alias{cdfFromBioC}
3 | \alias{cdfFromLibPath}
4 | \alias{cdfFromEnvironment}
5 | \title{Functions to obtain CDF files}
6 | \description{
7 | A set of functions to obtain CDF files from various locations.
8 | }
9 | \usage{
10 | cdfFromBioC(cdfname, lib = .libPaths()[1], verbose = TRUE)
11 | cdfFromLibPath(cdfname, lib = NULL, verbose=TRUE)
12 | cdfFromEnvironment(cdfname, where, verbose=TRUE)
13 | }
14 | \arguments{
15 | \item{cdfname}{name of the CDF.}
16 | \item{lib}{install directory for the CDF package.}
17 | \item{where}{environment to search.}
18 | \item{verbose}{logical controlling extra output.}
19 | }
20 | \details{
21 | These functions all take a requested CDF environment name and will
22 | attempt to locate that environment in the appropriate location (a
23 | package's data directory, as a CDF package in the .libPaths(), from a
24 | loaded environment or on the Bioconductor website. If the environment
25 | can not be found, it will return a list of the methods tried that failed.
26 | }
27 | \value{
28 | The CDF environment or a list detailing the failed locations.
29 | }
30 | \author{Jeff Gentry}
31 | \keyword{utilities}
32 |
--------------------------------------------------------------------------------
/man/barplot.ProbeSet.Rd:
--------------------------------------------------------------------------------
1 | \name{barplot.ProbeSet}
2 | \alias{barplot.ProbeSet}
3 | \title{show a ProbeSet as barplots}
4 | \description{
5 | Displays the probe intensities in a ProbeSet as a barplots
6 | }
7 | \usage{
8 | \method{barplot}{ProbeSet}(height, xlab = "Probe pair", ylab = "Intensity",
9 | main = NA, col.pm = "red", col.mm = "blue", beside = TRUE, names.arg = "pp",
10 | ask = TRUE, scale, ...)
11 | }
12 | \arguments{
13 | \item{height}{an object of class \code{ProbeSet}.}
14 | \item{xlab}{label for x axis.}
15 | \item{ylab}{label for y axis.}
16 | \item{main}{main label for the figure.}
17 | \item{col.pm}{color for the `pm' intensities.}
18 | \item{col.mm}{color for the `mm' intensities.}
19 | \item{beside}{bars beside each others or not.}
20 | \item{names.arg}{names to be plotted below each bar or group of bars.}
21 | \item{ask}{ask before ploting the next barplot.}
22 | \item{scale}{put all the barplot to the same scale.}
23 | \item{\dots}{extra parameters to be passed to \code{\link{barplot}}.}
24 | }
25 | \examples{
26 | if (require(affydata)) {
27 | data(Dilution)
28 | gn <- geneNames(Dilution)
29 | pps <- probeset(Dilution, gn[1])[[1]]
30 |
31 | barplot.ProbeSet(pps)
32 | }
33 | }
34 | \keyword{hplot}
35 |
--------------------------------------------------------------------------------
/R/barplot.ProbeSet.R:
--------------------------------------------------------------------------------
1 | barplot.ProbeSet <- function(height,
2 | xlab="Probe pair",ylab="Intensity",
3 | main=NA,
4 | col.pm="red", col.mm="blue",
5 | beside=TRUE, names.arg="pp",
6 | ask = TRUE, scale = TRUE,
7 | ...)
8 | {
9 |
10 | opar <- par()$ask
11 | par(ask=ask)
12 | on.exit(par(ask=opar))
13 |
14 | if (names.arg == "pp") {
15 | names.arg <- seq(1, nrow(pm(height)))
16 | }
17 |
18 | col <- c(col.pm, col.mm)
19 |
20 | if (scale) {
21 | ylim <- range(c(pm(height), mm(height)), na.rm=TRUE)
22 | } else {
23 | ylim <- NULL
24 | }
25 |
26 | if (is.na(main)) {
27 | main <- paste(height@id, "( sample", 1:ncol(pm(height)), ")")
28 | } else {
29 | main <- rep(main, length=ncol(pm(height)))
30 | }
31 |
32 | for (i in 1:ncol(pm(height))) {
33 |
34 | hh <- rbind(pm(height)[, i], mm(height)[, i])
35 |
36 | barplot(hh, xlab=xlab, ylab=ylab,
37 | main=main[i],
38 | col=col,
39 | beside=beside,
40 | names.arg=names.arg,
41 | ylim = ylim,
42 | ...)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/man/affy.scalevalue.exprSet.Rd:
--------------------------------------------------------------------------------
1 | %%%THIS FUNCTION SHOULD BE In BIOBASE or SOMEWHERE ELSE... NEXT RELEASE
2 | %% LG: In such a case, I assume the long awaited agreement about
3 | %% normalization methods will be here and all the normalization methods
4 | %% will be stored together
5 | \name{affy.scalevalue.exprSet}
6 | \alias{affy.scalevalue.exprSet}
7 | \title{Scale normalization for expreSets}
8 | \description{
9 | Normalizes expression values using the method described in the Affymetrix
10 | user manual.
11 | }
12 | \usage{
13 | affy.scalevalue.exprSet(eset, sc = 500, analysis="absolute")
14 | }
15 | \arguments{
16 | \item{eset}{An \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}}
17 | object.}
18 | \item{sc}{Value at which all arrays will be scaled to.}
19 | \item{analysis}{Should we do absolute or comparison analysis, although
20 | "comparison" is still not implemented.}
21 | }
22 | \details{
23 | This is function was implemented from the Affymetrix technical
24 | documentation for MAS 5.0. It can be downloaded from the website of
25 | the company. Please refer to this document for details.
26 | }
27 | \author{Laurent}
28 | \value{
29 | A normalized \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}}.
30 | }
31 | \keyword{manip}
32 |
--------------------------------------------------------------------------------
/man/normalize.constant.Rd:
--------------------------------------------------------------------------------
1 | \name{normalize.constant}
2 | \alias{normalize.constant}
3 | \alias{normalize.AffyBatch.constant}
4 | \title{Scale probe intensities}
5 | \description{
6 | Scale array intensities in a \code{\link[affy:AffyBatch-class]{AffyBatch}}.
7 | }
8 | \usage{
9 | normalize.AffyBatch.constant(abatch, refindex=1, FUN=mean, na.rm=TRUE)
10 | normalize.constant(x, refconstant, FUN=mean, na.rm=TRUE)
11 | }
12 | \arguments{
13 | \item{abatch}{ an instance of the \code{\link{AffyBatch-class}}.}
14 | \item{x}{a vector of intensities on a chip (to normalize to the reference).}
15 | \item{refindex}{the index of the array used as a reference.}
16 | \item{refconstant}{the constant used as a reference.}
17 | \item{FUN}{a function generating a value from the intensities on an
18 | array. Typically \code{mean} or \code{median}.}
19 | \item{na.rm}{parameter passed to the function FUN.}
20 | }
21 | \value{
22 | %A \code{\link[Biobase]{container-class}} of normalized objects.
23 | An \code{\link[affy:AffyBatch-class]{AffyBatch}} with an attribute "constant"
24 | holding the value of the factor used for scaling.
25 | }
26 | \author{
27 | L. Gautier
28 | }
29 | \seealso{
30 | \code{\link[affy:AffyBatch-class]{AffyBatch}}
31 | }
32 | \keyword{manip}
33 |
--------------------------------------------------------------------------------
/R/pmcorrect.mas.R:
--------------------------------------------------------------------------------
1 | ############################
2 | ##MPM Changed delta, Affy SADD states delta as 2e-20
3 | pmcorrect.mas <- function (object, contrast.tau = 0.03, scale.tau = 10, delta = 2^(-20))
4 | #function (object, contrast.tau = 0.03, scale.tau = 10, delta = 9.536743e-07)
5 | ###########################
6 | {
7 | all.pps.pm <- pm(object)
8 | all.pps.mm <- mm(object)
9 | diff <- log2(all.pps.pm) - log2(all.pps.mm)
10 | delta <- rep(delta, nrow(diff))
11 | for (i in 1:ncol(diff)) {
12 | sb <- tukey.biweight(diff[, i])
13 | pps.pm <- all.pps.pm[, i]
14 | pps.mm <- all.pps.mm[, i]
15 | pps.im <- pps.mm
16 | j <- (pps.mm >= pps.pm) & (sb > contrast.tau)
17 | pps.im[j] <- pps.pm[j]/2^sb
18 | j <- (pps.mm >= pps.pm) & (sb <= contrast.tau)
19 | pps.im[j] <- pps.pm[j]/2^(contrast.tau/(1 + (contrast.tau -
20 | sb)/scale.tau))
21 | #########################
22 | #MPM SADD Need to substract the PM-IM, I think this is the culprit
23 | pm.corrected <- apply(cbind(pps.pm-pps.im, delta), 1,
24 | max)
25 | #pm.corrected <- apply(cbind(pps.pm, pps.im, delta), 1,
26 | # max)
27 | ##########################
28 | diff[, i] <- pm.corrected
29 | }
30 | return(diff)
31 | }
32 |
--------------------------------------------------------------------------------
/man/normalize.contrast.Rd:
--------------------------------------------------------------------------------
1 | \name{normalize.contrasts}
2 | \alias{normalize.contrasts}
3 | \alias{normalize.AffyBatch.contrasts}
4 | \title{Normalize intensities using the contrasts method}
5 | \description{
6 | Scale chip objects in an \code{\link{AffyBatch-class}}.
7 | }
8 | \usage{
9 | %normalize.contrast() ## currently maffy.normalize
10 | normalize.AffyBatch.contrasts(abatch,span=2/3, choose.subset=TRUE,
11 | subset.size=5000, verbose=TRUE,
12 | family="symmetric",
13 | type=c("together","pmonly","mmonly","separate"))
14 | }
15 | \arguments{
16 | \item{abatch}{an \code{\link{AffyBatch-class}} object.}
17 | \item{span}{parameter to be passed to the function
18 | \code{\link[stats]{loess}}.}
19 | \item{choose.subset}{Boolean. Defaults to \code{TRUE}}
20 | \item{subset.size}{Integer. Number of probesets to use in each subset.}
21 | \item{verbose}{verbosity flag.}
22 | \item{family}{parameter to be passed to the function
23 | \code{\link[stats]{loess}}.}
24 | \item{type}{a string specifying how the normalization should be applied.}
25 | }
26 | \value{
27 | An object of the same class as the one passed.
28 | }
29 | \seealso{
30 | \code{\link{maffy.normalize}}
31 | }
32 | \keyword{manip}
33 |
--------------------------------------------------------------------------------
/man/mva.pairs.Rd:
--------------------------------------------------------------------------------
1 | \name{mva.pairs}
2 | \alias{mva.pairs}
3 | \title{M vs. A Matrix}
4 | \description{
5 | A matrix of M vs. A plots is produced. Plots are made on the upper
6 | triangle and the IQR of the Ms are displayed in the lower triangle
7 | }
8 | \usage{
9 | mva.pairs(x, labels=colnames(x), log.it=TRUE,span=2/3,family.loess="gaussian",
10 | digits=3,line.col=2,main="MVA plot",cex=2,...)
11 | }
12 | \arguments{
13 | \item{x}{a matrix containing the chip data in the columns.}
14 | \item{labels}{the names of the variables.}
15 | \item{log.it}{logical. If \code{TRUE}, uses log scale.}
16 | \item{span}{span to be used for loess fit.}
17 | \item{family.loess}{\code{"gaussian"} or \code{"symmetric"} as in
18 | \code{\link[stats]{loess}}.}
19 | \item{digits}{number of digits to use in the display of IQR.}
20 | \item{line.col}{color of the loess line.}
21 | \item{main}{an overall title for the plot.}
22 | \item{cex}{size for text.}
23 | \item{\dots}{graphical parameters can be given as arguments to
24 | \code{mva.plot}}.}
25 | \examples{
26 | x <- matrix(rnorm(4000),1000,4)
27 | x[,1] <- x[,1]^2
28 | dimnames(x) <- list(NULL,c("chip 1","chip 2","chip 3","chip 4"))
29 | mva.pairs(x,log=FALSE,main="example")
30 | }
31 | \seealso{\code{\link{pairs}}}
32 | \keyword{hplot}
33 |
--------------------------------------------------------------------------------
/R/normalize.contrasts.R:
--------------------------------------------------------------------------------
1 | normalize.AffyBatch.contrasts <- function(abatch,span=2/3,choose.subset=TRUE,subset.size=5000,verbose=TRUE,family="symmetric",type=c("together","pmonly","mmonly","separate")) {
2 |
3 | type <- match.arg(type)
4 |
5 | if (type == "pmonly"){
6 | Index <- unlist(pmindex(abatch))
7 | } else if (type == "mmonly"){
8 | Index <- unlist(mmindex(abatch))
9 | } else if (type == "together"){
10 | Index <- unlist(indexProbes(abatch,"both"))
11 | } else if (type == "separate"){
12 | abatch <- normalize.AffyBatch.contrasts(abatch,span=span,choose.subset=choose.subset,subset.size=subset.size,verbose=verbose,family=family,type="pmonly")
13 | Index <- unlist(mmindex(abatch))
14 | }
15 |
16 | ##we need default argumetns becuase they are used in this transitional file
17 | alldata <- intensity(abatch)[Index,]
18 |
19 | if(choose.subset)
20 | subset1 <- maffy.subset(alldata,verbose=verbose,subset.size=subset.size)$subset
21 | else
22 | subset1 <- sample(1:dim(alldata)[1],subset.size)
23 | aux <- maffy.normalize(alldata,subset=subset1,verbose=verbose,span=span,family=family)
24 |
25 | intensity(abatch)[Index,] <- aux
26 |
27 | ##attr(abatch, "normalization") <- normhisto
28 | return(abatch)
29 | }
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/R/generateExprVal.method.playerout.R:
--------------------------------------------------------------------------------
1 | generateExprVal.method.playerout <- function(probes, weights=FALSE, optim.method="L-BFGS-B"){
2 |
3 | probes <- t(probes)
4 | nprobes <- ncol(probes)
5 |
6 | ## skip if only one probe
7 | if (nprobes == 1) return(t(probes))
8 |
9 | ## I do not know to which extend the use of optim
10 | ## is really equivalent to the use of nlminb in S-plus
11 | S1 <- optim(runif(nprobes),
12 | playerout.costfunction,
13 | method=optim.method,
14 | control=list(maxit=500),
15 | y=probes)
16 | ##S1 <- nlm(playerout,runif(20),iterlim=500,y=t(y))
17 | r <- c(probes %*% S1$par / sum(S1$par))
18 | if (weights)
19 | attr(r,"weights") <- S1$par
20 | return(list(exprs=r,se.exprs=rep(NA,length(r))))
21 | }
22 |
23 |
24 | ## The loss function:
25 |
26 | playerout.costfunction <- function(w, y) {
27 | N <- length(w) # Number of players
28 | J <- length(y)/N # Number of games (the number of games is the number of chips used)
29 | sumw <- sum(w)
30 |
31 | tx <- y %*% w # Full weighted score at each game
32 | pl <- matrix(0,J,N) # Loss at each game due to each player
33 |
34 | for(j in 1:J)
35 | pl[j,] <- w * y[j,] - (tx[j] - w * y[j,]) / (sumw - w)
36 |
37 | sum(pl^2) # Loss
38 | }
39 |
40 |
41 |
--------------------------------------------------------------------------------
/inst/tests/affybatch.R:
--------------------------------------------------------------------------------
1 | ##
2 | ## Basic set of tests for the class AffyBatch
3 | ##
4 | library(affy)
5 |
6 | ## fake environment
7 | ##it the below change the environment def must change too
8 | NCOL <- 8
9 | NROW <- 8
10 | n <- NCOL*NROW
11 |
12 | cat("---> normalizing an environment...\n")
13 | tmp <- sample(1:50)
14 | dummy <- new.env(hash=T)
15 | index <- cbind(tmp[1:10], tmp[11:20])
16 | assign("gene.a", index, envir=dummy)
17 | index <- cbind(tmp[21:30],tmp[31:40])
18 | assign("gene.b", index, envir=dummy)
19 | cat("done.\n")
20 |
21 | cat("---> creating an AffyBatch...\n")
22 | samplenames <- c("sample1","sample2")
23 | signal <- exp(rexp(n,1))
24 | e <- cbind(exp(rnorm(n,4,1))+signal,exp(rnorm(n,4,1))+signal)
25 | colnames(e) <- samplenames
26 | afbatch <- new("AffyBatch",
27 | exprs=e,
28 | cdfName="dummy",
29 | ncol=NCOL,nrow=NROW)
30 | cat("done.\n")
31 |
32 |
33 | ##can i get pms?
34 | pms <- pm(afbatch)
35 | mms <- mm(afbatch)
36 |
37 | ## normalize the AffyBatch
38 | cat("---> normalizing an AffyBatch...\n")
39 | n.afbatch <- normalize(afbatch, method="constant")
40 | cat("done.\n")
41 |
42 | ## compute expression values
43 | cat("---> computing expression values...\n")
44 | e.set <- computeExprSet(n.afbatch, pmcorrect.method="pmonly", summary.method="avgdiff")
45 | if (!is(e.set, "ExpressionSet"))
46 | stop("e.set does not inherit from 'ExpressionSet'!")
47 | cat("done.\n")
48 |
--------------------------------------------------------------------------------
/man/plotLocation.Rd:
--------------------------------------------------------------------------------
1 | \name{plotLocation}
2 | \alias{plotLocation}
3 | \title{Plot a location on a cel image}
4 | \description{
5 | Plots a location on a previously plotted cel image. This can be used
6 | to locate the physical location of probes on the array.
7 | }
8 | \usage{
9 | plotLocation(x, col="green", pch=22, ...)
10 | }
11 | \arguments{
12 | \item{x}{a `location'. It can be obtained by the method of \code{AffyBatch}
13 | \code{indexProbes}, or made elsewhere (basically a location is nrows and
14 | two columns array. The first column corresponds to the x positions
15 | and the second columns corresponds to the y positions of n elements
16 | to locate).}
17 | \item{col}{colors for the plot.}
18 | \item{pch}{plotting type (see function \code{plot}).}
19 | \item{\dots}{other parameters passed to the function \code{points}.}
20 | }
21 | \author{
22 | Laurent
23 | }
24 | \seealso{
25 | \code{\link[affy:AffyBatch-class]{AffyBatch}}
26 | }
27 | \examples{
28 | if (require(affydata)) {
29 | data(Dilution)
30 |
31 | ## image of the celfile
32 | image(Dilution[, 1])
33 |
34 | ## genenames, arbitrarily pick the 101th
35 | n <- geneNames(Dilution)[101]
36 |
37 | ## get the location for the gene n
38 | l <- indexProbes(Dilution, "both", n)[[1]]
39 | ## convert the index to X/Y coordinates
40 | xy <- indices2xy(l, abatch=Dilution)
41 |
42 | ## plot
43 | plotLocation(xy)
44 | }
45 | }
46 | \keyword{aplot}
47 |
--------------------------------------------------------------------------------
/man/generateExprVal.method.playerout.Rd:
--------------------------------------------------------------------------------
1 | \name{generateExprVal.method.playerout}
2 | \alias{generateExprVal.method.playerout}
3 | \alias{playerout.costfunction}
4 | \title{Generate an expression value from the probes informations}
5 | \description{
6 | Generate an expression from the probes
7 | }
8 | \usage{
9 | generateExprVal.method.playerout(probes, weights=FALSE, optim.method="L-BFGS-B")
10 | }
11 | \arguments{
12 | \item{probes}{a list of \code{probes} slots from \code{PPSet.container}}
13 | \item{weights}{Should the resulting weights be returned ?}
14 | \item{optim.method}{see parameter 'optim' for the function \code{\link{optim}}}
15 | }
16 | \value{
17 | A vector of expression values.
18 | }
19 | \details{
20 | A non-parametric method to weight each perfect match probe in the set and
21 | to compute a weighted mean of the perfect match values. One will notice
22 | this method only makes use of the perfect matches. (see function
23 | \code{playerout.costfunction} for the cost function).
24 | }
25 | \author{
26 | Laurent \cr
27 | (Thanks to E. Lazaridris for the original playerout code and the
28 | discussions about it)
29 | }
30 | \references{
31 | Emmanuel N. Lazaridis, Dominic Sinibaldi, Gregory Bloom, Shrikant Mane and Richard Jove
32 | A simple method to improve probe set estimates from oligonucleotide
33 | arrays, Mathematical Biosciences, Volume 176, Issue 1, March 2002, Pages 53-58
34 | }
35 | \keyword{manip}
36 |
--------------------------------------------------------------------------------
/man/cleancdfname.Rd:
--------------------------------------------------------------------------------
1 | \name{cleancdfname}
2 | \alias{cleancdfname}
3 | \alias{mapCdfName}
4 | \title{Clean Affymetrix's CDF name}
5 | \description{
6 | This function converts Affymetrix's names for CDF files to the names
7 | used in the annotation package and in all Bioconductor.
8 | }
9 | \usage{
10 | cleancdfname(cdfname, addcdf = TRUE)
11 | }
12 | \arguments{
13 | \item{cdfname}{A \code{character} denoting Affymetrix'x CDF file name }
14 | \item{addcdf}{A \code{logical}. If \code{TRUE} it adds the string "cdf"
15 | at the end of the cleaned CDF name. This is used to name the
16 | \code{cdfenvs} packages.}
17 | }
18 | \details{
19 | This function takes a CDF filename obtained from an Affymetrix file
20 | (from a CEL file for example) and convert it to a convention of ours:
21 | all small caps and only alphanumeric characters. The details of the rule
22 | can be seen in the code.
23 | We observed exceptions that made us create a set of special cases for
24 | mapping CEL to CDF. The object \code{mapCdfName} holds information
25 | about these cases. It is a \code{data.frame} of three elements: the
26 | first is the name as found in the CDF file, the second the name in the
27 | CEL file and the third the name in Bioconductor. \code{mapCdfName} can
28 | be loaded using \code{data(mapCdfName)}.
29 | }
30 | \value{
31 | A \code{character}
32 | }
33 | \examples{
34 | cdf.tags <- c("HG_U95Av2", "HG-133A")
35 | for (i in cdf.tags)
36 | cat(i, "becomes", cleancdfname(i), "\n")
37 | }
38 | \keyword{character}
39 |
--------------------------------------------------------------------------------
/R/pairs.AffyBatch.R:
--------------------------------------------------------------------------------
1 | pairs.AffyBatch <- function(x, panel=points, ..., transfo=I, main=NULL, oma=NULL,
2 | font.main = par("font.main"), cex.main = par("cex.main"),
3 | cex.labels = NULL,
4 | lower.panel=panel, upper.panel=NULL,
5 | diag.panel=NULL,
6 | #text.panel = textPanel,
7 | #label.pos = 0.5 + has.diag/3,
8 | font.labels = 1, row1attop = TRUE, gap = 1) {
9 |
10 | #label1 <- chipNames(x)
11 | #label2 <- unlist(lapply(history(x), function(z) z$name))
12 |
13 | #textPanel <- function(x = 0.5, y = 0.5, txt, cex, font) {
14 | # text(x, y, txt, cex = cex, font = font)
15 | #}
16 |
17 | ##labels <- paste(sampleNames(x), unlist(lapply(history(x), function(z) if (is.null(z$name)) "" else z$name)), sep="\n")
18 | labels <- sampleNames(x)
19 | ##y <- matrix(intensity(x)[, , seq(along=x)], ncol=length(x))
20 | y <- intensity(x)
21 |
22 | pairs(transfo(y), labels=labels,
23 | panel=panel, ..., main=main, oma=oma,
24 | font.main = font.main, cex.main = cex.main,
25 | lower.panel=lower.panel, upper.panel=upper.panel, diag.panel=diag.panel,
26 | #text.panel = text.panel,
27 | #label.pos = label.pos,
28 | cex.labels = cex.labels,
29 | font.labels = font.labels, row1attop = row1attop, gap = gap
30 | )
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/R/whatcdf.R:
--------------------------------------------------------------------------------
1 | ##this function changes the Affymetrix cdf file name to the Bioconductor
2 | ##annotation name for that cdf file
3 | ## note: we had a hard time finding exact rules to match what is in the
4 | ## CEL file with what is in the CDF file
5 | ## ex: CEL says 'ecoli' while CDF says 'ecoligenome'
6 | ## or: CEL says '' while CDF says hu6800.1sq
7 | cleancdfname <- function(cdfname, addcdf=TRUE) {
8 | if( !is.character(cdfname) )
9 | stop(paste("invalid CDF name:", cdfname))
10 | if ( nchar(cdfname)[1] == 0 )
11 | stop("supplied cdf name has zero length")
12 | mapCdfName <- NULL # To appease R CMD check
13 | mapCdfName <- local({
14 | data("mapCdfName", package="affy", envir=environment())
15 | get("mapCdfName")
16 | })
17 | i <- match(cdfname, mapCdfName$inCDF)
18 | if (is.na(i)) {
19 | tmp <- tolower(cdfname) #make lower case
20 | tmp <- gsub("_", "", tmp) #take out underscore
21 | tmp <- gsub("-", "", tmp) #take out underscore
22 | tmp <- gsub("\ ", "", tmp) ##take out spaces
23 | if (addcdf) {
24 | ## make sure we haven't already added "cdf"
25 | endsWith <- substr(tmp, nchar(tmp)-2, nchar(tmp))
26 | if (endsWith != "cdf")
27 | tmp <- paste(tmp, "cdf", sep="")
28 | }
29 | } else {
30 | tmp <- mapCdfName$inBioC[i]
31 | }
32 | return(tmp)
33 | }
34 |
35 | ##this function gets the cdf from a celfile
36 | whatcdf <- function(filename, compress=getOption("BioC")$affy$compress.cel)
37 | return(read.celfile.header(as.character(filename))[[1]])
38 |
--------------------------------------------------------------------------------
/R/merge.AffyBatch.R:
--------------------------------------------------------------------------------
1 | merge.AffyBatch <- function(x, y, annotation=paste(annotation(x), annotation(y)),
2 | description=NULL,
3 | notes=character(0), ...) {
4 |
5 | adim <- dim(intensity(x))[1]
6 |
7 | if ((nrow(x) != nrow(y)) || (ncol(x) != ncol(y)))
8 | stop("cannot merge chips of different sizes !")
9 |
10 | if (cdfName(x) != cdfName(y))
11 | warning("cdfName mismatch (using the cdfName of x)!")
12 |
13 | if (is.null(description)){
14 | description <- new("MIAME")
15 | description@title <- "Created from merging two AffyBatches. No description was supplied. The description of the two original AffyBatches was not kept."
16 | }
17 |
18 | lx <- length(x)
19 | ly <- length(y)
20 |
21 | phenodata <- phenoData(x)
22 | pData(phenodata) <- rbind(pData(x),pData(y))
23 | protocoldata <- protocolData(x)
24 | pData(protocoldata) <- rbind(pData(protocolData(x)),pData(protocolData(y)))
25 | notes(description) <-
26 | if (length(notes)==0)
27 | list(paste("Merge from two AffyBatches with notes: 1)", notes(experimentData(x)), ", and 2)",notes(experimentData(y))))
28 | else notes
29 | return(new("AffyBatch",
30 | exprs=cbind(intensity(x),intensity(y)),
31 | phenoData=phenodata,
32 | experimentData=description, ##need to write a merge for MIAME
33 | cdfName=cdfName(x),
34 | nrow=nrow(x),
35 | ncol=ncol(x),
36 | annotation=x@annotation,
37 | protocolData=protocoldata
38 | ))
39 | }
40 |
--------------------------------------------------------------------------------
/R/bg.Affy.chipwide.R:
--------------------------------------------------------------------------------
1 | bg.correct.mas <- function(object, griddim=16)
2 | {
3 | nchips <- length(object)
4 |
5 | pm.index <- unique(unlist(indexProbes(object, "pm")))
6 | mm.index <- unique(unlist(indexProbes(object, "mm")))
7 |
8 | ## some chips have some probesets without MM probes
9 | ## which will return an NA in mm.index
10 |
11 | mm.index <- mm.index[!is.na(mm.index)]
12 |
13 | rows <- nrow(object)
14 | cols <- ncol(object)
15 |
16 | allintensities <- intensity(object)[c(pm.index, mm.index), ]
17 |
18 | # note that the indexing is +1 more than you'd expect because
19 | # the c code expects it that way
20 | ## (note about the remark above: R indexing starts at 1 and not at 0,
21 | ## that's why the indexing is done this way. The package is primarily done to
22 | ## be used with R...)
23 |
24 | allx <- c(pm.index-1, mm.index-1) %% nrow(object) +1
25 | ally <- c(pm.index-1, mm.index-1) %/% nrow(object) + 1
26 |
27 | nprobes <- length(allx)
28 |
29 | corrected <- matrix(.C("affy_background_adjust_R",
30 | as.double(as.vector(allintensities)), as.integer(allx), as.integer(ally),
31 | as.integer(nprobes), as.integer(nchips), as.integer(rows), as.integer(cols),
32 | as.integer(griddim), PACKAGE="affy")[[1]],
33 | nprobes, nchips)
34 |
35 | intensity(object)[c(pm.index, mm.index), ] <- corrected
36 | ## and what with the 'non pm or mm' probes ?
37 | ## answer: they are not used per Affymetrix Statistical Algorithms Description Document.
38 |
39 | return(object)
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/man/pmcorrect.Rd:
--------------------------------------------------------------------------------
1 | \name{pmcorrect}
2 | \alias{pmcorrect}
3 | \alias{pmcorrect.pmonly} %took out .pmonly casue rma is pm-only
4 | \alias{pmcorrect.mas}
5 | \alias{pmcorrect.subtractmm}
6 | \title{PM Correction}
7 | \description{
8 | Corrects the PM intensities in a \code{\link[affy:ProbeSet-class]{ProbeSet}}
9 | for non-specific binding.
10 | }
11 | \usage{
12 | pmcorrect.pmonly(object)
13 |
14 | pmcorrect.subtractmm(object)
15 |
16 | pmcorrect.mas(object, contrast.tau=0.03, scale.tau=10, delta=2^(-20))
17 | }
18 | \arguments{
19 | \item{object}{An object of class \code{\link[affy:ProbeSet-class]{ProbeSet}}.}
20 | \item{contrast.tau}{a number denoting the contrast tau parameter in
21 | the MAS 5.0 pm correction algorithm.}
22 | \item{scale.tau}{a number denoting the scale tau parameter in
23 | the MAS 5.0 pm correction algorithm.}
24 | \item{delta}{a number denoting the delta parameter in
25 | the MAS 5.0 pm correction algorithm.}
26 | }
27 | \details{
28 | These are the pm correction methods perfromed by Affymetrix MAS 4.0
29 | (subtractmm) and MAS 5.0 (mas). See the Affymetrix Manual for details.
30 | pmonly does what you think: does not change the PM values.}
31 | \value{A \code{\link[affy:ProbeSet-class]{ProbeSet}} for which the
32 | \code{pm} slot contains the corrected PM values.}
33 | \references{Affymetrix MAS 4.0 and 5.0 manual}
34 | \examples{
35 | if (require(affydata)) {
36 | data(Dilution)
37 | gn <- geneNames(Dilution)
38 | pps <- probeset(Dilution, gn[1])[[1]]
39 |
40 | pps.pmonly <- pmcorrect.pmonly(pps)
41 | pps.subtractmm <- pmcorrect.subtractmm(pps)
42 | pps.mas5 <- pmcorrect.mas(pps)
43 | }
44 | }
45 | \keyword{manip}
46 |
--------------------------------------------------------------------------------
/R/plot.density.R:
--------------------------------------------------------------------------------
1 | # matdensity <- function(x,
2 | # ylab="density", xlab="x", type="l", plot=TRUE,
3 | # ...) {
4 |
5 | # x.density <- apply(mat, 2, density)
6 |
7 | # all.x <- do.call("cbind", lapply(x.density, function(x) x$x))
8 | # all.y <- do.call("cbind", lapply(x.density, function(x) x$y))
9 |
10 | # if (plot)
11 | # matplot(all.x, all.y, ylab=ylab, xlab=xlab, ...)
12 |
13 | # invisible(list(all.x=all.x, all.y=all.y))
14 |
15 | # }
16 |
17 | plotDensity <- function(mat,
18 | ylab="density", xlab="x", type="l", col=1:6,
19 | na.rm = TRUE,
20 | ...) {
21 |
22 | x.density <- apply(mat, 2, density, na.rm = na.rm)
23 |
24 | all.x <- do.call(cbind, lapply(x.density, function(x) x$x))
25 | all.y <- do.call(cbind, lapply(x.density, function(x) x$y))
26 |
27 | matplot(all.x, all.y, ylab=ylab, xlab=xlab, type=type, col=col, ...)
28 |
29 | invisible(list(all.x=all.x, all.y=all.y))
30 | }
31 |
32 |
33 | plotDensity.AffyBatch <- function(x, col=1:6, log=TRUE,
34 | which=c("pm","mm","both"),
35 | ylab="density",
36 | xlab=NULL,
37 | ...){
38 |
39 | Index <- unlist(indexProbes(x, which=which))
40 |
41 | x <- intensity(x)[Index, ,drop=FALSE]
42 |
43 | if(log){
44 | x <- log2(x)
45 | if(is.null(xlab)) xlab <- "log intensity"
46 | }
47 | else if(is.null(xlab)) xlab <- "intensity"
48 |
49 | invisible(plotDensity(x, ylab=ylab, xlab=xlab, col=col, ...))
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/R/loess.normalize.R:
--------------------------------------------------------------------------------
1 | loess.normalize <- function(mat,subset=sample(1:(dim(mat)[2]),5000),
2 | epsilon=10^-2,maxit=1,log.it=TRUE,verbose=TRUE,span=2/3,
3 | family.loess="symmetric")
4 | {
5 | .Deprecated("normalize.loess", "affy")
6 | J <- dim(mat)[2]
7 | II <- dim(mat)[1]
8 | newData <- mat
9 | if(log.it){
10 | mat <- log2(mat)
11 | newData <- log2(newData)
12 | }
13 | change <- epsilon +1
14 | fs <- matrix(0,II,J)##contains what we substract
15 | iter <- 0
16 | w <- c(0,rep(1,length(subset)),0) ##this way we give 0 weight to the
17 | ##extremes added so that we can interpolate
18 | while(iter < maxit){
19 | iter <- iter+1
20 | means <- matrix(0,II,J) ##contains temp of what we substract
21 | for(j in 1:(J-1)){
22 | for(k in (j+1):J){
23 | y <- newData[,j]-newData[,k]
24 | x <-(newData[,j]+newData[,k])/2
25 | index <- c(order(x)[1],subset,order(-x)[1])
26 | ##put endpoints in so we can interpolate
27 | xx <- x[index]
28 | yy <- y[index]
29 | aux <-loess(yy~xx,span=span,degree=1,weights=w,family=family.loess)
30 | aux <- predict(aux,data.frame(xx=x))/J
31 | means[,j] <- means[,j] + aux
32 | means[,k] <- means[,k] - aux
33 | if(verbose) cat("Done with",j,"vs",k," in iteration ",iter,"\n")
34 | }
35 | }
36 | fs <- fs+means
37 | newData <- mat-fs
38 | change <- max(colMeans((means[subset,])^2))
39 | if(verbose) cat(iter,change,"\n")
40 | oldfs <- fs
41 | }
42 | if(change>epsilon & maxit>1) warning(paste("No convergence after",maxit,"iterations.\n"))
43 | if(log.it) return(2^newData)
44 | else return(newData)
45 | }
46 |
--------------------------------------------------------------------------------
/man/SpikeIn.Rd:
--------------------------------------------------------------------------------
1 | \name{SpikeIn}
2 | \alias{SpikeIn}
3 | \alias{concentrations}
4 | \title{SpikeIn Experiment Data: ProbeSet Example}
5 | \description{
6 | This \code{\link[affy:ProbeSet-class]{ProbeSet}} represents part of SpikeIn
7 | experiment data set.
8 | }
9 | \usage{data(SpikeIn)}
10 | \format{\code{SpikeIn} is \code{\link[affy:ProbeSet-class]{ProbeSet}} containing the
11 | $PM$ and $MM$ intensities for a gene spiked in at different
12 | concentrations (given in the vector \code{colnames(pm(SpikeIn))}) in 12
13 | different arrays.}
14 | \source{This comes from an experiments where 11 different cRNA
15 | fragments have been added to the hybridization mixture of the GeneChip
16 | arrays at different pM concentrations. The 11 control cRNAs were BioB-5,
17 | BioB-M, BioB-3, BioC-5, BioC-3, BioDn-5 (all \emph{E. coli}), CreX-5, CreX-3
18 | (phage P1), and DapX-5, DapX-M, DapX-3 (\emph{B. subtilis})
19 | The cRNA were chosen to match the target sequence for each of the
20 | Affymetrix control probe sets. For example, for DapX (a \emph{B. subtilis}
21 | gene), the 5', middle and 3' target sequences (identified by DapX-5,
22 | DapX-M, DapX-3) were each synthesized separately and spiked-in at a
23 | specific concentration. Thus, for example, DapX-3 target sequence may be
24 | added to the total hybridization solution of 200 micro-liters to give a final
25 | concentration of 0.5 pM.
26 |
27 | For this example we have the $PM$ and $MM$ for BioB-5
28 | obtained from the arrays where it was spiked in at
29 | 0.0, 0.5, 0.75, 1, 1.5, 2, 3, 5, 12.5, 25, 50, and 150
30 | pM.
31 |
32 | For more information see Irizarry, R.A., et al. (2001)
33 | \url{http://biosun01.biostat.jhsph.edu/~ririzarr/papers/index.html}}
34 | \keyword{datasets}
35 |
--------------------------------------------------------------------------------
/man/ppsetApply.Rd:
--------------------------------------------------------------------------------
1 | \name{ppsetApply}
2 | \alias{ppsetApply}
3 | \alias{ppset.ttest}
4 | \title{ Apply a function over the ProbeSets in an AffyBatch }
5 | \description{
6 | Apply a function over the ProbeSets in an AffyBatch
7 | }
8 | \usage{
9 | ppsetApply(abatch, FUN, genenames = NULL, ...)
10 |
11 | ppset.ttest(ppset, covariate, pmcorrect.fun = pmcorrect.pmonly, ...)
12 | }
13 | \arguments{
14 | \item{abatch}{an object inheriting from \code{AffyBatch}.}
15 | \item{ppset}{an object of class \code{ProbeSet}.}
16 | \item{covariate}{the name a covariate in the slot \code{phenoData}.}
17 | \item{pmcorrect.fun}{a function to correct PM intensities.}
18 | \item{FUN}{a function working on a \code{ProbeSet}.}
19 | \item{genenames}{a list of Affymetrix probesets ids to work with. All
20 | probe set ids used when \code{NULL}.}
21 | \item{\dots}{optional parameters to the function \code{FUN}.}
22 | }
23 | \value{
24 | Returns a \code{list} of objects, or values, as returned by the
25 | function \code{FUN} for each \code{ProbeSet} it processes.
26 | }
27 | \author{Laurent Gautier }
28 | \seealso{\code{\link[affy]{ProbeSet-class}} }
29 | \examples{
30 | ppset.ttest <- function(ppset, covariate, pmcorrect.fun = pmcorrect.pmonly, ...) {
31 | probes <- do.call("pmcorrect.fun", list(ppset))
32 | my.ttest <- function(x) {
33 | y <- split(x, get(covariate))
34 | t.test(y[[1]], y[[2]])$p.value
35 | }
36 | r <- apply(probes, 1, my.ttest)
37 | return(r)
38 | }
39 | ##this takes a long time - and rowttests is a good alternative
40 | ## eg: rt = rowttests(exprs(Dilution), Dilution$liver)
41 | \dontrun{
42 | data(Dilution)
43 | all.ttest <- ppsetApply(Dilution, ppset.ttest, covariate="liver")
44 | }
45 | }
46 | \keyword{ manip }
47 |
--------------------------------------------------------------------------------
/man/generateExprVal-methods.Rd:
--------------------------------------------------------------------------------
1 | \name{generateExprVal}
2 | \alias{express.summary.stat}
3 | \alias{express.summary.stat-methods}
4 | \alias{express.summary.stat.methods}
5 | \alias{upDate.express.summary.stat.methods}
6 | \title{Compute a summary expression value from the probes intensities}
7 | \description{
8 | Compute a summary expression value from the probes intensities
9 | }
10 | \usage{
11 | express.summary.stat(x, pmcorrect, summary, ...)
12 | express.summary.stat.methods() # vector of names of methods
13 | upDate.express.summary.stat.methods(x)
14 | }
15 | \arguments{
16 | \item{x}{a (\code{ProbeSet}}
17 | \item{pmcorrect}{the method used to correct the PM values before
18 | summarizing to an expression value.}
19 | \item{summary}{the method used to generate the expression value.}
20 | \item{\dots}{other parameters the method might need... (see the
21 | corresponding methods below...)}
22 | }
23 | \value{
24 | Returns a vector of expression values.
25 | }
26 | \examples{
27 | if (require(affydata)) {
28 | data(Dilution)
29 |
30 | p <- probeset(Dilution, "1001_at")[[1]]
31 |
32 | par(mfcol=c(5,2))
33 | mymethods <- express.summary.stat.methods()
34 | nmet <- length(mymethods)
35 | nc <- ncol(pm(p))
36 |
37 | layout(matrix(c(1:nc, rep(nc+1, nc)), nc, 2), width = c(1, 1))
38 |
39 | barplot(p)
40 |
41 | results <- matrix(0, nc, nmet)
42 | rownames(results) <- paste("sample", 1:nc)
43 | colnames(results) <- mymethods
44 |
45 | for (i in 1:nmet) {
46 | ev <- express.summary.stat(p, summary=mymethods[i], pmcorrect="pmonly")
47 | if (mymethods[[i]] != "medianpolish")
48 | results[, i] <- 2^(ev$exprs)
49 | else
50 | results[, i] <- ev$exprs
51 | }
52 |
53 | dotchart(results, labels=paste("sample", 1:nc))
54 | }
55 | }
56 | \keyword{manip}
57 |
--------------------------------------------------------------------------------
/man/normalize.quantiles.Rd:
--------------------------------------------------------------------------------
1 | \name{normalize.quantiles}
2 | \alias{normalize.AffyBatch.quantiles}
3 | \title{Quantile Normalization}
4 | \description{
5 | Using a normalization based upon quantiles, this function
6 | normalizes a matrix of probe level intensities.
7 | }
8 | \usage{
9 | normalize.AffyBatch.quantiles(abatch, type=c("separate","pmonly","mmonly","together"))
10 | }
11 | \arguments{
12 | \item{abatch}{an \code{\link[affy:AffyBatch-class]{AffyBatch}} object.}
13 | \item{type}{A string specifying how the normalization should be
14 | applied. See details for more.}
15 | }
16 | \details{This method is based upon the concept of a quantile-quantile
17 | plot extended to n dimensions. No special allowances are made for
18 | outliers. If you make use of quantile normalization either through
19 | \code{\link{rma}} or \code{\link{expresso}}
20 | please cite Bolstad et al, Bioinformatics (2003).
21 |
22 | The type argument should be one of
23 | \code{"separate","pmonly","mmonly","together"} which indicates whether
24 | to normalize only one probe type (PM,MM) or both together or separately.
25 | }
26 |
27 | \value{
28 | A normalized \code{AffyBatch}.
29 | }
30 | \references{
31 | Bolstad, B (2001) \emph{Probe Level Quantile Normalization of High Density
32 | Oligonucleotide Array Data}. Unpublished manuscript
33 | \url{http://bmbolstad.com/stuff/qnorm.pdf}
34 |
35 | Bolstad, B. M., Irizarry R. A., Astrand, M, and Speed, T. P. (2003)
36 | \emph{A Comparison of Normalization Methods for High Density
37 | Oligonucleotide Array Data Based on Bias and Variance.}
38 | Bioinformatics 19(2) ,pp 185-193. \url{http://bmbolstad.com/misc/normalize/normalize.html}
39 | }
40 | \author{Ben Bolstad, \email{bmbolstad.com}}
41 | \seealso{\code{\link{normalize}}}
42 | \keyword{manip}
43 |
--------------------------------------------------------------------------------
/man/affy-options.Rd:
--------------------------------------------------------------------------------
1 | \name{affy-options}
2 | \alias{affy-options}
3 | \title{Options for the affy package}
4 | \description{
5 | Description of the options for the affy package.
6 | }
7 | \note{
8 | The affy package options are contained in the Bioconductor options.
9 | The options are:
10 | \itemize{
11 | \item \code{use.widgets}: a logical used to decide on the default of
12 | widget use.
13 | \item \code{compress.cel}: a logical
14 | \item \code{compress.cdf}: a logical
15 | \item \code{probes.loc}: a list. Each element of the list is it self a
16 | list with two elements \emph{what} and \emph{where}. When looking for
17 | the informations about the locations of the probes on the array, the
18 | elements in the list will be looked at one after the other. The first
19 | one for which \emph{what} and \emph{where} lead to the matching
20 | locations information is used. The element \emph{what} can be one of
21 | \emph{package}, \emph{environment} or \emph{file}. The element \emph{where}
22 | depends on the corresponding element \emph{what}.
23 | \itemize{
24 | \item if \emph{package}: location for the package (like it would be for
25 | the argument \code{lib.loc} for the function \code{library}.)
26 | \item if \emph{environment}: an \code{environment} to look for the
27 | information (like the argument \code{env} for the function \code{get}).
28 | \item if \emph{file}: a \code{character} with the path in which a CDF
29 | file can be found.
30 | }
31 | }
32 | }
33 | \examples{
34 | ## get the options
35 | opt <- getOption("BioC")
36 | affy.opt <- opt$affy
37 |
38 | ## list their names
39 | names(affy.opt)
40 |
41 | ## set the option compress.cel
42 | affy.opt$compress.cel <- TRUE
43 | options(BioC=opt)
44 | }
45 | \keyword{manip}
46 |
--------------------------------------------------------------------------------
/man/read.probematrix.Rd:
--------------------------------------------------------------------------------
1 | \name{read.probematrix}
2 | \alias{read.probematrix}
3 | \title{Read CEL file data into PM or MM matrices}
4 | \description{
5 | Read CEL data into matrices.
6 | }
7 | \usage{
8 | read.probematrix(..., filenames = character(0),
9 | phenoData = new("AnnotatedDataFrame"),
10 | description = NULL,
11 | notes = "",
12 | compress = getOption("BioC")$affy$compress.cel,
13 | rm.mask = FALSE, rm.outliers = FALSE, rm.extra = FALSE,
14 | verbose = FALSE, which = "pm", cdfname = NULL)
15 | }
16 | \arguments{
17 | \item{\dots}{file names separated by comma.}
18 | \item{filenames}{file names in a character vector.}
19 | \item{phenoData}{a \code{\link[Biobase:class.AnnotatedDataFrame]{AnnotatedDataFrame}}
20 | object.}
21 | \item{description}{a \code{\link[Biobase:class.MIAME]{MIAME}} object.}
22 | \item{notes}{notes.}
23 | \item{compress}{are the CEL files compressed?}
24 | \item{rm.mask}{should the spots marked as 'MASKS' set to \code{NA}?}
25 | \item{rm.outliers}{should the spots marked as 'OUTLIERS' set to \code{NA}?}
26 | \item{rm.extra}{if \code{TRUE}, overrides what is in \code{rm.mask} and
27 | \code{rm.oultiers}.}
28 | \item{verbose}{verbosity flag.}
29 | \item{which}{should be either "pm", "mm" or "both".}
30 | \item{cdfname}{Used to specify the name of an alternative cdf package.
31 | If set to \code{NULL}, the usual cdf package based on Affymetrix's
32 | mappings will be used.}
33 | }
34 | \value{
35 | A list of one or two matrices. Each matrix is either PM or MM data. No
36 | \code{\link[affy:AffyBatch-class]{AffyBatch}} is created.
37 | }
38 | \author{Ben Bolstad \email{bmb@bmbolstad.com}}
39 | \seealso{\code{\link[affy:AffyBatch-class]{AffyBatch}},
40 | \code{\link[affy:read.affybatch]{read.affybatch}}}
41 | \keyword{manip}
42 |
--------------------------------------------------------------------------------
/man/pairs.AffyBatch.Rd:
--------------------------------------------------------------------------------
1 | \name{pairs.AffyBatch}
2 | \alias{pairs.AffyBatch}
3 | \title{plot intensities using 'pairs'}
4 | \description{
5 | Plot intensities using the function 'pairs'
6 | }
7 | \usage{
8 | \method{pairs}{AffyBatch}(x, panel=points, ..., transfo=I, main=NULL, oma=NULL,
9 | font.main = par("font.main"),
10 | cex.main = par("cex.main"), cex.labels = NULL,
11 | lower.panel=panel, upper.panel=NULL, diag.panel=NULL,
12 | font.labels = 1, row1attop = TRUE, gap = 1)
13 | }
14 | \arguments{
15 | \item{x}{an \code{\link[affy:AffyBatch-class]{AffyBatch}} object.}
16 | \item{panel}{a function to produce a plot (see \code{\link{pairs}}).}
17 | \item{\dots}{extra parameters for the 'panel' function.}
18 | \item{transfo}{a function to transform the intensity values before
19 | generating the plot. 'log' and 'log2' are popular choices.}
20 | \item{main}{title for the plot}
21 | \item{oma}{see 'oma' in \code{\link{par}}.}
22 | \item{font.main}{see \code{\link{pairs}}.}
23 | \item{cex.main}{see \code{\link{pairs}}.}
24 | \item{cex.labels}{see \code{\link{pairs}}.}
25 | \item{lower.panel}{a function to produce the plots in the lower
26 | triangle (see \code{\link{pairs}}).}
27 | \item{upper.panel}{a function to produce the plots in the upper
28 | triangle (see \code{\link{pairs}}).}
29 | \item{diag.panel}{a function to produce the plots in the diagonal
30 | (see \code{\link{pairs}}).}
31 | \item{font.labels}{see \code{\link{pairs}}.}
32 | \item{row1attop}{see \code{\link{pairs}}.}
33 | \item{gap}{see \code{\link{pairs}}.}
34 | }
35 | \details{
36 | Plots with several chips can represent zillions of points. They require
37 | a lot of memory and can be very slow to be displayed. You may want to
38 | try to split of the plots, or to plot them in a device like 'png' or
39 | 'jpeg'.
40 | }
41 | \keyword{hplot}
42 |
--------------------------------------------------------------------------------
/man/mas5.Rd:
--------------------------------------------------------------------------------
1 | \name{mas5}
2 | \alias{mas5}
3 | \title{MAS 5.0 expression measure}
4 | \description{
5 | This function converts an instance of \code{\link{AffyBatch}}
6 | into an instance of \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}} using
7 | our implementation of Affymetrix's MAS 5.0 expression measure.
8 | }
9 | \usage{
10 | mas5(object, normalize = TRUE, sc = 500, analysis = "absolute", ...)
11 | }
12 | \arguments{
13 | \item{object}{an instance of \code{\link{AffyBatch}}}
14 | \item{normalize}{logical. If \code{TRUE} scale normalization is used
15 | after we obtain an instance of \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}}}
16 | \item{sc}{Value at which all arrays will be scaled to.}
17 | \item{analysis}{should we do absolute or comparison analysis, although
18 | "comparison" is still not implemented.}
19 | \item{\dots}{other arguments to be passed to \code{\link{expresso}}.}
20 | }
21 | \details{
22 | This function is a wrapper for \code{\link{expresso}} and
23 | \code{\link{affy.scalevalue.exprSet}}.}
24 | \value{
25 | \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}}
26 |
27 | The methods used by this function were implemented based upon available
28 | documentation. In particular a useful reference is Statistical Algorithms
29 | Description Document by Affymetrix.
30 | Our implementation is based on what is written in the documentation and, as
31 | you might appreciate, there are places where the documentation is less than
32 | clear. This function does not give exactly the same results.
33 | All source code of our implementation is available. You are free to
34 | read it and suggest fixes.
35 |
36 | For more information visit this URL:
37 | \url{http://stat-www.berkeley.edu/users/bolstad/}
38 | }
39 | \seealso{\code{\link{expresso}},\code{\link{affy.scalevalue.exprSet}}}
40 | \examples{
41 | if (require(affydata)) {
42 | data(Dilution)
43 | eset <- mas5(Dilution)
44 | }
45 | }
46 | \keyword{manip}
47 |
--------------------------------------------------------------------------------
/changelog:
--------------------------------------------------------------------------------
1 | ###ask laurent: whats wrong with CDF.example
2 | ----> For some (mysterious) reasons, save(..., ascii=TRUE) is behaving wrong on my linux box
3 | at home. I saved it with ascii=FALSE (portability could be .....) LG
4 | ###why not have a slot in cel.container denoting the default Cdf
5 | ###then change all functions so that one does not need to pass Cdf
6 | ###with this and some methods we maybe able to get rid of Plobs entirely
7 | ###maybe this is a version 2.0 task.
8 | ----> Yep... mentioned in the file TODO for some time now...
9 |
10 |
11 | Yo, Laurentz takin' the mike now:
12 |
13 | - fixed a problem with CDF.example.RData
14 | - updated the documentation for the normalize functions
15 | (should keep 'R CMD check happy')
16 | - introduced a generic method 'normalize.methods' (Plob and Cel.container)
17 | - variables related to normalize.methods (normalize.Cel.container.methods and
18 | normalize.Plob.methods) are created.
19 | - changed the methods names 'normalize.Cel.XYZ' to 'normalize.Cel.container.XYZ'
20 | (more consistent). Documentation shoudlhave been updated accordingly.
21 | - removed image.Cel.Rd
22 | - fixed the method image for Cel-class. Added better ways of asking the function
23 | to mask areas. updated the documentation accordingly.
24 | - did a bit more with affy.Rnw (in inst/doc/). Now it goes through Sweave ok.
25 | - update the file 'TODO'
26 |
27 |
28 |
29 | still talkin'...:
30 |
31 | - cleaned read_cdffile.c (no more warnings)
32 | - made something usable for the documentation of 'normalize' (hopefully)
33 | - various fixes in the documentation
34 | - Did a bit more with affy.Rnw
35 | - the example in generateExprSet-methods.Rd is commented out... seems to work
36 | on the command line but fails through 'R CMD check' (??!?!!!?)
37 | - the 'normalize' part being done (apart of possible bugs), we reached the version
38 | number 0.8.0
39 | - started to finish the part about generateExprSet
40 |
41 | - accessor function sd in Cel moved to spotsd
42 |
43 |
44 |
--------------------------------------------------------------------------------
/man/ProbeSet-class.Rd:
--------------------------------------------------------------------------------
1 | \name{ProbeSet-class}
2 | \docType{class}
3 | \alias{ProbeSet-class}
4 | \alias{mm,ProbeSet-method}
5 | \alias{mm<-,ProbeSet,matrix-method}
6 | \alias{pm<-,ProbeSet,matrix-method}
7 | \alias{pm,ProbeSet-method}
8 | \alias{show,ProbeSet-method}
9 | \alias{barplot,ProbeSet-method}
10 | \alias{colnames,ProbeSet-method}
11 | \alias{express.summary.stat,ProbeSet,character,character-method}
12 | \alias{sampleNames,ProbeSet-method}
13 | \title{Class ProbeSet}
14 | \description{A simple class that contains the PM and MM data for a probe
15 | set from one or more samples.}
16 | \section{Objects from the Class}{
17 | Objects can be created by applying the method \code{\link{probeset}} to
18 | instances of AffyBatch.}
19 | \section{Slots}{
20 | \describe{
21 | \item{\code{id}:}{Object of class \code{"character"} containing the
22 | probeset ID.}
23 | \item{\code{pm}:}{Object of class \code{"matrix"} containing the PM
24 | intensities. Columns represent samples and rows the different probes.}
25 | \item{\code{mm}:}{Object of class \code{"matrix"} containing the MM
26 | intensities.}
27 | }
28 | }
29 | \section{Methods}{
30 | \describe{
31 | \item{colnames}{\code{signature(x = "ProbeSet")}: the column names
32 | of the \code{pm} matrices which are the sample names}
33 | \item{express.summary.stat}{\code{signature(x = "ProbeSet",
34 | pmcorrect = "character", summary = "character")}: applies a summary
35 | statistic to the probe set.}
36 | \item{sampleNames}{\code{signature(object = "ProbeSet")}: the column names
37 | of the \code{pm} matrices which are the sample names.}
38 | }
39 | }
40 | \note{More details are contained in the vignette.}
41 | \seealso{\code{\link[affy:AffyBatch-class]{probeset}},
42 | \code{\link[affy]{AffyBatch-class}}}
43 | \examples{
44 | if (require(affydata)) {
45 | data(Dilution)
46 | ps <- probeset(Dilution, geneNames(Dilution)[1:2])
47 | names(ps)
48 | print(ps[[1]])
49 | }
50 | }
51 | \keyword{classes}
52 |
--------------------------------------------------------------------------------
/man/MAplot.Rd:
--------------------------------------------------------------------------------
1 | \name{MAplot}
2 | \alias{ma.plot}
3 | \alias{Mbox}
4 | \alias{MAplot}
5 | \alias{Mbox,AffyBatch-method}
6 | \alias{MAplot,AffyBatch-method}
7 |
8 | \title{Relative M vs. A plots}
9 | \description{
10 | Create boxplots of M or M vs A plots. Where M is determined relative
11 | to a specified chip or to a pseudo-median reference chip.
12 | }
13 | \usage{
14 | MAplot(object,...)
15 | Mbox(object,...)
16 | ma.plot(A, M, subset = sample(1:length(M), min(c(10000, length(M)))),
17 | show.statistics = TRUE, span = 2/3, family.loess = "gaussian",
18 | cex = 2, plot.method = c("normal","smoothScatter","add"),
19 | add.loess = TRUE, lwd = 1, lty = 1, loess.col = "red", ...)
20 | }
21 | \arguments{
22 | \item{object}{an \code{\link[affy]{AffyBatch-class}}.}
23 | \item{\dots}{additional parameters for the routine.}
24 | \item{A}{a vector to plot along the horizontal axis.}
25 | \item{M}{a vector to plot along vertical axis.}
26 | \item{subset}{a set of indices to use when drawing the loess curve.}
27 | \item{show.statistics}{logical. If TRUE, some summary statistics of the M
28 | values are drawn.}
29 | \item{span}{span to be used for loess fit.}
30 | \item{family.loess}{\code{"guassian"} or \code{"symmetric"} as in
31 | \code{\link[stats]{loess}}.}
32 | \item{cex}{size of text when writing summary statistics on plot.}
33 | \item{plot.method}{a string specifying how the plot is to be drawn.
34 | \code{"normal"} plots points, \code{"smoothScatter"} uses the
35 | \code{\link[graphics]{smoothScatter}} function. Specifying
36 | \code{"add"} means that the MAplot should be added to the current plot.}
37 | \item{add.loess}{add a loess line to the plot.}
38 | \item{lwd}{width of loess line.}
39 | \item{lty}{line type for loess line.}
40 | \item{loess.col}{color for loess line.}
41 | }
42 | \examples{
43 | if (require(affydata)) {
44 | data(Dilution)
45 | MAplot(Dilution)
46 | Mbox(Dilution)
47 | }
48 | }
49 | \seealso{\code{\link[affy]{mva.pairs}}}
50 | \keyword{hplot}
51 |
--------------------------------------------------------------------------------
/R/summary.R:
--------------------------------------------------------------------------------
1 | ###these are summary functions they take matrices of probes x chips
2 | ###and return expression and se (when applicable)
3 |
4 | ##DEBUG: appending the se to the expression values in a same vector
5 | ## is too much hackish (I think)... we need to think about something
6 | ## better
7 |
8 | avdiff <- function(x,constant=3){
9 | e <- apply(x,2,function(y){
10 | o <- order(y)
11 | yy <- y[-c(o[1],o[length(y)])] #take out biggest and smallest
12 | if(length(yy)<2) # SK, some genes have only one probe
13 | mean(y)
14 | else
15 | mean(y[abs(y-mean(yy)) pmbg]
21 | sig.data <- sig.data-pmbg
22 |
23 | expmean <- max.density(sig.data,n.pts)
24 | alpha <- 1/expmean
25 | mubg <- pmbg
26 | list(alpha=alpha,mu=mubg,sigma=bgsd)
27 | }
28 |
29 | bg.adjust <- function(pm, n.pts=2^14, ...){
30 | param <- bg.parameters(pm,n.pts)
31 | b <- param$sigma
32 | pm <- pm - param$mu - param$alpha*b^2
33 | pm + b*((1./sqrt(2*pi))*exp((-1./2.)*((pm/b)^2)))/pnorm(pm/b)
34 | }
35 |
36 | bg.correct.none <- function(object, ...)
37 | object
38 |
39 | ##bg.correct.subtractmm <- function(object){
40 | ## pm(object) <- pm(object) - mm(object)
41 | ## return(object)
42 | ##}
43 |
44 | ###bg.correct.rma <- function(object, ...){
45 | ### pm(object) <- apply(pm(object),2,bg.adjust)
46 | ### return(object)
47 | ##}
48 |
49 | ##
50 | ## this function calls the c code as an alternative to the R code above.
51 | ## it should help end the disagreement between rma() and expresso()
52 | ##
53 |
54 | bg.correct.rma <- function(object,...){
55 |
56 | pm(object) <- rma.background.correct(pm(object),copy=FALSE)
57 | return(object)
58 | }
59 |
60 | ## --- pmcorrect things
61 |
62 | pmcorrect.subtractmm <- function(object){
63 | pm.corrected <- pm(object) - mm(object)
64 | return(pm.corrected)
65 | }
66 |
67 | pmcorrect.pmonly <- function(object) {
68 | return(pm(object))
69 | }
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/man/generateExprVal.method.avgdiff.Rd:
--------------------------------------------------------------------------------
1 | \name{generateExprVal.method.avgdiff}
2 | \alias{generateExprVal.method.avgdiff}
3 | \alias{generateExprVal.method.medianpolish}
4 | \alias{generateExprVal.method.liwong}
5 | \alias{generateExprVal.method.mas}
6 |
7 | \title{Generate an expression value from the probes informations}
8 | \description{
9 | Generate an expression from the probes
10 | }
11 | \usage{
12 | generateExprVal.method.avgdiff(probes, ...)
13 | generateExprVal.method.medianpolish(probes, ...)
14 | generateExprVal.method.liwong(probes, ...)
15 | generateExprVal.method.mas(probes, ...)
16 | }
17 | \arguments{
18 | \item{probes}{a matrix of probe intensities with rows representing
19 | probes and columns representing samples. Usually \code{pm(probeset)}
20 | where \code{probeset} is a of class
21 | \code{\link[affy:ProbeSet-class]{ProbeSet}}.}
22 | \item{\dots}{extra arguments to pass to the respective function.}
23 | }
24 | \value{
25 | A list containing entries:
26 | \item{exprs}{The expression values.}
27 | \item{se.exprs}{The standard error estimate.}
28 | }
29 | \examples{
30 | data(SpikeIn) ##SpikeIn is a ProbeSets
31 | probes <- pm(SpikeIn)
32 | avgdiff <- generateExprVal.method.avgdiff(probes)
33 | medianpolish <- generateExprVal.method.medianpolish(probes)
34 | liwong <- generateExprVal.method.liwong(probes)
35 | playerout <- generateExprVal.method.playerout(probes)
36 | mas <- generateExprVal.method.mas(probes)
37 |
38 | concentrations <- as.numeric(sampleNames(SpikeIn))
39 | plot(concentrations,avgdiff$exprs,log="xy",ylim=c(50,10000),pch="a",type="b")
40 | points(concentrations,2^medianpolish$exprs,pch="m",col=2,type="b",lty=2)
41 | points(concentrations,liwong$exprs,pch="l",col=3,type="b",lty=3)
42 | points(concentrations,playerout$exprs,pch="p",col=4,type="b",lty=4)
43 | points(concentrations,mas$exprs,pch="p",col=4,type="b",lty=4)
44 | }
45 | \seealso{
46 | \code{\link[affy]{generateExprSet-methods}},
47 | \code{\link[affy]{generateExprVal.method.playerout}},
48 | \code{\link[affy]{fit.li.wong}}
49 |
50 | }
51 |
52 | \keyword{manip}
53 |
--------------------------------------------------------------------------------
/man/normalize.loess.Rd:
--------------------------------------------------------------------------------
1 | \name{normalize.loess}
2 | \alias{normalize.loess}
3 | \alias{normalize.AffyBatch.loess}
4 | \title{Scale microarray data}
5 | \description{Normalizes arrays using loess.}
6 | \usage{
7 | normalize.loess(mat, subset = sample(1:(dim(mat)[1]), min(c(5000,
8 | nrow(mat)))), epsilon = 10^-2, maxit = 1, log.it =
9 | TRUE, verbose = TRUE, span = 2/3, family.loess =
10 | "symmetric")
11 | normalize.AffyBatch.loess(abatch,type=c("together","pmonly","mmonly","separate"), ...)
12 | }
13 | \arguments{
14 | \item{mat}{a matrix with columns containing the values of the chips
15 | to normalize.}
16 | \item{abatch}{an \code{\link[affy:AffyBatch-class]{AffyBatch}} object.}
17 | \item{subset}{a subset of the data to fit a loess to.}
18 | \item{epsilon}{a tolerance value (supposed to be a small value - used
19 | as a stopping criterion).}
20 | \item{maxit}{maximum number of iterations.}
21 | \item{log.it}{logical. If \code{TRUE} it takes the log2 of \code{mat}}
22 | \item{verbose}{logical. If \code{TRUE} displays current pair of chip being
23 | worked on.}
24 | \item{span}{parameter to be passed the function \code{\link[stats]{loess}}}
25 | \item{family.loess}{parameter to be passed the function
26 | \code{\link[stats]{loess}}. \code{"gaussian"} or \code{"symmetric"}
27 | are acceptable values for this parameter.}
28 | \item{type}{A string specifying how the normalization should be
29 | applied. See details for more.}
30 | \item{\dots}{any of the options of normalize.loess you would like to
31 | modify (described above).}
32 | }
33 | \details{
34 | The type argument should be one of
35 | \code{"separate","pmonly","mmonly","together"} which indicates whether
36 | to normalize only one probe type (PM,MM) or both together or separately.
37 | }
38 | \seealso{
39 | \code{\link{normalize}}
40 | }
41 | \examples{
42 | if (require(affydata)) {
43 | #data(Dilution)
44 | #x <- pm(Dilution[,1:3])
45 | #mva.pairs(x)
46 | #x <- normalize.loess(x,subset=1:nrow(x))
47 | #mva.pairs(x)
48 | }
49 | }
50 | \keyword{smooth}
51 |
--------------------------------------------------------------------------------
/R/xy2indices.R:
--------------------------------------------------------------------------------
1 | xy2indices <- function(x, y, nc=NULL, cel=NULL, abatch=NULL, cdf=NULL, xy.offset = NULL) {
2 |
3 | if ( is.null(xy.offset) ) {
4 | xy.offset <- getOption("BioC")$affy$xy.offset
5 | }
6 |
7 | if (any(x < xy.offset) || any(y < xy.offset))
8 | stop("Xs and Ys must start at 0 or 1 (please refer to the help file) !")
9 |
10 | ct <- sum(c(is.null(nc), is.null(cel), is.null(abatch), is.null(cdf)))
11 | if (ct != 3)
12 | stop("One and only one of 'nc', 'cel', 'abatch', 'cdf' should be specified.")
13 | if (! is.null(cel))
14 | stop("Cel class no longer supported") #nr <- nrow(intensity(cel))
15 | if (! is.null((abatch)))
16 | nc <- ncol(abatch)
17 | if(!is.null(cdf)){
18 | require(cdf, character.only = TRUE, quietly = TRUE) ||
19 | stop(paste(cdf, "package must be installed first"))
20 | nam <- paste(sub("cdf$", "", cdf), "dim", sep = "")
21 | nc <- get("NCOL", get(nam))
22 | }
23 |
24 | return( (x - xy.offset) + 1 + nc * (y - xy.offset) )
25 | }
26 |
27 |
28 | indices2xy <- function(i, nc=NULL, cel=NULL, abatch=NULL, cdf=NULL, xy.offset = NULL) {
29 |
30 | if ( is.null(xy.offset) ) {
31 | xy.offset <- getOption("BioC")$affy$xy.offset
32 | }
33 |
34 | if (any(i <= 0))
35 | stop("Indices must start at 0 or 1 (please refer to the help file) !")
36 |
37 | ct <- sum(c(is.null(nc), is.null(cel), is.null(abatch), is.null(cdf)))
38 |
39 | if (ct != 3)
40 | stop("One and only one of 'nc', 'cel', 'abatch', 'cdf' should be specified.")
41 | if (! is.null(cel))
42 | stop("Cel class no longer supported")# nr <- nrow(intensity(cel))
43 | if (! is.null((abatch)))
44 | nc <- ncol(abatch)
45 | if(!is.null(cdf)){
46 | require(cdf, character.only = TRUE, quietly = TRUE) ||
47 | stop(paste(cdf, "package must be installed first"))
48 | nam <- paste(sub("cdf$", "", cdf), "dim", sep = "")
49 | nc <- get("NCOL", get(nam))
50 | }
51 |
52 |
53 | ##x <- i %% nr
54 | ##x[x == 0] <- nr
55 | ##y <- (i - 1) %/% nr + 1
56 | x <- (i - 1) %% nc + xy.offset
57 | y <- (i - 1) %/% nc + xy.offset
58 | xy <- cbind(x, y)
59 | colnames(xy) <- c("x", "y")
60 | return(xy)
61 | }
62 |
--------------------------------------------------------------------------------
/man/AffyRNAdeg.Rd:
--------------------------------------------------------------------------------
1 | \name{AffyRNAdeg}
2 | \alias{AffyRNAdeg}
3 | \alias{summaryAffyRNAdeg}
4 | \alias{plotAffyRNAdeg}
5 | \title{Function to assess RNA degradation in Affymetrix GeneChip data.}
6 | \description{
7 | Uses ordered probes in probeset to detect possible RNA degradation.
8 | Plots and statistics used for evaluation.
9 | }
10 | \usage{
11 | AffyRNAdeg(abatch,log.it=TRUE)
12 | summaryAffyRNAdeg(rna.deg.obj,signif.digits=3)
13 | plotAffyRNAdeg(rna.deg.obj, transform = "shift.scale", cols = NULL, ...)
14 | }
15 | \arguments{
16 | \item{abatch}{An object of class \code{\link{AffyBatch-class}}.}
17 | \item{log.it}{A logical argument: If log.it=T, then probe data is log2
18 | transformed.}
19 | \item{rna.deg.obj}{Output from AffyRNAdeg.}
20 | \item{signif.digits}{Number of significant digits to show.}
21 | \item{transform}{Possible choices are "shift.scale","shift.only", and
22 | "neither". "Shift" vertically staggers the plots for individual chips,
23 | to make the display easier to read. "Scale" normalizes so that standard
24 | deviation is equal to 1.}
25 | \item{cols}{A vector of colors for plot, length = number of chips.}
26 | \item{\dots}{further arguments for \code{\link{plot}} function.}
27 | }
28 | \details{Within each probeset, probes are numbered directionally from
29 | the 5' end to the 3' end. Probe intensities are averaged by probe
30 | number, across all genes. If log.it=\code{FALSE} and transform="Neither",
31 | then plotAffyRNAdeg simply shows these means for each chip. Shifted and
32 | scaled versions of the plot can make it easier to see.
33 | }
34 | \value{
35 | \code{AffyRNAdeg} returns a list with the following components:
36 | \item{sample.names }{names of samples, derived from affy batch object}
37 | \item{means.by.number}{average intensity by probe position}
38 | \item{ses}{standard errors for probe position averages}
39 | \item{slope}{from linear regression of means.by.number}
40 | \item{pvalue}{from linear regression of means.by.number}
41 | }
42 | \examples{
43 | if (require(affydata)) {
44 | data(Dilution)
45 | RNAdeg<-AffyRNAdeg(Dilution)
46 | plotAffyRNAdeg(RNAdeg)
47 | }
48 | }
49 | \author{Leslie Cope}
50 | \keyword{hplot}
51 | \keyword{manip}
52 |
--------------------------------------------------------------------------------
/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Package: affy
2 | Version: 1.79.3
3 | Title: Methods for Affymetrix Oligonucleotide Arrays
4 | Author: Rafael A. Irizarry , Laurent Gautier
5 | , Benjamin Milo Bolstad
6 | , and Crispin Miller
7 | with contributions from Magnus
8 | Astrand , Leslie M. Cope
9 | , Robert Gentleman, Jeff Gentry, Conrad
10 | Halling , Wolfgang Huber, James
11 | MacDonald , Benjamin I. P. Rubinstein,
12 | Christopher Workman , John Zhang
13 | Maintainer: Robert D. Shear
14 | URL: https://github.com/rafalab/affy
15 | BugReports: https://github.com/rafalab/affy/issues
16 | Depends: R (>= 2.8.0), BiocGenerics (>= 0.1.12), Biobase (>= 2.5.5)
17 | Imports: affyio (>= 1.13.3),
18 | BiocManager, graphics, grDevices, methods, preprocessCore,
19 | stats, utils, zlibbioc
20 | Suggests: tkWidgets (>= 1.19.0), affydata, widgetTools, hgu95av2cdf
21 | LinkingTo: preprocessCore
22 | Description: The package contains functions for exploratory
23 | oligonucleotide array analysis. The dependence on tkWidgets
24 | only concerns few convenience functions. 'affy' is fully
25 | functional without it.
26 | License: LGPL (>= 2.0)
27 | Collate: ProgressBarText.R ppset.ttest.R ppsetApply.R expressoWidget.R
28 | getCDFenv.R AffyRNAdeg.R avdiff.R barplot.ProbeSet.R
29 | bg.Affy.chipwide.R bg.R expresso.R fit.li.wong.R
30 | generateExprVal.method.avgdiff.R
31 | generateExprVal.method.liwong.R generateExprVal.method.mas.R
32 | generateExprVal.method.medianpolish.R
33 | generateExprVal.method.playerout.R hlog.R justrma.R
34 | loess.normalize.R maffy.R mas5.R merge.AffyBatch.R
35 | normalize.constant.R normalize.contrasts.R
36 | normalize.invariantset.R normalize.loess.R normalize.qspline.R
37 | normalize.quantiles.R pairs.AffyBatch.R plot.density.R
38 | plotLocation.R plot.ProbeSet.R pmcorrect.mas.R AffyBatch.R
39 | mva.pairs.R ProbeSet.R read.affybatch.R rma.R summary.R
40 | tukey.biweight.R whatcdf.R xy2indices.R zzz.R
41 | biocViews: Microarray, OneChannel, Preprocessing
42 | LazyLoad: yes
43 |
--------------------------------------------------------------------------------
/man/expressoWidget.Rd:
--------------------------------------------------------------------------------
1 | \name{expressoWidget}
2 | \alias{expressoWidget}
3 | \title{A widget for users to pick correction methods}
4 | \description{
5 | This widget is called by expresso to allow users to select
6 | correction methods that will be used to process affy data.
7 | }
8 | \usage{
9 | expressoWidget(BGMethods, normMethods, PMMethods, expMethods, BGDefault,
10 | normDefault, PMDefault, expDefault)
11 | }
12 | \arguments{
13 | \item{BGMethods}{a vector of character strings for the available methods
14 | that can be used as a background correction method of affy data.}
15 | \item{normMethods}{a vector of character strings for the available methods
16 | that can be used as a normalization method of affy data.}
17 | \item{PMMethods}{a vector of character strings for the available methods
18 | that can be used as a PM correction method of affy data.}
19 | \item{expMethods}{a vector of character strings for the available methods
20 | that can be used as a summary method of affy data.}
21 | \item{BGDefault}{a character string for the name of a default background
22 | correction method.}
23 | \item{normDefault}{a character string for the name of a default
24 | normalization method.}
25 | \item{PMDefault}{a character string for the name of a default PM correction
26 | method.}
27 | \item{expDefault}{a character string for the name of a default summary
28 | method.}
29 | }
30 | \details{
31 | The widget will be invoked when expresso is called with argument
32 | "widget" set to TRUE. Default values can be changed using the drop
33 | down list boxes. Double clicking on an option from the drop-down list
34 | makes an selection. The first element of the list for available methods
35 | will be the default method if no default is provided.
36 | }
37 | \value{
38 | The widget returns a list of selected correction methods.
39 | \item{BG}{background correction method}
40 | \item{NORM}{normalization method}
41 | \item{PM}{PM correction method}
42 | \item{EXP}{summary method}
43 | }
44 | \references{Documentations of affy package}
45 | \author{Jianhua Zhang}
46 |
47 | \seealso{\code{\link{expresso}}}
48 | \examples{
49 | if(interactive()){
50 | require(widgetTools)
51 | expressoWidget(c("mas", "none", "rma"), c("constant", "quantiles"),
52 | c("mas", "pmonly"), c("liwong", "playerout"))
53 | }
54 | }
55 | \keyword{interface}
56 |
--------------------------------------------------------------------------------
/R/rma.R:
--------------------------------------------------------------------------------
1 | ######################################################
2 | #
3 | # rma - RMA interface to c code
4 | #
5 | # the RMA method implemented in c code
6 | #
7 | # this code serves as interface to the c code.
8 | # currently
9 | # implemented (version 0.25) background correction
10 | #
11 | # Background correction code has been added.
12 | #
13 | # note this function does not leave the supplied
14 | # AffyBatch unchanged if you select DESTRUCTIVE=TRUE. this is
15 | # for memory purposes but can be quite
16 | # dangerous if you are not careful. Use destructive=FALSE if this is
17 | # deemed likely to be a problem.
18 | #
19 | # UPDATE: note that the affybatch is now not affected if you use
20 | # destructive=TRUE and you might actually save a little memory.
21 | # the destructive refers only to Plobs, which would be destroyed.
22 | #
23 | # History
24 | #
25 | # Feb 22, 2004 - activated subset. In is now possible to
26 | # do the entire RMA procedure using a subset of probesets
27 | #
28 | # Oct 26, 2007 = makesure verbosity flag is correctly passed down to C-level routines
29 | #
30 | # Oct 28, 2007 MM are no longer passed to the C code
31 | #
32 | # Jul 2, 2008 - change how probeNames (which is really probe/row indexing) is passed down to
33 | # c code
34 | #
35 | #
36 | ########################################################
37 |
38 | rma <- function(object,subset=NULL, verbose=TRUE, destructive = TRUE,normalize=TRUE,background=TRUE,bgversion=2,...){
39 |
40 | rows <- length(probeNames(object,subset))
41 | cols <- length(object)
42 |
43 | if (is.null(subset)){
44 | ngenes <- length(geneNames(object))
45 | } else {
46 | ngenes <- length(subset)
47 | }
48 |
49 | pNList <- probeNames(object,subset)
50 | pNList <- split(0:(length(pNList) -1), pNList)
51 |
52 | if (destructive){
53 | exprs <-
54 | .Call("rma_c_complete",pm(object,subset), pNList, ngenes, normalize, background, bgversion, verbose, PACKAGE="affy")
55 | } else {
56 | exprs <-
57 | .Call("rma_c_complete_copy", pm(object,subset), pNList, ngenes, normalize, background, bgversion, verbose, PACKAGE="affy")
58 | }
59 | colnames(exprs) <- sampleNames(object)
60 |
61 | new("ExpressionSet",
62 | phenoData = phenoData(object),
63 | annotation = annotation(object),
64 | protocolData = protocolData(object),
65 | experimentData = experimentData(object),
66 | exprs = exprs)
67 | }
68 |
--------------------------------------------------------------------------------
/man/bgc.Rd:
--------------------------------------------------------------------------------
1 | \name{bg.correct}
2 | \alias{bg.correct}
3 | \alias{bg.correct.none} %took out .pmonly casue rma is pm-only
4 | %\alias{bg.correct.subtractmm}
5 | \alias{bg.correct.rma}
6 | \alias{bg.correct.mas}
7 | \title{Background Correction}
8 | \description{
9 | Background corrects probe intensities in an object of class
10 | \code{\link[affy:AffyBatch-class]{AffyBatch}}.
11 | }
12 | \usage{
13 | bg.correct(object, method, ...)
14 |
15 | bg.correct.rma(object,...)
16 | bg.correct.mas(object, griddim)
17 | bg.correct.none(object, ...)
18 | }
19 | \arguments{
20 | \item{object}{An object of class \code{\link[affy:AffyBatch-class]{AffyBatch}}.}
21 | \item{method}{A \code{character} that defines what background
22 | correction method will be used. Available methods are given by
23 | \code{bg.correct.methods}.}
24 | \item{griddim}{grid dimension used for mas background estimate. The array
25 | is divided into griddim equal parts. Default is 16.}
26 | \item{\dots}{arguments to pass along to the engine function.}
27 | }
28 | \details{
29 | The name of the method to apply must be double-quoted.
30 | Methods provided with the package are currently:
31 | \itemize{
32 | \item bg.correct.none: returns \code{object} unchanged.
33 | \item bg.correct.chipwide: noise correction as described in a
34 | `white paper' from Affymetrix.
35 | \item bg.correct.rma: the model based correction used by the RMA
36 | expression measure.
37 | }
38 |
39 | They are listed in the variable \code{bg.correct.methods}. The user must
40 | supply the word after "bg.correct", i.e none, subtractmm, rma, etc...
41 |
42 | More details are available in the vignette.
43 |
44 | R implementations similar in function to the internal implementation used by
45 | \code{bg.correct.rma} are in \code{\link{bg.adjust}}.
46 | }
47 | \value{
48 | An \code{\link[affy:AffyBatch-class]{AffyBatch}} for which the
49 | intensities have been background adjusted.
50 | For some methods (RMA), only PMs are corrected and the MMs remain the
51 | same.
52 | }
53 | \examples{
54 | if (require(affydata)) {
55 | data(Dilution)
56 |
57 | ##bgc will be the bg corrected version of Dilution
58 | bgc <- bg.correct(Dilution, method="rma")
59 |
60 | ##This plot shows the tranformation
61 | plot(pm(Dilution)[,1],pm(bgc)[,1],log="xy",
62 | main="PMs before and after background correction")
63 | }
64 | }
65 | \keyword{manip}
66 |
--------------------------------------------------------------------------------
/man/generateExprSet-methods.Rd:
--------------------------------------------------------------------------------
1 | \name{generateExprSet-method}
2 | \docType{methods}
3 | \alias{generateExprSet-methods}
4 | \alias{computeExprSet}
5 | \alias{generateExprSet.methods}
6 | \alias{upDate.generateExprSet.methods}
7 | \title{generate a set of expression values}
8 | \description{
9 | Generate a set of expression values from the probe pair
10 | information. The set of expression is returned as an
11 | \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}} object.
12 | }
13 | \usage{
14 | computeExprSet(x, pmcorrect.method, summary.method, ...)
15 |
16 | generateExprSet.methods()
17 |
18 | upDate.generateExprSet.methods(x)
19 | }
20 | \arguments{
21 | \item{x}{a \code{\link[=AffyBatch-class]{AffyBatch}} holding the probe level
22 | informations to generate the expression values, for computeExprSet,
23 | and for upDate.generateExprSet.methods it is a character vector..}
24 | \item{pmcorrect.method}{the method used to correct PM values (see
25 | section 'details').}
26 | \item{summary.method}{the method used to generate the expression value (see
27 | section 'details').}
28 | \item{\dots}{any of the options of the normalization you would like to
29 | modify.}
30 | }
31 | \details{
32 | An extra argument \code{ids=} can be passed. It must be a vector of
33 | affids. The expression values will only be computed and returned for
34 | these affyids.
35 |
36 | The different methods available through this mechanism can be accessed
37 | by calling the method \code{generateExprSet.methods} with an object of
38 | call \code{Cel.container} as an argument.
39 |
40 | In the Affymetrix design, \emph{MM} probes were included to measure
41 | the noise (or background signal). The original algorithm for
42 | background correction was to subtract the \emph{MM} signal to the
43 | \emph{PM} signal. The methods currently included in the package are
44 | "bg.correct.subtractmm", "bg.correct.pmonly" and "bg.correct.adjust".
45 |
46 | To alter the available methods for generating ExprSets use
47 | upDate.generateExprSet.methods.
48 | }
49 | \seealso{
50 | method \code{generateExprSet} of the class
51 | \code{\link[=AffyBatch-class]{AffyBatch}}\cr
52 | \code{\link{expresso}}
53 | }
54 | \examples{
55 | if (require(affydata)) {
56 | data(Dilution)
57 |
58 | ids <- c( "1000_at","1001_at")
59 |
60 | eset <- computeExprSet(Dilution, pmcorrect.method="pmonly",
61 | summary.method="avgdiff", ids=ids)
62 | }
63 | }
64 | \keyword{manip}
65 |
--------------------------------------------------------------------------------
/man/normalize.invariantset.Rd:
--------------------------------------------------------------------------------
1 | \name{normalize.invariantset}
2 | \alias{normalize.invariantset}
3 | \alias{normalize.AffyBatch.invariantset}
4 | \title{Invariant Set normalization}
5 | \description{
6 | Normalize arrays in an \code{\link[affy:AffyBatch-class]{AffyBatch}} using an
7 | invariant set.
8 | }
9 | \usage{
10 | normalize.AffyBatch.invariantset(abatch, prd.td = c(0.003, 0.007),
11 | verbose = FALSE,
12 | baseline.type = c("mean","median","pseudo-mean","pseudo-median"),
13 | type = c("separate","pmonly","mmonly","together"))
14 |
15 | normalize.invariantset(data, ref, prd.td=c(0.003,0.007))
16 | }
17 | \arguments{
18 | \item{abatch}{an \code{\link[affy:AffyBatch-class]{AffyBatch}} object.}
19 | \item{data}{a vector of intensities on a chip (to normalize to the reference).}
20 | \item{ref}{a vector of reference intensities.}
21 | \item{prd.td}{cutoff parameter (details in the bibliographic
22 | reference).}
23 | \item{baseline.type}{specifies how to determine the baseline array.}
24 | \item{type}{a string specifying how the normalization should be
25 | applied. See details for more.}
26 | \item{verbose}{logical indicating printing throughout the normalization.}
27 | }
28 | \value{
29 | Respectively a \code{\link[affy:AffyBatch-class]{AffyBatch}} of normalized
30 | objects, or a vector of normalized intensities, with an attribute
31 | "invariant.set" holding the indexes of the 'invariant' intensities.
32 | }
33 | \details{
34 | The set of invariant intensities between \code{data} and \code{ref} is
35 | found through an iterative process (based on the respective ranks the
36 | intensities). This set of intensities is used to generate a normalization
37 | curve by smoothing.
38 |
39 | The \code{type} argument should be one of
40 | \code{"separate","pmonly","mmonly","together"} which indicates whether
41 | to normalize only one probe type (PM,MM) or both together or separately.
42 | }
43 | \author{
44 | L. Gautier
45 | (Thanks to Cheng Li for the discussions about the algorithm.)
46 | }
47 | \references{
48 | Cheng Li and Wing Hung Wong, Model-based analysis of
49 | oligonucleotides arrays: model validation, design issues and
50 | standard error application. Genome Biology 2001, 2(8):research0032.1-0032.11
51 | }
52 | \seealso{
53 | \code{\link{normalize}} to normalize \code{\link[affy:AffyBatch-class]{AffyBatch}} objects.
54 | }
55 | \keyword{manip}
56 |
--------------------------------------------------------------------------------
/man/ProgressBarText-class.Rd:
--------------------------------------------------------------------------------
1 | \name{ProgressBarText-class}
2 | \docType{class}
3 | \alias{ProgressBarText-class}
4 | \alias{close,ProgressBarText-method}
5 | \alias{initialize,ProgressBarText-method}
6 | \alias{open,ProgressBarText-method}
7 | \alias{updateMe}
8 | \alias{updateMe,ProgressBarText-method}
9 | \title{Class "ProgressBarText" }
10 | \description{A class to handle progress bars in text mode.}
11 | \section{Objects from the Class}{
12 | Objects can be created by calls of the form \code{new("ProgressBarText", steps)}.
13 | }
14 | \section{Slots}{
15 | \describe{
16 | \item{\code{steps}:}{Object of class \code{"integer"}. The total number of
17 | steps the progress bar should represent.}
18 | \item{\code{barsteps}:}{Object of class \code{"integer"}. The size of the
19 | progress bar.}
20 | \item{\code{internals}:}{Object of class \code{"environment"}.
21 | For internal use.}
22 | }
23 | }
24 | \section{Methods}{
25 | \describe{
26 | \item{close}{\code{signature(con = "ProgressBarText")}: Terminate
27 | the progress bar (i.e. print what needs to be printed). Note that
28 | closing the instance will ensure the progress bar is plotted to
29 | its end.}
30 | \item{initialize}{\code{signature(.Object = "ProgressBarText")}:
31 | initialize a instance.}
32 | \item{open}{\code{signature(con = "ProgressBarText")}: Open a
33 | progress bar (i.e. print things). In the case open is called on
34 | a progress bar that was 'progress', the progress bar is resumed
35 | (this might be useful when one wishes to insert text output while
36 | there is a progress bar running).}
37 | \item{updateMe}{\code{signature(object = "ProgressBarText")}: Update
38 | the progress bar (see examples).}
39 | }
40 | }
41 | \author{ Laurent }
42 | \examples{
43 | f <- function(x, header = TRUE) {
44 | pbt <- new("ProgressBarText", length(x), barsteps = as.integer(20))
45 |
46 | open(pbt, header = header)
47 |
48 | for (i in x) {
49 | Sys.sleep(i)
50 | updateMe(pbt)
51 | }
52 | close(pbt)
53 | }
54 |
55 | ## if too fast on your machine, change the number
56 | x <- runif(15)
57 |
58 | f(x)
59 | f(x, header = FALSE)
60 |
61 | ## 'cost' of the progress bar:
62 | g <- function(x) {
63 | z <- 1
64 | for (i in 1:x) {
65 | z <- z + 1
66 | }
67 | }
68 | h <- function(x) {
69 | pbt <- new("ProgressBarText", as.integer(x), barsteps = as.integer(20))
70 | open(pbt)
71 | for (i in 1:x) {
72 | updateMe(pbt)
73 | }
74 | close(pbt)
75 | }
76 |
77 | system.time(g(10000))
78 | system.time(h(10000))
79 |
80 | }
81 | \keyword{classes}
82 |
--------------------------------------------------------------------------------
/man/normalize.quantiles.robust.Rd:
--------------------------------------------------------------------------------
1 | \name{normalize.quantiles.robust}
2 | \alias{normalize.AffyBatch.quantiles.robust}
3 | \title{Robust Quantile Normalization}
4 | \description{Using a normalization based upon quantiles, this function
5 | normalizes a matrix of probe level intensities. Allows weighting of chips}
6 | \usage{
7 | normalize.AffyBatch.quantiles.robust(abatch,
8 | type = c("separate","pmonly","mmonly","together"),
9 | weights = NULL,
10 | remove.extreme = c("variance","mean","both","none"),
11 | n.remove = 1, use.median = FALSE,
12 | use.log2 = FALSE)
13 | }
14 | \arguments{
15 | \item{abatch}{an \code{\link[affy:AffyBatch-class]{AffyBatch}} object.}
16 | \item{type}{a string specifying how the normalization should be applied.
17 | See details for more.}
18 | \item{weights}{a vector of weights, one for each chip.}
19 | \item{remove.extreme}{if weights is NULL, then this will be used for
20 | determining which chips to remove from the calculation of the
21 | normalization distribution. See details for more info.}
22 | \item{n.remove}{number of chips to remove.}
23 | \item{use.median}{if TRUE, the use the median to compute normalization
24 | chip; otherwise uses a weighted mean.}
25 | \item{use.log2}{work on log2 scale. This means we will be using the
26 | geometric mean rather than ordinary mean.}
27 | }
28 | \details{This method is based upon the concept of a quantile-quantile
29 | plot extended to n dimensions. Note that the matrix is of intensities
30 | not log intensities. The function performs better with raw
31 | intensities.
32 |
33 | Choosing \bold{variance} will remove chips with variances much higher
34 | or lower than the other chips, \bold{mean} removes chips with the mean
35 | most different from all the other means, \bold{both} removes first
36 | extreme variance and then an extreme mean. The option \bold{none} does
37 | not remove any chips, but will assign equal weights to all chips.
38 |
39 | The type argument should be one of
40 | \code{"separate","pmonly","mmonly","together"} which indicates whether
41 | to normalize only one probe type (PM,MM) or both together or separately.
42 | }
43 | \note{This function is still experimental.}
44 | \value{a matrix of normalized intensities}
45 | \author{Ben Bolstad, \email{bmb@bmbolstad.com}}
46 | \seealso{\code{\link{normalize}}, \code{\link[preprocessCore:normalize.quantiles]{normalize.quantiles}}}
47 | \keyword{manip}
48 |
--------------------------------------------------------------------------------
/NAMESPACE:
--------------------------------------------------------------------------------
1 | useDynLib("affy")
2 |
3 | importFrom(BiocGenerics, updateObject, colnames, boxplot, image)
4 |
5 | import(affyio)
6 |
7 | import(zlibbioc)
8 |
9 | importClassesFrom(Biobase, AnnotatedDataFrame, AssayData, eSet, MIAME,
10 | Versioned, VersionedBiobase, Versions)
11 |
12 | importClassesFrom(methods, ANY, character, environment, integer,
13 | matrix, missing, numeric)
14 |
15 | importMethodsFrom(Biobase, annotatedDataFrameFrom, annotation,
16 | assayData, classVersion, "classVersion<-",
17 | description, "description<-", experimentData, exprs,
18 | "exprs<-", featureNames, "featureNames<-",
19 | isCurrent, isVersioned,
20 | notes,
21 | "notes<-", pData, "pData<-", phenoData,
22 | "phenoData<-", preproc, "preproc<-", protocolData,
23 | "protocolData<-", rowMedians, sampleNames, "sampleNames<-",
24 | se.exprs, "se.exprs<-")
25 |
26 | importMethodsFrom(methods, initialize, show)
27 |
28 | importFrom(Biobase, addVigs2WinMenu, assayDataElementReplace,
29 | assayDataNew, multiassign, read.AnnotatedDataFrame,
30 | read.MIAME, testBioCConnection)
31 |
32 | importMethodsFrom(BiocGenerics, normalize)
33 |
34 | importFrom(BiocManager, repositories)
35 |
36 | importFrom(graphics, abline, axis, barplot, frame, hist,
37 | lines, matplot, mtext, pairs, par, plot, points,
38 | smoothScatter, text)
39 |
40 | importFrom(grDevices, dev.interactive, gray)
41 |
42 | importFrom(methods, as, callNextMethod, getMethod, is, new,
43 | slot)
44 |
45 | importFrom(preprocessCore, normalize.quantiles,
46 | normalize.quantiles.robust, rma.background.correct)
47 |
48 | importFrom(stats, approx, density, IQR, lm, loess, loess.control,
49 | median, medpolish, model.response, model.weights, optim,
50 | pnorm, predict, quantile, runif, sd, smooth.spline,
51 | splinefun, t.test, terms, var, wilcox.test)
52 |
53 | importFrom(utils, available.packages, contrib.url, data, flush.console,
54 | install.packages, object.size, packageVersion)
55 |
56 | ##export everything that does not start with a .
57 | exportPattern("^[^\\.]")
58 |
59 | export(.setAffyOptions)
60 |
61 | exportMethods(show, boxplot, image, exprs, "exprs<-", featureNames, geneNames, sampleNames,
62 | se.exprs, updateObject)
63 |
64 | exportClasses("AffyBatch")
65 |
66 | ## S3 methods
67 |
68 | S3method(plot, ProbeSet)
69 | S3method("$", AffyBatch)
70 | S3method(barplot, ProbeSet)
71 | S3method(merge, AffyBatch)
72 | S3method(pairs, AffyBatch)
73 |
--------------------------------------------------------------------------------
/man/normalize-methods.Rd:
--------------------------------------------------------------------------------
1 | \name{normalize-methods}
2 | \title{Normalize Affymetrix Probe Level Data - methods}
3 | \docType{methods}
4 | \alias{normalize.AffyBatch}
5 | \alias{normalize.methods}
6 | \alias{normalize.AffyBatch.methods}
7 | \alias{upDate.normalize.AffyBatch.methods}
8 | \alias{normalize,AffyBatch-method}
9 | \alias{normalize.methods,AffyBatch-method}
10 | \alias{normalize.AffyBatch.methods}
11 | \alias{bgcorrect.methods}
12 | \alias{upDate.bgcorrect.methods}
13 | \alias{pmcorrect.methods}
14 | \alias{upDate.pmcorrect.methods}
15 | \description{
16 | Method for normalizing Affymetrix Probe Level Data
17 | }
18 | \usage{
19 | normalize.methods(object)
20 | bgcorrect.methods()
21 | upDate.bgcorrect.methods(x)
22 | pmcorrect.methods()
23 | upDate.pmcorrect.methods(x)
24 | }
25 | \arguments{
26 | \item{object}{An \code{\link[affy:AffyBatch-class]{AffyBatch}}.}
27 | \item{x}{A character vector that will replace the existing one.}
28 | }
29 | \details{
30 | If \code{object} is an
31 | \code{\link[affy:AffyBatch-class]{AffyBatch}} object, then
32 | \code{normalize(object)} returns an
33 | \code{\link[affy:AffyBatch-class]{AffyBatch}} object with the
34 | intensities normalized using the methodology specified by
35 | \code{getOption("BioC")$affy$normalize.method}. The affy package
36 | default is \code{quantiles}.
37 |
38 | Other methodologies can be used by specifying them with the
39 | \code{method} argument. For example to use the invariant set
40 | methodology described by Li and Wong (2001) one would type:
41 | \code{normalize(object, method="invariantset")}.
42 |
43 | Further arguments passed by \code{...}, apart from \code{method}, are
44 | passed along to the function responsible for the methodology defined by
45 | the \code{method} argument.
46 |
47 | A character vector of \emph{nicknames} for the methodologies available
48 | is returned by \code{normalize.methods(object))}, where \code{object}
49 | is an \code{\link[affy:AffyBatch-class]{AffyBatch}}, or simply by
50 | typing \code{normalize.AffyBatch.methods}. If the nickname of a method
51 | is called "loess", the help page for that specific methodology can
52 | be accessed by typing \code{?normalize.loess}.
53 |
54 | For more on the normalization methodologies currently implemented
55 | please refer to the vignette `Custom Processing Methods'.
56 |
57 | To add your own normalization procedures please refer to the
58 | customMethods vignette.
59 |
60 | The functions: \code{bgcorrect.methods}, \code{pmcorrect.methods},
61 | provide access to internal vectors listing the corresponding capabilities.
62 | }
63 | \seealso{
64 | \code{\link{AffyBatch-class}}, \code{\link{normalize}}.
65 | }
66 | \examples{
67 | if (require(affydata)) {
68 | data(Dilution)
69 | normalize.methods(Dilution)
70 | generateExprSet.methods()
71 | bgcorrect.methods()
72 | pmcorrect.methods()
73 | }
74 | }
75 | \keyword{manip}
76 |
--------------------------------------------------------------------------------
/R/normalize.loess.R:
--------------------------------------------------------------------------------
1 | normalize.AffyBatch.loess <- function(abatch,type=c("together","pmonly","mmonly","separate"),...) {
2 |
3 | type <- match.arg(type)
4 |
5 | if (type == "separate"){
6 | Index <- unlist(indexProbes(abatch,"pm"))
7 | intensity(abatch)[Index,] <- normalize.loess(intensity(abatch)[Index,], ...)
8 | Index <- unlist(indexProbes(abatch,"mm"))
9 | intensity(abatch)[Index,] <- normalize.loess(intensity(abatch)[Index,], ...)
10 | } else if (type=="together"){
11 | Index <- unlist(indexProbes(abatch,"both"))
12 | intensity(abatch)[Index,] <- normalize.loess(intensity(abatch)[Index,], ...)
13 | } else if (type=="pmonly"){
14 | Index <- unlist(indexProbes(abatch,"pm"))
15 | intensity(abatch)[Index,] <- normalize.loess(intensity(abatch)[Index,], ...)
16 | } else if (type=="mmonly"){
17 | Index <- unlist(indexProbes(abatch,"mm"))
18 | intensity(abatch)[Index,] <- normalize.loess(intensity(abatch)[Index,], ...)
19 | }
20 | ##set.na.spotsd(listcel) # set 'sd' to nothing (meaningless after normalization)
21 | ##cat(cols,rows)
22 |
23 |
24 | ##need to use MIAME
25 | ##for (i in 1:abatch@nexp) {
26 | ## history(abatch)[[i]] <- list(name="normalized by loess")
27 | ##}
28 |
29 | return(abatch)
30 | }
31 |
32 |
33 |
34 | normalize.loess <- function(mat, subset=sample(1:(dim(mat)[1]), min(c(5000, nrow(mat)))),
35 | epsilon=10^-2, maxit=1, log.it=TRUE, verbose=TRUE, span=2/3,
36 | family.loess="symmetric"){
37 |
38 | J <- dim(mat)[2]
39 | II <- dim(mat)[1]
40 | if(log.it){
41 | mat <- log2(mat)
42 | }
43 |
44 | change <- epsilon +1
45 | iter <- 0
46 | w <- c(0, rep(1,length(subset)), 0) ##this way we give 0 weight to the
47 | ##extremes added so that we can interpolate
48 |
49 | while(iter < maxit){
50 | iter <- iter + 1
51 | means <- matrix(0,II,J) ##contains temp of what we substract
52 |
53 | for (j in 1:(J-1)){
54 | for (k in (j+1):J){
55 | y <- mat[,j] - mat[,k]
56 | x <- (mat[,j] + mat[,k]) / 2
57 | index <- c(order(x)[1], subset, order(-x)[1])
58 | ##put endpoints in so we can interpolate
59 | xx <- x[index]
60 | yy <- y[index]
61 | aux <-loess(yy~xx, span=span, degree=1, weights=w, family=family.loess)
62 | aux <- predict(aux, data.frame(xx=x)) / J
63 | means[, j] <- means[, j] + aux
64 | means[, k] <- means[, k] - aux
65 | if (verbose)
66 | cat("Done with",j,"vs",k,"in iteration",iter,"\n")
67 | }
68 | }
69 | mat <- mat - means
70 | change <- max(colMeans((means[subset,])^2))
71 |
72 | if(verbose)
73 | cat(iter, change,"\n")
74 |
75 | }
76 |
77 | if ((change > epsilon) & (maxit > 1))
78 | warning(paste("No convergence after", maxit, "iterations.\n"))
79 |
80 | if(log.it) {
81 | return(2^mat)
82 | } else
83 | return(mat)
84 | }
85 |
--------------------------------------------------------------------------------
/man/rma.Rd:
--------------------------------------------------------------------------------
1 | \name{rma}
2 | \alias{rma}
3 | \title{Robust Multi-Array Average expression measure}
4 | \description{
5 | This function converts an \code{\link[affy:AffyBatch-class]{AffyBatch}}
6 | object into an \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}}
7 | object using the robust multi-array average (RMA) expression measure.
8 | }
9 | \usage{
10 | rma(object, subset=NULL, verbose=TRUE, destructive=TRUE, normalize=TRUE,
11 | background=TRUE, bgversion=2, ...)
12 | }
13 | \arguments{
14 | \item{object}{an \code{\link[affy:AffyBatch-class]{AffyBatch}} object.}
15 | \item{subset}{a character vector with the the names of the probesets
16 | to be used in expression calculation.}
17 | \item{verbose}{logical value. If \code{TRUE}, it writes out some messages
18 | indicating progress. If \code{FALSE} nothing should be printed.}
19 | \item{destructive}{logical value. If \code{TRUE}, works on the PM matrix
20 | in place as much as possible, good for large datasets.}
21 | \item{normalize}{logical value. If \code{TRUE}, normalize data using
22 | quantile normalization.}
23 | \item{background}{logical value. If \code{TRUE}, background correct
24 | using RMA background correction.}
25 | \item{bgversion}{integer value indicating which RMA background to use
26 | 1: use background similar to pure R rma background given in affy version 1.0 - 1.0.2
27 | 2: use background similar to pure R rma background given in affy version 1.1 and above}
28 | \item{\dots}{further arguments to be passed (not currently implemented - stub for future use).}
29 | }
30 | \details{
31 | This function computes the RMA (Robust Multichip Average) expression measure
32 | described in Irizarry et al Biostatistics (2003).
33 |
34 | Note that this expression measure is given to you in log base 2
35 | scale. This differs from most of the other expression measure methods.
36 |
37 | Please note that the default background adjustment method was changed during
38 | the lead up to the Bioconductor 1.2 release. This means that this function and
39 | \code{\link{expresso}} should give results that directly agree.
40 | }
41 | \value{
42 | An \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}}
43 | }
44 | \author{Ben Bolstad \email{bmb@bmbolstad.com}}
45 | \references{
46 | Rafael. A. Irizarry, Benjamin M. Bolstad, Francois Collin, Leslie M. Cope, Bridget Hobbs and Terence P. Speed (2003), Summaries of Affymetrix GeneChip probe level data Nucleic Acids Research 31(4):e15
47 |
48 | Bolstad, B.M., Irizarry R. A., Astrand M., and Speed, T.P. (2003), A Comparison of Normalization Methods for High Density Oligonucleotide Array Data Based on Bias and Variance. Bioinformatics 19(2):185-193
49 |
50 | Irizarry, RA, Hobbs, B, Collin, F, Beazer-Barclay, YD, Antonellis, KJ, Scherf, U, Speed, TP (2003) Exploration, Normalization, and Summaries of High Density Oligonucleotide Array Probe Level Data. Biostatistics .Vol. 4, Number 2: 249-264
51 | }
52 | \seealso{\code{\link{expresso}}}
53 | \examples{
54 | if (require(affydata)) {
55 | data(Dilution)
56 | eset <- rma(Dilution)
57 | }
58 | }
59 | \keyword{manip}
60 |
--------------------------------------------------------------------------------
/R/ProgressBarText.R:
--------------------------------------------------------------------------------
1 | debug.affy123 <- FALSE
2 |
3 | setClass("ProgressBarText", representation(steps = "integer", barsteps = "integer", internals = "environment"))
4 |
5 | setMethod("initialize", "ProgressBarText",
6 | function(.Object, steps, barsteps = 10, internals = NULL) {
7 | ##.Object <- callNextMethod()
8 | if ( ! is.null(internals)) {
9 | stop("slot 'internals' is for internal use !")
10 | }
11 | .Object@barsteps = barsteps
12 | .Object@internals = new.env()
13 | assign("milestones.i", as.integer(1), envir=.Object@internals)
14 | assign("increment", as.integer(1), envir=.Object@internals)
15 | assign("milestones", as.integer(seq(1, steps, length=barsteps)), envir=.Object@internals)
16 | assign("i", as.integer(0), envir=.Object@internals)
17 | return(.Object)
18 | })
19 |
20 | setMethod("open", "ProgressBarText",
21 | function(con, header = TRUE) {
22 | if (header) {
23 | cat("|", paste(rep(" ", con@barsteps), collapse=""), "|\n", sep="")
24 | }
25 | cat("|")
26 | increment <- get("increment", con@internals)
27 | milestones.i <- get("milestones.i", con@internals)
28 | milestones <- get("milestones", con@internals)
29 | while(milestones.i > length(milestones)) {
30 | cat("#")
31 | }
32 | if (.Platform$OS.type == "windows")
33 | flush.console()
34 | })
35 |
36 | ## to avoid 'loosing' the default update.
37 | ## (not sure this is the most elegant way to do this)
38 |
39 | setGeneric("updateMe", function(object, ...) standardGeneric("updateMe"))
40 |
41 | setMethod("updateMe", "ProgressBarText",
42 | function(object) {
43 | increment <- get("increment", object@internals)
44 | i <- get("i", object@internals) + increment
45 | milestones.i <- get("milestones.i", object@internals)
46 | milestones <- get("milestones", object@internals)
47 | touched <- FALSE
48 | while(milestones.i <= length(milestones) && i >= milestones[milestones.i]) {
49 | cat("#")
50 | milestones.i <- milestones.i + increment
51 | touched <- TRUE
52 | }
53 | ## the 'touch' thing appears to make it save 0.1 sec / 100000 iteration
54 | ## (which makes it absolutely mandatory :) ).
55 | if (touched) {
56 | assign("milestones.i", milestones.i, envir = object@internals)
57 | if (.Platform$OS.type == "windows")
58 | flush.console()
59 | }
60 | assign("i", i, , envir = object@internals)
61 | })
62 |
63 |
64 | setMethod("close", "ProgressBarText",
65 | function(con) {
66 | increment <- get("increment", con@internals)
67 | milestones.i <- get("milestones.i", con@internals)
68 | milestones <- get("milestones", con@internals)
69 | while(milestones.i <= length(milestones)) {
70 | cat("#")
71 | milestones.i <- milestones.i + increment
72 | }
73 | assign("milestones.i", milestones.i, envir = con@internals)
74 | cat("|\n")
75 | if (.Platform$OS.type == "windows")
76 | flush.console()
77 | })
78 |
--------------------------------------------------------------------------------
/R/AffyRNAdeg.R:
--------------------------------------------------------------------------------
1 | "AffyRNAdeg" <-
2 | function (abatch,log.it=TRUE)
3 | {
4 | {
5 | data <- pm(abatch, LIST = TRUE)
6 | if(log.it==TRUE) data <- lapply(data,log2)
7 | names <- colnames(exprs(abatch))
8 | probe.set.size <- function(x) {
9 | size <- dim(x)[1]
10 | return(size)
11 | }
12 | max.num <- sapply(data, probe.set.size)
13 | tab <- (table(max.num))
14 | ord <- order(-as.numeric(tab))
15 | K <- as.numeric(names(tab))[ord[1]]
16 | data <- data[max.num == K]
17 | }
18 | get.row <- function(x, i = 1) {
19 | return(x[i, ])
20 | }
21 | get.col <- function(x, i = 1) {
22 | return(x[, i])
23 | }
24 | rowstack <- function(x, i = 1) {
25 | return(t(sapply(x, get.row, i)))
26 | }
27 | colstack <- function(x, i = 1) {
28 | return(t(sapply(x, get.col, i)))
29 | }
30 | N <- length(data)
31 |
32 | n <- dim(data[[1]])[2]
33 | mns <- matrix(nrow = n, ncol = K)
34 | sds <- mns
35 | for (i in 1:K) {
36 | data.stack <- rowstack(data, i)
37 | if(dim(data[[1]])[2]==1) data.stack <- t(data.stack)
38 | mns[, i] <- colMeans(data.stack)
39 | sds[, i] <- apply(data.stack, 2, sd)
40 | }
41 | mns.orig <- mns
42 | mn <- mns[, 1]
43 | mns <- sweep(mns, 1, mn)
44 | mns <- mns/(sds/sqrt(N))
45 | lm.stats <- function(x) {
46 | index <- 0:(length(x) - 1)
47 | ans <- summary(lm(x ~ index))$coefficients[2, c(1, 4)]
48 | return(ans)
49 | }
50 | stats <- apply(mns, 1, lm.stats)
51 | answer <- list(N, names, mns.orig, sds/sqrt(N), stats[1,
52 | ], stats[2, ])
53 | names(answer) <- c("N", "sample.names", "means.by.number",
54 | "ses", "slope", "pvalue")
55 | return(answer)
56 | }
57 | "summaryAffyRNAdeg" <-
58 | function (rna.deg.obj, signif.digits = 3)
59 | {
60 | temp.table <- rbind(signif(rna.deg.obj$slope, signif.digits),
61 | signif(rna.deg.obj$pvalue, signif.digits))
62 | colnames(temp.table) <- rna.deg.obj$sample.names
63 | rownames(temp.table) <- c("slope", "pvalue")
64 | ##write.table(temp.table, file = "", quote = FALSE)
65 | return(temp.table)
66 | }
67 | "plotAffyRNAdeg" <-
68 | function (rna.deg.obj,transform="shift.scale",cols=NULL, ...)
69 | {
70 | if(!is.element(transform,c("shift.scale","shift.only","neither"))) stop("Tranform must be 'shift.scale','shift.only', or 'neither'")
71 | mns <- rna.deg.obj$means.by.number
72 | if(is.null(cols)) cols=rep(4,dim(mns)[1])
73 | ylab="Mean Intensity"
74 | if(transform=="shift.scale"){
75 | sds <- rna.deg.obj$ses
76 | mn <- mns[, 1]
77 | mns <- sweep(mns, 1, mn)
78 | mns <- mns/(sds)
79 | mns <- sweep(mns, 1, 1:(dim(mns)[1]), "+")
80 | ylab <- paste(ylab,": shifted and scaled")
81 | }else if(transform=="shift.only"){
82 | mn <- mns[, 1]
83 | mns <- sweep(mns, 1, mn)
84 | mns <- sweep(mns, 1, 1:(dim(mns)[1]), "+")
85 | ylab <- paste(ylab,": shifted")
86 | }
87 | plot(-2, -1, pch = "", xlim = range(-1, (dim(mns)[2])),
88 | ylim = range(min(as.vector(mns)) - 1, max(as.vector(mns)) + 1), xlab = "5' <-----> 3'\n Probe Number ",
89 | ylab = ylab, axes = FALSE, main = "RNA degradation plot",
90 | ...)
91 | axis(1)
92 | axis(2)
93 | for (i in 1:dim(mns)[1]) lines(0:((dim(mns)[2]-1)), mns[i, ],col=cols[i])
94 | }
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/src/getall_locations.c:
--------------------------------------------------------------------------------
1 | /**
2 | * An helping function to speed up the computation of expression values
3 | *
4 | * Laurent@cbs.dtu.dk (2002)
5 | */
6 |
7 |
8 | #include
9 | #include
10 |
11 | /*****************EXPORT**********************/
12 | SEXP getallLocations(SEXP namesR, SEXP dimR, SEXP atomsR, SEXP ispmR, SEXP nb_affyidR);
13 | /* Takes as input a matrix of integers (the slot 'name'
14 | of a 'Cdf' object), and return a list of 'locations'.
15 | Each locations is a (n,2) array (n being the number of
16 | probes related to an affyid).*/
17 | /*********************************************/
18 |
19 |
20 | SEXP getallLocations(SEXP namesR, SEXP dimR, SEXP atomsR, SEXP selectR, SEXP nb_affyidR) {
21 | int nrows, ncols, nb_affyid;
22 | int ii, jj;
23 | int *names, *atoms, *select;
24 | int *nbElements;
25 | int iLastElementNA;
26 | int x, nAtom;
27 |
28 | SEXP loc_list;
29 | SEXP tmp_dim;
30 |
31 | nrows = INTEGER_POINTER(dimR)[0];
32 | ncols = INTEGER_POINTER(dimR)[1];
33 | nb_affyid = INTEGER(nb_affyidR)[0];
34 | names = INTEGER_POINTER(namesR);
35 | atoms = INTEGER_POINTER(atomsR);
36 | select = INTEGER_POINTER(selectR);
37 |
38 | nbElements = (int *)R_alloc(nb_affyid, sizeof(int));
39 | iLastElementNA = 0;
40 |
41 | PROTECT(loc_list = NEW_LIST(nb_affyid));
42 | PROTECT(tmp_dim = NEW_INTEGER(2));
43 |
44 | for (ii=0; ii nbElements[x-1])) {
102 | error("Inconsistency in the Cdf object (slot atom, element [%i,%i])! The atom value %i should be positive and lower than %i for the probeset %i.", ii+1, jj+1, nAtom, nbElements[x-1], x-1);
103 | }
104 |
105 | INTEGER_POINTER(VECTOR_ELT(loc_list, x-1))[nAtom + nbElements[x-1] * 0] = ii+1;
106 | INTEGER_POINTER(VECTOR_ELT(loc_list, x-1))[nAtom + nbElements[x-1] * 1] = jj+1;
107 | /* iLastElement[x-1]++; */
108 | }
109 | }
110 | UNPROTECT(2);
111 | return loc_list;
112 | }
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/src/rma_common.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | **
3 | ** file: rma_common.c
4 | **
5 | ** aim: a location for commonly used utility functions
6 | **
7 | **
8 | ** written by: B. M. Bolstad
9 | **
10 | ** created: Oct 16, 2002
11 | ** last modified: Oct 16, 2002
12 | **
13 | ** history:
14 | ** Oct 16, 2002 - a place to put common utility code, created to help
15 | ** the R package build.
16 | ** Jan 2, 2003 - Clean up code comments
17 | ** Nov 13, 2006 - moved median function into this file from rma2.c
18 | **
19 | ***********************************************************************/
20 |
21 | #include "rma_common.h"
22 | #include
23 | #include
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | /**********************************************************
31 | **
32 | ** int sort_double(const void *a1,const void *a2)
33 | **
34 | ** a comparison function used when sorting doubles.
35 | **
36 | **********************************************************/
37 |
38 | int sort_double(const double *a1,const double *a2){
39 | if (*a1 < *a2)
40 | return (-1);
41 | if (*a1 > *a2)
42 | return (1);
43 | return 0;
44 | }
45 |
46 |
47 |
48 | /**************************************************************************
49 | **
50 | ** double median(double *x, int length)
51 | **
52 | ** double *x - vector
53 | ** int length - length of *x
54 | **
55 | ** returns the median of *x
56 | **
57 | *************************************************************************/
58 |
59 | double median(double *x, int length){
60 | int half;
61 | double med;
62 | double *buffer = Calloc(length,double);
63 |
64 | memcpy(buffer,x,length*sizeof(double));
65 |
66 | half = (length + 1)/2;
67 | /*
68 | qsort(buffer,length,sizeof(double), (int(*)(const void*, const void*))sort_double);
69 |
70 | if (length % 2 == 1){
71 | med = buffer[half - 1];
72 | } else {
73 | med = (buffer[half] + buffer[half-1])/2.0;
74 | }
75 | */
76 |
77 | rPsort(buffer, length, half-1);
78 | med = buffer[half-1];
79 | if (length % 2 == 0){
80 | rPsort(buffer, length, half);
81 | med = (med + buffer[half])/2.0;
82 | }
83 |
84 | Free(buffer);
85 | return med;
86 | }
87 |
88 |
89 | /**************************************************************************
90 | **
91 | ** double median_nocopy(double *x, int length)
92 | **
93 | ** double *x - vector
94 | ** int length - length of *x
95 | **
96 | ** returns the median of *x. note x is not order preserved when this function
97 | ** is called.
98 | **
99 | *************************************************************************/
100 |
101 | double median_nocopy(double *x, int length){
102 | int half;
103 | double med;
104 | double *buffer = x; //Calloc(length,double);
105 |
106 | memcpy(buffer,x,length*sizeof(double));
107 |
108 | half = (length + 1)/2;
109 | /*
110 | qsort(buffer,length,sizeof(double), (int(*)(const void*, const void*))sort_double);
111 |
112 | if (length % 2 == 1){
113 | med = buffer[half - 1];
114 | } else {
115 | med = (buffer[half] + buffer[half-1])/2.0;
116 | }
117 | */
118 |
119 | rPsort(buffer, length, half-1);
120 | med = buffer[half-1];
121 | if (length % 2 == 0){
122 | rPsort(buffer, length, half);
123 | med = (med + buffer[half])/2.0;
124 | }
125 |
126 |
127 | return med;
128 | }
129 |
--------------------------------------------------------------------------------
/man/expresso.Rd:
--------------------------------------------------------------------------------
1 | \name{expresso}
2 | \alias{expresso}
3 | \alias{bgcorrect}
4 | \title{ From raw probe intensities to expression values }
5 | \description{
6 | Goes from raw probe intensities to expression values
7 | }
8 | \usage{
9 | expresso(
10 | afbatch,
11 | # background correction
12 | bg.correct = TRUE,
13 | bgcorrect.method = NULL,
14 | bgcorrect.param = list(),
15 | # normalize
16 | normalize = TRUE,
17 | normalize.method = NULL,
18 | normalize.param = list(),
19 | # pm correction
20 | pmcorrect.method = NULL,
21 | pmcorrect.param = list(),
22 | # expression values
23 | summary.method = NULL,
24 | summary.param = list(),
25 | summary.subset = NULL,
26 | # misc.
27 | verbose = TRUE,
28 | % warnings = TRUE,
29 | widget = FALSE)
30 | }
31 | \arguments{
32 | \item{afbatch}{an \code{\link[affy:AffyBatch-class]{AffyBatch}} object.}
33 | \item{bg.correct}{a boolean to express whether background correction
34 | is wanted or not.}
35 | \item{bgcorrect.method}{the name of the background adjustment method.}
36 | \item{bgcorrect.param}{a list of parameters for bgcorrect.method
37 | (if needed/wanted).}
38 | \item{normalize}{ normalization step wished or not.}
39 | \item{normalize.method}{the normalization method to use.}
40 | \item{normalize.param}{a list of parameters to be passed to the
41 | normalization method (if wanted).}
42 | \item{pmcorrect.method}{the name of the PM adjustment method.}
43 | \item{pmcorrect.param}{a list of parameters for pmcorrect.method
44 | (if needed/wanted).}
45 | \item{summary.method}{the method used for the computation of expression
46 | values.}
47 | \item{summary.param}{a list of parameters to be passed to the
48 | \code{summary.method} (if wanted).}
49 | \item{summary.subset}{a list of 'affyids'. If \code{NULL}, an
50 | expression summary value is computed for everything on the chip.}
51 | \item{verbose}{logical value. If \code{TRUE}, it writes out some
52 | messages.}
53 | % \item{warnings}{warning when something goes wrong}
54 | \item{widget}{a boolean to specify the use of widgets (the package
55 | tkWidget is required).}
56 | }
57 | \details{
58 | Some arguments can be left to \code{NULL} if the \code{widget=TRUE}.
59 | In this case, a widget pops up and let the user choose with the mouse.
60 | The arguments are: \code{AffyBatch}, \code{bgcorrect.method},
61 | \code{normalize.method}, \code{pmcorrect.method} and \code{summary.method}.
62 |
63 | For the mas 5.0 and 4.0 methods ones need to normalize after obtaining
64 | expression. The function \code{\link{affy.scalevalue.exprSet}} does this.
65 |
66 | For the Li and Wong summary method notice you will not get
67 | the same results as you would get with dChip. dChip is not open source
68 | so it is not easy to reproduce.
69 | Notice also that this iterative algorithm will not always converge.
70 | If you run the algorithm on thousands of probes expect some non-convergence
71 | warnings. These are more likely when few arrays are used. We recommend
72 | using this method only if you have 10 or more arrays.
73 | Please refer to the \code{\link{fit.li.wong}} help page for more details.
74 | }
75 | \value{
76 | An object of class \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}},
77 | with an attribute \code{pps.warnings} as returned by the method
78 | \code{\link{computeExprSet}}.
79 | }
80 | \seealso{\code{\link[affy:AffyBatch-class]{AffyBatch}}}
81 | \examples{
82 | if (require(affydata)) {
83 | data(Dilution)
84 |
85 | eset <- expresso(Dilution, bgcorrect.method="rma",
86 | normalize.method="constant",pmcorrect.method="pmonly",
87 | summary.method="avgdiff")
88 |
89 | ##to see options available for bg correction type:
90 | bgcorrect.methods()
91 | }
92 | }
93 | \keyword{manip}
94 |
--------------------------------------------------------------------------------
/man/normalize.qspline.Rd:
--------------------------------------------------------------------------------
1 | \name{normalize.qspline}
2 | \alias{qspline-normalize}
3 | \alias{normalize.qspline}
4 | \alias{normalize.AffyBatch.qspline}
5 | \title{Normalize arrays}
6 | \description{
7 | normalizes arrays in an AffyBatch each other or to a set of target intensities
8 | }
9 | \usage{
10 | normalize.AffyBatch.qspline(abatch,type=c("together", "pmonly", "mmonly",
11 | "separate"), ...)
12 |
13 | normalize.qspline(x, target = NULL, samples = NULL,
14 | fit.iters = 5, min.offset = 5,
15 | spline.method = "natural", smooth = TRUE,
16 | spar = 0, p.min = 0, p.max = 1.0,
17 | incl.ends = TRUE, converge = FALSE,
18 | verbose = TRUE, na.rm = FALSE)
19 | }
20 | \arguments{
21 | \item{x}{a \code{data.matrix} of intensities}
22 | \item{abatch}{an \code{AffyBatch}}
23 | \item{target}{numerical vector of intensity values to normalize to.
24 | (could be the name for one of the celfiles in 'abatch').}
25 | \item{samples}{numerical, the number of quantiles to be used for spline.
26 | if (0,1], then it is a sampling rate.}
27 | \item{fit.iters}{number of spline interpolations to average.}
28 | \item{min.offset}{minimum span between quantiles (rank difference) for the
29 | different fit iterations.}
30 | \item{spline.method}{specifies the type of spline to be used. Possible values are
31 | `"fmm"', `"natural"', and `"periodic"'.}
32 | \item{smooth}{logical, if `TRUE', smoothing splines are used on the quantiles.}
33 | \item{spar}{smoothing parameter for `splinefun', typically in (0,1].}
34 | \item{p.min}{minimum percentile for the first quantile.}
35 | \item{p.max}{maximum percentile for the last quantile.}
36 | \item{incl.ends}{include the minimum and maximum values from the normalized
37 | and target arrays in the fit.}
38 | \item{converge}{(currently unimplemented)}
39 | \item{verbose}{logical, if `TRUE' then normalization progress is reported.}
40 | \item{na.rm}{logical, if `TRUE' then handle NA values (by ignoring
41 | them).}
42 | \item{type}{a string specifying how the normalization should be
43 | applied. See details for more.}
44 | \item{\dots}{optional parameters to be passed through.}
45 | }
46 | \value{
47 | a normalized \code{AffyBatch}.
48 | }
49 | \details{
50 | This normalization method uses the quantiles from each array and the
51 | target to fit a system of cubic splines to normalize the data. The
52 | target should be the mean (geometric) or median of each probe but could
53 | also be the name of a particular chip in the \code{abatch} object.
54 |
55 | Parameters setting can be of much importance when using this method.
56 | The parameter \code{fit.iter} is used as a starting point to find a
57 | more appropriate value. Unfortunately the algorithm used do not
58 | converge in some cases. If this happens, the \code{fit.iter} value is
59 | used and a warning is thrown. Use of different settings for the
60 | parameter \code{samples} was reported to give good results. More
61 | specifically, for about 200 data points use
62 | \code{samples = 0.33}, for about 2000 data points use
63 | \code{samples = 0.05}, for about 10000 data points use
64 | \code{samples = 0.02}
65 | (thanks to Paul Boutros).
66 |
67 | The \code{type} argument should be one of
68 | \code{"separate","pmonly","mmonly","together"} which indicates whether
69 | to normalize only one probe type (PM,MM) or both together or separately.
70 | }
71 | \author{
72 | Laurent and Workman C.
73 | }
74 | \references{
75 | Christopher Workman, Lars Juhl Jensen, Hanne Jarmer, Randy Berka,
76 | Laurent Gautier, Henrik Bjorn Nielsen, Hans-Henrik Saxild, Claus
77 | Nielsen, Soren Brunak, and Steen Knudsen. A new non-linear normal-
78 | ization method for reducing variability in dna microarray experiments.
79 | Genome Biology, accepted, 2002
80 | }
81 | \keyword{manip}
82 |
--------------------------------------------------------------------------------
/vignettes/vim.Rnw:
--------------------------------------------------------------------------------
1 | % -*- mode: noweb; noweb-default-code-mode: R-mode; -*-
2 | %\VignetteIndexEntry{4. Import Methods}
3 | %\VignetteKeywords{Preprocessing, Affymetrix}
4 | %\VignetteDepends{affy}
5 | %\VignettePackage{affy}
6 | %documentclass[12pt, a4paper]{article}
7 | \documentclass[12pt]{article}
8 |
9 | \usepackage{amsmath}
10 | \usepackage{hyperref}
11 | \usepackage[authoryear,round]{natbib}
12 |
13 | \textwidth=6.2in
14 | \textheight=8.5in
15 | %\parskip=.3cm
16 | \oddsidemargin=.1in
17 | \evensidemargin=.1in
18 | \headheight=-.3in
19 |
20 | \newcommand{\scscst}{\scriptscriptstyle}
21 | \newcommand{\scst}{\scriptstyle}
22 |
23 | \author{Laurent}
24 | \begin{document}
25 | \title{affy: Import Methods (HowTo)}
26 |
27 | \maketitle
28 | \tableofcontents
29 | \section{Introduction}
30 | This document describes briefly how to write import methods for
31 | the \verb+affy+ package. As one might know, the Affymetrix data are
32 | originally stored in files of type \verb+.CEL+ and \verb+.CDF+. The
33 | package extracts and store the information contained in \verb+R+ data
34 | structures using file parsers. This document outlines how to get the
35 | data from other sources than the current\footnote{today's date is
36 | early 2003} file formats.
37 |
38 | As usual, loading the package in your \verb+R+ session is required.
39 | \begin{Sinput}
40 | R> library(affy) ##load the affy package
41 | \end{Sinput}
42 | <>=
43 | library(affy)
44 | @
45 |
46 | {\bf note: this document only describes the process for .CEL files}
47 |
48 | Knowing the slots of \verb+Cel+ and \verb+AffyBatch+ objects will
49 | probably help you to achieve your goals. You may want to refer to
50 | the respective help pages. Try \verb+help(Cel)+, \verb+help(AffyBatch)+.
51 |
52 | \section{How-to}
53 | \subsection{Cel objects}
54 | The functions \verb+getNrowForCEL+ and \verb+getNcolForCEL+ are assumed to return
55 | the number of rows and the number of columns in the \verb+.CEL+ file respectively
56 |
57 | You will also need to have access to the $X$ and $Y$ position for the probes in the
58 | {\verb .CEL} file. The functions \verb+getPosXForCel+ and \verb+getPosYForCEL+
59 | are assumed to return the $X$ and $Y$ positions respectively. The corresponding
60 | probe intensities are assumed to be returned by the function \verb+getIntensitiesForCEL+.
61 |
62 | If you stored {\bf all} the $X$ and $Y$ values that were in the \verb+.CEL+, the
63 | functions verb+getNrowForCEL+ and \verb+getNcolForCEL+ can written:
64 | <<<>>=
65 | getNrowForCEL <- function() max(getPosXForCEL())
66 | getNcolForCEL <- function() max(getPosYForCEL())
67 | @
68 |
69 | You will also need the name for the corresponding \verb+.CDF+ (although you will
70 | probably no need the \verb+.CDF+ file itself, the cdf packages available for download
71 | will probably be enough).
72 |
73 | \begin{Sinput}
74 | import.celfile <- function(celfile, ...) {
75 |
76 | cel.nrow <- getNrowForCEL(celfile)
77 | cel.ncol <- getNcolForCEL(celfile)
78 | x <- matrix(NA, nr=cel.nrow, nc=cel.ncol)
79 |
80 | cel.intensities <- getIntensitiesForCEL(celfile)
81 |
82 | cel.posx <- getPosXForCEL(celfile) # +1 if indexing starts at 0 (like in .CEL)
83 | cel.posy <- getPosYForCEL(celfile) # idem
84 |
85 | x[cbind(cel.posx, cel.posy)] <- cel.intensities
86 |
87 | mycdfName <- whatcdf("aCELfile.CEL")
88 |
89 | myCel <- new("Cel", exprs=x, cdfName=mycdfName)
90 |
91 | return(myCel)
92 | }
93 | \end{Sinput}
94 |
95 | The function \verb+import.celfile+ can now replace the function \verb+read.celfile+
96 | in the \verb+affy+ package
97 |
98 |
99 | \subsection{AffyBatch objects}
100 |
101 | (scratch)
102 | the use of \verb+...+ should make you able to override the function
103 | read.celfile by a hack like:
104 | \begin{Sinput}
105 | read.celfile <- import.celfile
106 | \end{Sinput}
107 | The function \verb+read.affybatch+ should now function using your \verb+import.celfile+
108 |
109 |
110 | \end{document}
111 |
--------------------------------------------------------------------------------
/man/xy2indices.Rd:
--------------------------------------------------------------------------------
1 | \name{xy2indices}
2 | \alias{xy2indices}
3 | \alias{indices2xy}
4 | \title{Functions to convert indices to x/y (and reverse)}
5 | \description{
6 | Functions to convert indices to x/y (and reverse)
7 | }
8 | \usage{
9 | xy2indices(x, y, nc = NULL, cel = NULL, abatch = NULL, cdf = NULL, xy.offset = NULL)
10 | indices2xy(i, nc = NULL, cel = NULL, abatch = NULL, cdf = NULL, xy.offset = NULL)
11 | }
12 | \arguments{
13 | \item{x}{A numeric vector of \code{X} (column) position(s) for the probes.}
14 | \item{y}{A numeric vector of \code{Y} (row) position(s) for the probes.}
15 | \item{i}{A numeric vector of indices in the \code{AffyBatch} for the probes.}
16 | \item{nc}{total number of columns on the chip. It is usually better to
17 | specify either the cdf or abatch arguments rather than the number of columns.}
18 | \item{cel}{a corresponding object of class \code{Cel}. This has been
19 | deprecated. Use abatch or cdf instead.}
20 | \item{abatch}{a corresponding object of class
21 | \code{\link[affy:AffyBatch-class]{AffyBatch}}.}
22 | \item{cdf}{character - the name of the corresponding cdf package.}
23 | \item{xy.offset}{an eventual offset for the XY coordinates. See Details.}
24 | }
25 | \details{
26 | The Affymetrix scanner reads data from a GeneChip by row, and exports
27 | those data to a CEL file. When we read in the CEL file data to an
28 | \code{AffyBatch} object, we store data for each GeneChip as a single
29 | column in a matrix of probe-wise intensity values.
30 |
31 | The CDF files that Affymetrix make available for various GeneChips map
32 | individual probes to probesets based on their (x,y) coordinates on the
33 | GeneChip. Note that these coordinates are zero-based, and (x,y) is the
34 | same as (column, row). In other words, the x coordinate indicates the
35 | horizontal location of the probe, and the y coordinate indicates the
36 | vertical location of the probe. By convention, (0,0) is the coordinate
37 | location for the top left position, and (ncol-1, nrow-1) is the
38 | coordinate location of the lower right position.
39 |
40 | For most users, the mapping of probes to probeset is handled
41 | internally by various functions (\code{rma}, \code{espresso}, etc),
42 | and in general usage it is never necessary for a user to convert probe
43 | index position in an \code{AffyBatch} to the corresponding (x,y)
44 | coordinates on the GeneChip. These functions are only useful for those
45 | who wish to know more about the internal workings of the Affymetrix
46 | GeneChip.
47 |
48 | The parameter \code{xy.offset} is there for compatibility.
49 | For historical reasons, the xy-coordinates for the features
50 | on Affymetrix GeneChips were decided to start at 1 (one) rather than 0
51 | (zero). One can set the offset to 1 or to 0. Unless the you \_really\_
52 | know what you are doing, it is advisable to let it at the default
53 | value \code{NULL}. This way the package-wide option \code{xy.offset} is
54 | always used.
55 | }
56 | \value{
57 | A vector of indices or a two-columns matrix of Xs and Ys.
58 | }
59 | \author{L.}
60 | \section{Warning}{Even if one really knows what is going on, playing with
61 | the parameter \code{xy.offset} could be risky. Changing the package-wide
62 | option \code{xy.offset} appears much more sane.}
63 | \seealso{\code{\link{indexProbes}}}
64 | \examples{
65 | if (require(affydata)) {
66 | data(Dilution)
67 | pm.i <- indexProbes(Dilution, which="pm", genenames="AFFX-BioC-5_at")[[1]]
68 | mm.i <- indexProbes(Dilution, which="mm", genenames="AFFX-BioC-5_at")[[1]]
69 |
70 | pm.i.xy <- indices2xy(pm.i, abatch = Dilution)
71 | mm.i.xy <- indices2xy(mm.i, abatch = Dilution)
72 |
73 | ## and back to indices
74 | i.pm <- xy2indices(pm.i.xy[,1], pm.i.xy[,2], cdf = "hgu95av2cdf")
75 | i.mm <- xy2indices(mm.i.xy[,1], mm.i.xy[,2], cdf = "hgu95av2cdf")
76 |
77 | identical(pm.i, as.integer(i.pm))
78 | identical(mm.i, as.integer(i.mm))
79 |
80 | image(Dilution[1], transfo=log2)
81 | ## plot the pm in red
82 | plotLocation(pm.i.xy, col="red")
83 | plotLocation(mm.i.xy, col="blue")
84 | }
85 | }
86 | \keyword{manip}
87 |
--------------------------------------------------------------------------------
/R/zzz.R:
--------------------------------------------------------------------------------
1 | .initNormalize <- function(all.affy, env) {
2 | if (debug.affy123) cat("-->detecting normalization methods from naming convention\n")
3 |
4 | ## this could move into the respective methods of AffyBatch later
5 |
6 | assign("normalize.AffyBatch.methods",
7 | sub("^normalize\\.AffyBatch\\.", "",
8 | grep("^normalize.AffyBatch", all.affy, value = TRUE)),
9 | envir=env)
10 | }
11 |
12 | .initExpression <- function(all.affy, env) {
13 | if (debug.affy123) cat("-->detecting expression value methods from naming convention\n")
14 |
15 | ## the first one is deprecated (well... "should be"...)
16 | vals <- sub("^generateExprVal\\.method\\.", "",
17 | grep("^generateExprVal.method", all.affy, value = TRUE))
18 | assign("generateExprSet.methods", vals,
19 | envir=env)
20 | assign("express.summary.stat.methods", vals,
21 | envir=env)
22 | }
23 |
24 | .initBackgroundCorrect <- function(all.affy, env) {
25 | if (debug.affy123) cat("-->detecting background correction methods from naming convention\n")
26 | start <- nchar("bg.correct.")
27 | assign("bgcorrect.methods",
28 | sub("^bg\\.correct\\.", "",
29 | grep("^bg.correct", all.affy, value = TRUE)),
30 | envir=env)
31 | }
32 |
33 | .initPmCorrect <- function(all.affy, env) {
34 | if (debug.affy123) cat("-->detecting pm correction methods from naming convention\n")
35 |
36 | assign("pmcorrect.methods",
37 | sub("^pmcorrect\\.", "",
38 | grep("^pmcorrect", all.affy, value = TRUE)),
39 | envir=env)
40 | }
41 |
42 | .setAffyOptions <- function(affy.opt=NA) {
43 |
44 | if (! any(is.na(affy.opt))) {
45 | if (class(affy.opt) != "BioCPkg")
46 | stop("obviously invalid package options !")
47 |
48 | BioC <- getOption("BioC")
49 | BioC$affy <- affy.opt
50 | options("BioC"=BioC)
51 | return()
52 | }
53 |
54 | ## add affy specific options
55 | ## (not unlike what is done in 'Biobase')
56 | if (is.null(getOption("BioC"))) {
57 | BioC <- list()
58 | class(BioC) <- "BioCOptions"
59 | options("BioC"=BioC)
60 | }
61 |
62 | probesloc.first <- list(what="environment", where=.GlobalEnv)
63 | probesloc.second <- list(what="libPath", where=NULL)
64 | probesloc.third <- list(what="data", where="affy")
65 | probesloc.fourth <- list(what="bioC", where=.libPaths()[1])
66 |
67 |
68 | ## default for the methods
69 | bgcorrect.method <- "mas"
70 | normalize.method <- "quantiles"
71 | pmcorrect.method <- "pmonly"
72 | summary.method <- "liwong"
73 |
74 | affy.opt <- list(compress.cdf=FALSE, compress.cel=FALSE,
75 | use.widgets=FALSE,
76 | probesloc = list(probesloc.first, probesloc.second,
77 | probesloc.third, probesloc.fourth),
78 | bgcorrect.method = bgcorrect.method,
79 | normalize.method = normalize.method,
80 | pmcorrect.method = pmcorrect.method,
81 | summary.method = summary.method,
82 | xy.offset = 0 ## this one is for temporary compatibility
83 | )
84 |
85 | class(affy.opt) <- "BioCPkg"
86 |
87 | BioC <- getOption("BioC")
88 | BioC$affy <- affy.opt
89 | options("BioC"=BioC)
90 | ## ---
91 | }
92 |
93 | .affyInternalEnv <- NULL
94 |
95 | .onLoad <- function(libname, pkgname) {
96 |
97 | # where <- match(paste("package:", pkgname, sep=""), search())
98 | all.affy <- ls(environment(sys.function()))
99 |
100 | ##a place to store some variables that need to be accessed
101 | .affyInternalEnv <<- new.env(parent=emptyenv())
102 |
103 | .initNormalize(all.affy, .affyInternalEnv)
104 | .initExpression(all.affy, .affyInternalEnv)
105 | .initBackgroundCorrect(all.affy, .affyInternalEnv)
106 | .initPmCorrect(all.affy, .affyInternalEnv)
107 |
108 | .setAffyOptions()
109 |
110 | if(.Platform$OS.type == "windows" && interactive()
111 | && .Platform$GUI == "Rgui"){
112 | addVigs2WinMenu("affy")
113 | }
114 | }
115 |
116 |
--------------------------------------------------------------------------------
/R/normalize.quantiles.R:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | ##
3 | ## file: normalize.quantiles.R
4 | ##
5 | ## For a description of quantile normalization method see
6 | ##
7 | ## Bolstad, B. M., Irizarry R. A., Astrand, M, and Speed, T. P. (2003)(2003)
8 | ## A Comparison of Normalization Methods for High
9 | ## Density Oligonucleotide Array Data Based on Bias and Variance.
10 | ## Bioinformatics 19,2,pp 185-193
11 | ##
12 | ## History
13 | ## Pre Aug 23, 2003 Two years worth of stuff
14 | ## Aug 23, 2003 - Added use.log2 to "robust",
15 | ## added ability to pass additional parameters
16 | ## to normalize.AffyBatch.Quantiles.robust
17 | ## changed pmonly parameters on functions
18 | ## so that it is now a string argument "type"
19 | ## the options are pmonly, mmonly, together, separate
20 | ## Jan 31, 2004 - put a check for an integer matrix and force coercision to
21 | ## doubles if required in normalize.quantiles
22 | ## Mar 13, 2005 - Modifications to normalize.quantiles.robust including removing
23 | ## approx.method which never got implemented. Making it a use a .Call()
24 | ## rather than a .C()
25 | ##
26 | ## Sep 20, 2006 - fix .Call in normalize.quantiles.robust
27 | ## May 20, 2007 - remove the functions that have been moved to preprocessCore
28 | ##
29 | ##################################################################
30 |
31 | normalize.AffyBatch.quantiles <- function(abatch,type=c("separate","pmonly","mmonly","together")) {
32 |
33 |
34 | type <- match.arg(type)
35 |
36 | if ((type == "pmonly")|(type == "separate")){
37 | pms <- unlist(pmindex(abatch))
38 | ## Change to faster computation of noNA - SDR 11/06/2003
39 | ##noNA <- apply(intensity(abatch)[pms,,drop=FALSE],1,function(x) all(!is.na(x)))
40 | noNA <- rowSums(is.na(intensity(abatch)[pms,,drop=FALSE])) == 0
41 | pms <- pms[noNA]
42 | intensity(abatch)[pms,] <- normalize.quantiles(intensity(abatch)[pms,,drop=FALSE ],copy=FALSE)
43 | }
44 | if((type == "mmonly") | (type == "separate")){
45 | mms <- unlist(mmindex(abatch))
46 | ## Change to faster computation of noNA - SDR 11/06/2003
47 | ##noNA <- apply(intensity(abatch)[mms,,drop=FALSE],1,function(x) all(!is.na(x)))
48 | noNA <- rowSums(is.na(intensity(abatch)[mms,,drop=FALSE])) == 0
49 | mms <- mms[noNA]
50 |
51 | intensity(abatch)[mms,] <- normalize.quantiles(intensity(abatch)[mms,,drop=FALSE ],copy=FALSE)
52 | }
53 | if (type == "together"){
54 | pms <- unlist(indexProbes(abatch,"both"))
55 | intensity(abatch)[pms,] <- normalize.quantiles(intensity(abatch)[pms,,drop=FALSE ],copy=FALSE)
56 | }
57 |
58 | ##this is MIAME we need to decide how to do this properly.
59 | ##for (i in 1:length(abatch)) {
60 | ## history(abatch)[[i]]$name <- "normalized by quantiles"
61 | ##}
62 |
63 | return(abatch)
64 | }
65 |
66 | normalize.AffyBatch.quantiles.robust <- function(abatch, type=c("separate","pmonly","mmonly","together"),weights=NULL,remove.extreme=c("variance","mean","both","none"),n.remove=1,use.median=FALSE,use.log2=FALSE) {
67 |
68 | type <- match.arg(type)
69 |
70 | if ((type == "pmonly")|(type == "separate")){
71 | pms <- unlist(pmindex(abatch))
72 | intensity(abatch)[pms, ] <- normalize.quantiles.robust(intensity(abatch)[pms, ], copy=FALSE,weights=weights,remove.extreme,n.remove=n.remove,use.median=use.median,use.log2=use.log2)
73 | }
74 | if ((type == "mmonly")|(type == "separate")){
75 | mms <- unlist(mmindex(abatch))
76 | intensity(abatch)[mms, ] <- normalize.quantiles.robust(intensity(abatch)[mms, ],copy=FALSE,weights=weights,remove.extreme,n.remove=n.remove,use.median=use.median,use.log2=use.log2)
77 | }
78 |
79 | if (type == "together"){
80 | pms <- unlist(indexProbes(abatch,"both"))
81 | intensity(abatch) <- normalize.quantiles.robust(intensity(abatch)[pms,,drop=FALSE ],copy=FALSE, weights=weights,remove.extreme=remove.extreme,n.remove=n.remove,use.median=use.median,use.log2=use.log2)
82 | }
83 |
84 |
85 |
86 | ##this is MIAME we need to decide how to do this properly.
87 | ##for (i in 1:length(abatch)) {
88 | ## history(abatch)[[i]]$name <- "normalized by quantiles"
89 | ##}
90 |
91 | return(abatch)
92 | }
93 |
94 |
--------------------------------------------------------------------------------
/demo/affy.tour.R:
--------------------------------------------------------------------------------
1 | ## A quick demo to overview the package
2 | ## -- Laurent
3 |
4 | if(dev.cur() <= 1) get(getOption("device"))()
5 |
6 | opar <- par(ask= (interactive() &&
7 | (.Device %in% c("X11", "GTK", "windows", "Macintosh"))),
8 | bg="cornsilk", mfrow=c(1,1))
9 |
10 |
11 |
12 | ## load the data
13 | library(affydata)
14 | data(cdf.example)
15 | data(Dilution)
16 |
17 | ## display the image of the data in the CEL file
18 |
19 | cel <- Dilution[[1]]
20 |
21 | image(cel,transfo=log)
22 |
23 | image(cel,transfo=log)
24 |
25 | ## find the locations for probes corresponding to a given ID
26 |
27 | l.pm <- locate.name("AFFX-BioC-5_at", cdf.example, type="pm")
28 | plotLocation(l.pm, cdf.example, col="red")
29 | l.mm <- locate.name("AFFX-BioC-5_at", cdf.example, type="mm")
30 | plotLocation(l.mm, cdf.example, col="blue")
31 |
32 | arrows(20,60, min(l.pm[,1]), min(l.pm[,2]), col="white")
33 | legend(20,60,c("perfect match","mismatch"),c("red","blue"),bg="white")
34 |
35 | rm(l.pm, l.mm)
36 |
37 |
38 |
39 | ## The '5', 'M' or '3' in the names means the set of probes relates to
40 | ## the 5-prime, middle or 3-prime sectors respectively.
41 | ## The at or st ending means the sequence relates to the complementary
42 | ## sequence of the gene or not respectively.
43 |
44 | namesspot <- c("AFFX-BioB-5_at","AFFX-BioB-M_at", "AFFX-BioB-3_at")
45 |
46 | p <- probeset(Dilution, genenames=namesspot)
47 |
48 | par(mfrow=c(3,3))
49 |
50 | for (pps in p)
51 | barplot(pps)
52 |
53 |
54 | ## normalize
55 | plot.new()
56 | par(mfrow=c(2,2))
57 |
58 | nat <- pmormm(cdf.example)
59 |
60 | cel2 <- Dilution[[2]]
61 | plot(intensity(cel), intensity(cel2), xlab="CEL file 1", ylab="CEL file 2",main="raw values",sub="all probes plotted",type="n")
62 | points(intensity(cel)[nat], intensity(cel2)[nat], col="red")
63 | points(intensity(cel)[!nat], intensity(cel2)[!nat], col="blue")
64 | points(intensity(cel)[is.na(nat)], intensity(cel2)[is.na(nat)], pch="+")
65 | legend(25000, 15000, c("PM","MM","Unknown","identity line"), c("red","blue","black","grey"), bg="white")
66 | abline(0, 1, type="l", col="gray")
67 | rm(nat)
68 |
69 | abatch.n <- normalize(Dilution, method="constant", refindex=2)
70 | plot(intensity(abatch.n[[1]]), intensity(abatch.n[[2]]), xlab="CEL file 1", ylab="CEL file 2",main="normalized by constant",sub="all probes plotted")
71 | abline(0, 1, type="l", col="gray")
72 |
73 |
74 | abatch.n <- normalize(Dilution, method="invariantset")
75 | i.set <- history(abatch.n[[1]])$invariantset
76 |
77 | plot(intensity(cel), intensity(cel2), xlab="CEL file 1", ylab="CEL file 2",main="raw values",sub="all probes plotted")
78 |
79 | abline(0, 1, type="l", col="gray")
80 | legend(25000,15000,c("invariant set","identity line","spline through the invariant set"),c("orange","grey","red"),bg="white")
81 |
82 | plot(intensity(abatch.n[[1]]), intensity(abatch.n[[2]]), xlab="CEL file 1", ylab="CEL file 2",main="normalized by invariant set",sub="all probes plotted")
83 | points(intensity(abatch.n[[1]])[i.set], intensity(abatch.n[[2]])[i.set], col="orange",pch=16)
84 | abline(0, 1, type="l", col="gray")
85 | legend(20000,10000,c("invariant set","identity line"),c("orange","grey"),bg="white")
86 |
87 | ##
88 | ## Normalization and its effects can be observed in a couple of commands
89 | ##
90 |
91 | #par(mfrow=c(2,2))
92 | #data(Dilution)
93 | #boxplot(Dilution)
94 | #boxplot(normalize(Dilution))
95 |
96 |
97 | p <- probeset(Dilution, "1001_at")[[1]]
98 |
99 | par(mfcol=c(5,2))
100 | mymethods <- express.summary.stat.methods
101 | nmet <- length(mymethods)
102 | nc <- ncol(pm(p))
103 |
104 | layout(matrix(c(1:nc, rep(nc+1, nc)), nc, 2), width = c(1, 1))
105 | ##p@pm <- log(p@pm)
106 | ##p@mm <- log(p@mm)
107 |
108 | barplot(p)
109 |
110 | results <- matrix(0, nc, nmet)
111 | rownames(results) <- paste("sample", 1:nc)
112 | colnames(results) <- mymethods
113 |
114 | for (i in 1:nmet) {
115 | ev <- express.summary.stat(p, summary=mymethods[i], pmcorrect="pmonly")
116 | if (mymethods[[i]] != "medianpolish")
117 | results[, i] <- log(ev$exprs)
118 | else
119 | results[, i] <- ev$exprs
120 | }
121 | ##matplot(results, matrix(1:3, nr=nc, nc=nmet), type="l", lty=1:3, col=rainbow(nmet),
122 | ## xlab="expression value", lab="sample")
123 | dotchart(results, labels=paste("sample", 1:nc))
124 | ##legend()
125 |
126 | par(opar)
127 | rm(opar)
128 |
129 |
130 |
131 |
--------------------------------------------------------------------------------
/R/expresso.R:
--------------------------------------------------------------------------------
1 | expresso <- function(afbatch,
2 | ## --
3 | bg.correct=TRUE,
4 | bgcorrect.method = NULL,
5 | bgcorrect.param = list(),
6 | ## --
7 | normalize = TRUE,
8 | normalize.method = NULL,
9 | normalize.param=list(),
10 | ## --
11 | pmcorrect.method = NULL,
12 | pmcorrect.param = list(),
13 | ## --
14 | summary.method = NULL,
15 | summary.param = list(),
16 | summary.subset = NULL,
17 | ## ---
18 | verbose = TRUE,
19 | widget = FALSE
20 | ) {
21 | # JZ added this function
22 | setCorrections <- function(){
23 | bioc.opt <- getOption("BioC")
24 | if(bg.correct){
25 | if(is.null(bgcorrect.method)){
26 | BGMethods <- bgcorrect.methods()
27 | }else{
28 | BGMethods <- bgcorrect.method
29 | }
30 | }else{
31 | BGMethods <- "None"
32 | }
33 | if(normalize){
34 | if(is.null(normalize.method)){
35 | normMethods <- normalize.methods(afbatch)
36 | }else{
37 | normMethods <- normalize.method
38 | }
39 | }else{
40 | normMethods <- "None"
41 | }
42 | # Default for this one may not be correct
43 | if(is.null(pmcorrect.method)){
44 | PMMethods <- pmcorrect.methods()
45 | }else{
46 | PMMethods <- pmcorrect.method
47 | }
48 | # Default for this one may not be correct
49 | if(is.null(summary.method)){
50 | expMethods <- generateExprSet.methods()
51 |
52 | }else{
53 | expMethods <- summary.method
54 | }
55 |
56 | corrections <- expressoWidget(BGMethods, normMethods, PMMethods,
57 | expMethods, bioc.opt$affy$bgcorrect.method,
58 | bioc.opt$affy$normalize.method,
59 | bioc.opt$affy$pmcorrect.method,
60 | bioc.opt$affy$summary.method)
61 | if(!is.null(corrections)){
62 | if(corrections[["BG"]] != "None"){
63 | bgcorrect.method <<- corrections[["BG"]]
64 | }
65 | if(corrections[["NORM"]] != "None"){
66 | normalize.method <<- corrections[["NORM"]]
67 | }
68 | if(corrections[["PM"]] != "None"){
69 | pmcorrect.method <<- corrections[["PM"]]
70 | }
71 | if(corrections[["EXP"]] != "None"){
72 | summary.method <<- corrections[["EXP"]]
73 | }
74 | }else{
75 | stop("Aborted by user")
76 | }
77 | }
78 |
79 | if (widget) {
80 | requireNamespace("tkWidgets")
81 | }
82 |
83 | nchips <- length(afbatch)
84 |
85 | ###background stuff must be added before normalization!
86 |
87 | if(widget){
88 | setCorrections()
89 | }
90 |
91 | ## -- summary of what will be done
92 | if (verbose) {
93 | if (bg.correct){
94 | cat("background correction:", bgcorrect.method, "\n")
95 | }
96 | if (normalize) {
97 | cat("normalization:", normalize.method, "\n")
98 | }
99 | cat("PM/MM correction :", pmcorrect.method, "\n")
100 | cat("expression values:", summary.method, "\n")
101 | }
102 |
103 |
104 | ## -- background correct (if needed)
105 | if (bg.correct) {
106 |
107 | if (verbose)
108 | cat("background correcting...")
109 |
110 | afbatch <- do.call("bg.correct", c(alist(afbatch, method=bgcorrect.method), bgcorrect.param))
111 |
112 | if (verbose)
113 | cat("done.\n")
114 | }
115 |
116 | ## -- normalize (if wished)
117 | if (normalize) {
118 |
119 | if (verbose)
120 | cat("normalizing...")
121 |
122 | afbatch <- do.call(BiocGenerics::normalize, c(alist(afbatch, normalize.method), normalize.param))
123 |
124 | if (verbose)
125 | cat("done.\n")
126 | }
127 |
128 | eset <- computeExprSet(afbatch,
129 | summary.method=summary.method, pmcorrect.method= pmcorrect.method,
130 | ids=summary.subset,
131 | summary.param=summary.param, pmcorrect.param=pmcorrect.param)
132 |
133 | return(eset)
134 | }
135 |
136 |
137 |
138 |
--------------------------------------------------------------------------------
/man/fit.li.wong.Rd:
--------------------------------------------------------------------------------
1 | \name{fit.li.wong}
2 | \alias{fit.li.wong}
3 | \alias{li.wong}
4 | \title{Fit Li and Wong Model to a Probe Set}
5 | \description{Fits the model described in Li and Wong (2001) to a probe
6 | set with I chips and J probes.
7 | }
8 | \usage{
9 | fit.li.wong(data.matrix, remove.outliers=TRUE, normal.array.quantile=0.5,
10 | normal.resid.quantile=0.9, large.threshold=3, large.variation=0.8,
11 | outlier.fraction=0.14, delta=1e-06, maxit=50,
12 | outer.maxit=50,verbose=FALSE, ...)
13 |
14 | li.wong(data.matrix,remove.outliers=TRUE, normal.array.quantile=0.5,
15 | normal.resid.quantile=0.9, large.threshold=3, large.variation=0.8,
16 | outlier.fraction=0.14, delta=1e-06, maxit=50,
17 | outer.maxit=50,verbose=FALSE)
18 | }
19 | \arguments{
20 | \item{data.matrix}{an I x J matrix containing the probe set data. Typically
21 | the i,j entry will contain the PM-MM value for probe pair j in chip i.
22 | Another possible use, is to use PM instead of PM-MM.}
23 | \item{remove.outliers}{logical value indicating if the algorithm
24 | will remove outliers according to the procedure described in Li and
25 | Wong (2001).}
26 | \item{large.threshold}{used to define outliers.}
27 | \item{normal.array.quantile}{quantile to be used when determining what
28 | a normal SD is. probes or chips having estimates with SDs bigger
29 | than the quantile \code{normal.array.quantile} of all SDs x
30 | \code{large.threshold}.}
31 | \item{normal.resid.quantile}{any residual bigger than the
32 | \code{normal.resid.quantile} quantile of all residuals x
33 | \code{large.threshold} is considered an outlier.}
34 | \item{large.variation}{any probe or chip describing more than this
35 | much total variation is considered an outlier.}
36 | \item{outlier.fraction}{this is the maximum fraction of single
37 | outliers that can be in the same probe or chip.}
38 | \item{delta}{numerical value used to define the stopping criterion.}
39 | \item{maxit}{maximum number of iterations when fitting the model.}
40 | \item{outer.maxit}{maximum number of iterations of defined outliers.}
41 | \item{verbose}{logical value. If \code{TRUE} information is given of
42 | the status of the algorithm.}
43 | \item{\dots}{additional arguments.}
44 | }
45 | \details{
46 | This is Bioconductor's implementation of the Li and Wong algorithm. The
47 | Li and Wong PNAS 2001 paper was followed. However, you will not get
48 | the same results as you would get with dChip. dChip is not open source
49 | so it is not easy to reproduce.
50 |
51 | Notice that this iterative algorithm will not always converge.
52 | If you run the algorithm on thousands of probes expect some
53 | non-convergence warnings. These are more likely when few arrays are used.
54 | We recommend using this method only if you have 10 or more arrays.
55 |
56 | Please refer to references for more details.
57 | }
58 |
59 | \value{\code{li.wong} returns a vector of expression measures (or column
60 | effects) followed by their respective standard error estimates. It
61 | was designed to work with \code{express} which is no longer part of
62 | the package.
63 |
64 | \code{fit.li.wong} returns much more. Namely, a list containing the
65 | fitted parameters and relevant information.
66 | \item{theta}{fitted thetas.}
67 | \item{phi}{fitted phis.}
68 | \item{sigma.eps}{estimated standard deviation of the error term.}
69 | \item{sigma.theta}{estimated standard error of theta.}
70 | \item{sigma.phi}{estimated standard error of phis.}
71 | \item{theta.outliers}{logical vector describing which chips (thetas) are
72 | considered outliers (\code{TRUE}).}
73 | \item{phi.outliers}{logical vector describing which probe sets (phis) are
74 | considered outliers (\code{TRUE})}
75 | \item{convergence1}{logical value. If \code{FALSE} the algorithm did
76 | not converge when fitting the phis and thetas.}
77 | \item{convergence2}{logical value. If \code{FALSE} the algorithm did
78 | not converge in deciding what are outliers.}
79 | \item{iter}{number of iterations needed to achieve convergence.}
80 | \item{delta}{difference between thetas when iteration stopped.}
81 | }
82 | \examples{
83 | x <- sweep(matrix(2^rnorm(600),30,20),1,seq(1,2,len=30),FUN="+")
84 | fit1 <- fit.li.wong(x)
85 | plot(x[1,])
86 | lines(fit1$theta)
87 | }
88 | \references{
89 | Li, C. and Wong, W.H. (2001) \emph{Genome Biology} \bold{2}, 1--11.\cr
90 |
91 | Li, C. and Wong, W.H. (2001) \emph{Proc. Natl. Acad. Sci USA}
92 | \bold{98}, 31--36.
93 | }
94 | \author{Rafael A. Irizarry, Cheng Li, Fred A. Wright, Ben Bolstad}
95 | \seealso{\code{\link{li.wong}}, \code{\link{expresso}}}
96 | \keyword{manip}
97 | \keyword{models}
98 |
--------------------------------------------------------------------------------
/R/expressoWidget.R:
--------------------------------------------------------------------------------
1 | # A function that takes user inputs for correction methods for
2 | # expresso (affy). Default values can be missing, in which case the
3 | # first element will be chosen as the default.
4 |
5 | expressoWidget <- function(BGMethods, normMethods, PMMethods, expMethods,
6 | BGDefault, normDefault, PMDefault, expDefault){
7 | methodList <- list()
8 | END <- FALSE
9 |
10 | if(any(missing(BGMethods), missing(normMethods),
11 | missing(PMMethods), missing(expMethods))){
12 | stop("At least one of the method arguments is missing")
13 | }
14 | if(any(c(length(BGMethods), length(normMethods),
15 | length(PMMethods), length(expMethods)) == 0)){
16 | stop("At least one of the method argument is of length 1")
17 | }
18 |
19 | if(missing(BGDefault)){
20 | BGM <- tcltk::tclVar(BGMethods[1])
21 | }else{
22 | BGM <- tcltk::tclVar(BGDefault)
23 | }
24 | if(missing(normDefault)){
25 | NMM <- tcltk::tclVar(normMethods[1])
26 | }else{
27 | NMM <- tcltk::tclVar(normDefault)
28 | }
29 | if(missing(PMDefault)){
30 | PMM <- tcltk::tclVar(PMMethods[1])
31 | }else{
32 | PMM <- tcltk::tclVar(PMDefault)
33 | }
34 | if(missing(expDefault)){
35 | EXM <- tcltk::tclVar(expMethods[1])
36 | }else{
37 | EXM <- tcltk::tclVar(expDefault)
38 | }
39 |
40 |
41 | quit <- function(){
42 | tcltk::tkdestroy(base)
43 | }
44 | end <- function(){
45 | END <<- TRUE
46 | methodList[["BG"]] <<- tcltk::tclvalue(BGM)
47 | methodList[["NORM"]] <<- tcltk::tclvalue(NMM)
48 | methodList[["PM"]] <<- tcltk::tclvalue(PMM)
49 | methodList[["EXP"]] <<- tcltk::tclvalue(EXM)
50 | quit()
51 | }
52 |
53 | base <- tcltk::tktoplevel()
54 | ## post -- hook
55 | on.exit(tcltk::tkdestroy(base))
56 |
57 | tcltk::tktitle(base) <- "Expresso methods selection"
58 | ## Description text
59 | tcltk::tkpack(tcltk::tklabel(base, text = "Welcome to Expresso methods selection"),
60 | expand = FALSE, fill = "x", padx = 5, pady = 5)
61 | tcltk::tkpack(tcltk::tklabel(base, text = paste("You need to choose correction",
62 | "methods or go with the defaults")),
63 | expand = FALSE, fill = "x", padx = 5)
64 |
65 | ## Selections for correction methods
66 | methodFrame <- tcltk::tkframe(base)
67 | ## Background selection
68 | BGLabel <- tcltk::tklabel(methodFrame, text = "Background correction")
69 | BGDropdown <- tcltk::tkframe(methodFrame)
70 | widgetTools::dropdownList(BGDropdown, BGMethods, BGM, 20,
71 | tcltk::tclvalue(BGM), TRUE)
72 | tcltk::tkgrid(BGLabel, BGDropdown)
73 | tcltk::tkgrid.configure(BGLabel, sticky = "e")
74 | tcltk::tkgrid.configure(BGDropdown, sticky = "w")
75 |
76 | ## Normlization
77 | NMLabel <- tcltk::tklabel(methodFrame, text = "Normalization")
78 | NMDropdown <- tcltk::tkframe(methodFrame)
79 | widgetTools::dropdownList(NMDropdown,normMethods, NMM, 20,
80 | tcltk::tclvalue(NMM), TRUE)
81 | tcltk::tkgrid(NMLabel, NMDropdown)
82 | tcltk::tkgrid.configure(NMLabel, sticky = "e")
83 | tcltk::tkgrid.configure(NMDropdown, sticky = "w")
84 |
85 | ## PM correction
86 | PMLabel <- tcltk::tklabel(methodFrame, text = "PM correction")
87 | PMDropdown <- tcltk::tkframe(methodFrame)
88 | widgetTools::dropdownList(PMDropdown, PMMethods, PMM, 20,
89 | tcltk::tclvalue(PMM), TRUE)
90 | tcltk::tkgrid(PMLabel, PMDropdown)
91 | tcltk::tkgrid.configure(PMLabel, sticky = "e")
92 | tcltk::tkgrid.configure(PMDropdown, sticky = "w")
93 |
94 | ## PM correction
95 | EXLabel <- tcltk::tklabel(methodFrame, text = "Expression")
96 | EXDropdown <- tcltk::tkframe(methodFrame)
97 | widgetTools::dropdownList(EXDropdown, expMethods, EXM, 20,
98 | tcltk::tclvalue(EXM), TRUE)
99 | tcltk::tkgrid(EXLabel, EXDropdown)
100 | tcltk::tkgrid.configure(EXLabel, sticky = "e")
101 | tcltk::tkgrid.configure(EXDropdown, sticky = "w")
102 |
103 | tcltk::tkpack(methodFrame, expand = TRUE, fill = "both", padx = 5,
104 | pady = 10)
105 |
106 | butFrame <- tcltk::tkframe(base)
107 | quitBut <- tcltk::tkbutton(butFrame, text = "Quit", width = 7, command = quit)
108 | endBut <- tcltk::tkbutton(butFrame, text = "Select", width = 7, command = end)
109 | tcltk::tkgrid(quitBut, endBut, padx = 5)
110 | tcltk::tkpack(butFrame, expand = FALSE, fill = "x", pady = 5)
111 |
112 | tcltk::tkwait.window(base)
113 |
114 | if(END){
115 | return(methodList)
116 | }else{
117 | return(NULL)
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/man/read.affybatch.Rd:
--------------------------------------------------------------------------------
1 | \name{read.affybatch}
2 | \alias{read.affybatch}
3 | \alias{AllButCelsForReadAffy}
4 | \alias{ReadAffy}
5 | \title{Read CEL files into an AffyBatch}
6 | \description{
7 | Read CEL files into an Affybatch.
8 | }
9 | \usage{
10 | read.affybatch(\dots, filenames = character(0),
11 | phenoData = new("AnnotatedDataFrame"),
12 | description = NULL,
13 | notes = "",
14 | compress = getOption("BioC")$affy$compress.cel,
15 | rm.mask = FALSE, rm.outliers = FALSE, rm.extra = FALSE,
16 | verbose = FALSE,sd=FALSE, cdfname = NULL)
17 |
18 | ReadAffy(\dots, filenames=character(0),
19 | widget=getOption("BioC")$affy$use.widgets,
20 | compress=getOption("BioC")$affy$compress.cel,
21 | celfile.path=NULL,
22 | sampleNames=NULL,
23 | phenoData=NULL,
24 | description=NULL,
25 | notes="",
26 | rm.mask=FALSE, rm.outliers=FALSE, rm.extra=FALSE,
27 | verbose=FALSE,sd=FALSE, cdfname = NULL)
28 | }
29 | \arguments{
30 | \item{\dots}{file names separated by comma.}
31 | \item{filenames}{file names in a character vector.}
32 | \item{phenoData}{an \code{\link[Biobase:class.AnnotatedDataFrame]{AnnotatedDataFrame}}
33 | object, a \code{character} of length one, or a \code{data.frame}.}
34 | \item{description}{a \code{\link[Biobase:class.MIAME]{MIAME}} object.}
35 | \item{notes}{notes.}
36 | \item{compress}{are the CEL files compressed?}
37 | \item{rm.mask}{should the spots marked as 'MASKS' set to \code{NA}?}
38 | \item{rm.outliers}{should the spots marked as 'OUTLIERS' set to \code{NA}?}
39 | \item{rm.extra}{if \code{TRUE}, then overrides what is in \code{rm.mask} and
40 | \code{rm.oultiers}.}
41 | \item{verbose}{verbosity flag.}
42 | \item{widget}{a logical specifying if widgets should be used.}
43 | \item{celfile.path}{a character denoting the path \code{ReadAffy}
44 | should look for cel files.}
45 | \item{sampleNames}{a character vector of sample names to be used in
46 | the \code{AffyBatch}.}
47 | \item{sd}{should the standard deviation values in the CEL file be read
48 | in? Since these are typically not used default is not to read them
49 | in. This also save lots of memory.}
50 | \item{cdfname}{used to specify the name of an alternative cdf package.
51 | If set to \code{NULL}, then the usual cdf package based on Affymetrix's
52 | mappings will be used.}
53 | }
54 | \details{
55 | \code{ReadAffy} is a wrapper for \code{read.affybatch} that permits the
56 | user to read in phenoData, MIAME information, and CEL files using
57 | widgets. One can also define files where to read phenoData and MIAME
58 | information.
59 |
60 | If the function is called with no arguments \code{ReadAffy()} all the CEL
61 | files in the working directory are read and put into an \code{AffyBatch}.
62 | However, the arguments give the user great flexibility.
63 |
64 | If \code{phenoData} is a character vector of length 1, the function
65 | \code{\link[Biobase]{read.AnnotatedDataFrame}} is called to read a file
66 | of that name and produce the \code{AnnotationDataFrame} object with the
67 | sample metadata. If \code{phenoData} is a \code{data.frame}, it is
68 | converted to an \code{AnnotatedDataFrame}.
69 | If it is \code{NULL} and \code{widget=FALSE} (\code{widget=TRUE} is not currently
70 | supported), then a default object of class
71 | \code{\link[Biobase:class.AnnotatedDataFrame]{AnnotatedDataFrame}} is created,
72 | whose \code{pData} is a data.frame with rownames being the names
73 | of the CEL files, and with one column \code{sample} with an integer index.
74 |
75 | \code{AllButCelsForReadAffy} is an internal function that gets called
76 | by \code{ReadAffy}. It gets all the information except the cel intensities.
77 |
78 | \code{description} is read using \code{\link[Biobase]{read.MIAME}}. If a
79 | character is given, then it tries to read the file with that name to obtain a
80 | \code{MIAME} instance. If left \code{NULL} but \code{widget=TRUE}, then
81 | widgets are used. If left \code{NULL} and \code{widget=FALSE}, then an
82 | empty instance of \code{MIAME} is created.
83 | }
84 | \value{
85 | An \code{AffyBatch} object.
86 | }
87 | \author{Ben Bolstad \email{bmb@bmbolstad.com} (read.affybatch),
88 | Laurent Gautier, and Rafael A. Irizarry (ReadAffy)}
89 | \seealso{\code{\link[affy:AffyBatch-class]{AffyBatch}}}
90 | \examples{
91 | if(require(affydata)){
92 | celpath <- system.file("celfiles", package="affydata")
93 | fns <- list.celfiles(path=celpath,full.names=TRUE)
94 |
95 | cat("Reading files:\n",paste(fns,collapse="\n"),"\n")
96 | ##read a binary celfile
97 | abatch <- ReadAffy(filenames=fns[1])
98 | ##read a text celfile
99 | abatch <- ReadAffy(filenames=fns[2])
100 | ##read all files in that dir
101 | abatch <- ReadAffy(celfile.path=celpath)
102 | }
103 | }
104 | \keyword{manip}
105 |
--------------------------------------------------------------------------------
/R/normalize.qspline.R:
--------------------------------------------------------------------------------
1 | normalize.AffyBatch.qspline <- function(abatch, type=c("together","pmonly","mmonly","separate"),...) {
2 |
3 | type <- match.arg(type)
4 |
5 | if (type == "together"){
6 | Index <- unlist(indexProbes(abatch,"both"))
7 | intensity(abatch)[Index,] <- normalize.qspline(intensity(abatch)[Index,], ...)
8 | } else if (type == "pmonly"){
9 | Index <- unlist(indexProbes(abatch,"pm"))
10 | intensity(abatch)[Index,] <- normalize.qspline(intensity(abatch)[Index,], ...)
11 | } else if (type == "mmonly"){
12 | Index <- unlist(indexProbes(abatch,"mm"))
13 | intensity(abatch)[Index,] <- normalize.qspline(intensity(abatch)[Index,], ...)
14 | } else if (type == "separate"){
15 | Index <- unlist(indexProbes(abatch,"pm"))
16 | intensity(abatch)[Index,] <- normalize.qspline(intensity(abatch)[Index,], ...)
17 | Index <- unlist(indexProbes(abatch,"mm"))
18 | intensity(abatch)[Index,] <- normalize.qspline(intensity(abatch)[Index,], ...)
19 | }
20 | #set.na.spotsd(listcel)
21 | normhisto <- vector("list", length=ncol(intensity(abatch)))
22 | ##need to use MIAME for this
23 | for (i in 1:length(abatch)) {
24 | normhisto[[i]] <- list(name="normalized by qspline")
25 | }
26 |
27 | attr(abatch, "normalization") <- normhisto
28 |
29 | return(abatch)
30 | }
31 |
32 | normalize.qspline <- function(x,
33 | target = NULL,
34 | samples = NULL,
35 | fit.iters = 5,
36 | min.offset = 5,
37 | spline.method = "natural", # c("fmm", "natural", "periodic")
38 | smooth = TRUE,
39 | spar = 0, # smoothing parameter
40 | p.min = 0,
41 | p.max = 1.0,
42 | incl.ends = TRUE,
43 | converge = FALSE,
44 | verbose = TRUE,
45 | na.rm = FALSE
46 | ){
47 |
48 | if (is.null(target))
49 | target <- exp(apply(log(x), 1, mean))
50 |
51 | x.n <- dim(x)[1]
52 | m <- dim(x)[2]
53 |
54 | if (is.null(samples))
55 | samples <- max(round(x.n/1000), 100)
56 | else
57 | if (samples < 1)
58 | samples <- round(samples * x.n)
59 |
60 | p <- (1:samples) / samples
61 | p <- p[ which(p <= p.max) & which(p >= p.min) ]
62 | samples <- length(p)
63 |
64 | k <- fit.iters
65 |
66 | if (na.rm==TRUE)
67 | y.n <- sum(!is.na(target))
68 | else
69 | y.n <- length(target)
70 |
71 | py.inds <- as.integer(p * y.n)
72 | y.offset <- round(py.inds[1]/fit.iters)
73 |
74 | if (y.offset <= min.offset) {
75 | y.offset <- min.offset;
76 | k <- round(py.inds[1]/min.offset)
77 | }
78 |
79 | if (k <= 1) {
80 | warning("'k' found is non-sense. using default 'fit.iter'")
81 | k <- fit.iters
82 | }
83 |
84 | y.offset <- c(0, array(y.offset, (k-1)))
85 | y.order <- order(target)
86 |
87 | fx <- matrix(0, x.n,m)
88 | if(verbose==TRUE)
89 | print(paste("samples=",samples, "k=", k, "first=", py.inds[1]))
90 |
91 | for (i in 1:m) {
92 | # to handel NA values for each array
93 | if (na.rm==TRUE)
94 | x.valid <- which(!is.na(x[,i]))
95 | else
96 | x.valid <- 1:x.n
97 |
98 | x.n <- length(x.valid)
99 | px.inds <- as.integer(p * x.n)
100 | x.offset <- round(px.inds[1]/fit.iters)
101 |
102 | if (x.offset<=min.offset) {
103 | x.offset <- min.offset;
104 | k <- min(round(px.inds[1]/min.offset), k)
105 | }
106 |
107 | x.offset <- c(0, array(x.offset, (k-1)))
108 | x.order <- order(x[,i]) # NA's at the end (?)
109 |
110 | y.inds <- py.inds ## must be reset each iteration
111 | x.inds <- px.inds
112 |
113 | for (j in 1:k) {
114 | y.inds <- y.inds - y.offset[j]
115 | x.inds <- x.inds - x.offset[j]
116 | ty.inds <- y.inds
117 | tx.inds <- x.inds
118 | if (verbose==TRUE)
119 | print(paste("sampling(array=", i, "iter=", j, "off=",
120 | x.inds[1], -x.offset[j], y.inds[1], -y.offset[j], ")"))
121 |
122 | if (converge==TRUE) {
123 | ty.inds <- as.integer(c(1, y.inds))
124 | tx.inds <- as.integer(c(1, x.inds))
125 |
126 | if (j > 1) {
127 | ty.inds <- c(ty.inds, y.n)
128 | tx.inds <- c(tx.inds, x.n)
129 | }
130 | }
131 | qy <- target[y.order[ty.inds]]
132 | qx <- x[x.order[tx.inds],i]
133 |
134 | if (smooth==TRUE) {
135 | sspl <- smooth.spline(qx, qy, spar=spar)
136 | qx <- sspl$x
137 | qy <- sspl$y
138 | }
139 |
140 | fcn <- splinefun(qx, qy, method=spline.method)
141 | fx[x.valid,i] <- fx[x.valid,i] + fcn(x[x.valid,i])/k
142 | }
143 |
144 | if (na.rm==TRUE) {
145 | invalid <- which(is.na(x[,i]))
146 | fx[invalid,i] <- NA
147 | }
148 | }
149 | return(fx)
150 | }
151 |
--------------------------------------------------------------------------------
/man/justrma.Rd:
--------------------------------------------------------------------------------
1 | \name{justRMA}
2 | \alias{justRMA}
3 | \alias{just.rma}
4 | \title{Read CEL files into an ExpressionSet}
5 | \description{
6 | Read CEL files and compute an expression measure without using an AffyBatch.}
7 | \usage{
8 | just.rma(\dots, filenames = character(0),
9 | phenoData = new("AnnotatedDataFrame"),
10 | description = NULL,
11 | notes = "",
12 | compress = getOption("BioC")$affy$compress.cel,
13 | rm.mask = FALSE, rm.outliers = FALSE, rm.extra = FALSE,
14 | verbose=FALSE, background=TRUE, normalize=TRUE,
15 | bgversion=2, destructive=FALSE, cdfname = NULL)
16 |
17 | justRMA(\dots, filenames=character(0),
18 | widget=getOption("BioC")$affy$use.widgets,
19 | compress=getOption("BioC")$affy$compress.cel,
20 | celfile.path=getwd(),
21 | sampleNames=NULL,
22 | phenoData=NULL,
23 | description=NULL,
24 | notes="",
25 | rm.mask=FALSE, rm.outliers=FALSE, rm.extra=FALSE,
26 | hdf5=FALSE, hdf5FilePath=NULL,verbose=FALSE,
27 | normalize=TRUE, background=TRUE,
28 | bgversion=2, destructive=FALSE, cdfname = NULL)
29 | }
30 | \arguments{
31 | \item{\dots}{file names separated by comma.}
32 | \item{filenames}{file names in a character vector.}
33 | \item{phenoData}{an
34 | \code{\link[Biobase:class.AnnotatedDataFrame]{AnnotatedDataFrame}}
35 | object.}
36 | \item{description}{a \code{\link[Biobase:class.MIAME]{MIAME}} object.}
37 | \item{notes}{notes.}
38 | \item{compress}{are the CEL files compressed?}
39 | \item{rm.mask}{should the spots marked as 'MASKS' set to \code{NA}?}
40 | \item{rm.outliers}{should the spots marked as 'OUTLIERS' set to \code{NA}?}
41 | \item{rm.extra}{if \code{TRUE}, then overrides what is in
42 | \code{rm.mask} and \code{rm.oultiers}.}
43 | \item{hdf5}{use of hdf5 ? (not available yet)}
44 | \item{hdf5FilePath}{a filename to use with hdf5 (not available yet).}
45 | \item{verbose}{verbosity flag.}
46 | \item{widget}{a logical specifying if widgets should be used.}
47 | \item{celfile.path}{a character denoting the path \code{ReadAffy} should look
48 | for cel files.}
49 | \item{sampleNames}{a character vector of sample names to be used in the
50 | \code{AffyBatch}.}
51 | \item{normalize}{logical value. If \code{TRUE}, then normalize data using
52 | quantile normalization.}
53 | \item{background}{logical value. If \code{TRUE}, then background correct
54 | using RMA background correction.}
55 | \item{bgversion}{integer value indicating which RMA background to use
56 | 1: use background similar to pure R rma background given in affy
57 | version 1.0 - 1.0.2
58 |
59 | 2: use background similar to pure R rma background given in affy
60 | version 1.1 and above}
61 | \item{destructive}{logical value. If \code{TRUE}, then works on the PM matrix
62 | in place as much as possible, good for large datasets.}
63 | \item{cdfname}{Used to specify the name of an alternative cdf package. If set
64 | to \code{NULL}, then the usual cdf package based on Affymetrix' mappings
65 | will be used.}
66 | }
67 | \details{
68 | \code{justRMA} is a wrapper for \code{just.rma} that permits the user to read
69 | in phenoData, MIAME information, and CEL files using widgets. One can also
70 | define files where to read phenoData and MIAME information.
71 |
72 | If the function is called with no arguments \code{justRMA()}, then all the CEL
73 | files in the working directory are read, converted to an expression measure
74 | using RMA and put into an
75 | \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}}.
76 | However, the arguments give the user great flexibility.
77 |
78 | \code{phenoData} is read using \code{\link[Biobase]{read.AnnotatedDataFrame}}.
79 | If a character is given, it tries to read the file with that name to obtain the
80 | \code{AnnotatedDataFrame} object as described in \code{\link[Biobase]{read.AnnotatedDataFrame}}.
81 | If left \code{NULL} and \code{widget=FALSE} (\code{widget=TRUE} is not currently
82 | supported), then a default object is created.
83 | It will be an object of class \code{\link[Biobase:class.AnnotatedDataFrame]{AnnotatedDataFrame}}
84 | with its pData being a data.frame with column x indexing the CEL files.
85 |
86 | \code{description} is read using \code{\link[Biobase]{read.MIAME}}. If a
87 | character is given, it tries to read the file with that name to obtain a
88 | \code{MIAME} instance. If left \code{NULL} but \code{widget=TRUE}, then
89 | widgets are used. If left \code{NULL} and \code{widget=FALSE}, then an
90 | empty instance of \code{MIAME} is created.
91 |
92 | The arguments \code{rm.masks}, \code{rm.outliers}, \code{rm.extra} are
93 | passed along to the function \code{read.celfile}.
94 | }
95 | \value{
96 | An \code{ExpressionSet} object, containing expression values identical to
97 | what one would get from running \code{rma} on an \code{AffyBatch}.
98 | }
99 | \author{In the beginning: James MacDonald
100 | Supporting routines, maintenance and just.rma: Ben Bolstad }
101 | \seealso{\code{\link[affy]{rma}}, \code{\link{read.affybatch}}}
102 | \keyword{manip}
103 |
--------------------------------------------------------------------------------
/R/ProbeSet.R:
--------------------------------------------------------------------------------
1 | ## A ProbeSet holds probe values for a probe pairs set(*) accross a batch of experiments.
2 | ## methods 'express.summary.stat' returns of expression value per experiement in the
3 | ## batch, and 'bg.correct' does background correction (in some sense... the MM probes
4 | ## were created to measure unspecific hybridization. People thought that doing
5 | ## PM - MM would remove background noise. The method 'bg.correct' accepts extra parameters
6 | ## through '...' (can be used to pass background correction parameters common to different
7 | ## ProbeSet)
8 | ##
9 | ## -
10 | ## (*) : a probe pair set is the set of probes pairs(**) related to an affyid. Generally a
11 | ## a probe pair set has 20 elements.
12 | ## (**): a probe pair (or atom) is a pair of PM/MM values
13 | ##
14 |
15 | if (debug.affy123) cat("-->initProbeSet\n")
16 |
17 | setClass("ProbeSet",
18 | representation(id="character", pm="matrix", mm="matrix"),
19 | prototype=list(pm=matrix(), mm=matrix()))
20 |
21 | setMethod("show", "ProbeSet",
22 | function(object) {
23 | cat("ProbeSet object:\n")
24 | cat(" id=", object@id, "\n", sep="")
25 | cat(" pm=", nrow(object@pm), "probes x ", ncol(object@pm), " chips\n")
26 | })
27 |
28 | ##DEBUG: what to do with that ?
29 | ## --> with what ?
30 |
31 | setMethod("sampleNames", "ProbeSet",
32 | function(object) colnames(object))
33 |
34 | setMethod("colnames", signature(x="ProbeSet"),
35 | function(x ,do.NULL=FALSE, prefix="row") {
36 |
37 | cnames<-colnames(pm(x))
38 |
39 | if (is.null(cnames)) {
40 |
41 | if (do.NULL) {
42 | warning("No column names for ProbeSet")
43 | }
44 | else {
45 | cnames <- paste(prefix, 1:ncol(x@pm))
46 | }
47 |
48 | }
49 | return(cnames)
50 | })
51 |
52 | ## pm
53 | if( is.null(getGeneric("pm")))
54 | setGeneric("pm", function(object) standardGeneric("pm"))
55 |
56 | setMethod("pm", "ProbeSet", function(object) object@pm)
57 |
58 | if( is.null(getGeneric("pm<-")))
59 | setGeneric("pm<-", function(object, value) standardGeneric("pm<-"))
60 |
61 | setReplaceMethod("pm", signature=c("ProbeSet", "matrix"),
62 | function(object, value) {
63 | if (! all(dim(value) == dim(object@mm)))
64 | stop("dimension mismatch between 'pm' and 'mm'")
65 | object@pm <- value
66 | })
67 |
68 | ## mm
69 | if( is.null(getGeneric("mm")))
70 | setGeneric("mm", function(object) standardGeneric("mm"))
71 |
72 | setMethod("mm", "ProbeSet", function(object) object@mm)
73 |
74 |
75 | if( is.null(getGeneric("mm<-")))
76 | setGeneric("mm<-", function(object, value) standardGeneric("mm<-"))
77 |
78 | setReplaceMethod("mm", signature=c("ProbeSet", "matrix"),
79 | function(object, value) {
80 | if (sum(dim(value) == dim(object@mm)) != 2)
81 | stop("dimension mismatch between 'pm' and 'mm'")
82 | object@mm <- value
83 | })
84 |
85 | ## method express.summary.stat
86 | if( is.null(getGeneric("express.summary.stat")))
87 | setGeneric("express.summary.stat", function(x, pmcorrect, summary, ...)
88 | standardGeneric("express.summary.stat"))
89 |
90 | setMethod("express.summary.stat",signature(x="ProbeSet", pmcorrect="character", summary="character"),
91 | function(x, pmcorrect, summary, summary.param=list(), pmcorrect.param=list()) {
92 |
93 | pmcorrect <- match.arg(pmcorrect, pmcorrect.methods())
94 | summary <- match.arg(summary, express.summary.stat.methods())
95 |
96 | ## simple for system to let one add background correction methods
97 | ## relies on naming convention
98 | pmcorrect.methodname <- paste("pmcorrect.", pmcorrect, sep="")
99 | summary.methodname <- paste("generateExprVal.method.", summary, sep="")
100 |
101 | if (! exists(summary.methodname))
102 | stop(paste("Unknown method (cannot find function", summary.methodname, ")"))
103 | if (! exists(pmcorrect.methodname))
104 | stop(paste("Unknown method (cannot find function", pmcorrect.methodname, ")"))
105 |
106 | ## NOTE: this could change...
107 | #m <- do.call(bg.correct, c(alist(x@pm, x@mm), param.bg.correct))
108 | pm.corrected <- do.call(pmcorrect.methodname, c(alist(x), pmcorrect.param))
109 | r <- do.call(summary.methodname, c(alist(pm.corrected), summary.param))
110 |
111 | ##DEBUG: name stuff to sort
112 | #names(r) <- names(allprobes)
113 |
114 | return(r)
115 | })
116 |
117 |
118 | setMethod("barplot",signature(height="ProbeSet"),function(height,...) barplot.ProbeSet(height,...))
119 |
120 | if( is.null(getGeneric("mas5calls")) )
121 | setGeneric("mas5calls", function(object,...) standardGeneric("mas5calls"))
122 |
123 | setMethod("mas5calls",signature(object="ProbeSet"),
124 | function(object,...) mas5calls.ProbeSet(object,...))
125 |
126 |
--------------------------------------------------------------------------------
/R/justrma.R:
--------------------------------------------------------------------------------
1 | ## Sept 11, 2003 - justRMA calls just.rma2
2 | ### A user friendly wrapper for just.rma
3 | justRMA <- function(..., filenames=character(0),
4 | widget=getOption("BioC")$affy$use.widgets,
5 | compress=getOption("BioC")$affy$compress.cel,
6 | celfile.path=getwd(),
7 | sampleNames=NULL,
8 | phenoData=NULL,
9 | description=NULL,
10 | notes="",
11 | rm.mask=FALSE, rm.outliers=FALSE, rm.extra=FALSE,
12 | hdf5=FALSE, hdf5FilePath=NULL,verbose=FALSE,
13 | normalize=TRUE, background=TRUE,
14 | bgversion=2, destructive=FALSE,
15 | cdfname = NULL){
16 |
17 | l <- AllButCelsForReadAffy(..., filenames=filenames,
18 | widget=widget,
19 | celfile.path=celfile.path,
20 | sampleNames=sampleNames,
21 | phenoData=phenoData,
22 | description=description)
23 |
24 |
25 | ##and now we are ready to read cel files
26 | ret<- just.rma(filenames=l$filenames,
27 | phenoData=l$phenoData,
28 | description=l$description,
29 | notes=notes,
30 | compress=compress,
31 | rm.mask=rm.mask,
32 | rm.outliers=rm.outliers,
33 | rm.extra=rm.extra,
34 | verbose=verbose,
35 | normalize=normalize,
36 | background=background,
37 | bgversion=bgversion,
38 | destructive=destructive,
39 | cdfname = cdfname)
40 | sampleNames(ret) <- l$sampleNames
41 | return(ret)
42 |
43 | }
44 |
45 |
46 |
47 |
48 | ###########################################################################################
49 | #
50 | # this function uses a different parsing routine
51 | # It was added Jul 7, 2003 by B. M. Bolstad
52 | #
53 | ###########################################################################################
54 |
55 | just.rma <- function(..., filenames=character(0),
56 | phenoData=new("AnnotatedDataFrame"),
57 | description=NULL,
58 | notes="",
59 | compress=getOption("BioC")$affy$compress.cel,
60 | rm.mask=FALSE, rm.outliers=FALSE, rm.extra=FALSE,
61 | verbose=FALSE, background=TRUE, normalize=TRUE,
62 | bgversion=2, destructive=FALSE, cdfname = NULL) {
63 |
64 | auxnames <- unlist(list(...))
65 | filenames <- c(filenames, auxnames)
66 |
67 | checkValidFilenames(filenames)
68 |
69 | n <- length(filenames)
70 |
71 | pdata <- pData(phenoData)
72 | ##try to read sample names form phenoData. if not there use CEL filenames
73 | if(dim(pdata)[1]!=n){#if empty pdata filename are samplenames
74 | warning("Incompatible phenoData object. Created a new one.\n")
75 |
76 | samplenames <- gsub("^/?([^/]*/)*", "", unlist(filenames))
77 | pdata <- data.frame(sample=1:n,row.names=samplenames)
78 | phenoData <- new("AnnotatedDataFrame",
79 | data=pdata,
80 | varMetadata=data.frame(
81 | labelDescription="arbitrary numbering",
82 | row.names="sample"))
83 | }
84 | else samplenames <- rownames(pdata)
85 |
86 | if (is.null(description))
87 | {
88 | description <- new("MIAME")
89 | description@preprocessing$filenames <- filenames
90 | description@preprocessing$affyversion <-
91 | as.character(packageVersion("affy"))
92 | }
93 | ## read the first file to see what we have
94 | ##if (verbose) cat(1, "reading",filenames[[1]],"...")
95 |
96 | ## get information from cdf environment
97 |
98 | headdetails <- read.celfile.header(filenames[[1]])
99 | if(is.null(cdfname))
100 | cdfname <- headdetails[[1]]
101 | scandates <-
102 | sapply(seq_len(length(filenames)), function(i) {
103 | sdate <- read.celfile.header(filenames[i], info = "full")[["ScanDate"]]
104 | if (is.null(sdate) || length(sdate) == 0) NA_character_ else sdate
105 | })
106 | protocol <-
107 | new("AnnotatedDataFrame",
108 | data=data.frame("ScanDate"=scandates, row.names = sampleNames(phenoData),
109 | stringsAsFactors=FALSE),
110 | dimLabels=c("sampleNames", "sampleColumns"))
111 | tmp <- new("AffyBatch",
112 | cdfName=cdfname,
113 | annotation=cleancdfname(cdfname, addcdf=FALSE))
114 | pmIndex <- pmindex(tmp)
115 | probenames <- rep(names(pmIndex), unlist(lapply(pmIndex,length)))
116 | pNList <- split(0:(length(probenames) -1), probenames)
117 |
118 |
119 | ## read pm data into matrix
120 |
121 | probeintensities <- read.probematrix(filenames=filenames, cdfname = cdfname)
122 |
123 | ##pass matrix of pm values to rma
124 |
125 | ngenes <- length(geneNames(tmp))
126 |
127 | exprs <- .Call("rma_c_complete",probeintensities$pm, pNList, ngenes, normalize, background, bgversion, verbose, PACKAGE="affy")
128 |
129 | colnames(exprs) <- samplenames
130 | se.exprs <- array(NA, dim(exprs),
131 | dimnames=list(rownames(exprs), colnames(exprs)))
132 |
133 | annotation <- annotation(tmp)
134 | notes(description) <- notes
135 | new("ExpressionSet",
136 | phenoData = phenoData,
137 | protocolData = protocol,
138 | annotation = annotation,
139 | experimentData = description,
140 | exprs = exprs, se.exprs = se.exprs)
141 | }
142 |
--------------------------------------------------------------------------------
/R/normalize.invariantset.R:
--------------------------------------------------------------------------------
1 | normalize.AffyBatch.invariantset <- function(abatch, prd.td=c(0.003,0.007), verbose=FALSE,baseline.type=c("mean","median","pseudo-mean","pseudo-median"),type=c("separate","pmonly","mmonly","together")) {
2 |
3 | do.normalize.Affybatch.invariantset <- function(abatch, pms, prd.td, baseline.type){
4 |
5 |
6 | nc <- length(abatch) # number of CEL files
7 |
8 | if (baseline.type == "mean"){
9 | # take as a reference the array having the median overall intensity
10 | m <- vector("numeric", length=nc)
11 | for (i in 1:nc)
12 | m[i] <- mean(intensity(abatch)[pms, i])
13 | refindex <- match(trunc(median(rank(m))), rank(m))
14 | rm(m)
15 | baseline.chip <- c(intensity(abatch)[pms, refindex])
16 | if (verbose) cat("Data from", sampleNames(abatch)[refindex], "used as baseline.\n")
17 | }
18 | else if (baseline.type == "median"){
19 | # take as a reference the array having the median median intensity
20 | m <- vector("numeric", length=nc)
21 | for (i in 1:nc)
22 | m[i] <- median(intensity(abatch)[pms, i])
23 | refindex <- match(trunc(median(rank(m))), rank(m))
24 | rm(m)
25 | baseline.chip <- c(intensity(abatch)[pms, refindex])
26 | if (verbose) cat("Data from", sampleNames(abatch)[refindex], "used as baseline.\n")
27 | } else if (baseline.type == "pseudo-mean"){
28 | # construct a psuedo chip to serve as the baseline by taking probewise means
29 | refindex <- 0
30 | baseline.chip <- rowMeans(intensity(abatch)[pms,])
31 | } else if (baseline.type == "pseudo-median"){
32 | # construct a pseudo chip to serve as the baseline by taking probewise medians
33 | refindex <- 0
34 | baseline.chip <- rowMedians(intensity(abatch)[pms,])
35 | }
36 |
37 |
38 | ##set.na.spotsd(cel.container)
39 |
40 | normhisto <- vector("list", length=nc)
41 | # normhisto[[refindex]] <- list(name="reference for the invariant set")
42 |
43 | ## loop over the CEL files and normalize them
44 |
45 | for (i in (1:nc)) {
46 | if (i != refindex){
47 | if (verbose) cat("normalizing array", sampleNames(abatch)[i], "...")
48 |
49 | ##temporary
50 | tmp <- normalize.invariantset(c(intensity(abatch)[pms, i]),
51 | c(baseline.chip),
52 | prd.td)
53 | #i.set <- which(i.pm)[tmp$i.set]
54 | tmp <- as.numeric(approx(tmp$n.curve$y, tmp$n.curve$x,
55 | xout=intensity(abatch)[pms, i], rule=2)$y)
56 | attr(tmp,"invariant.set") <- NULL
57 | intensity(abatch)[pms, i] <- tmp
58 |
59 | ## storing information about what has been done
60 | #normhisto[[i]] <- list(name="normalized by invariant set",
61 | # invariantset=i.set)
62 |
63 | if (verbose) cat("done.\n")
64 |
65 | }
66 | }
67 | attr(abatch, "normalization") <- normhisto
68 | return(abatch)
69 | }
70 |
71 | type <- match.arg(type)
72 | baseline.type <- match.arg(baseline.type)
73 |
74 | if (type == "pmonly"){
75 | pms <- unlist(pmindex(abatch))
76 | do.normalize.Affybatch.invariantset(abatch, pms, prd.td, baseline.type)
77 | } else if (type == "mmonly"){
78 | pms <- unlist(mmindex(abatch))
79 | do.normalize.Affybatch.invariantset(abatch, pms, prd.td, baseline.type)
80 | } else if (type == "together"){
81 | pms <- unlist(indexProbes(abatch,"both"))
82 | do.normalize.Affybatch.invariantset(abatch, pms, prd.td, baseline.type)
83 | } else if (type == "separate"){
84 | pms <- unlist(pmindex(abatch))
85 | abatch <- do.normalize.Affybatch.invariantset(abatch, pms, prd.td, baseline.type)
86 | pms <- unlist(mmindex(abatch))
87 | do.normalize.Affybatch.invariantset(abatch, pms, prd.td, baseline.type)
88 | }
89 |
90 | }
91 |
92 |
93 |
94 | ## The 'common-to-all' part of the algorithm. Operates on two vectors of numeric data
95 | ##
96 | normalize.invariantset <- function(data, ref, prd.td=c(0.003,0.007)) {
97 |
98 | np <- length(data)
99 | r.ref <- rank(ref)
100 | r.array <- rank(data)
101 |
102 | ## init
103 | prd.td.adj <- prd.td*10 # adjusted threshold things
104 | i.set <- rep(TRUE, np) # index all the PM probes as being in the invariant set
105 | ns <- sum(i.set) # number of probes in the invariant set
106 | ns.old <- ns+50+1 # number of probes previously in the invariant set
107 |
108 | ## iterate while the number of genes in the invariant set (ns) still varies...
109 | while ( (ns.old-ns) > 50 ) {
110 | air <- (r.ref[i.set] + r.array[i.set]) / (2*ns) # average intensity rank for the probe intensities
111 | prd <- abs(r.ref[i.set] - r.array[i.set]) / ns
112 | threshold <- (prd.td.adj[2]-prd.td[1]) * air + prd.td.adj[1]
113 | i.set[i.set] <- (prd < threshold)
114 |
115 | ns.old <- ns
116 | ns <- sum(i.set)
117 |
118 | if (prd.td.adj[1] > prd.td[1])
119 | prd.td.adj <- prd.td.adj * 0.9 # update the adjusted threshold parameters
120 | }
121 |
122 | ## the index i.set corresponds to the 'invariant genes'
123 | n.curve <- smooth.spline(ref[i.set], data[i.set])
124 | ## n.curve$x contains smoothed reference intensities
125 | ## n.curve$y contains smoothed i-th array intensities
126 |
127 | ##data <- as.numeric(approx(n.curve$y, n.curve$x, xout=data)$y)
128 | ##attr(data,"invariant.set") <- i.set
129 | ##return(data)
130 | return(list(n.curve=n.curve, i.set=i.set))
131 | }
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/NEWS:
--------------------------------------------------------------------------------
1 | version 1.41.1
2 | o Fixed bug. attr(r,"constant") <- thisconstant * refconstant to attr(r,"constant") <- refconstant / thisconstant. Reported Aris Floratos.
3 |
4 |
5 | version 1.23.x
6 |
7 | o Populate new eSet slot 'protocolData' with information from cel files.
8 |
9 |
10 | version 1.17.x
11 |
12 | o Replaced usage of defunct Biobase classes exprSet and phenoData with
13 | ExpressionSet and AnnotatedDataFrame.
14 |
15 |
16 | version 1.4.x [under development]
17 |
18 | o xy2indices/indices2xy have now a (dangerous) parameter xy.offset.
19 | See below for more details.
20 |
21 | o a new package-wide parameter called 'xy.offset' was added. This is
22 | the first towards getting rid of the 'indexing-starting-at-one-and
23 | -not-at-zero' difficulty. This package-wide parameter is the only
24 | thing one should play play with to change the offset of x/y
25 | coordinates for features on a chip.
26 |
27 | o computeExprSet (method of AffyBatch) has the following (visible)
28 | improvements:
29 | - better reporting of errors
30 | - better handlings ids as parameters (does not crash any longer when
31 | unknown ids are given)
32 |
33 | o indexProbes (method of AffyBatch) sees the deprecated flag 'xy' removed
34 | for good.
35 |
36 | o mmindex (see indexProbes above)
37 |
38 | o pmindex (see indexProbes above)
39 |
40 | o ppsetApply: a function to apply a function over the probe sets that can be
41 | built from an instance of AffyBatch. This is done in the spirit of
42 | esetApply in Biobase (the covariate information in phenoData are
43 | directly accessible from the function (see example in the man page).
44 |
45 | o rma - the subset parameter now works properly.
46 |
47 | o mva.pairs - now uses a subset to fit the loess curve (much more efficient).
48 | also the summary statistics displayed are different. In particular the
49 | median and IQR of the M's are shown in the lower triangle. Previously,
50 | an IQR of loess curve values was shown.
51 |
52 |
53 | version 1.3.x
54 |
55 | Things done:
56 |
57 | 0 (wh:) moved everything related to Cdf-class from 'affy' to 'makecdfenv':
58 | R/Cdf.R, R/getLocationsData.Cdf.R, locate.name.R, pmormm.R
59 | R/read.cdffile.R, data/cdf.example.rda, man/Cdf-class.Rd
60 | man/getLocationsData.Cdf.Rd, man/locate.name.Rd, man/pmormm.Rd
61 | man/read.cdffile.Rd, src/read_cdffile.c
62 |
63 | o read.affybatch2 reads all cel files together in one big hit
64 | into an affybatch
65 |
66 | o the baseline in normalize.AffyBatch,invariant can be selected
67 | using a baseline.type parameter. Also changed "progress" to the
68 | more standard "verbose". Seemed to be an error since both PM and
69 | MM probes were normalized by only PM's where used to establish the
70 | normalization, now follows same standard as been introduced for
71 | normalize.AffyBatch.quantiles.
72 |
73 | o Most normalization routines can now be called with the parameter
74 | type which specifies whether to be pmonly, mmonly, both together
75 | or both separately. This introduces more consistency to the how
76 | the normalization routines are actually applied to affybatchs.
77 |
78 | o express() has been completely removed.
79 |
80 |
81 | Things that would be good to see before next release:
82 | o More consistent usage/application of MIAME
83 |
84 |
85 | version 1.2.x:
86 |
87 | o Autoload of cdfenvs on demand (uses reposTools). Can be
88 | configured through the options.
89 |
90 | o slot 'preprocessing' of the MIAME attribute used to store
91 | normalization step information [will be polished, list returned
92 | for the moment. Need for a class and check compliance with MIAME
93 | standards]
94 |
95 | o default methods for normalization, bg correction, pm correction
96 | and summary now in the package options [options exist for all, but
97 | only used by normalize for the moment].
98 |
99 | o tuning of the MAS5.0 methods implemented (bgcorrect.mas, ...)
100 | [Ben for details. add URL for the comparison he made]
101 |
102 | o method plot.ProbeSet, an alternative to barplot, to plot probe
103 | level information.
104 |
105 | o parameter 'scale' in the method barplot for ProbeSet. All the
106 | barplots are scaled to eachothers.This is the default.
107 |
108 | o bug in the parser fixed (infinite loop reported with apparently
109 | non-standard CEL files.).
110 |
111 | o bug in the parser fixed (the 'sd' data returned were not correct).
112 |
113 | o missing slot in the dataset SpikeIn fixed.
114 |
115 | o The function express() is deprecated. It still functions normally
116 | but gives warning mesage. It will be removed in a future release.
117 | The function expresso() should be used as a replacement.
118 |
119 | o bug in normalize.AffyBatch.qspline fixed (thanks to people at
120 | Insightful). The expression data matrix sent to normalize.qspline
121 | was mistakingly transposed.
122 |
123 | o The default background on the rma() function has been changed. Now
124 | the results from rma() and expresso() should agree completely.
125 |
126 | o New functions 'xy2indices' and 'indices2xy' to shuttle from
127 | x/y pos to indices (like the ones in cdfenvs) (and reverse).
128 |
129 | o Reformating of the documentation.
130 |
131 | version 1.1.x:
132 |
133 | o 'image(cel)' scales to the size (# rows and # cols) of a chip.
134 | locations can be plotted over directly ('plotLocations' was fixed
135 | accordiginly).
136 |
137 | o 'write.celfile(cel)' to write Cel objects into .CEL files
138 |
139 | o 'getInfoInAffyFile' to snoop in CEL and CDF files
140 |
141 | o 'whatcdf' to get the name of the CDF from the CEL
142 |
143 | o one more slot in class 'Cdf': cdfName (will match with what is
144 | returned by 'whatcdf')
145 |
146 | o one more slot in class 'Cel': cdfName (returned by whatcdf)
147 |
148 | o new class 'AffyBatch': cdfName (returned by whatcdf)
149 |
150 | o extensive set of tests in the directory 'tests/'
151 |
--------------------------------------------------------------------------------