limma/0000775007451300017500000000000012177406450012020 5ustar charlescharleslimma/R/0000755007451300017500000000000012175540776012227 5ustar charlescharleslimma/R/rankSumTestWithCorrelation.R0000644007451300017500000000217412127125240017652 0ustar charlescharlesrankSumTestWithCorrelation <- function(index,statistics,correlation=0,df=Inf) # Rank sum test as for two-sample Wilcoxon-Mann-Whitney test, # but allowing for correlation between members of test set. # Gordon Smyth and Di Wu # Created 2007. Last modified 24 Feb 2012. { n <- length(statistics) r <- rank(statistics) r1 <- r[index] n1 <- length(r1) n2 <- n-n1 U <- n1*n2 + n1*(n1+1)/2 - sum(r1) mu <- n1*n2/2 if(correlation==0 || n1==1) { sigma2 <- n1*n2*(n+1)/12 } else { sigma2 <- asin(1)*n1*n2 + asin(0.5)*n1*n2*(n2-1) + asin(correlation/2)*n1*(n1-1)*n2*(n2-1) + asin((correlation+1)/2)*n1*(n1-1)*n2 sigma2 <- sigma2/2/pi } TIES <- (length(r) != length(unique(r))) if(TIES) { NTIES <- table(r) adjustment <- sum(NTIES*(NTIES+1)*(NTIES-1)) / (n*(n+1)*(n-1)) sigma2 <- sigma2 * (1 - adjustment) } zlowertail <- (U+0.5-mu)/sqrt(sigma2) zuppertail <- (U-0.5-mu)/sqrt(sigma2) # Lower and upper tails are reversed on output # because R's ranks are the reverse of Mann-Whitney's ranks pvalues <- c(less=pt(zuppertail,df=df,lower.tail=FALSE), greater=pt(zlowertail,df=df)) pvalues } limma/R/dups.R0000755007451300017500000001765612175540776013347 0ustar charlescharles# DUPS.R # Functions to handle duplicate spots or blocking unwrapdups <- function(M,ndups=2,spacing=1) { # Unwrap M matrix for a series of experiments so that all spots for a given gene are in one row # Gordon Smyth # 18 Jan 2002. Last revised 2 Nov 2002. if(ndups==1) return(M) M <- as.matrix(M) nspots <- dim(M)[1] nslides <- dim(M)[2] ngroups <- nspots / ndups / spacing dim(M) <- c(spacing,ndups,ngroups,nslides) M <- aperm(M,perm=c(1,3,2,4)) dim(M) <- c(spacing*ngroups,ndups*nslides) M } uniquegenelist <- function(genelist,ndups=2,spacing=1) { # Eliminate entries in genelist for duplicate spots # Gordon Smyth # 2 Nov 2002. Last revised 10 Jan 2005 if(ndups <= 1) return(genelist) i <- drop(unwrapdups(1:NROW(genelist),ndups=ndups,spacing=spacing)[,1]) if(is.null(dim(genelist))) return(genelist[i]) else return(genelist[i,,drop=FALSE]) } duplicateCorrelation <- function(object,design=NULL,ndups=2,spacing=1,block=NULL,trim=0.15,weights=NULL) # Estimate the correlation between duplicates given a series of arrays # Gordon Smyth # 25 Apr 2002. Last revised 28 July 2013. { # Extract components from y y <- getEAWP(object) M <- y$exprs ngenes <- nrow(M) narrays <- ncol(M) # Check design matrix if(is.null(design)) design <- y$design if(is.null(design)) design <- matrix(1,ncol(y$exprs),1) else { design <- as.matrix(design) if(mode(design) != "numeric") stop("design must be a numeric matrix") } if(nrow(design) != narrays) stop("Number of rows of design matrix does not match number of arrays") ne <- nonEstimable(design) if(!is.null(ne)) cat("Coefficients not estimable:",paste(ne,collapse=" "),"\n") nbeta <- ncol(design) # Weights and spacing arguments can be specified in call or stored in y # Precedence for these arguments is # 1. Specified in function call # 2. Stored in object # 3. Default values if(missing(ndups) && !is.null(y$printer$ndups)) ndups <- y$printer$ndups if(missing(spacing) && !is.null(y$printer$spacing)) spacing <- y$printer$spacing if(missing(weights) && !is.null(y$weights)) weights <- y$weights # Check weights if(!is.null(weights)) { weights <- as.matrix(weights) if(any(dim(weights) != dim(M))) weights <- array(weights,dim(M)) M[weights < 1e-15 ] <- NA weights[weights < 1e-15] <- NA } # Setup spacing or blocking arguments if(is.null(block)) { if(ndups<2) { warning("No duplicates: correlation between duplicates not estimable") return( list(cor=NA,cor.genes=rep(NA,nrow(M))) ) } if(is.character(spacing)) { if(spacing=="columns") spacing <- 1 if(spacing=="rows") spacing <- object$printer$nspot.c if(spacing=="topbottom") spacing <- nrow(M)/2 } Array <- rep(1:narrays,rep(ndups,narrays)) } else { ndups <- 1 nspacing <- 1 Array <- block } # Unwrap data to get all data for a gene in one row if(is.null(block)) { M <- unwrapdups(M,ndups=ndups,spacing=spacing) ngenes <- nrow(M) if(!is.null(weights)) weights <- unwrapdups(weights,ndups=ndups,spacing=spacing) design <- design %x% rep(1,ndups) } require( "statmod" ) # need mixedModel2Fit function rho <- rep(NA,ngenes) for (i in 1:ngenes) { y <- drop(M[i,]) o <- is.finite(y) A <- factor(Array[o]) nobs <- sum(o) nblocks <- length(levels(A)) if(nobs>(nbeta+2) && nblocks>1 && nblocks1) object$df.prior <- object$df.prior[i] object$sigma <- object$sigma[i] object$s2.post <- object$s2.post[i] object$Amean <- object$Amean[i] } if(!is.null(object$F)) if(missing(j)) { object$F <- object$F[i] object$F.p.value <- object$F.p.value[i] } else { F.stat <- classifyTestsF(object,fstat.only=TRUE) object$F <- as.vector(F.stat) df1 <- attr(F.stat,"df1") df2 <- attr(F.stat,"df2") if (df2[1] > 1e+06) object$F.p.value <- pchisq(df1*object$F,df1,lower.tail=FALSE) else object$F.p.value <- pf(object$F,df1,df2,lower.tail=FALSE) } object }) limma/R/geneset-roast.R0000644007451300017500000003543312127125240015120 0ustar charlescharles## ROAST.R setClass("Roast", # rotation gene set test representation("list") ) setMethod("show","Roast", # Di Wu, Gordon Smyth # 14 May 2010. Last modified 19 May 2010. function(object) print(object$p.value) ) roast <- function(y,index=NULL,design=NULL,contrast=ncol(design),set.statistic="mean",gene.weights=NULL,array.weights=NULL,weights=NULL,block=NULL,correlation,var.prior=NULL,df.prior=NULL,trend.var=FALSE,nrot=999) UseMethod("roast") roast.EList <- function(y,index=NULL,design=NULL,contrast=ncol(design),set.statistic="mean",gene.weights=NULL,array.weights=NULL,weights=NULL,block=NULL,correlation,var.prior=NULL,df.prior=NULL,trend.var=FALSE,nrot=999) # Gordon Smyth # Created 4 Jan 2013. Last modified 22 Jan 2013. { if(is.null(design)) design <- y$design if(is.null(weights) && is.null(array.weights)) weights <- y$weights y <- as.matrix(y) roast(y=y,index=index,design=design,contrast=contrast,set.statistic=set.statistic,gene.weights=gene.weights,array.weights=array.weights,weights=weights,block=block,correlation=correlation,var.prior=var.prior,df.prior=df.prior,trend.var=trend.var,nrot=nrot) } roast.MAList <- function(y,index=NULL,design=NULL,contrast=ncol(design),set.statistic="mean",gene.weights=NULL,array.weights=NULL,weights=NULL,block=NULL,correlation,var.prior=NULL,df.prior=NULL,trend.var=FALSE,nrot=999) # Gordon Smyth # Created 4 Jan 2013. Last modified 22 Jan 2013. { if(is.null(design)) design <- y$design if(is.null(weights) && is.null(array.weights)) weights <- y$weights y <- as.matrix(y) roast(y=y,index=index,design=design,contrast=contrast,set.statistic=set.statistic,gene.weights=gene.weights,array.weights=array.weights,weights=weights,block=block,correlation=correlation,var.prior=var.prior,df.prior=df.prior,trend.var=trend.var,nrot=nrot) } roast.default <- function(y,index=NULL,design=NULL,contrast=ncol(design),set.statistic="mean",gene.weights=NULL,array.weights=NULL,weights=NULL,block=NULL,correlation,var.prior=NULL,df.prior=NULL,trend.var=FALSE,nrot=999) # Rotation gene set testing for linear models # Gordon Smyth and Di Wu # Created 24 Apr 2008. Last modified 22 Jan 2013. { # Check y y <- as.matrix(y) ngenes <- nrow(y) n <- ncol(y) # Check index if(is.null(index)) index <- rep.int(TRUE,ngenes) # Check design if(is.null(design)) stop("no design matrix") design <- as.matrix(design) if(nrow(design) != n) stop("row dimension of design matrix must match column dimension of data") p <- ncol(design) p0 <- p-1 d <- n-p # Check contrast if(length(contrast) == 1) { u <- rep.int(0,p) u[contrast] <- 1 contrast <- u } if(length(contrast) != p) stop("length of contrast must match column dimension of design") if(all(contrast==0)) stop("contrast all zero") # Check set.statistic set.statistic <- match.arg(set.statistic,c("mean","floormean","mean50","msq")) # Check var.prior and df.prior if(!is.null(var.prior) && var.prior<0) stop("var.prior must be non-negative") if(!is.null(df.prior) && df.prior<0) stop("df.prior must be non-negative") # Check and divide out array weights if(!is.null(array.weights)) { if(!is.null(weights)) stop("Can't specify both array.weights and observational weights") if(any(array.weights <= 0)) stop("array.weights must be positive") if(length(array.weights) != n) stop("Length of array.weights doesn't match number of array") design <- design*sqrt(array.weights) y <- t(t(y)*sqrt(array.weights)) } # Check and divide out block correlation if(!is.null(block)) { if(!is.null(weights)) stop("Can't use block with weights") block <- as.vector(block) if (length(block) != n) stop("Length of block does not match number of arrays") ub <- unique(block) nblocks <- length(ub) Z <- matrix(block,n,nblocks) == matrix(ub,n,nblocks,byrow = TRUE) cormatrix <- Z %*% (correlation * t(Z)) diag(cormatrix) <- 1 R <- chol(cormatrix) y <- t(backsolve(R, t(y), transpose = TRUE)) design <- backsolve(R, design, transpose = TRUE) } # Check weights if(!is.null(weights)) { weights <- as.matrix(weights) dimw <- dim(weights) if(dimw[1]!=ngenes || dimw[2]!=n) stop("weights must have same dimensions as y") if(any(weights<=0)) stop("weights must be positive") } # Reform design matrix so that contrast of interest is last column qr <- qr(contrast) Q <- qr.Q(qr,complete=TRUE) sign1 <- sign(qr$qr[1,1]) Q <- cbind(Q[,-1],Q[,1]) X <- design %*% Q qr <- qr(X) sign2 <- sign(qr$qr[p,p]) if(is.null(var.prior) || is.null(df.prior)) { # Fit model to all genes if(is.null(weights)) { effects <- qr.qty(qr,t(y)) } else { ws <- sqrt(weights) effects <- matrix(0,n,ngenes) sign2 <- rep.int(0,ngenes) for (g in 1:ngenes) { wX <- X*ws[g,] wy <- y[g,]*ws[g,] qrX <- qr(wX) sign2[g] <- sign(qrX$qr[p,p]) effects[,g] <- qr.qty(qrX,wy) } sign2 <- sign2[index] } # Estimate global parameters s0 and d0 s2 <- colMeans(effects[-(1:p),,drop=FALSE]^2) if(trend.var) covariate <- rowMeans(y,na.rm=TRUE) else covariate <- NULL sv <- squeezeVar(s2,df=d,covariate=covariate) d0 <- sv$df.prior s02 <- sv$var.prior if(trend.var) s02 <- s02[index] effects <- effects[,index,drop=FALSE] sd.post <- sqrt(sv$var.post[index]) } else { d0 <- df.prior s02 <- var.prior if(length(s02)>1) { names(s02) <- rownames(y) s02 <- s02[index] } y <- y[index,,drop=FALSE] if(is.null(weights)) { effects <- qr.qty(qr,t(y)) } else { ws <- sqrt(weights[index,,drop=FALSE]) nset <- nrow(y) effects <- matrix(0,n,nset) sign2 <- rep.int(0,nset) for (g in 1:nset) { wX <- X*ws[g,] wy <- y[g,]*ws[g,] qrX <- qr(wX) sign2[g] <- sign(qrX$qr[p,p]) effects[,g] <- qr.qty(qrX,wy) } } s2 <- colMeans(effects[-(1:p),,drop=FALSE]^2) if(is.finite(d0)) sd.post <- sqrt( (d0*s02+d*s2)/(d0+d) ) else sd.post <- sqrt(s02) } # From here, all results are for set only nset <- ncol(effects) if(p0>0) Y <- effects[-(1:p0),,drop=FALSE] else Y <- effects YY <- colSums(Y^2) B <- Y[1,] signc <- sign1*sign2 modt <- signc*B/sd.post statobs <- p <- rep(0,3) names(statobs) <- names(p) <- c("down","up","mixed") statrot <- array(0,c(nrot,3),dimnames=list(NULL,names(p))) # Convert to z-scores modt <- zscoreT(modt,df=d0+d) # Active proportions if(!is.null(gene.weights)) { lgw <- length(gene.weights) if(lgw > nset && lgw==ngenes) { gene.weights <- gene.weights[index] } else { if(lgw != nset) stop("length of gene.weights disagrees with size of set") } s <- sign(gene.weights) r1 <- mean(s*modt > sqrt(2)) r2 <- mean(s*modt < -sqrt(2)) } else { r1 <- mean(modt > sqrt(2)) r2 <- mean(modt < -sqrt(2)) } # Random rotations R <- matrix(rnorm(nrot*(d+1)),nrot,d+1) R <- R/sqrt(rowSums(R^2)) Br <- R %*% Y s2r <- (matrix(YY,nrot,nset,byrow=TRUE)-Br^2)/d if(is.finite(d0)) sdr.post <- sqrt((d0*s02+d*s2r)/(d0+d)) else sdr.post <- sqrt(s02) modtr <- signc*Br/sdr.post modtr <- zscoreT(modtr,df=d0+d) if(set.statistic=="msq") { # Observed statistics modt2 <- modt^2 if(!is.null(gene.weights)) { modt2 <- abs(gene.weights)*modt2 modt <- gene.weights*modt } statobs["mixed"] <- mean(modt2) statobs["up"] <- sum(modt2[modt > 0])/nset statobs["down"] <- sum(modt2[modt < 0])/nset # Simulated statistics if(!is.null(gene.weights)) { gene.weights <- sqrt(abs(gene.weights)) modtr <- t(gene.weights*t(modtr)) } statrot[,"mixed"] <- rowMeans(modtr^2) statrot[,"up"] <- rowMeans(pmax(modtr,0)^2) statrot[,"down"] <- rowMeans(pmax(-modtr,0)^2) # p-values p <- (rowSums(t(statrot) >= statobs)+1)/(nrot+1) } if(set.statistic=="mean50") { # Observed statistics if(!is.null(gene.weights)) modt <- gene.weights*modt half <- nset %/% 2L +1L meanTop <- function(x,n) mean(sort(x,partial=n)[n:length(x)]) statobs["mixed"] <- meanTop(abs(modt),half) statobs["up"] <- meanTop(modt,half) statobs["down"] <- meanTop(-modt,half) # Simulated statistics if(!is.null(gene.weights)) modtr <- t(gene.weights*t(modtr)) statrot[,"mixed"] <- apply(abs(modtr),1,meanTop,n=half) statrot[,"up"] <- apply(modtr,1,meanTop,n=half) statrot[,"down"] <- apply(-modtr,1,meanTop,n=half) # p-values p <- (rowSums(t(statrot) >= statobs) + 1)/(nrot + 1) } if(set.statistic=="floormean") { # Observed statistics chimed <- qchisq(0.5,df=1) amodt <- pmax(abs(modt),chimed) if(!is.null(gene.weights)) { amodt <- gene.weights*amodt modt <- gene.weights*modt } statobs["mixed"] <- mean(amodt) statobs["up"] <- mean(pmax(modt,0)) statobs["down"] <- mean(pmax(-modt,0)) # Simulated statistics amodtr <- pmax(abs(modtr),chimed) if(!is.null(gene.weights)) { amodtr <- t(gene.weights*t(amodtr)) modtr <- t(gene.weights*t(modtr)) } statrot[,"mixed"] <- rowMeans(amodtr) statrot[,"up"] <- rowMeans(pmax(modtr,0)) statrot[,"down"] <- rowMeans(pmax(-modtr,0)) # p-values p <- (rowSums(t(statrot) >= statobs) + 1)/(nrot + 1) } if(set.statistic=="mean") { # Observed statistics if(!is.null(gene.weights)) modt <- gene.weights*modt m <- mean(modt) statobs["mixed"] <- mean(abs(modt)) statobs["up"] <- m statobs["down"] <- -m # Simulated statistics if(!is.null(gene.weights)) modtr <- t(gene.weights*t(modtr)) m <- rowMeans(modtr) statrot[,"mixed"] <- rowMeans(abs(modtr)) statrot[,"up"] <- m statrot[,"down"] <- -m # p-values p <- (rowSums(t(statrot) >= statobs) + 1)/(nrot + 1) } # Output out <- data.frame(c(r2,r1,r1+r2),p) dimnames(out) <- list(c("Down","Up","Mixed"),c("Active.Prop","P.Value")) new("Roast",list(p.value=out,var.prior=s02,df.prior=d0,ngenes.in.set=nset)) } mroast <- function(y,index=NULL,design=NULL,contrast=ncol(design),set.statistic="mean",gene.weights=NULL,array.weights=NULL,weights=NULL,block=NULL,correlation,var.prior=NULL,df.prior=NULL,trend.var=FALSE,nrot=999,adjust.method="BH",midp=TRUE,sort="directional") UseMethod("mroast") mroast.EList <- function(y,index=NULL,design=NULL,contrast=ncol(design),set.statistic="mean",gene.weights=NULL,array.weights=NULL,weights=NULL,block=NULL,correlation,var.prior=NULL,df.prior=NULL,trend.var=FALSE,nrot=999,adjust.method="BH",midp=TRUE,sort="directional") # Gordon Smyth # Created 8 Jan 2013. { if(is.null(design)) design <- y$design if(is.null(weights) && is.null(array.weights)) weights <- y$weights y <- as.matrix(y) mroast(y=y,index=index,design=design,contrast=contrast,set.statistic=set.statistic,gene.weights=gene.weights,array.weights=array.weights,weights=weights,block=block,correlation=correlation,var.prior=var.prior,df.prior=df.prior,trend.var=trend.var,nrot=nrot) } mroast.MAList <- function(y,index=NULL,design=NULL,contrast=ncol(design),set.statistic="mean",gene.weights=NULL,array.weights=NULL,weights=NULL,block=NULL,correlation,var.prior=NULL,df.prior=NULL,trend.var=FALSE,nrot=999,adjust.method="BH",midp=TRUE,sort="directional") # Gordon Smyth # Created 8 Jan 2013. { if(is.null(design)) design <- y$design if(is.null(weights) && is.null(array.weights)) weights <- y$weights y <- as.matrix(y) mroast(y=y,index=index,design=design,contrast=contrast,set.statistic=set.statistic,gene.weights=gene.weights,array.weights=array.weights,weights=weights,block=block,correlation=correlation,var.prior=var.prior,df.prior=df.prior,trend.var=trend.var,nrot=nrot) } mroast.default <- function(y,index=NULL,design=NULL,contrast=ncol(design),set.statistic="mean",gene.weights=NULL,array.weights=NULL,weights=NULL,block=NULL,correlation,var.prior=NULL,df.prior=NULL,trend.var=FALSE,nrot=999,adjust.method="BH",midp=TRUE,sort="directional") # Rotation gene set testing with multiple sets # Gordon Smyth and Di Wu # Created 28 Jan 2010. Last revised 8 Feb 2012. { # Check y y <- as.matrix(y) # Check index if(is.null(index)) index <- rep(TRUE,nrow(y)) if(!is.list(index)) index <- list(set = index) nsets <- length(index) if(is.null(names(index))) names(index) <- paste("set",1:nsets,sep="") # Check design if(is.null(design)) stop("No design matrix") design <- as.matrix(design) # Check gene.weights if(!is.null(gene.weights)) if(length(gene.weights) != nrow(y)) stop("gene.weights must have length equal to nrow(y)") # Check weights if(!is.null(weights)) { if(!is.null(array.weights)) stop("Can't specify both array weights and observational weights") weights <- as.matrix(weights) if(any(dim(weights) != dim(y))) stop("weights must have same dimensions as y") } # Check array.weights if(!is.null(array.weights)) { if(length(array.weights) != ncol(y)) stop("array.weights wrong length") weights <- array.weights } # Estimate var.prior and df.prior if not preset if(is.null(var.prior) || is.null(df.prior)) { fit <- lmFit(y,design=design,weights=weights,block=block,correlation=correlation) if(trend.var) { covariate <- fit$Amean if(is.null(covariate)) covariate <- rowMeans(y) } else { covariate=NULL } sv <- squeezeVar(fit$sigma^2,df=fit$df.residual,covariate=covariate) var.prior <- sv$var.prior df.prior <- sv$df.prior } pv <- adjpv <- active <- array(0,c(nsets,3),dimnames=list(names(index),c("Down","Up","Mixed"))) NGenes <- rep(0,nsets) if(nsets<1) return(pv) for(i in 1:nsets) { out <- roast(y=y,index=index[[i]],design=design,contrast=contrast,set.statistic=set.statistic,gene.weights=gene.weights,array.weights=array.weights,block=block,correlation=correlation,var.prior=var.prior,df.prior=df.prior,nrot=nrot) pv[i,] <- out$p.value$P.Value active[i,] <- out$p.value$Active.Prop NGenes[i] <- out$ngenes.in.set } # Use mid-p-values or ordinary p-values? pv2 <- pv if(midp) pv2 <- pv2-1/2/(nrot+1) # adjpv[,"Down"] <- p.adjust(pv2[,"Down"], method=adjust.method) # adjpv[,"Up"] <- p.adjust(pv2[,"Up"], method=adjust.method) # adjpv[,"Mixed"] <- p.adjust(pv2[,"Mixed"], method=adjust.method) # list(P.Value=pv, Adj.P.Value=adjpv, Active.Proportion=active) # New-style output Up <- pv[,"Up"] < pv[,"Down"] Direction <- rep.int("Down",nsets); Direction[Up] <- "Up" TwoSidedP <- pv[,"Down"]; TwoSidedP[Up] <- pv[Up,"Up"]; TwoSidedP <- 2*TwoSidedP TwoSidedP2 <- pv2[,"Down"]; TwoSidedP2[Up] <- pv2[Up,"Up"]; TwoSidedP2 <- 2*TwoSidedP2 tab <- data.frame( NGenes=NGenes, PropDown=active[,"Down"], PropUp=active[,"Up"], Direction=Direction, PValue=TwoSidedP, FDR=p.adjust(TwoSidedP2,method="BH"), PValue.Mixed=pv[,"Mixed"], FDR.Mixed=p.adjust(pv2[,"Mixed"],method="BH"), row.names=names(index), stringsAsFactors=FALSE ) # Sort by p-value sort <- match.arg(sort,c("directional","mixed","none")) if(sort=="none") return(tab) if(sort=="directional") o <- order(tab$PValue) else o <- order(tab$PValue.Mixed) tab[o,,drop=FALSE] } limma/R/geneset-romer.R0000644007451300017500000002763712127125240015123 0ustar charlescharles## ROMER.R symbols2indices <- function(gene.sets, symbols, remove.empty=TRUE) # Make a list of gene sets symbols into a list of gene sets indices used to create input for romer # Gordon Smyth and Yifang Hu # 25 March 2009. Last modified 21 March 2011. { gene.sets <- as.list(gene.sets) index <- lapply(gene.sets, function(x) which(symbols %in% x)) if(remove.empty) for (i in length(index):1) if(!length(index[[i]])) index[[i]] <- NULL index } romer <- function(index,y,design,contrast=ncol(design),array.weights=NULL,block=NULL,correlation=NULL,set.statistic="mean",nrot=9999) # rotation mean-rank version of GSEA (gene set enrichment analysis) for linear models # Gordon Smyth and Yifang Hu # 27 March 2009. Last modified 3 June 2010. { set.statistic <- match.arg(set.statistic,c("mean","floormean","mean50")) if(set.statistic=="mean50") { return(.romer.mean50(index=index,y=y,design=design,contrast=contrast,array.weights=array.weights,block=block,correlation=correlation,nrot=nrot)) } else { return(.romer.mean.floormean(index=index,y=y,design=design,contrast=contrast,array.weights=array.weights,block=block,correlation=correlation,floor=(set.statistic=="floormean"),nrot=nrot)) } } .romer.mean50 <- function(index,y,design,contrast=ncol(design),array.weights=NULL,block=NULL,correlation,nrot=9999) # rotation-mean50-rank version of GSEA (gene set enrichment analysis) for linear models # Gordon Smyth and Yifang Hu # 27 March 2009. Last modified 15 Sep 2009. { # Check input arguments if(!is.list(index)) index <- list(set=index) nset<-length(index) y <- as.matrix(y) design <- as.matrix(design) ngenes<-nrow(y) p <- ncol(design) p0 <- p-1 n <- ncol(y) d <- n-p if(length(contrast) == 1) { u <- rep.int(0,p) u[contrast] <- 1 contrast <- u } if(length(contrast) != p) stop("length of contrast must match column dimension of design") if(all(contrast==0)) stop("contrast all zero") if(nrow(design) != n) stop("row dimension of design matrix must match column dimension of data") # Divide out array weights, if they exist if(!is.null(array.weights)) { if(any(array.weights <= 0)) stop("array.weights must be positive") if(length(array.weights) != n) stop("Length of array.weights doesn't match number of array") design <- design*sqrt(array.weights) y <- t(t(y)*sqrt(array.weights)) } # Divide out correlation structure, it is exists if(!is.null(block)) { block <- as.vector(block) if (length(block) != n) stop("Length of block does not match number of arrays") ub <- unique(block) nblocks <- length(ub) Z <- matrix(block,n,nblocks) == matrix(ub,n,nblocks,byrow = TRUE) cormatrix <- Z %*% (correlation * t(Z)) diag(cormatrix) <- 1 R <- chol(cormatrix) y <- t(backsolve(R, t(y), transpose = TRUE)) design <- backsolve(R, design, transpose = TRUE) } # Reform design matrix so that contrast of interest is last column qr <- qr(contrast) Q <- qr.Q(qr,complete=TRUE) sign1 <- sign(qr$qr[1,1]) Q <- cbind(Q[,-1],Q[,1]) X <- design %*% Q qr <- qr(X) sign2 <- sign(qr$qr[p,p]) signc <- sign1 * sign2 # Fit model to all genes effects <- qr.qty(qr,t(y)) # Estimate global hyper-parameters s0 and d0 s2 <- colMeans(effects[-(1:p),,drop=FALSE]^2) sv <- squeezeVar(s2,df=d) d0 <- sv$df.prior s02 <- sv$var.prior sd.post <- sqrt(sv$var.post) # t-statistics and effects Y <- effects[-(1:p0),,drop=FALSE] YY <- colSums(Y^2) B <- Y[1,] modt <- signc*B/sd.post # Observed rankings for each set s.r <- rank(modt) s.rank.mixed<-rep(0,nset) s.rank.up<-rep(0,nset) s.rank.down<-rep(0,nset) modt.abs<-abs(modt) s.abs.r <-rank(modt.abs) m<-unlist(lapply(index,length)) m<-floor((m+1)/2) for(i in 1:nset) { mh<-.meanHalf(s.r[index[[i]]],m[i]) s.rank.up[i] <-mh[2] s.rank.down[i]<-mh[1] s.rank.mixed[i]<-.meanHalf(s.abs.r[index[[i]]],m[i])[2] } # Estimate hyper-parameters p0 p.obs <- 2*pt(abs(modt),df=d0+d,lower.tail=FALSE) p0.obs <- 1-convest(p.obs) # proportion of DE probes # Estimate hyper-paremeter v0 covmat <- chol2inv(qr$qr, size = qr$rank) stdev.unscaled <- rep(sqrt(covmat[qr$rank,qr$rank]),ngenes) proportion<-p0.obs stdev.coef.lim <- c(0.1, 4) # get v0 df.total <- rep(d,ngenes) + sv$df.prior var.prior.lim <- stdev.coef.lim^2/sv$var.prior var.prior <- tmixture.vector(modt, stdev.unscaled, df.total,proportion, var.prior.lim) if (any(is.na(var.prior))) { var.prior[is.na(var.prior)] <- 1/sv$var.prior warning("Estimation of var.prior failed - set to default value") } # Estimate posterior probability of DE r <- rep(1, ngenes) %o% var.prior r <- (stdev.unscaled^2 + r)/stdev.unscaled^2 if (sv$df.prior > 10^6) kernel <- modt^2 * (1 - 1/r)/2 else kernel <- (1 + df.total)/2 * log((modt^2 + df.total)/(modt^2/r + df.total)) lods <- log(proportion/(1 - proportion)) - log(r)/2 + kernel pg <- exp(lods)/(1+exp(lods)) # Shrink contrast to be like a residual Y[1,] <- Y[1,]*(sv$var.post/(sv$var.post+var.prior*pg))^(1/2) # Random rotations p.value <- matrix(rep(0,nset*3),nrow=nset,ncol=3) for(i in 1:nrot) { R <- matrix(rnorm((d+1)),1,d+1) R <- R/sqrt(rowSums(R^2)) Br <- R %*% Y s2r <- (YY-Br^2)/d if(is.finite(d0)) sdr.post <- sqrt((d0*s02+d*s2r)/(d0+d)) else sdr.post <- sqrt(s02) modtr <- signc*Br/sdr.post modtr.abs<-abs(modtr) s.r.2<-rank(modtr) s.abs.r.2<-rank(modtr.abs) for(j in 1:nset) { mh.2<-.meanHalf(s.r.2[index[[j]]],m[j]) s.rank.up.2 <-mh.2[2] s.rank.down.2 <-mh.2[1] s.rank.mixed.2 <-.meanHalf(s.abs.r.2[index[[j]]],m[j])[2] if(s.rank.mixed.2>=s.rank.mixed[j]) p.value[j,1]<-p.value[j,1]+1 if(s.rank.up.2>=s.rank.up[j]) p.value[j,2]<-p.value[j,2]+1 if(s.rank.down.2<=s.rank.down[j]) p.value[j,3]<-p.value[j,3]+1 } } p.value <- (p.value+1)/(nrot+1) colnames(p.value)<-c("Mixed","Up","Down") SetNames <- names(index) if(is.null(SetNames)) rownames(p.value) <- 1:nset else rownames(p.value) <- SetNames len.index<-as.numeric(lapply(index,length)) cbind(NGenes=len.index,p.value) } ## Return means of top half and bottom half of the ranks for romer2 .meanHalf<- function(x,n) # Yifang Hu { l<-length(x) a<-sort(x,partial=n) top<-mean(a[1:n]) if((l%%2)==0) bottom<-mean(a[(n+1):l]) if((l%%2)!=0) bottom<-mean(a[n:l]) c(top,bottom) } .romer.mean.floormean <- function(index,y,design,contrast=ncol(design),array.weights=NULL,block=NULL,correlation,floor=FALSE,nrot=9999) # rotation mean-rank version of GSEA (gene set enrichment analysis) for linear models # Gordon Smyth and Yifang Hu # 27 March 2009. Last modified 5 Oct 2009. { # Check input arguments if(!is.list(index)) index <- list(set=index) nset<-length(index) y <- as.matrix(y) design <- as.matrix(design) ngenes<-nrow(y) p <- ncol(design) p0 <- p-1 n <- ncol(y) d <- n-p if(length(contrast) == 1) { u <- rep.int(0,p) u[contrast] <- 1 contrast <- u } if(length(contrast) != p) stop("length of contrast must match column dimension of design") if(all(contrast==0)) stop("contrast all zero") if(nrow(design) != n) stop("row dimension of design matrix must match column dimension of data") # Divide out array weights, it they exist if(!is.null(array.weights)) { if(any(array.weights <= 0)) stop("array.weights must be positive") if(length(array.weights) != n) stop("Length of array.weights doesn't match number of array") design <- design*sqrt(array.weights) y <- t(t(y)*sqrt(array.weights)) } # Divide out correlation structure, it is exists if(!is.null(block)) { block <- as.vector(block) if (length(block) != n) stop("Length of block does not match number of arrays") ub <- unique(block) nblocks <- length(ub) Z <- matrix(block,n,nblocks) == matrix(ub,n,nblocks,byrow = TRUE) cormatrix <- Z %*% (correlation * t(Z)) diag(cormatrix) <- 1 R <- chol(cormatrix) y <- t(backsolve(R, t(y), transpose = TRUE)) design <- backsolve(R, design, transpose = TRUE) } # Reform design matrix so that contrast of interest is last column qr <- qr(contrast) Q <- qr.Q(qr,complete=TRUE) sign1 <- sign(qr$qr[1,1]) Q <- cbind(Q[,-1],Q[,1]) X <- design %*% Q qr <- qr(X) sign2 <- sign(qr$qr[p,p]) signc <- sign1 * sign2 # Fit model to all genes effects <- qr.qty(qr,t(y)) # Sample variances s2 <- colMeans(effects[-(1:p),,drop=FALSE]^2) # Estimate global hyper-parameters s0 and d0 sv <- squeezeVar(s2,df=d) d0 <- sv$df.prior s02 <- sv$var.prior sd.post <- sqrt(sv$var.post) # t-statistics and effects (orthogonal residuals) Y <- effects[-(1:p0),,drop=FALSE] YY <- colSums(Y^2) B <- Y[1,] modt <- signc*B/sd.post # Estimate hyper-parameter p0 p.obs <- 2*pt(abs(modt),df=d0+d,lower.tail=FALSE) p0.obs <- 1-convest(p.obs) # proportion of DE probes # Estimate hyper-paremeter v0 covmat <- chol2inv(qr$qr, size = qr$rank) stdev.unscaled <- rep(sqrt(covmat[qr$rank,qr$rank]),ngenes) proportion<-p0.obs stdev.coef.lim <- c(0.1, 4) df.total <- rep(d,ngenes) + sv$df.prior var.prior.lim <- stdev.coef.lim^2/sv$var.prior var.prior <- tmixture.vector(modt, stdev.unscaled, df.total,proportion, var.prior.lim) if (any(is.na(var.prior))) { var.prior[is.na(var.prior)] <- 1/sv$var.prior warning("Estimation of var.prior failed - set to default value") } # Estimate posterior probability of DE for each probe r <- rep(1, ngenes) %o% var.prior r <- (stdev.unscaled^2 + r)/stdev.unscaled^2 if (sv$df.prior > 10^6) kernel <- modt^2 * (1 - 1/r)/2 else kernel <- (1 + df.total)/2 * log((modt^2 + df.total)/(modt^2/r + df.total)) lods <- log(proportion/(1 - proportion)) - log(r)/2 + kernel pg <- exp(lods)/(1+exp(lods)) # Observed rankings for each set obs.ranks <- matrix(0,ngenes,3) if(floor) { obs.ranks[,1] <- rank(pmax(modt,0)) obs.ranks[,2] <- rank(pmax(-modt,0)) obs.ranks[,3] <- rank(pmax(abs(modt),1)) } else { obs.ranks[,1] <- rank(modt) obs.ranks[,2] <- ngenes-obs.ranks[,1]+1 obs.ranks[,3] <- rank(abs(modt)) } obs.set.ranks <- matrix(0,nset,3) for(i in 1:nset) obs.set.ranks[i,] <- colMeans(obs.ranks[index[[i]],,drop=FALSE]) # Shrink contrast to be like a residual Y[1,] <- Y[1,]*(sv$var.post/(sv$var.post+var.prior*pg))^(1/2) # Random rotations to simulate null hypothesis rot.ranks <- obs.ranks p.value <- matrix(0,nrow=nset,ncol=3) for(i in 1:nrot) { R <- matrix(rnorm((d+1)),1,d+1) R <- R/sqrt(rowSums(R^2)) Br <- R %*% Y s2r <- (YY-Br^2)/d if(is.finite(d0)) sdr.post <- sqrt((d0*s02+d*s2r)/(d0+d)) else sdr.post <- sqrt(s02) modtr <- signc*Br/sdr.post if(floor) { rot.ranks[,1] <- rank(pmax(modtr,0)) rot.ranks[,2] <- rank(pmax(-modtr,0)) rot.ranks[,3] <- rank(pmax(abs(modtr),1)) } else { rot.ranks[,1] <- rank(modtr) rot.ranks[,2] <- ngenes-rot.ranks[,1]+1 rot.ranks[,3] <- rank(abs(modtr)) } for(k in 1:nset) { rot.set.ranks <- colMeans(rot.ranks[index[[k]],,drop=FALSE]) p.value[k,] <- p.value[k,] + (rot.set.ranks >= obs.set.ranks[k,]) } } p.value <- (p.value+1)/(nrot+1) colnames(p.value)<-c("Up","Down","Mixed") SetNames <- names(index) if(is.null(SetNames)) rownames(p.value) <- 1:nset else rownames(p.value) <- SetNames set.sizes <- unlist(lapply(index,length)) cbind(NGenes=set.sizes,p.value) } topRomer<-function(x,n=10,alternative="up") # extracts a number of top gene sets results from the romer output. # Gordon Smyth and Yifang Hu. # 22 Mar 2010. Last modified 5 Sep 2011. { n <- min(n,nrow(x)) alternative <- match.arg(tolower(alternative),c("up","down","mixed")) alternative <- switch(alternative,"up"="Up","down"="Down","mixed"="Mixed") o <- switch(alternative, "Up"=order(x[,"Up"],x[,"Mixed"],-x[,"NGenes"]), "Down"=order(x[,"Down"],x[,"Mixed"],-x[,"NGenes"]), "Mixed"=order(x[,"Mixed"],x[,"Up"],x[,"Down"],-x[,"NGenes"]) ) x[o,][1:n,,drop=FALSE] } limma/R/zscore.R0000755007451300017500000000353312127125240013644 0ustar charlescharles# SCORE.R zscore <- function(q, distribution=NULL, ...) # Z-score equivalents for deviates from specified distribution # Gordon Smyth # 13 June 2012 { z <- q n <- length(q) pdist <- get(paste("p",as.character(distribution),sep="")) pupper <- pdist(q,...,lower.tail=FALSE,log.p=TRUE) plower <- pdist(q,...,lower.tail=TRUE,log.p=TRUE) up <- pupper shape*scale) if(any(up)) z[up] <- qnorm(pgamma(q[up],shape=shape[up],scale=scale[up],lower.tail=FALSE,log.p=TRUE),lower.tail=FALSE,log.p=TRUE) if(any(!up)) z[!up] <- qnorm(pgamma(q[!up],shape=shape[!up],scale=scale[!up],lower.tail=TRUE,log.p=TRUE),lower.tail=TRUE,log.p=TRUE) z } zscoreT <- function(x, df) # Z-score equivalents for t distribution deviates # Gordon Smyth # 24 August 2003 { z <- x df <- rep(df,length.out=length(x)) pos <- x>0 if(any(pos)) z[pos] <- qnorm(pt(x[pos],df=df[pos],lower.tail=FALSE,log.p=TRUE),lower.tail=FALSE,log.p=TRUE) if(any(!pos)) z[!pos] <- qnorm(pt(x[!pos],df=df[!pos],lower.tail=TRUE,log.p=TRUE),lower.tail=TRUE,log.p=TRUE) z } tZscore <- function(x, df) # t-statistics equivalents for z-scores deviates # Gordon Smyth # 1 June 2004 { z <- x df <- rep(df,length.out=length(x)) pos <- x>0 if(any(pos)) z[pos] <- qt(pnorm(x[pos],lower.tail=FALSE,log.p=TRUE),df=df[pos],lower.tail=FALSE,log.p=TRUE) if(any(!pos)) z[!pos] <- qt(pnorm(x[!pos],lower.tail=TRUE,log.p=TRUE),df=df[!pos],lower.tail=TRUE,log.p=TRUE) z } limma/R/background-normexp.R0000644007451300017500000001420612127125240016140 0ustar charlescharles# BACKGROUND-NORMEXP.R normexp.signal <- function(par,x) # Expected value of signal given foreground in normal + exponential model # Gordon Smyth # 24 Aug 2002. Last modified 24 February 2012. { mu <- par[1] sigma <- exp(par[2]) sigma2 <- sigma*sigma alpha <- exp(par[3]) # cat(c(mu,sigma,alpha),"\n") if(alpha <= 0) stop("alpha must be positive") if(sigma <= 0) stop("sigma must be positive") mu.sf <- x-mu-sigma2/alpha signal <- mu.sf + sigma2 * exp(dnorm(0,mean=mu.sf,sd=sigma,log=TRUE) - pnorm(0,mean=mu.sf,sd=sigma,lower.tail=FALSE,log.p=TRUE)) o <- !is.na(signal) if(any(signal[o]<0)) { warning("Limit of numerical accuracy reached with very low intensity or very high background:\nsetting adjusted intensities to small value") signal[o] <- pmax(signal[o],1e-6) } signal } normexp.fit <- function(x, method="saddle", n.pts=NULL, trace=FALSE) # Estimate parameters of normal+exponential convolution model # Pure R Version Gordon Smyth 24 Aug 2002. # Version with C by Jeremy Silver 29 Oct 2007. # Last modified 25 Sept 2008. { isna <- is.na(x) if(any(isna)) x <- x[!isna] if(length(x)<4) stop("Not enough data: need at least 4 non-missing corrected intensities") if(trace) cat("trace not currently implemented\n") method <- match.arg(method,c("mle","saddle","rma","rma75","mcgee","nlminb","nlminblog")) # Backward compatility with old names if(method=="mcgee") method <- "rma75" if(method=="nlminb") method <- "mle" if(method=="nlminblog") method <- "mle" if(method=="rma") { require(affy) out <- bg.parameters(x) return(list(par=c(out$mu,log(out$sigma),-log(out$alpha)))) } if(method=="rma75") { out <- .bg.parameters.rma75(x) return(list(par=c(out$mu,log(out$sigma),-log(out$alpha)))) } # Starting values for parameters mu, alpha and sigma q <- quantile(x, c(0,0.05,0.1,1), na.rm = TRUE, names = FALSE) if(q[1]==q[4]) return(list(par=c(q[1],-Inf,-Inf),m2loglik=NA,convergence=0)) if(q[2] > q[1]) { mu <- q[2] } else { if(q[3] > q[1]) { mu <- q[3] } else { mu <- q[1] + 0.05*(q[4]-q[1]) } } sigma2 <- mean((x[x= 4 & n.pts < length(x)) { a <- 0.5 x <- quantile(x,((1:n.pts)-a)/n.pts,type=5) } # Maximize saddlepoint approximation to likelihood out1 <- .C("fit_saddle_nelder_mead", par = as.double(Par0), X = as.double(x), N = as.integer(length(x)), convergence = as.integer(0), fncount = as.integer(0), m2loglik = as.double(0), PACKAGE="limma") out1$X <- out1$N <- NULL if(method=="saddle") return(out1) Par1 <- out1$par # Convert from log-sd to log-var parametrization Par1[2] <- 2*Par1[2] LL1 <- .normexp.m2loglik(Par1, f = x) out2 <- nlminb(start = Par1, objective = .normexp.m2loglik, gradient = .normexp.gm2loglik, hessian = .normexp.hm2loglik, f = x, scale = median(abs(Par1))/abs(Par1)) # Convert back to log-sd parametrization out2$par[2] <- out2$par[2]/2 out2$m2loglik <- out2$objective out2$objective <- NULL # Check whether nlminb helped if(out2$m2loglik >= LL1) return(out1) out2 } .normexp.m2loglik <- function(theta,f) # normexp minus-twice log-likelihood # Jeremy Silver # 29 Oct 2007. # Last modified 25 Sept 2008. { mu <- theta[1] s2 <- exp(theta[2]) al <- exp(theta[3]) .C("normexp_m2loglik", mu = as.double(mu), s2 = as.double(s2), al = as.double(al), n = as.integer(length(f)), f = as.double(f), m2LL = double(1), PACKAGE="limma" )$m2LL } .normexp.gm2loglik <- function(theta,f) # Gradient of normexp m2loglik # with respect to mu, log(sigma^2) and log(alpha) # Jeremy Silver # 29 Oct 2007. # Last modified 25 Sept 2008. { mu <- theta[1] s2 <- exp(theta[2]) al <- exp(theta[3]) .C("normexp_gm2loglik", mu = as.double(mu), s2 = as.double(s2), al = as.double(al), n = as.integer(length(f)), f = as.double(f), dm2LL = double(3), PACKAGE = "limma" )$dm2LL } .normexp.hm2loglik <- function(theta,f) # Hessian of normexp m2loglik # with respect to mu, log(sigma^2) and log(alpha) # Jeremy Silver # 29 Oct 2007. # Last modified 25 Sept 2008. { mu <- theta[1] s2 <- exp(theta[2]) al <- exp(theta[3]) matrix(.C("normexp_hm2loglik", mu = as.double(mu), s2 = as.double(s2), al = as.double(al), n = as.integer(length(f)), f = as.double(f), d2m2LL = double(9), PACKAGE="limma" )$d2m2LL,3,3) } .bg.parameters.rma75 <- function(pm,n.pts = 2^14) # Estimate normexp parameters # This code is extracted without alteration from the RMA-75 function of # McGee, M. and Chen, Z. (2006). Parameter estimation for the # exponential-normal convolution model for background correction # of Affymetrix GeneChip data. # Stat Appl Genet Mol Biol, 5(1), Article 24. { ## mu-correction function mu.est.correct <- function(m,s,a) { f <- function(x) (dnorm(x-s*a)-s*a*(pnorm(x-s*a)+pnorm(m/s+s*a)-1)) t <- uniroot(f, c(-5, 10), tol = 1e-12)$root t <- m-s*t return(t) } ## getting mode function max.density <- function(x, n.pts) { aux <- density(x, kernel = "epanechnikov", n = n.pts, na.rm = TRUE) aux$x[order(-aux$y)[1]] } pmbg <- max.density(pm, n.pts) bg.data <- pm[pm < pmbg] pmbg <- max.density(bg.data, n.pts) mubg <- pmbg ## the mode bg.data <- pm[pm < pmbg] bg.data <- bg.data - pmbg bgsd <- sqrt(sum(bg.data^2)/(length(bg.data) - 1)) * sqrt(2) ## estimate sigma sig.data<-pm[pm > pmbg] sig.data <- sig.data - pmbg q75 <- 0.75 alpha3 <- -(quantile(pm,q75)-pmbg)/log(1-q75) ## 75th quantile estimation ## mode-correction mu3 <- mu.est.correct(m=mubg,s=bgsd,a=1/alpha3) mu3 <- (mu3+mubg)/2 ## take ave bg.data3<- pm[pm < mu3] bg.data3 <- bg.data3 - mu3 bgsd3 <- sqrt(sum(bg.data3^2)/(length(bg.data3) - 1)) * sqrt(2) sig.data3 <- pm[pm > mu3] alpha3<- -(quantile(pm,q75)-mu3)/log(1-q75) list(alpha = 1/alpha3, mu = mu3, sigma = bgsd3) } limma/R/modelmatrix.R0000755007451300017500000000757412127125240014675 0ustar charlescharles# MODELMATRIX.R uniqueTargets <- function(targets) { sort(unique(as.vector(as.matrix(targets[,c("Cy3","Cy5")])))) } modelMatrix <- function(targets, parameters=NULL, ref=NULL, verbose=TRUE) # Design matrix for two-color experiments # 'targets' is matrix or data.frame with columns Cy3 and Cy5 # 'parameters' specifies desired coefficients corresponding to columns of design matrix # 'ref' is common reference if such exists # Gordon Smyth # 25 June 2003. Last modified 1 Aug 2005. { if(missing(targets)) stop("targets is required argument") targets <- as.matrix(targets) if(!all(c("Cy3","Cy5") %in% colnames(targets))) stop("targets should contain columns: Cy3 and Cy5") if(is.null(parameters)==is.null(ref)) stop("exactly one of the arguments parameters and ref should be specified") target.names <- sort(unique(as.vector(t(as.matrix(targets[,c("Cy3","Cy5")]))))) if(verbose) cat("Found unique target names:\n",target.names,"\n") if(is.null(parameters)) { if(!(ref %in% target.names)) stop(paste("\"",ref,"\" not among the target names found",sep="")) other.names <- setdiff(target.names,ref) target.names <- c(ref,other.names) ntargets <- length(target.names) parameters <- rbind(-1,diag(ntargets-1)) rownames(parameters) <- target.names colnames(parameters) <- other.names } else { parameters <- as.matrix(parameters) if(length(target.names) != nrow(parameters)) stop("rows of parameters don't match unique target names") if(any(sort(target.names)!=sort(rownames(parameters)))) stop("rownames of parameters don't match unique target names") target.names <- rownames(parameters) ntargets <- nrow(parameters) if(ncol(parameters) != ntargets-1) warning("number of parameters should be one less than number of targets") } narrays <- nrow(targets) J <- matrix(rep(target.names,narrays),ntargets,narrays) J <- t((t(J) == targets[,"Cy5"]) - (t(J) == targets[,"Cy3"])) rownames(J) <- target.names colnames(J) <- rownames(targets) zapsmall(t(solve(crossprod(parameters),crossprod(parameters,J))),14) } makeContrasts <- function(..., contrasts=NULL, levels) # Construct matrix of custom contrasts # Gordon Smyth # 30 June 2003. Last modified 2 April 2010. { e <- substitute(list(...)) if(is.factor(levels)) levels <- levels(levels) if(!is.character(levels)) levels <- colnames(levels) if(levels[1]=="(Intercept)") { levels[1] <- "Intercept" warning("Renaming (Intercept) to Intercept") } notvalid <- (levels != make.names(levels)) if(any(notvalid)) stop("The levels must by syntactically valid names in R, see help(make.names). Non-valid names: ",paste(levels[notvalid],collapse=",")) n <- length(levels) if(n < 1) stop("No levels to construct contrasts from") indicator <- function(i,n) { out <- rep(0,n) out[i] <- 1 out } levelsenv <- new.env() for (i in 1:n) assign(levels[i], indicator(i,n), pos=levelsenv) # Contrasts given as character vector if(!is.null(contrasts)) { if(length(e)>1) stop("Can't specify both ... and contrasts") e <- as.character(contrasts) ne <- length(e) cm <- matrix(0,n,ne, dimnames=list(Levels=levels,Contrasts=e)) if(ne==0) return(cm) for (j in 1:ne) { ej <- parse(text=e[j]) cm[,j] <- eval(ej, envir=levelsenv) } return(cm) } # Contrasts given as list of expressions ne <- length(e) enames <- names(e)[2:ne] easchar <- as.character(e)[2:ne] if(is.null(enames)) cn <- easchar else cn <- ifelse(enames=="",easchar,enames) cm <- matrix(0,n,ne-1, dimnames=list(Levels=levels,Contrasts=cn)) if(ne < 2) return(cm) for (j in 1:(ne-1)) { ej <- e[[j+1]] if(is.character(ej)) ej <- parse(text=ej) ej <- eval(ej, envir=levelsenv) # Character variable if(!is.numeric(ej)) { colnames(cm)[j] <- as.character(ej)[1] if(is.character(ej)) ej <- parse(text=ej) ej <- eval(ej, envir=levelsenv) } cm[,j] <- ej } cm } limma/R/bwss.R0000644007451300017500000000501612127125240013310 0ustar charlescharles# EVALUATION bwss <- function(x,group) { # Within and between group sums of squares # Gordon Smyth # 14 Mar 2002. Revised 13 May 2002. is.na.xg <- is.na(x) | is.na(group) if(any(is.na.xg)) { x <- x[!is.na.xg] group <- group[!is.na.xg] } if(length(x)==0) return(list(bss=NA,wss=NA,bdf=NA,wdf=NA)) m <- tapply(x,group,mean) v <- tapply(x,group,var) n <- table(group) if(any(n==0)) { m <- m[n>0] v <- v[n>0] n <- n[n>0] } mm <- sum(n*m)/sum(n) wss <- sum((n-1)*v,na.rm=TRUE) bss <- sum(n*(m-mm)^2) wdf <- sum(n-1) bdf <- length(m)-1 list(bss=bss,wss=wss,bdf=bdf,wdf=wdf) } bwss.matrix <- function(x) { # Sums of squares between and within columns of a matrix # Gordon Smyth # 16 Mar 2002. Revised 13 May 2002. n <- colSums(!is.na(x)) if(any(n==0)) { x <- x[,n>0,drop=FALSE] n <- n[n>0] } nc <- length(n) if(nc==0) return(list(bss=NA,wss=NA,bdf=NA,wdf=NA)) m <- colMeans(x,na.rm=TRUE) v <- apply(x,2,var,na.rm=TRUE) mm <- sum(n*m)/sum(n) wss <- sum((n-1)*v,na.rm=TRUE) bss <- sum(n*(m-mm)^2) wdf <- sum(n-1) bdf <- nc-1 list(bss=bss,wss=wss,bdf=bdf,wdf=wdf) } anova.MAList <- function(object,design=NULL,ndups=2,...) { # Analysis of variance, gene x array, for series of replicate arrays # Useful for comparing between to within gene variability # Gordon Smyth # 16 March 2002. Last modified 17 Aug 2004. M <- object$M if(!is.null(design)) { d <- dim(design) if(!is.null(d)) if(d[2]>1) stop("Design matrix should have only one column") M <- .matvec(M,design) } bwss.array <- bwss.matrix(M) nspots <- dim(M)[1] narrays <- dim(M)[2] ngenes <- nspots/ndups dim(M) <- c(ndups,ngenes*narrays) bwss.genearray <- bwss.matrix(M) dim(M) <- c(ndups,ngenes,narrays) M <- aperm(M,c(1,3,2)) dim(M) <- c(ndups*narrays,ngenes) bwss.gene <- bwss.matrix(M) src <- c("Genes","Arrays","Interaction","Duplicates") ss <- c(bwss.gene$bss,bwss.array$bss,bwss.genearray$bss-bwss.array$bss-bwss.gene$bss,bwss.genearray$wss) df <- c(bwss.gene$bdf,bwss.array$bdf,bwss.genearray$bdf-bwss.array$bdf-bwss.gene$bdf,bwss.genearray$wdf) ms <- ss/df sig <- ms sig[1] <- (ms[1]-ms[3])/ndups/narrays sig[2] <- (ms[2]-ms[3])/ndups/ngenes sig[3] <- (ms[3]-ms[4])/ndups ratio <- c(sig[1]/sum(sig[2:4]),NA,NA,NA) table <- data.frame(df, ss, ms, sig, ratio) dimnames(table) <- list(src,c("Df","Sum Sq","Mean Sq","Var Comp","Ratio")) structure(table,heading=c("Analysis of Variance Table\n","Between and Within Genes"),class=c("anova","data.frame")) } limma/R/read.R0000755007451300017500000003324712127125240013257 0ustar charlescharles# READ.R # GAL FILES readGAL <- function(galfile=NULL,path=NULL,header=TRUE,sep="\t",quote="\"",skip=NULL,as.is=TRUE,...) { # Read GenePix Array List (GAL) file # Gordon Smyth # 1 Mar 2003. Last revised 2 May 2005. if(is.null(galfile)) { if(is.null(path)) path <- "." galfile <- dir(path=path,pattern="\\.gal$") nfiles <- length(galfile) if(nfiles == 0) stop("Cannot find GAL file") if(nfiles > 1) { galfile <- galfile[1] warning(paste("More than one GAL file found. Reading",galfile)) } } if(!is.null(path)) galfile <- file.path(path,galfile) if(is.null(skip)) { chunk <- readLines(galfile,n=100) skip <- intersect(grep("Name",chunk), grep("ID",chunk)) - 1 n <- length(skip) if(n == 0) stop("Cannot find ID and Name columns in GAL file") if(n > 1) stop("Multiple lines with ID and Name labels") } gal <- read.table(galfile,header=header,sep=sep,quote=quote,skip=skip,as.is=as.is,comment.char="",...) nblocks <- max(gal$Block,na.rm=TRUE) ncolumns <- max(gal$Column,na.rm=TRUE) nrows <- max(gal$Row,na.rm=TRUE) spotindex <- ((gal$Block-1)*nrows+(gal$Row-1))*ncolumns+gal$Column if(any(diff(spotindex)<0)) { o <- order(spotindex) gal <- gal[o,] } gal } strsplit2 <- function(x, split, ...) { # Split vector of composite names into matrix of simple names # Gordon Smyth # 8 May 2003 (originally called splitName). Last modified 22 October 2009. x <- as.character(x) n <- length(x) s <- strsplit(x,split=split,...) nc <- unlist(lapply(s,length)) out <- matrix("",n,max(nc)) for (i in 1:n) { if(nc[i]) out[i,1:nc[i]] <- s[[i]] } out } getLayout <- function(gal,guessdups=FALSE) # Guess print layout from a gene list including Block, Row and Column indices # as for a GenePix Allocation List (GAL) # Gordon Smyth # 7 Apr 2003. Last revised 4 June 2004. { if( !all(c("Block","Row","Column") %in% names(gal)) ) stop("gal needs to have columns Block, Row and Column") ngrid.r <- max(gal$Block,na.rm=TRUE) if(ngrid.r %% 4 == 0) { ngrid.c <- 4 ngrid.r <- ngrid.r/4 } else { ngrid.c <- 1 } nspot.r <- max(gal$Row,na.rm=TRUE) nspot.c <- max(gal$Column,na.rm=TRUE) printer <- list( ngrid.r=as.integer(ngrid.r), ngrid.c=as.integer(ngrid.c), nspot.r=as.integer(nspot.r), nspot.c=as.integer(nspot.c) ) if(guessdups) { ID <- paste(gal$ID,gal$Name) printer <- c(printer,getDupSpacing(ID)) } structure(printer,class="PrintLayout") } getDupSpacing <- function(ID) # Find the valid ndups and spacing values for a set of IDs # Assumes at least one probe with a unique ID, from which # spacing can be determined. # Gordon Smyth # 15 Oct 2008 { if(any(is.na(ID))) return(list(ndups=NA,spacing=NA)) ID <- as.factor(ID) nspots <- length(ID) tab <- table(ID) wm <- which.min(tab) ndups <- as.vector(tab[wm]) if(any(tab %% ndups !=0)) ndups <- 1 if(ndups==1) return(list(ndups=ndups,spacing=1)) d <- diff(which(ID==names(tab)[wm])) if(diff(range(d))==0) return(list(ndups=ndups,spacing=d[1])) else return(list(ndups=1,spacing=1)) } getLayout2 <- function(galfile) # Guess print layout from header of GenePix Allocation List (GAL) file # using block position and dimension information # James Wettenhall # 4 June 2004 { if(missing(galfile)) galfile <- dir(pattern="\\.gal$")[1] if(is.na(galfile) || length(galfile)==0 || !is.character(galfile) || nchar(galfile)==0) stop("Please specify a gal file name.") galHeader <- readLines(galfile,n=100) blockLines <- galHeader[grep("Block[0-9]",galHeader)] if(length(blockLines)==0) stop("Invalid or missing header in GAL file.") blockLines <- gsub("[ \t]*$","",blockLines) # Removing trailing whitespace (e.g. tabs) numBlocks <- length(blockLines) if(length(grep(",",blockLines))) delimiter <- "," else delimiter <- "\t" blockCoordinates <- t(matrix(as.numeric(unlist(strsplit( gsub("[ \t]*$","",gsub("\\\"","",gsub("Block[0-9]+=[ \t]*","", galHeader[grep("Block[0-9]",galHeader)]))),delimiter,fixed=TRUE))), ncol=numBlocks)) ngrid.r <- length(table(blockCoordinates[,2])) ngrid.c <- as.numeric(table(blockCoordinates[,2])[1]) nspot.r <- blockCoordinates[1,6] nspot.c <- blockCoordinates[1,4] printer <- list(ngrid.r=ngrid.r,ngrid.c=ngrid.c,nspot.r=nspot.r,nspot.c=nspot.c) structure(printer, class = "PrintLayout") } readTargets <- function(file="Targets.txt",path=NULL,sep="\t",row.names=NULL,quote="\"",...) # Read data frame of target information # Gordon Smyth # 19 Oct 2003. Last modified 24 Jan 2013. { if(!is.null(path)) file <- file.path(path,file) tab <- read.table(file,header=TRUE,stringsAsFactors=FALSE,sep=sep,quote=quote,fill=TRUE,...) # if(!all(c("Cy3","Cy5") %in% names(tab))) warning("File should contain columns: Cy3 and Cy5") if(is.null(row.names)) { rn <- tab[["Label"]] if(anyDuplicated(rn)) rn <- NULL if(is.null(rn)) rn <- tab[["Labels"]] if(anyDuplicated(rn)) rn <- NULL if(is.null(rn)) rn <- tab[["FileName"]] if(!is.null(rn)) rn <- removeExt(rn) if(anyDuplicated(rn)) rn <- NULL if(!is.null(rn)) row.names(tab) <- rn } else { row.names <- as.character(row.names) if(row.names %in% names(tab)) row.names(tab) <- tab[[row.names]] } tab } readSpotTypes <- function(file="SpotTypes.txt",path=NULL,sep="\t",check.names=FALSE,...) # Read regexp for spot types # Gordon Smyth following idea of James Wettenhall # 19 Oct 2003. Last modified 16 Feb 2004. { if(!is.null(path)) file <- file.path(path,file) tab <- read.table(file,header=TRUE,as.is=TRUE,sep=sep,quote="\"",check.names=check.names,...) if(ncol(tab)<2) stop("File should contain at least two columns") tab } controlStatus <- function(types, genes, spottypecol="SpotType", regexpcol, verbose=TRUE) # Set status of each spot # Gordon Smyth # 19 Oct 2003. Last modified 9 Nov 2003. { # Check input if (is(genes, "RGList") || is(genes, "MAList") || is(genes, "MArrayLM")) genes <- genes$genes cntypes <- colnames(types) cngenes <- colnames(genes) if(is.null(cntypes) || is.null(cngenes)) stop("types and genes must have column names") ntypes <- nrow(types) nspots <- nrow(genes) if(ntypes==0 || nspots==0) return(NULL) # Any undo conversion of types to factors for (j in cntypes) { x <- types[,j] if(is.factor(x) && is.character(levels(x))) types[,j] <- as.character(x) } if(is.numeric(spottypecol)) spottypecol <- cntypes[spottypecol[1]] if(is.null(spottypecol) || !is.character(spottypecol) || !is.element(spottypecol,cntypes)) stop("spottypecol not valid column of types") # Find common columns between types and genes if(!missing(regexpcol) && is.numeric(regexpcol)) regexpcol <- cntypes[regexpcol] cntypes <- setdiff(cntypes,spottypecol) if(missing(regexpcol)) { incommon <- (cntypes %in% cngenes) if(!length(incommon)) stop("types and genes have no column names in common") regexpcol <- cntypes[incommon] } else { if(!all(is.element(regexpcol,cntypes) & is.element(regexpcol,cngenes))) stop("types and genes must both contain regexpcol colums") } if(verbose) cat("Matching patterns for:",regexpcol,"\n") # Simplified regular expressions for (j in regexpcol) { types[,j] <- paste("^",gsub("\\*","\\.*",types[,j]),"$",sep="") genes[,j] <- as.character(genes[,j]) } # Set spot status spottype <- as.character(types[,spottypecol]) if(default <- all(types[1,regexpcol]=="*")) { status <- rep(spottype[1],nspots) if(ntypes==1) return(status) } else status <- character(nspots) nregexp <- length(regexpcol) for (i in (1+default):ntypes) { sel <- grep(types[i,regexpcol[1]],genes[,regexpcol[1]]) if(nregexp>1) for (j in regexpcol[-1]) sel <- intersect(sel,grep(types[i,j],genes[,j])) status[sel] <- spottype[i] if(verbose) cat("Found",length(sel),spottype[i],"\n") } # Set attributes attr(status,"values") <- spottype cntypes <- setdiff(cntypes,regexpcol) npar <- length(cntypes) if(npar) { parnames <- sub("^Color$","col",cntypes) for (j in 1:npar) attr(status,parnames[j]) <- types[,cntypes[j]] } if(verbose) cat("Setting attributes: values",cntypes,"\n") status } removeExt <- function(x) { # Remove any common extension from a vector of file names # Gordon Smyth # 19 July 2002. Last modified 19 Jan 2005. x <- as.character(x) n <- length(x) if(length(grep("\\.",x)) < n) return(x) ext <- sub("(.*)\\.(.*)$","\\2",x) if(all(ext[1] == ext)) return(sub("(.*)\\.(.*)$","\\1",x)) else return(x) } trimWhiteSpace <- function(x) # Trim white space from start and end of character strings # Tim Beissbarth and Gordon Smyth # 7 June 2004 { sub("[ \t\n\r]*$", "", sub("^[ \t\n\r]*", "", x)) } protectMetachar <- function(x) # Insert backslashs before an metacharacters (to allow them to be included in search strings) # Note that backslashs themselves are not handled # Gordon Smyth # 9 June 2004. Last modified 5 Jan 2007. { x <- gsub("\\.", "\\\\.", x) x <- gsub("\\|", "\\\\|", x) x <- gsub("\\(", "\\\\(", x) x <- gsub("\\)", "\\\\)", x) x <- gsub("\\[", "\\\\[", x) x <- gsub("\\{", "\\\\{", x) x <- gsub("\\^", "\\\\^", x) x <- gsub("\\$", "\\\\$", x) x <- gsub("\\*", "\\\\*", x) x <- gsub("\\+", "\\\\+", x) x <- gsub("\\?", "\\\\?", x) x } # LAYOUT FUNCTIONS spotc <- function(layout) { # GKS 24 Nov 2002 rep(1:layout$nspot.c, length=prod(unlist(layout))) } spotr <- function(layout) { # GKS 24 Nov 2002 rep(1:layout$nspot.r, times=layout$ngrid.r*layout$ngrid.c, each=layout$nspot.c) } gridc <- function(layout) { # GKS 24 Nov 2002 rep(1:layout$ngrid.c, times=layout$ngrid.r, each=layout$nspot.c*layout$nspot.r) } gridr <- function(layout) { # GKS 24 Nov 2002 rep(1:layout$ngrid.r, each=layout$nspot.c*layout$nspot.r*layout$ngrid.c) } printorder <- function(layout, ndups=1, spacing="columns", npins, start="topleft") { # Identify order in which spots were printed and from which 384-well plate # Gordon Smyth # 2 May 2003. Last revised 28 Dec 2003. if(is(layout,"RGList") || is(layout,"MAList")) { if(missing(ndups) && !is.null(layout$printer$ndups)) ndups <- layout$printer$ndups if(missing(spacing) && !is.null(layout$printer$spacing)) spacing <- layout$printer$spacing if(missing(npins) && !is.null(layout$printer$npins)) npins <- layout$printer$npins if(missing(start) && !is.null(layout$printer$start)) start <- layout$printer$start layout <- layout$printer } ngrid.r <- layout$ngrid.r ngrid.c <- layout$ngrid.c nspot.r <- layout$nspot.r nspot.c <- layout$nspot.c ngrids <- ngrid.r * ngrid.c nspots <- nspot.r * nspot.c if(is(spacing,"numeric")) { if(spacing==1) spacing <- "columns" if(spacing==layout$ngrid.c) spacing <- "rows" if(spacing==ngrids * nspots %/% 2) spacing <- "topbottom" if(is(spacing,"numeric")) stop("spacing not recognized choice") } spacing <- match.arg(spacing,c("columns","rows","topbottom")) start <- match.arg(start,c("topleft","topright")) # DNA plates assumed to have 384 wells nwell.r <- 16 nwell.c <- 24 nwells <- nwell.r * nwell.c # FIRST DO ALL FOR NDUPS=1 if(spacing=="columns") { nspot.c <- nspot.c %/% ndups nspots <- nspots %/% ndups } if(spacing=="rows") { nspot.r <- nspot.r %/% ndups nspots <- nspots/ndups } if(spacing=="topbottom") { ngrid.r <- ngrid.r %/% ndups ngrids <- ngrids %/% ndups } # Pin columns assumed to be same as grid columns if(missing(npins)) npins <- ngrid.r * ngrid.c npin.c <- ngrid.c npin.r <- npins %/% npin.c pin.c <- rep(1:npin.c, times = npin.r, each = nspots) pin.r <- rep(1:npin.r, each = npin.c * nspots) # PRINTORDER FOR NPINS=NGRIDS spot.c <- rep(1:nspot.c, times = npins * nspot.r) spot.r <- rep(1:nspot.r, times = npins, each = nspot.c) po <- switch(start, topleft=nspot.c*(spot.r-1)+spot.c, topright=nspot.c*(spot.r-1)+nspot.c-spot.c+1 ) # PRINTORDER FOR NPINS 1) po <- rep(po,m) + nspots * rep(0:(m-1), each = npins * nspots) # Plate position ndips <- nwells %/% npins plate <- 1 + (po-1) %/% ndips platedip <- 1 + (po-1) %% ndips plateblock.r <- 1 + (platedip-1) %/% (nwell.c %/% npin.r) plateblock.c <- 1 + (platedip-1) %% (nwell.c %/% npin.r) plate.r <- (plateblock.r-1) * npin.c + npin.c - pin.c + 1 plate.c <- (plateblock.c-1) * npin.r + pin.r # NOW ADJUST FOR NDUPS>1 if(ndups>1) { dupseq <- 1:ndups if(start=="topright" && spacing=="columns") dupseq <- rev(dupseq) spacing <- getSpacing(spacing,layout) ngenes <- length(po) po <- rep(po,each=ndups) dim(po) <- c(ndups,spacing,ngenes/spacing) po <- po-1+dupseq/ndups po <- round(po*ndups) po <- as.vector(aperm(po,c(2,1,3))) adups <- function(x) { x <- rep(x,each=ndups) dim(x) <- c(ndups,spacing,ngenes/spacing) as.vector(aperm(x,c(2,1,3))) } plate <- adups(plate) plate.r <- adups(plate.r) plate.c <- adups(plate.c) } # Final output platedigits <- 1+floor(log(ngrids*nspots/nwells,10)) platepos <- paste("p",formatC(plate, width=platedigits, flag = "0"), LETTERS[plate.r], formatC(plate.c, width=2, flag = "0"), sep="") list(printorder=po, plate=plate, plate.r=plate.r, plate.c=plate.c, plateposition=platepos) } getSpacing <- function(spacing, layout) # Convert character to integer duplicating spacing # Gordon Smyth # 15 Dec 2003. Last revised 15 Oct 2008. { if(is(spacing,"numeric")) return(spacing) spacing <- match.arg(spacing, c("columns","rows","subarrays","topbottom")) switch(spacing, columns=1, rows=layout$nspot.c, subarrays=layout$ngrid.r/layout$ndups*layout$ngrid.c*layout$nspot.r*layout$nspot.c, topbottom=layout$ngrid.r/2*layout$ngrid.c*layout$nspot.r*layout$nspot.c ) } limma/R/fitGammaIntercept.R0000644007451300017500000000124612127125240015736 0ustar charlescharlesfitGammaIntercept <- function(y,offset=0,maxit=1000) # Estimate intercept of additive gamma glm # Belinda Phipson and Gordon Smyth # Created 17 May 2012. Last modified 2 Dec 2012. { if(any(y<0)) stop("negative y not permitted") if(any(offset<0)) stop("offsets must be positive") # Treat constant offset as special case r <- range(offset) if(r[1]+1e-14 > r[2]) return(mean(y)-r[1]) n <- length(y) x <- 0 iter <- 0 repeat { iter <- iter+1 Q <- sum(y/(offset+x)) dQ <- sum(y/(offset+x)^2) dif <- (Q-n)/dQ x <- x+dif if(abs(dif) < 1e-8) break if(iter > maxit) { warning("iteration limit maxit exceeded") break } } x } limma/R/plotdensities.R0000755007451300017500000000702112127125240015221 0ustar charlescharles# PLOT DENSITIES plotDensities<-function(object,log=TRUE,arrays=NULL,singlechannels=NULL,groups=NULL,col=NULL) # Plot empirical single-channel densities # Original version by Natalie Thorne, 9 September 2003 # Modified by Gordon Smyth. Last modified 1 June 2005. { matDensities<-function(X){ densXY<-function(Z){ zd<-density(Z,na.rm=TRUE) x<-zd$x y<-zd$y cbind(x,y) } out<-apply(X,2,densXY) outx<-out[(1:(nrow(out)/2)),] outy<-out[(((nrow(out)/2)+1):nrow(out)),] list(X=outx,Y=outy) } if(is(object,"MAList")) { R <- object$A+object$M/2 G <- object$A-object$M/2 if(!log) { R <- 2^R G <- 2^G } } else { R <- object$R G <- object$G if(!is.null(object$Rb)) R <- R-object$Rb if(!is.null(object$Gb)) G <- G-object$Gb if(log) { R[R <= 0] <- NA G[G <= 0] <- NA R <- log(R,2) G <- log(G,2) } } if( is.null(arrays) & is.null(singlechannels) ){ arrays <- 1:(ncol(R)) x <- cbind(R,G) if(is.null(groups)) { groups <- c(length(arrays),length(arrays)) if(is.null(col)) cols <- rep(c("red","green"),groups) if(!is.null(col)) { if(length(col)!=2) { warning("number of groups=2 not equal to number of col") cols<-"black" } else { cols<-rep(col,groups) } } } else { if(!is.null(col)) { if(length(as.vector(table(groups)))!=length(col)) { warning("number of groups not equal to number of col") cols <- col } else { cols <- col[groups] } } else { warning("warning no cols in col specified for the groups") cols <- "black" } } }else{ if(!is.null(singlechannels)) { if(!is.null(arrays)) warning("cannot index using arrays AND singlechannels") x <- cbind(R,G)[,singlechannels] if(is.null(groups)) { groups <- c(length(intersect((1:ncol(R)),singlechannels)), length(intersect(((ncol(R)+1):ncol(cbind(G,R))), singlechannels))) if(is.null(col)) cols <- rep(c("red","green"),groups) if(!is.null(col)) { if(length(col)!=2) { warning("number of groups=2 not equal to number of col") cols<-"black" } else { cols<-rep(col,groups) } } } else { if(!is.null(col)) { if(length(as.vector(table(groups)))!=length(col)) { warning("number of groups not equal to number of col") cols <- col } else { cols <- col[groups] } } else { print("warning no cols in col specified for the groups") cols <- "black" } } }else{ if(!is.null(arrays)) { if(!is.null(singlechannels)) warning("cannot index using arrays AND singlechannels") x <- cbind(R[,arrays],G[,arrays]) if(is.null(groups)) { groups <- c(length(arrays),length(arrays)) if(is.null(col)) cols <- rep(c("red","green"),groups) if(!is.null(col)) { if(length(col)!=2) { warning("number of groups=2 not equal to number of col") cols<-"black" } else { cols <- rep(col,groups) } } }else{ if(!is.null(col)) { if(length(as.vector(table(groups)))!=length(col)){ warning("number of groups not equal to number of col") cols <- "black" }else{ cols <- col[groups] } }else{ warning("warning no cols in col specified for the groups") cols <- "black" } } } } } dens.x<-matDensities(x) matplot(dens.x$X,dens.x$Y,xlab="Intensity",ylab="Density",main="RG densities",type="l",col=cols,lwd=2,lty=1) } limma/R/toptable.R0000644007451300017500000001363112130404410014137 0ustar charlescharles# TOPTABLE.R topTable <- function(fit,coef=NULL,number=10,genelist=fit$genes,adjust.method="BH",sort.by="B",resort.by=NULL,p.value=1,lfc=0,confint=FALSE) # Summary table of top genes, object-orientated version # Gordon Smyth # 4 August 2003. Last modified 7 April 2013. { # Check fit if(!is(fit,"MArrayLM")) stop("fit must be an MArrayLM object") if(is.null(fit$coefficients)) stop("coefficients not found in fit object") if(is.null(fit$stdev.unscaled)) stop("stdev.unscaled not found in fit object") if(is.null(coef)) coef <- 1:ncol(fit) if(length(coef)>1) { coef <- unique(coef) if(length(fit$coef[1,coef]) < ncol(fit)) fit <- eBayes(fit[,coef]) if(sort.by=="B") sort.by <- "F" return(topTableF(fit,number=number,genelist=genelist,adjust.method=adjust.method,sort.by=sort.by,p.value=p.value,lfc=lfc)) } fit <- unclass(fit) ebcols <- c("t","p.value","lods") if(confint) ebcols <- c("s2.post","df.total",ebcols) toptable(fit=fit[c("coefficients","stdev.unscaled")], coef=coef, number=number, genelist=genelist, A=fit$Amean, eb=fit[ebcols], adjust.method=adjust.method, sort.by=sort.by, resort.by=resort.by, p.value=p.value, lfc=lfc, confint=confint) } topTableF <- function(fit,number=10,genelist=fit$genes,adjust.method="BH",sort.by="F",p.value=1,lfc=0) # Summary table of top genes by F-statistic # Gordon Smyth # 27 August 2006. Last modified 19 Jan 2012. { # Check input if(is.null(fit$F)) stop("F-statistics not available. Try topTable for individual coef instead.") if(!is.null(genelist) && is.null(dim(genelist))) genelist <- data.frame(ProbeID=genelist,stringsAsFactors=FALSE) sort.by <- match.arg(sort.by,c("F","none")) M <- as.matrix(fit$coefficients) if(is.null(colnames(M))) colnames(M) <- paste("Coef",1:ncol(M),sep="") rn <- rownames(M) if(is.null(rn) || length(rn) > length(unique(rn))) rn <- 1:nrow(M) adj.P.Value <- p.adjust(fit$F.p.value,method=adjust.method) if(lfc > 0) { big <- apply(abs(M)>lfc,1,any) big[is.na(big)] <- FALSE if(any(!big)) { fit <- fit[big,] if(!is.null(genelist)) genelist <- genelist[big,,drop=FALSE] M <- M[big,] rn <- rn[big] adj.P.Value <- adj.P.Value[big] } } if(nrow(fit) < number) number <- nrow(fit) if(sort.by=="F") o <- order(fit$F.p.value,decreasing=FALSE)[1:number] else o <- 1:number if(p.value < 1) { nsig <- sum(adj.P.Value[o] <= p.value,na.rm=TRUE) if(nsig < number) o <- o[1:nsig] } if(is.null(genelist)) tab <- data.frame(M[o,,drop=FALSE]) else tab <- data.frame(genelist[o,,drop=FALSE],M[o,,drop=FALSE]) if(!is.null(fit$Amean)) tab <- data.frame(tab,AveExpr=fit$Amean[o]) tab <- data.frame(tab,F=fit$F[o],P.Value=fit$F.p.value[o],adj.P.Val=adj.P.Value[o]) rownames(tab) <- rn[o] tab } toptable <- function(fit,coef=1,number=10,genelist=NULL,A=NULL,eb=NULL,adjust.method="BH",sort.by="B",resort.by=NULL,p.value=1,lfc=0,confint=FALSE,...) # Summary table of top genes # Gordon Smyth # 21 Nov 2002. Last revised 30 Jan 2011. { # Check input if(length(coef)>1) coef <- coef[1] if(!is.null(genelist) && is.null(dim(genelist))) genelist <- data.frame(ID=genelist,stringsAsFactors=FALSE) if(is.null(eb)) { fit$coefficients <- as.matrix(fit$coefficients)[,coef] fit$stdev.unscaled <- as.matrix(fit$stdev.unscaled)[,coef] eb <- ebayes(fit,...) coef <- 1 } M <- as.matrix(fit$coefficients)[,coef] if(is.null(A)) { if(sort.by=="A") stop("Cannot sort by A-values as these have not been given") } else { if(NCOL(A)>1) A <- rowMeans(A,na.rm=TRUE) } tstat <- as.matrix(eb$t)[,coef] P.Value <- as.matrix(eb$p.value)[,coef] B <- as.matrix(eb$lods)[,coef] rownum <- 1:length(M) sort.by <- match.arg(sort.by,c("logFC","M","A","Amean","AveExpr","P","p","T","t","B","none")) if(sort.by=="M") sort.by="logFC" if(sort.by=="A" || sort.by=="Amean") sort.by <- "AveExpr" if(sort.by=="T") sort.by <- "t" if(sort.by=="p") sort.by <- "P" # Apply multiple testing adjustment adj.P.Value <- p.adjust(P.Value,method=adjust.method) # Apply p.value or lfc thresholds if(p.value < 1 | lfc > 0) { sig <- (adj.P.Value < p.value) & (abs(M) > lfc) if(any(is.na(sig))) sig[is.na(sig)] <- FALSE if(all(!sig)) return(data.frame()) genelist <- genelist[sig,,drop=FALSE] M <- M[sig] A <- A[sig] tstat <- tstat[sig] P.Value <- P.Value[sig] adj.P.Value <- adj.P.Value[sig] B <- B[sig] rownum <- rownum[sig] } ord <- switch(sort.by, logFC=order(abs(M),decreasing=TRUE), AveExpr=order(A,decreasing=TRUE), P=order(P.Value,decreasing=FALSE), t=order(abs(tstat),decreasing=TRUE), B=order(B,decreasing=TRUE), none=1:length(M) ) if(length(M) < number) number <- length(M) if(number < 1) return(data.frame()) top <- ord[1:number] if(is.null(genelist)) tab <- data.frame(logFC=M[top]) else { tab <- data.frame(genelist[top,,drop=FALSE],logFC=M[top],stringsAsFactors=FALSE) } if(confint) { margin.error <- sqrt(eb$s2.post[top])*fit$stdev.unscaled[top]*qnorm(0.975) tab$CI.025 <- M[top]-margin.error tab$CI.975 <- M[top]+margin.error } if(!is.null(A)) tab <- data.frame(tab,AveExpr=A[top]) tab <- data.frame(tab,t=tstat[top],P.Value=P.Value[top],adj.P.Val=adj.P.Value[top],B=B[top]) rownames(tab) <- as.character(rownum)[top] if(!is.null(resort.by)) { resort.by <- match.arg(resort.by,c("logFC","M","A","Amean","AveExpr","P","p","T","t","B")) if(resort.by=="M") resort.by <- "logFC" if(resort.by=="A" || resort.by=="Amean") resort.by <- "AveExpr" if(resort.by=="p") resort.by <- "P" if(resort.by=="T") resort.by <- "t" ord <- switch(resort.by, logFC=order(tab$logFC,decreasing=TRUE), AveExpr=order(tab$AveExpr,decreasing=TRUE), P=order(tab$P.Value,decreasing=FALSE), t=order(tab$t,decreasing=TRUE), B=order(tab$B,decreasing=TRUE) ) tab <- tab[ord,] } # attr(tab,"coef") <- coef # attr(tab,"adjust.method") <- adjust.method tab } limma/R/predFCm.R0000644007451300017500000000242512127125240013653 0ustar charlescharlespredFCm <- function(fit,coef=2,prob=TRUE,VarRel=NULL) # Belinda Phipson 29 May 2012. Updated 8 January 2013. { p <- 1-propTrueNull(fit$p.value[,coef]) if(p==0) p<-1e-8 if(length(fit$s2.prior)==1) trend<-FALSE else trend<-TRUE fit <- eBayes(fit,proportion = p,trend=trend) v <- fit$cov.coefficients[coef,coef] if(is.null(VarRel)) VarRel <- "Independent" if(VarRel=="Independent"){ v0 <- fitGammaIntercept(fit$coeff[,coef]^2,offset=v*fit$s2.post) if(v0<0) v0<-1e-8 pfc <- fit$coeff[,coef]*v0/(v0+v*fit$s2.post) if(prob){ A <- p/(1-p) B <- (v*fit$s2.post/(v*fit$s2.post+v0))^0.5 C <- exp(fit$coeff[,coef]^2*v0/(2*v^2*fit$s2.post^2+2*v*v0*fit$s2.post)) lods <- log(A*B*C) probDE <- exp(lods)/(1+exp(lods)) probDE[lods>700] <- 1 pfc <- pfc*probDE } } else if(VarRel=="Increasing"){ b2 <- fit$coeff[,coef]^2/fit$s2.post v0 <- fitGammaIntercept(b2,offset=v) if(v0<0) v0<-1e-8 pfc <- fit$coeff[,coef]*v0/(v0+v) if(prob){ A <- p/(1-p) B <- (v/(v+v0))^0.5 C <- exp(fit$coeff[,coef]^2*v0/(2*v^2*fit$s2.post+2*v*v0*fit$s2.post)) lods <- log(A*B*C) probDE <- exp(lods)/(1+exp(lods)) probDE[lods>700] <- 1 pfc <- pfc*probDE } } else stop("Invalid VarRel, please select either Independent or Increasing") pfc } limma/R/plots-image.R0000755007451300017500000000567712127125240014573 0ustar charlescharles# PRESENTATION PLOTS imageplot <- function(z, layout, low=NULL, high=NULL, ncolors=123, zerocenter=NULL, zlim=NULL, mar=c(2,1,1,1), legend=TRUE, ...) { # Image plot of spotted microarray data # Gordon Smyth # 20 Nov 2001. Last revised 18 Sep 2004. # Check input gr <- layout$ngrid.r gc <- layout$ngrid.c sr <- layout$nspot.r sc <- layout$nspot.c if(is.null(gr)||is.null(gc)||is.null(sr)||is.null(sc)) stop("Layout needs to contain components ngrid.r, ngrid.c, nspot.r and nspot.c") if(length(z) != gr*gc*sr*sc) stop("Number of image spots does not agree with layout dimensions") # Check colours if(is.character(low)) low <- col2rgb(low)/255 if(is.character(high)) high <- col2rgb(high)/255 if(!is.null(low) && is.null(high)) high <- c(1,1,1) - low if(is.null(low) && !is.null(high)) low <- c(1,1,1) - high # Is zlim preset? zr0 <- range(z,na.rm=TRUE) if(!is.null(zlim)) { z <- pmax(zlim[1],z) z <- pmin(zlim[2],z) } # Plot differential expression from "green" to "red" or plot one variable from "white" to "blue"? zr <- range(z,na.rm=TRUE) if(!all(is.finite(zr))) stop("Infinite values found: consider using finite zlim value") zmax <- max(abs(zr)) zmin <- zr[1] if(is.null(zerocenter)) zerocenter <- (zmin < 0) if(zerocenter) { if(is.null(low)) low <- c(0,1,0) if(is.null(high)) high <- c(1,0,0) if(is.null(zlim)) zlim <- c(-zmax,zmax) } else { if(is.null(low)) low <- c(1,1,1) if(is.null(high)) high <- c(0,0,1) if(is.null(zlim)) zlim <- c(zmin,zmax) } # Now make the plot col <- rgb( seq(low[1],high[1],len=ncolors), seq(low[2],high[2],len=ncolors), seq(low[3],high[3],len=ncolors) ) dim(z) <- c(sc,sr,gc,gr) z <- aperm(z,perm=c(2,4,1,3)) dim(z) <- c(gr*sr,gc*sc) old.par <- par(mar=mar) on.exit(par(old.par)) image(0:(gr*sr),0:(gc*sc),z,zlim=zlim,col=col,xaxt="n",yaxt="n",...) for (igrid in 0:gc) lines( c(0,gr*sr), rep(igrid*sc,2) ) for (igrid in 0:gr) lines( rep(igrid*sr,2), c(0,gc*sc) ) if(legend) mtext(paste("z-range ",round(zr0[1],1)," to ",round(zr0[2],1)," (saturation ",round(zlim[1],1),", ",round(zlim[2],1),")",sep=""),side=1,cex=0.6) invisible() } imageplot3by2 <- function(RG, z="Gb", prefix=paste("image",z,sep="-"), path=NULL, zlim=NULL, common.lim=TRUE, ...) # Make files of image plots, six to a page # Gordon Smyth 10 June 2004. # Suggestions of Marcus Davy implemented 30 September 2005. { if(is.null(path)) path="." narrays <- ncol(RG) npages <- ceiling(narrays/6) cnames <- colnames(RG) if(is.null(zlim) && common.lim) zlim <- quantile(RG[[z]],c(0.05,0.95),na.rm=TRUE) for (ipage in 1:npages) { i1 <- ipage*6-5 i2 <- min(ipage*6,narrays) fn <- file.path(path, paste(prefix,"-",i1,"-",i2,".png",sep="")) png(filename=fn,width=6.5*140,height=10*140,pointsize=20) par(mfrow=c(3,2)) for (i in i1:i2) { imageplot(RG[[z]][,i],RG$printer,zlim=zlim,mar=c(2,2,4,2),main=cnames[i],...) } dev.off() } invisible() } limma/R/printtipWeights.R0000755007451300017500000001656012127125240015547 0ustar charlescharlesprinttipWeights <- function(object, design = NULL, weights = NULL, method="genebygene", layout = object$printer, maxiter=50, tol = 1e-10, trace = FALSE) # Compute print-tip quality weights # Matt Ritchie # 21 Sep 2006. Last revised 16 Jan 2008. # Gordon Smyth simplified argument checking to use getEAWP, 9 Mar 2008. { # Check arguments y <- getEAWP(object) if(is.null(design)) design <- matrix(1,ncol(y$exprs),1) else design <- as.matrix(design) if(mode(design) != "numeric") stop("design must be a numeric matrix") ne <- nonEstimable(design) if(!is.null(ne)) cat("Coefficients not estimable:",paste(ne,collapse=" "),"\n") if(missing(weights) && !is.null(y$weights)) weights <- y$weights method <- match.arg(method,c("genebygene","reml")) M <- y$exprs p <- ncol(design) # cols <- seq(1:p) QR <- qr(design) nparams <- QR$rank # ncol(design) nprobes <- nrow(M) narrays <- ncol(M) if(narrays < 3) stop("too few arrays") if(nprobes < narrays) stop("too few probes") if(is.null(layout)) stop("printer layout information must be specified") ngr <- layout$ngrid.r ngc <- layout$ngrid.c nspots <- layout$nspot.r * layout$nspot.c nprobes2 <- ngr*ngc*nspots if(nprobes2 != nprobes) stop("printer layout information does not match M row dimension") printtipwts <- matrix(0, ngr*ngc, narrays) # Set up design matrix for array variance model Z <- contr.sum(narrays) spots <- 1:nspots gridnum <- 1 for (gridr in 1:ngr) { for (gridc in 1:ngc) { # Intialise sub-array variances to zero arraygammas <- rep(0, (narrays-1)) method <- match.arg(method,c("genebygene","reml")) switch(method, genebygene = { # Estimate sub-array variances via gene-by-gene update algorithm Zinfo <- 10*(narrays-nparams)/narrays*crossprod(Z, Z) for(i in spots) { if(!all(is.finite(arraygammas))) stop("convergence problem at gene ", i, " in print-tip grid row ", gridr, ", column ", gridc, ": array weights not estimable") vary <- exp(Z%*%arraygammas) if(!is.null(weights)) { # combine spot weights with running weights if(max(weights[i,], na.rm=TRUE) > 1) { weights[i,] <- weights[i,]/max(weights[i,]) } w <- as.vector(1/vary*weights[i,]) } else { w <- as.vector(1/vary) } y <- as.vector(M[i,]) obs <- is.finite(y) & w!=0 if (sum(obs) > 1) { if(sum(obs) == narrays) { X <- design } else { # remove missing/infinite values X <- design[obs, , drop = FALSE] y <- y[obs] vary <- vary[obs] Z2 <- Z[obs,] } out <- lm.wfit(X, y, w[obs]) d <- rep(0, narrays) d[obs] <- w[obs]*out$residuals^2 s2 <- sum(d[obs])/out$df.residual Q <- qr.Q(out$qr) if(ncol(Q)!=out$rank) Q <- Q[,-((out$rank+1):ncol(Q)),drop=FALSE] h <- rep(1, narrays) h[obs] <- rowSums(Q^2) Agam <- crossprod(Z, (1-h)*Z) Agam.del <- crossprod(t(rep(h[narrays], narrays-1)-h[1:(length(narrays)-1)])) Agene.gam <- (Agam - 1/out$df.residual*Agam.del) if(is.finite(sum(Agene.gam)) && sum(obs) == narrays) { Zinfo <- Zinfo + Agene.gam R <- chol(Zinfo) Zinfoinv <- chol2inv(R) zd <- d/s2 - 1 + h Zzd <- crossprod(Z, zd) gammas.iter <- Zinfoinv%*%Zzd arraygammas <- arraygammas + gammas.iter } if(is.finite(sum(Agene.gam)) && sum(obs) < narrays && sum(obs) > 2) { Zinfo <- Zinfo + Agene.gam A1 <- (diag(1, sum(obs))-1/sum(obs)*matrix(1, sum(obs), sum(obs)))%*%Z2 A1 <- A1[-sum(obs),] # remove last row R <- chol(Zinfo) Zinfoinv <- chol2inv(R) zd <- d/s2 - 1 + h Zzd <- A1%*%crossprod(Z, zd) Zinfoinv.A1 <- A1%*%Zinfoinv%*%t(A1) alphas.old <- A1%*%arraygammas alphas.iter <- Zinfoinv.A1%*%Zzd alphas.new <- alphas.old + alphas.iter Us <- rbind(diag(1, sum(obs)-1), -1) Usalphas <- Us%*%(alphas.new-alphas.old) Usgammas <- Z%*%arraygammas Usgammas[obs] <- Usgammas[obs] + Usalphas arraygammas <- Usgammas[1:(narrays-1)] } } } }, reml = { # Estimate sub-array variances via reml # const <- narrays * log(2 * pi) iter <- 0 dev <- 0 repeat { # devold <- dev # dev <- 0 iter <- iter + 1 zd <- matrix(0, narrays, 1) sum1minush <- matrix(0, narrays, 1) K <- matrix(0, nprobes, narrays) for(i in spots) { vary <- exp(Z%*%arraygammas) if(!is.null(weights)) { # combine spot weights with running weights if(max(weights[i,], na.rm=TRUE) > 1) { weights[i,] <- weights[i,]/max(weights[i,]) } w <- as.vector(1/vary*weights[i,]) } else { w <- as.vector(1/vary) } y <- as.vector(M[i,]) obs <- is.finite(y) & w!=0 n <- sum(obs) if (n > 0) { if(n == narrays) { X <- design #Z2 <- Z } else { # remove missing/infinite values X <- design[obs, , drop = FALSE] y <- y[obs] vary <- vary[obs] w <- w[obs] const <- sum(obs) * log(2 * pi) } # cat(i) out <- lm.wfit(X, y, w) d <- rep(0, narrays) d[obs] <- w*out$residuals^2 s2 <- sum(d[obs])/out$df.residual Q <- qr.Q(out$qr) if(ncol(Q)!=out$rank) Q <- Q[,-((out$rank+1):ncol(Q)),drop=FALSE] h <- rowSums(Q^2) zd[obs] <- zd[obs] + d[obs]/s2 - 1 + h sum1minush[obs,1] <- sum1minush[obs,1] + 1-h K[i,][obs] <- as.vector(h[n]-h) # dev <- dev + sum(d[obs]/vary) + sum(log(vary)) + const + 2 * log(prod(abs(diag(out$qr$qr)))) } } Zzd <- crossprod(Z, zd) Zinfo <- diag(sum1minush[1:(narrays-1)]) + sum1minush[narrays] - crossprod(K[,-narrays])/out$df.residual # (narrays-nparams) R <- chol(Zinfo) Zinfoinv <- chol2inv(R) gammas.iter <- Zinfoinv%*%Zzd arraygammas <- arraygammas + gammas.iter # arrayw <- drop(exp(Z %*% (-arraygammas))) x2 <- crossprod(Zzd, gammas.iter) / narrays if(trace) cat("Iter =", iter, " X2 =", x2, " Print-tip grid row ", gridr, " column ", gridc, " gammas: ", arraygammas, "\n") if(!all(is.finite(arraygammas))) stop("convergence problem at iteration ", iter, ": array weights not estimable") # if (dev < devold - 1e-50) # break if (x2 < tol) break if (iter == maxiter) { warning("Maximum iterations ", maxiter, " reached", sep="") break } } }) # matrix(rep(1/exp(Z%*%arraygammas), each=nspots), nprobes, narrays) printtipwts[gridnum, ] <- drop(exp(Z %*% (-arraygammas))) spots <- spots + nspots # arrays <- arrays + narrays gridnum <- gridnum + 1 # cat("\n") } } # Make a matrix of print-tip weights for use in lmFit() ngrids <- ngr*ngc wts <- matrix(0, nspots*ngrids, narrays) spots <- 1:nspots for(i in 1:ngrids) { for(j in 1:narrays) { wts[spots,j] <- printtipwts[i,j] } spots <- spots + nspots } wts } limma/R/roc.R0000755007451300017500000000102212127125240013111 0ustar charlescharles# ROC.R auROC <- function(truth, stat=NULL) { # Area under Receiver Operating Curve for empirical data # Gordon Smyth # 21 Dec 2003. Last modified 4 Dec 2009. if(!length(truth)) return(NULL) truth <- as.numeric(as.logical(truth)) if(!is.null(stat)) { if(length(stat) != length(truth)) stop("lengths differ") truth[is.na(stat)] <- NA truth <- truth[order(stat,decreasing=TRUE)] } isna <- is.na(truth) if(any(isna)) truth <- truth[!isna] sens <- cumsum(truth)/sum(truth) mean(sens[truth==0]) } limma/R/propexpr.R0000644007451300017500000000206712127125240014214 0ustar charlescharlespropexpr <- function(x,neg.x=NULL,status=x$genes$Status,labels=c("negative","regular")) # Estimate proportion of expressed probes on each array # Wei Shi and Gordon Smyth. # 17 April 2009. Last modified 15 Oct 2009. { if(is.null(neg.x)) { ineg <- grep(tolower(labels[1]),tolower(status)) if(length(labels)>1) { ireg <- grep(tolower(labels[2]),tolower(status)) } else { ireg <- -ineg } x <- as.matrix(x) neg.x <- x[ineg,,drop=FALSE] x <- x[ireg,,drop=FALSE] } else { x <- as.matrix(x) neg.x <- as.matrix(neg.x) } narrays <- ncol(x) p <- pb <- p1 <- rep(NA, narrays) for(i in 1:narrays) { b <- neg.x[, i] b <- b[!is.na(b)] nb <- length(b) r <- x[, i] r <- r[!is.na(r)] nr <- length(r) mu <- mean(b) alpha <- max(mean(r) - mu, 10) b1 <- median(b) p1[i] <- mean(pexp(b1-b, rate=1/alpha)) pb[i] <- (sum(b 1] <- 1 pi1[pi1 < 0] <- 0 names(pi1) <- colnames(x) pi1 } limma/R/propTrueNull.R0000644007451300017500000000273012127125240015005 0ustar charlescharlespropTrueNull <- function(p, method="lfdr", nbins=20, ...) # Estimate proportion of null p-values # Belinda Phipson and Gordon Smyth # Created 23 May 2012. Last revised 2 Dec 2012. { method <- match.arg(method, c("lfdr","mean","hist","convest")) switch(method, lfdr = .propTrueNullByLocalFDR(p), mean = .propTrueNullByMeanP(p), hist = .propTrueNullFromHistogram(p, nbins=nbins), convest = convest(p, ...) ) } .propTrueNullByLocalFDR <- function(p) # Estimate proportion of null p-values # by average local FDR # Belinda Phipson and Gordon Smyth # 23 May 2012. Last revised 30 July 2012. { n <- length(p) i <- n:1L p <- sort(p, decreasing = TRUE) q <- pmin(n/i * p, 1) n1 <- n+1L sum(i*q) / n/n1*2 } .propTrueNullByMeanP <- function(p) # Estimate proportion of null p-values # by mean p-value # Gordon Smyth # 12 Feb 2013. { n <- length(p) i <- 1:n p <- sort(p) q <- pmin(p, (i-0.5)/n) 2*mean(q) } .propTrueNullFromHistogram <- function(p, nbins=20) # Estimate proportion of null p-values # by histogram method # Adapted by Gordon Smyth from the function estimate.m0 from # http://www.public.iastate.edu/~dnett/microarray/multtest.txt # Accessed March 2012 # Created 2 Dec 2012. Last revised 2 Dec 2012. { bin <- c(-0.1, (1:nbins)/nbins) bin.counts <- tabulate(cut(p,bin)) tail.means <- rev(cumsum(rev(bin.counts))/(1:nbins)) index <- which(tail.means >= bin.counts)[1] tail.means[index]/tail.means[1] } limma/R/venn.R0000755007451300017500000003114312127125240013303 0ustar charlescharles# VENN DIAGRAM COUNTS AND PLOTS vennCounts <- function(x,include="both") { # Venn diagram counts # Gordon Smyth # 4 July 2003. Last modified 10 March 2013. x <- as.matrix(x) include <- match.arg(include,c("both","up","down")) x <- sign(switch(include, both = abs(x), up = x > 0, down = x < 0 )) nprobes <- nrow(x) ncontrasts <- ncol(x) names <- colnames(x) if(is.null(names)) names <- paste("Group",1:ncontrasts) noutcomes <- 2^ncontrasts outcomes <- matrix(0,noutcomes,ncontrasts) colnames(outcomes) <- names for (j in 1:ncontrasts) outcomes[,j] <- rep(0:1,times=2^(j-1),each=2^(ncontrasts-j)) xlist <- list() for (i in 1:ncontrasts) xlist[[i]] <- factor(x[,ncontrasts-i+1],levels=c(0,1)) counts <- as.vector(table(xlist)) rownames(outcomes) <- 1:nrow(outcomes) structure(cbind(outcomes,Counts=counts),class="VennCounts") } vennDiagram <- function(object,include="both",names=NULL,mar=rep(1,4),cex=c(1.5,1,0.7),lwd=1,circle.col=NULL,counts.col=NULL,show.include=NULL,...) # Plot Venn diagram # Gordon Smyth, James Wettenhall. # Capabilities for multiple counts and colors by Francois Pepin. # 4 July 2003. Last modified 10 March 2013. { # Check include include <- as.character(include) LenInc <- min(length(include),2) # Get counts if(is(object, "VennCounts")) { include <- include[1] LenInc <- 1 } else { if(LenInc>1) z2 <- vennCounts(object, include=include[2])[,"Counts"] object <- vennCounts(object, include=include[1]) } z <- object[,"Counts"] nsets <- ncol(object)-1 if(nsets > 5) stop("Can't plot Venn diagram for more than 5 sets") # Attach zone names to counts VennZone <- object[,1:nsets,drop=FALSE] VennZone <- apply(VennZone,1,function(x) paste(x,sep="",collapse="")) names(z) <- VennZone if(length(include)==2) names(z2) <- VennZone # Set names if(is.null(names)) names <- colnames(object)[1:nsets] # Set colors if(is.null(circle.col)) circle.col <- par('col') if(length(circle.col) 3 sets ############################################## # Open plot plot(c(-20, 420), c(-20, 420), type="n", axes=FALSE, ylab="", xlab="") # Function to turn and move ellipses relocate_elp <- function(e, alpha, x, y) { phi <- (alpha/180)*pi xr <- e[,1]*cos(phi)+e[,2]*sin(phi) yr <- -e[,1]*sin(phi)+e[,2]*cos(phi) xr <- x+xr yr <- y+yr cbind(xr, yr) } ############################################## # 4 sets ############################################## if (4 == nsets) { rect(-20, -20, 420, 400) elps <- cbind(162*cos(seq(0,2*pi,len=1000)), 108*sin(seq(0,2*pi,len=1000))) polygon(relocate_elp(elps, 45, 130, 170),border=circle.col[1],lwd=lwd) polygon(relocate_elp(elps, 45, 200, 200),border=circle.col[1],lwd=lwd) polygon(relocate_elp(elps, 135, 200, 200),border=circle.col[1],lwd=lwd) polygon(relocate_elp(elps, 135, 270, 170),border=circle.col[1],lwd=lwd) text( 35, 315, names[1], cex=cex[1]) text(138, 350, names[2], cex=cex[1]) text(262, 347, names[3], cex=cex[1]) text(365, 315, names[4], cex=cex[1]) text( 35, 250, z["1000"], cex=cex[2], col=counts.col[1],) text(140, 315, z["0100"], cex=cex[2], col=counts.col[1]) text(260, 315, z["0010"], cex=cex[2], col=counts.col[1]) text(365, 250, z["0001"], cex=cex[2], col=counts.col[1]) text( 90, 282, z["1100"], cex=cex[3], col=counts.col[1]) text( 95, 110, z["1010"], cex=cex[2], col=counts.col[1]) text(200, 52, z["1001"], cex=cex[3], col=counts.col[1]) text(200, 292, z["0110"], cex=cex[2], col=counts.col[1]) text(300, 110, z["0101"], cex=cex[2], col=counts.col[1]) text(310, 282, z["0011"], cex=cex[3], col=counts.col[1]) text(130, 230, z["1110"], cex=cex[2], col=counts.col[1]) text(245, 81, z["1101"], cex=cex[3], col=counts.col[1]) text(155, 81, z["1011"], cex=cex[3], col=counts.col[1]) text(270, 230, z["0111"], cex=cex[2], col=counts.col[1]) text(200, 152, z["1111"], cex=cex[2], col=counts.col[1]) text(400, 15, z["0000"], cex=cex[1], col=counts.col[1]) if(length(include)==2) { text( 35, 238, z2["1000"], cex=cex[2], col=counts.col[2]) text(140, 304, z2["0100"], cex=cex[2], col=counts.col[2]) text(260, 304, z2["0010"], cex=cex[2], col=counts.col[2]) text(365, 238, z2["0001"], cex=cex[2], col=counts.col[2]) text( 90, 274, z2["1100"], cex=cex[3], col=counts.col[2]) text( 95, 100, z2["1010"], cex=cex[2], col=counts.col[2]) text(200, 43, z2["1001"], cex=cex[3], col=counts.col[2]) text(200, 280, z2["0110"], cex=cex[2], col=counts.col[2]) text(300, 100, z2["0101"], cex=cex[2], col=counts.col[2]) text(310, 274, z2["0011"], cex=cex[3], col=counts.col[2]) text(130, 219, z2["1110"], cex=cex[2], col=counts.col[2]) text(245, 71, z2["1101"], cex=cex[3], col=counts.col[2]) text(155, 72, z2["1011"], cex=cex[3], col=counts.col[2]) text(270, 219, z2["0111"], cex=cex[2], col=counts.col[2]) text(200, 140, z2["1111"], cex=cex[2], col=counts.col[2]) text(400, -2, z2["0000"], cex=cex[1], col=counts.col[2]) if(show.include) { text(10,15,include[1], cex=cex[1], col=counts.col[1]) text(10,-2,include[2], cex=cex[1], col=counts.col[2]) } } return(invisible()) } ############################################## # 5 sets ############################################## rect(-20, -30, 430, 430) elps <- cbind(150*cos(seq(0,2*pi,len=1000)), 60*sin(seq(0,2*pi,len=1000))) polygon(relocate_elp(elps, 90,200, 250),border=circle.col[1],lwd=lwd) polygon(relocate_elp(elps, 162,250, 220),border=circle.col[1],lwd=lwd) polygon(relocate_elp(elps, 234,250, 150),border=circle.col[1],lwd=lwd) polygon(relocate_elp(elps, 306,180, 125),border=circle.col[1],lwd=lwd) polygon(relocate_elp(elps, 378,145, 200),border=circle.col[1],lwd=lwd) text( 50, 285, names[1],cex=cex[1]) text(200, 415, names[2],cex=cex[1]) text(350, 305, names[3],cex=cex[1]) text(350, 20, names[4],cex=cex[1]) text(100, -10, names[5],cex=cex[1]) text( 61, 231, z["10000"], cex=cex[2], col=counts.col[1]) text(194, 332, z["01000"], cex=cex[2], col=counts.col[1]) text(321, 248, z["00100"], cex=cex[2], col=counts.col[1]) text(290, 84, z["00010"], cex=cex[2], col=counts.col[1]) text(132, 72, z["00001"], cex=cex[2], col=counts.col[1]) text(146, 253, z["11000"], cex=cex[3], col=counts.col[1]) text(123, 191, z["10100"], cex=cex[3], col=counts.col[1]) text(275, 155, z["10010"], cex=cex[3], col=counts.col[1]) text(137, 149, z["10001"], cex=cex[3], col=counts.col[1]) text(243, 271, z["01100"], cex=cex[3], col=counts.col[1]) text(175, 270, z["01010"], cex=cex[3], col=counts.col[1]) text(187, 120, z["01001"], cex=cex[3], col=counts.col[1]) text(286, 193, z["00110"], cex=cex[3], col=counts.col[1]) text(267, 238, z["00101"], cex=cex[3], col=counts.col[1]) text(228, 108, z["00011"], cex=cex[3], col=counts.col[1]) text(148, 213, z["11100"], cex=cex[3], col=counts.col[1]) text(159, 255, z["11010"], cex=cex[3], col=counts.col[1]) text(171, 144, z["11001"], cex=cex[3], col=counts.col[1]) text(281, 178, z["10110"], cex=cex[3], col=counts.col[1]) text(143, 166, z["10101"], cex=cex[3], col=counts.col[1]) text(252, 148, z["10011"], cex=cex[3], col=counts.col[1]) text(205, 258, z["01110"], cex=cex[3], col=counts.col[1]) text(254, 248, z["01101"], cex=cex[3], col=counts.col[1]) text(211, 121, z["01011"], cex=cex[3], col=counts.col[1]) text(267, 214, z["00111"], cex=cex[3], col=counts.col[1]) text(170, 234, z["11110"], cex=cex[3], col=counts.col[1]) text(158, 172, z["11101"], cex=cex[3], col=counts.col[1]) text(212, 142, z["11011"], cex=cex[3], col=counts.col[1]) text(263, 183, z["10111"], cex=cex[3], col=counts.col[1]) text(239, 235, z["01111"], cex=cex[3], col=counts.col[1]) text(204, 193, z["11111"], cex=cex[2], col=counts.col[1]) text(400, 7, z["00000"], cex=cex[1], col=counts.col[1]) if(length(include)==2) { text( 61, 220, z2["10000"], cex=cex[2], col=counts.col[2]) text(194, 321, z2["01000"], cex=cex[2], col=counts.col[2]) text(321, 237, z2["00100"], cex=cex[2], col=counts.col[2]) text(290, 73, z2["00010"], cex=cex[2], col=counts.col[2]) text(132, 61, z2["00001"], cex=cex[2], col=counts.col[2]) text(146, 244, z2["11000"], cex=cex[3], col=counts.col[2]) text(123, 180, z2["10100"], cex=cex[3], col=counts.col[2]) text(275, 144, z2["10010"], cex=cex[3], col=counts.col[2]) text(137, 143, z2["10001"], cex=cex[3], col=counts.col[2]) text(243, 260, z2["01100"], cex=cex[3], col=counts.col[2]) text(175, 259, z2["01010"], cex=cex[3], col=counts.col[2]) text(187, 110, z2["01001"], cex=cex[3], col=counts.col[2]) text(286, 186, z2["00110"], cex=cex[3], col=counts.col[2]) text(267, 230, z2["00101"], cex=cex[3], col=counts.col[2]) text(228, 97, z2["00011"], cex=cex[3], col=counts.col[2]) text(148, 203, z2["11100"], cex=cex[3], col=counts.col[2]) text(159, 249, z2["11010"], cex=cex[3], col=counts.col[2]) text(171, 137, z2["11001"], cex=cex[3], col=counts.col[2]) text(281, 171, z2["10110"], cex=cex[3], col=counts.col[2]) text(143, 155, z2["10101"], cex=cex[3], col=counts.col[2]) text(252, 137, z2["10011"], cex=cex[3], col=counts.col[2]) text(205, 247, z2["01110"], cex=cex[3], col=counts.col[2]) text(254, 242, z2["01101"], cex=cex[3], col=counts.col[2]) text(211, 112, z2["01011"], cex=cex[3], col=counts.col[2]) text(267, 207, z2["00111"], cex=cex[3], col=counts.col[2]) text(170, 223, z2["11110"], cex=cex[3], col=counts.col[2]) text(158, 162, z2["11101"], cex=cex[3], col=counts.col[2]) text(212, 133, z2["11011"], cex=cex[3], col=counts.col[2]) text(263, 172, z2["10111"], cex=cex[3], col=counts.col[2]) text(239, 228, z2["01111"], cex=cex[3], col=counts.col[2]) text(204, 182, z2["11111"], cex=cex[2], col=counts.col[2]) text(400, -10, z2["00000"], cex=cex[1], col=counts.col[2]) if(show.include) { text(10, 7,include[1], cex=cex[1], col=counts.col[1]) text(10,-10,include[2], cex=cex[1], col=counts.col[2]) } } invisible() } limma/R/removeBatchEffect.R0000644007451300017500000000165712127125240015715 0ustar charlescharles# removeBatchEffect.R # A refinement would be to empirical Bayes shrink # the batch effects before subtracting them. removeBatchEffect <- function(x,batch=NULL,batch2=NULL,covariates=NULL,design=matrix(1,ncol(x),1)) # Remove batch effects from matrix of expression data # Gordon Smyth and Carolyn de Graaf # Created 1 Aug 2008. Last revised 4 Feb 2012. { x <- as.matrix(x) if(is.null(batch) && is.null(batch2) && is.null(covariates)) return(x) if(!is.null(batch)) { batch <- as.factor(batch) contrasts(batch) <- contr.sum(levels(batch)) batch <- model.matrix(~batch)[,-1,drop=FALSE] } if(!is.null(batch2)) { batch2 <- as.factor(batch2) contrasts(batch2) <- contr.sum(levels(batch2)) batch2 <- model.matrix(~batch2)[,-1,drop=FALSE] } if(!is.null(covariates)) covariates <- as.matrix(covariates) X <- cbind(batch,batch2,covariates) X <- qr.resid(qr(design),X) t(qr.resid(qr(X),t(x))) } limma/R/read-maimages.R0000644007451300017500000003337312127125240015035 0ustar charlescharles# READ IMAGE ANALYSIS FILES INTO RGList or EListRaw read.maimages <- function(files=NULL,source="generic",path=NULL,ext=NULL,names=NULL,columns=NULL,other.columns=NULL,annotation=NULL,green.only=FALSE,wt.fun=NULL,verbose=TRUE,sep="\t",quote=NULL,...) # Extracts an RG list from a set of two-color image analysis output files # or an EListRaw from a set of one-color files # Gordon Smyth. # 1 Nov 2002. Last revised 9 March 2012. { # Begin checking input arguments if(is.null(files)) { if(is.null(ext)) stop("Must specify input files") else { extregex <- paste("\\.",ext,"$",sep="") files <- dir(path=ifelse(is.null(path),".",path),pattern=extregex) files <- sub(extregex,"",files) } } source <- match.arg(source,c("generic","agilent","agilent.mean","agilent.median","arrayvision","arrayvision.ARM","arrayvision.MTM","bluefuse","genepix","genepix.mean","genepix.median","genepix.custom","imagene","imagene9","quantarray","scanarrayexpress","smd.old","smd","spot","spot.close.open")) # source2 is the source type with qualifications removed source2 <- strsplit(source,split=".",fixed=TRUE)[[1]][1] if(is.null(quote)) if(source=="agilent") quote <- "" else quote <- "\"" if(source2=="imagene") return(read.imagene(files=files,path=path,ext=ext,names=names,columns=columns,other.columns=other.columns,wt.fun=wt.fun,verbose=verbose,sep=sep,quote=quote,...)) if(is.data.frame(files)) { targets <- files files <- files$FileName if(is.null(files)) stop("targets frame doesn't contain FileName column") if(is.null(names)) names <- targets$Label } else { targets <- NULL } slides <- as.vector(as.character(files)) if(!is.null(ext)) slides <- paste(slides,ext,sep=".") nslides <- length(slides) if(is.null(names)) names <- removeExt(files) if(is.null(columns)) { if(source2=="generic") stop("must specify columns for generic input") columns <- switch(source, agilent.mean = list(G="gMeanSignal",Gb="gBGMedianSignal",R="rMeanSignal",Rb="rBGMedianSignal"), agilent =, agilent.median = list(G="gMedianSignal",Gb="gBGMedianSignal",R="rMedianSignal",Rb="rBGMedianSignal"), arrayvision=, arrayvision.ARM = list(G="ARM Dens - Levels",Gb="Bkgd",R="ARM Dens - Levels",Rb="Bkgd"), arrayvision.MTM = list(G="MTM Dens - Levels",Gb="Bkgd",R="MTM Dens - Levels",Rb="Bkgd"), bluefuse = list(G="AMPCH1",R="AMPCH2"), genepix =, genepix.mean= list(R="F635 Mean",G="F532 Mean",Rb="B635 Median",Gb="B532 Median"), genepix.median = list(R="F635 Median",G="F532 Median",Rb="B635 Median",Gb="B532 Median"), genepix.custom = list(R="F635 Mean",G="F532 Mean",Rb="B635",Gb="B532"), quantarray = list(R="ch2 Intensity",G="ch1 Intensity",Rb="ch2 Background",Gb="ch1 Background"), imagene9 = list(R="Signal Mean 2",G="Signal Mean 1",Rb="Background Median 2",Gb="Background Median 1"), scanarrayexpress = list(G="Ch1 Mean",Gb="Ch1 B Median",R="Ch2 Mean",Rb="Ch2 B Median"), smd.old = list(G="CH1I_MEAN",Gb="CH1B_MEDIAN",R="CH2I_MEAN",Rb="CH2B_MEDIAN"), smd = list(G="Ch1 Intensity (Mean)",Gb="Ch1 Background (Median)",R="Ch2 Intensity (Mean)",Rb="Ch2 Background (Median)"), spot = list(R="Rmean",G="Gmean",Rb="morphR",Gb="morphG"), spot.close.open = list(R="Rmean",G="Gmean",Rb="morphR.close.open",Gb="morphG.close.open"), NULL ) if(green.only) { columns$R <- columns$Rb <- NULL nRG <- 1 E <- FALSE } else { nRG <- 2 E <- FALSE } cnames <- names(columns) } else { columns <- as.list(columns) # if(!is.list(columns)) stop("columns must be a list") cnames <- names(columns) if(is.null(cnames)) { if(length(columns)==1) { # Single channel with no background names(columns) <- "E" E <- TRUE nRG <- 0 } else { stop("columns needs to be a named list") } } else { names(columns)[cnames=="Gf"] <- "G" names(columns)[cnames=="Rf"] <- "R" cnames <- names(columns) nRG <- sum(c("R","G") %in% cnames) E <- ("E" %in% cnames) if(E && nRG>0) stop("columns can be R,G for two color data, or E for single channel, but not both") if(!E && nRG==0) stop("columns must specify foreground G or R or E") if(!all(cnames %in% c("G","R","Gb","Rb","E","Eb"))) warning("non-standard columns specified") } } if(is.null(annotation)) annotation <- switch(source2, agilent = c("Row","Col","Start","Sequence","SwissProt","GenBank","Primate","GenPept","ProbeUID","ControlType","ProbeName","GeneName","SystematicName","Description"), arrayvision = c("Spot labels","ID"), bluefuse = c("ROW","COL","SUBGRIDROW","SUBGRIDCOL","BLOCK","NAME","ID"), genepix = c("Block","Row","Column","ID","Name"), imagene9 = c("Meta Row","Meta Column","Row","Column","Gene ID"), quantarray= c("Array Row","Array Column","Row","Column","Name"), scanarrayexpress = c("Array Row","Array Column","Spot Row","Spot Column"), smd = c("Spot","Clone ID","Gene Symbol","Gene Name","Cluster ID","Accession","Preferred name","Locuslink ID","Name","Sequence Type","X Grid Coordinate (within sector)","Y Grid Coordinate (within sector)","Sector","Failed","Plate Number","Plate Row","Plate Column","Clone Source","Is Verified","Is Contaminated","Luid"), NULL ) if(source=="smd.old") annotation <- c("SPOT","NAME","Clone ID","Gene Symbol","Gene Name","Cluster ID","Accession","Preferred name","SUID") # End checking input arguments # Read first file to get nspots fullname <- slides[1] if(!is.null(path)) fullname <- file.path(path,fullname) required.col <- unique(c(annotation,unlist(columns),other.columns)) text.to.search <- if(is.null(wt.fun)) "" else deparse(wt.fun) switch(source2, quantarray = { firstfield <- scan(fullname,what="",sep="\t",flush=TRUE,quiet=TRUE,blank.lines.skip=FALSE,multi.line=FALSE,allowEscapes=FALSE) skip <- grep("Begin Data",firstfield) if(length(skip)==0) stop("Cannot find \"Begin Data\" in image output file") nspots <- grep("End Data",firstfield) - skip -2 obj <- read.columns(fullname,required.col,text.to.search,skip=skip,sep=sep,quote=quote,stringsAsFactors=FALSE,fill=TRUE,nrows=nspots,flush=TRUE,...) }, arrayvision = { skip <- 1 cn <- scan(fullname,what="",sep=sep,quote=quote,skip=1,nlines=1,quiet=TRUE,allowEscapes=FALSE) fg <- grep(" Dens - ",cn) if(length(fg) != 2) stop(paste("Cannot find foreground columns in",fullname)) bg <- grep("^Bkgd$",cn) if(length(bg) != 2) stop(paste("Cannot find background columns in",fullname)) # Note that entries for columns for ArrayVision are now numeric columns <- list(R=fg[1],Rb=bg[1],G=fg[2],Gb=bg[2]) obj <- read.columns(fullname,required.col,text.to.search,skip=skip,sep=sep,quote=quote,stringsAsFactors=FALSE,fill=TRUE,flush=TRUE,...) # obj <- read.table(fullname,skip=skip,header=TRUE,sep=sep,quote=quote,stringsAsFactors=FALSE,check.names=FALSE,fill=TRUE,comment.char="",flush=TRUE,...) fg <- grep(" Dens - ",names(obj)) bg <- grep("^Bkgd$",names(obj)) columns <- list(R=fg[1],Rb=bg[1],G=fg[2],Gb=bg[2]) nspots <- nrow(obj) }, bluefuse = { skip <- readGenericHeader(fullname,columns=c(columns$G,columns$R))$NHeaderRecords obj <- read.columns(fullname,required.col,text.to.search,skip=skip,sep=sep,quote=quote,stringsAsFactors=FALSE,fill=TRUE,flush=TRUE,...) nspots <- nrow(obj) }, genepix = { h <- readGPRHeader(fullname) if(verbose && source=="genepix.custom") cat("Custom background:",h$Background,"\n") skip <- h$NHeaderRecords obj <- read.columns(fullname,required.col,text.to.search,skip=skip,sep=sep,quote=quote,stringsAsFactors=FALSE,fill=TRUE,flush=TRUE,...) nspots <- nrow(obj) }, imagene9 = { h <- readImaGeneHeader(fullname) skip <- h$NHeaderRecords FD <- h$"Field Dimensions" if(is.null(FD)) stop("Can't find Field Dimensions in ImaGene header") nspots <- sum(apply(FD,1,prod)) obj <- read.columns(fullname,required.col,text.to.search,skip=skip,sep=sep,quote=quote,stringsAsFactors=FALSE,fill=TRUE,flush=TRUE,nrows=nspots,...) }, smd = { skip <- readSMDHeader(fullname)$NHeaderRecords obj <- read.columns(fullname,required.col,text.to.search,skip=skip,sep=sep,quote=quote,stringsAsFactors=FALSE,fill=TRUE,flush=TRUE,...) nspots <- nrow(obj) }, { skip <- readGenericHeader(fullname,columns=columns,sep=sep)$NHeaderRecords obj <- read.columns(fullname,required.col,text.to.search,skip=skip,sep=sep,quote=quote,stringsAsFactors=FALSE,fill=TRUE,flush=TRUE,...) nspots <- nrow(obj) }) # Initialize RG list object (object.size for matrix of NAs is smaller) Y <- matrix(NA,nspots,nslides) colnames(Y) <- names RG <- columns for (a in cnames) RG[[a]] <- Y if(!is.null(wt.fun)) RG$weights <- Y if(is.data.frame(targets)) { RG$targets <- targets } else { RG$targets <- data.frame(FileName=files,row.names=names,stringsAsFactors=FALSE) } # Set annotation columns if(!is.null(annotation)) { j <- match(annotation,colnames(obj),0) if(any(j>0)) RG$genes <- data.frame(obj[,j,drop=FALSE],check.names=FALSE) } RG$source <- source # Set printer layout, if possible if(source2=="agilent") { if(!is.null(RG$genes$Row) && !is.null(RG$genes$Col)) { nr <- length(unique(RG$genes$Row)) nc <- length(unique(RG$genes$Col)) if(nspots==nr*nc) RG$printer <- list(ngrid.r=1,ngrid.c=1,nspot.r=nr,nspot.c=nc) } } if(source2=="genepix") { if(!is.null(RG$genes$Block) && !is.null(RG$genes$Row) && !is.null(RG$genes$Column)) { RG$printer <- getLayout(RG$genes,guessdups=FALSE) nblocks <- RG$printer$ngrid.r*RG$printer$ngrid.c if(!is.na(nblocks) && (nblocks>1) && !is.null(obj$X)) { blocksize <- RG$printer$nspot.r*RG$printer$nspot.c i <- (1:(nblocks-1))*blocksize ngrid.r <- sum(obj$X[i] > obj$X[i+1]) + 1 if(!is.na(ngrid.r) && nblocks%%ngrid.r==0) { RG$printer$ngrid.r <- ngrid.r RG$printer$ngrid.c <- nblocks/ngrid.r } else { warning("Can't determine number of grid rows") RG$printer$ngrid.r <- RG$printer$ngrid.c <- NA } } } } if(source2=="imagene9") { printer <- list(ngrid.r=FD[1,"Metarows"],ngrid.c=FD[1,"Metacols"],nspot.r=FD[1,"Rows"],nspot.c=FD[1,"Cols"]) if(nrow(FD)==1) { RG$printer <- printer } else { printer$ngrid.r <- sum(FD[,"Metarows"]) if(all(printer$ngrid.c==FD[,"Metacols"]) && all(printer$nspot.r==FD[,"Rows"]) && all(printer$nspot.c==FD[,"Cols"]) ) RG$printer <- printer } } # Other columns if(!is.null(other.columns)) { other.columns <- as.character(other.columns) j <- match(other.columns,colnames(obj),0) if(any(j>0)) { other.columns <- colnames(obj)[j] RG$other <- list() for (j in other.columns) RG$other[[j]] <- Y } else { other.columns <- NULL } } # Read remainder of files for (i in 1:nslides) { if(i > 1) { fullname <- slides[i] if(!is.null(path)) fullname <- file.path(path,fullname) switch(source2, quantarray = { firstfield <- scan(fullname,what="",sep="\t",flush=TRUE,quiet=TRUE,blank.lines.skip=FALSE,multi.line=FALSE,allowEscapes=FALSE) skip <- grep("Begin Data", firstfield) }, arrayvision = { skip <- 1 }, genepix = { skip <- readGPRHeader(fullname)$NHeaderRecords }, smd = { skip <- readSMDHeader(fullname)$NHeaderRecords }, { skip <- readGenericHeader(fullname,columns=columns)$NHeaderRecords }) if(verbose && source=="genepix.custom") cat("Custom background:",h$Background,"\n") obj <- read.columns(fullname,required.col,text.to.search,skip=skip,sep=sep,stringsAsFactors=FALSE,quote=quote,fill=TRUE,nrows=nspots,flush=TRUE,...) } for (a in cnames) RG[[a]][,i] <- obj[,columns[[a]]] if(!is.null(wt.fun)) RG$weights[,i] <- wt.fun(obj) if(!is.null(other.columns)) for (j in other.columns) { RG$other[[j]][,i] <- obj[,j] } if(verbose) cat(paste("Read",fullname,"\n")) } if(nRG==1) { n <- names(RG) n[n=="G"] <- "E" n[n=="Gb"] <- "Eb" n[n=="R"] <- "E" n[n=="Rb"] <- "Eb" names(RG) <- n } if(E || nRG==1) new("EListRaw",RG) else new("RGList",RG) } read.columns <- function(file,required.col=NULL,text.to.search="",sep="\t",quote="\"",skip=0,fill=TRUE,blank.lines.skip=TRUE,comment.char="",allowEscapes=FALSE,...) # Read specified columns from a delimited text file with header line # Gordon Smyth # 3 Feb 2007. Last modified 5 Jan 2011. { # Default is to read all columns if(is.null(required.col)) return(read.table(file=file,header=TRUE,check.names=FALSE,sep=sep,quote=quote,skip=skip,fill=fill,blank.lines.skip=blank.lines.skip,comment.char=comment.char,allowEscapes=allowEscapes,...)) text.to.search <- as.character(text.to.search) # Read header to get column names allcnames <- scan(file,what="",sep=sep,quote=quote,nlines=1,quiet=TRUE,skip=skip,strip.white=TRUE,blank.lines.skip=blank.lines.skip,comment.char=comment.char,allowEscapes=allowEscapes) ncn <- length(allcnames) colClasses <- rep("NULL",ncn) # Are required columns in the header? if(is.numeric(required.col)) { colClasses[required.col] <- NA } else { required.col <- trimWhiteSpace(as.character(required.col)) colClasses[allcnames %in% required.col] <- NA } # Search for column names in text if(any(text.to.search != "")) for (i in 1:ncn) { if(length(grep(protectMetachar(allcnames[i]),text.to.search))) colClasses[i] <- NA } # Is there a leading column of row.names without a header? secondline <- scan(file,what="",sep=sep,quote=quote,nlines=1,quiet=TRUE,skip=skip+1,strip.white=TRUE,blank.lines.skip=blank.lines.skip,comment.char=comment.char,allowEscapes=allowEscapes) if(length(secondline) > ncn) colClasses <- c(NA,colClasses) # Read specified columns read.table(file=file,header=TRUE,col.names=allcnames,check.names=FALSE,colClasses=colClasses,sep=sep,quote=quote,skip=skip,fill=fill,blank.lines.skip=blank.lines.skip,comment.char=comment.char,allowEscapes=allowEscapes,...) } limma/R/plots-fit.R0000755007451300017500000001646012127125240014263 0ustar charlescharles# PRESENTATION PLOTS FROM FITTED MODEL OBJECTS volcanoplot <- function(fit,coef=1,highlight=0,names=fit$genes$ID,xlab="Log Fold Change",ylab="Log Odds",pch=16,cex=0.35, ...) # Volcano plot of log-fold-change and B-statistic # Gordon Smyth # 27 Oct 2006. Last modified 26 Sep 2007. { if(!is(fit,"MArrayLM")) stop("fit must be an MArrayLM") if(is.null(fit$lods)) stop("No B-statistics found, perhaps eBayes() not yet run") x <- as.matrix(fit$coef)[,coef] y <- as.matrix(fit$lods)[,coef] plot(x,y,xlab=xlab,ylab=ylab,pch=pch,cex=cex,...) if(highlight>0) { if(is.null(names)) names <- 1:length(x) names <- as.character(names) o <- order(y,decreasing=TRUE) i <- o[1:highlight] text(x[i],y[i],labels=substring(names[i],1,8),cex=0.8,col="blue") } invisible() } heatDiagram <- function(results,coef,primary=1,names=NULL,treatments=colnames(coef),limit=NULL,orientation="landscape",low="green",high="red",cex=1,mar=NULL,ncolors=123,...) { # Heat diagram to display fold changes of genes under different conditions # Gordon Smyth # 27 Oct 2002. Last revised 11 Oct 2004. # Check input results <- as.matrix(results) results[is.na(results)] <- 0 coef <- as.matrix(coef) if(!identical(dim(results),dim(coef))) stop("results and coef must be the same size") nt <- ncol(results) if(is.null(names)) names <- as.character(1:nrow(coef)) names <- substring(names,1,15) if(is.null(treatments)) treatments <- as.character(1:nt) orientation <- match.arg(orientation,c("landscape","portrait")) # Sort coefficients DE <- (abs(results[,primary]) > 0.5) ng <- sum(DE) if(ng == 0) { warning("Nothing significant to plot") return(invisible()) } results <- results[DE,,drop=FALSE] coef <- coef[DE,,drop=FALSE] coef[abs(results) < 0.5] <- NA names <- names[DE] ord <- order(coef[,primary],decreasing=TRUE) # Truncate coefficients if limit is preset if(!is.null(limit)) if(limit > 0) { coef[coef < -limit] <- -limit coef[coef > limit] <- limit } else warning("limit ignored because not positive") # Check colours if(is.character(low)) low <- col2rgb(low)/255 if(is.character(high)) high <- col2rgb(high)/255 r <- range(coef,na.rm=TRUE) r <- r/max(abs(r)) low2 <- low + (high-low)*(1+r[1])/2 high2 <- high + (low-high)*(1-r[2])/2 col <- rgb( seq(low2[1],high2[1],len=ncolors), seq(low2[2],high2[2],len=ncolors), seq(low2[3],high2[3],len=ncolors) ) # Output dataframe coef <- coef[ord,,drop=FALSE] names <- names[ord] out <- coef rownames(out) <- names # Insert white space between up and down nup <- sum(coef[,primary]>=0) if(nup>0 && nup critical.primary) if(any(is.na(DE))) DE[is.na(DE)] <- FALSE ng <- sum(DE) if(sum(DE) == 0) { warning("Nothing significant to plot") return(invisible()) } stat <- stat[DE,,drop=FALSE] coef <- coef[DE,,drop=FALSE] if(!is.null(names)) names <- names[DE] if(critical.other > critical.primary) warning("critical.other greater than critical.primary") otherDE <- (stat > critical.other) otherDE[,primary] <- TRUE coef[!otherDE] <- NA ord <- order(coef[,primary],decreasing=TRUE) # Check colours if(is.character(low)) low <- col2rgb(low)/255 if(is.character(high)) high <- col2rgb(high)/255 col <- rgb( seq(low[1],high[1],len=ncolors), seq(low[2],high[2],len=ncolors), seq(low[3],high[3],len=ncolors) ) # Truncate coefficients if limit is preset if(!is.null(limit)) if(limit > 0) { coef[coef < -limit] <- -limit coef[coef > limit] <- limit } else warning("limit ignored because not positive") # Heat plot coef <- coef[ord,,drop=FALSE] names <- names[ord] out <- data.frame(Name=names,coef) if(orientation=="portrait") { coef <- t(coef) coef <- coef[,ng:1,drop=FALSE] } on.exit(par(old.par)) if(orientation=="portrait") { if(is.null(mar)) mar <- cex*c(1,1,4,3) old.par <- par(mar=mar) image(coef,col=col,xaxt="n",yaxt="n",...) cext <- cex*min(1,8/nt) mtext(paste(" ",treatments,sep=""),side=3,las=2,at=(cext-1)*0.005+(0:(nt-1))/(nt-1),cex=cext) cex <- cex*min(1,40/ng) mtext(paste(" ",names,sep=""),side=4,las=2,at=(1-cex)*0.005+((ng-1):0)/(ng-1),cex=cex) } else { if(is.null(mar)) mar <- cex*c(5,6,1,1) old.par <- par(mar=mar) image(coef,col=col,xaxt="n",yaxt="n",...) cext <- cex*min(1,12/nt) mtext(paste(treatments," ",sep=""),side=2,las=1,at=(1-cext)*0.005+(0:(nt-1))/(nt-1),cex=cext) cex <- cex*min(1,60/ng) mtext(paste(names," ",sep=""),side=1,las=2,at=(cex-1)*0.005+(0:(ng-1))/(ng-1),cex=cex) } invisible(out) } plotSA <- function(fit, xlab="Average log-expression", ylab="log2(sigma)", zero.weights=FALSE, pch=16, cex=0.2, ...) # Plot log-residual variance vs intensity # Gordon Smyth 14 Jan 2009. # Last modified 27 October 2010. { if(!is(fit,"MArrayLM")) stop("fit must be a MArrayLM object") x <- fit$Amean y <- log2(fit$sigma) if(!is.null(fit$weights) && !zero.weights) { w <- fit$weights w[is.na(w)] <- 0 w[w<0] <- 0 allzero <- apply(w==0,1,all) y[allzero] <- NA } plot(x,y,xlab=xlab,ylab=ylab,pch=pch,cex=cex,...) lines(lowess(x,y,f=0.4),col="red") if(!is.null(fit$s2.prior)) { if(length(fit$s2.prior)==1) { abline(h=log2(fit$s2.prior)/2,col="blue") } else { o <- order(x) lines(x[o],log2(fit$s2.prior[o])/2,col="blue") legend("topright",legend=c("lowess","prior"),col=c("red","blue"),lty=1) } } invisible() } limma/R/zscoreHyper.R0000644007451300017500000000204712127125240014650 0ustar charlescharleszscoreHyper <- function(q,m,n,k) # Z-score equivalents for deviates from hypergeometric distribution # Gordon Smyth # 12 Aug 2012 { z <- q suppressWarnings(d <- dhyper(q,m,n,k,log=TRUE)-log(2)) suppressWarnings(pupper <- phyper(q,m,n,k,lower.tail=FALSE,log.p=TRUE)) suppressWarnings(plower <- phyper(q-1,m,n,k,lower.tail=TRUE,log.p=TRUE)) d[is.na(d)] <- -Inf pupper[is.na(pupper)] <- -Inf plower[is.na(plower)] <- -Inf # Add half point probability to upper tail probability preserving log-accuracy a <- pupper b <- d-pupper a[b>0] <- d[b>0] b <- -abs(b) pmidupper <- a+log1p(exp(b)) pmidupper[is.infinite(a)] <- a[is.infinite(a)] # Similarly for lower tail probability preserving log-accuracy a <- plower b <- d-plower a[b>0] <- d[b>0] b <- -abs(b) pmidlower <- a+log1p(exp(b)) pmidlower[is.infinite(a)] <- a[is.infinite(a)] up <- pmidupper1 && dw[2]==dim[2]) { weights <- matrix(weights,dim[1],dim[2],byrow=TRUE) attr(weights,"arrayweights") <- TRUE return(weights) } lw <- prod(dw) # Probe weights if(lw==1 || lw==dim[1]) return(matrix(weights,dim[1],dim[2])) # Array weights if(lw==dim[2]) { weights <- matrix(weights,dim[1],dim[2],byrow=TRUE) attr(weights,"arrayweights") <- TRUE return(weights) } # All other cases stop("weights is of unexpected size") } limma/R/fitFDistRobustly.R0000644007451300017500000001473212136342054015623 0ustar charlescharlesfitFDistRobustly <- function(x,df1,covariate=NULL,winsor.tail.p=c(0.05,0.1),trace=FALSE) # Robust estimation of the parameters of a scaled F-distribution, # given the first degrees of freedom, using first and second # moments of Winsorized z-values # Gordon Smyth and Belinda Phipson # 8 Sept 2002. Last revised 25 April 2013. { # Check x n <- length(x) # Eliminate case of no useful data if(n==0) if(is.null(covariate)) return(list(scale=NaN,df2=NaN,df2.robust=NaN)) else return(list(scale=numeric(0),df2=numeric(0),df2.robust=NaN)) # Check df1 if(length(df1)>1) if(length(df1) != n) stop("x and df1 are different lengths") # Check covariate if(!is.null(covariate)) { if(length(covariate) != n) stop("x and covariate are different lengths") if(!all(is.finite(covariate))) stop("covariate contains NA or infinite values") } # Treat zero df1 values as non-informative cases # Similarly for missing values or x or df1 ok <- !is.na(x) & is.finite(df1) & (df1 > 1e-6) notallok <- !all(ok) if(notallok) { scale <- df2.shrunk <- x x <- x[ok] if(length(df1)>1) df1 <- df1[ok] if(!is.null(covariate)) { covariate2 <- covariate[!ok] covariate <- covariate[ok] } fit <- Recall(x=x,df1=df1,covariate=covariate,winsor.tail.p=winsor.tail.p,trace=trace) df2.shrunk[ok] <- fit$df2.shrunk df2.shrunk[!ok] <- fit$df2 scale[ok] <- fit$scale scale[!ok] <- exp(approx(covariate,log(fit$scale),xout=covariate2,rule=2)$y) return(list(scale=scale,df2=fit$df2,df2.shrunk=df2.shrunk)) } # Avoid zero or negative x values m <- median(x) if(m<=0) stop("x values are mostly <= 0") i <- (x < m*1e-12) if(any(i)) { warning("small x values have been offset away from zero") x[i] <- m*1e-12 } # Store non-robust estimates NonRobust <- fitFDist(x=x,df1=df1,covariate=covariate) # Check winsor.tail.p prob <- winsor.tail.p <- rep(winsor.tail.p,length=2) prob[2] <- 1-winsor.tail.p[2] if(all(winsor.tail.p < 1/n)) { NonRobust$df2.shrunk <- rep.int(NonRobust$df2,n) return(NonRobust) } # Transform x to constant df1 if(length(df1)>1) { df1max <- max(df1) i <- (df1 < (df1max - 1e-14)) if(any(i)) { if(is.null(covariate)) s <- NonRobust$scale else s <- NonRobust$scale[i] f <- x[i]/s df2 <- NonRobust$df2 pupper <- pf(f,df1=df1[i],df2=df2,lower.tail=FALSE,log.p=TRUE) plower <- pf(f,df1=df1[i],df2=df2,lower.tail=TRUE,log.p=TRUE) up <- pupper= 0) { df2 <- NonRobust$df2 } else { u <- uniroot(fun,interval=c(rbx,1),tol=1e-8,f.lower=funvalLow,f.upper=funvalInf) df2 <- linkinv(u$root) } # Correct ztrend for bias mom <- winsorizedMoments(df1=df1,df2=df2,winsor.tail.p=winsor.tail.p) ztrendcorrected <- ztrend+zwmean-mom$mean s20 <- exp(ztrendcorrected) # Posterior df for outliers zresid <- z-ztrendcorrected Fstat <- exp(zresid) TailP <- pf(Fstat,df1=df1,df2=df2,lower.tail=FALSE) r <- rank(Fstat) EmpiricalTailProb <- (n-r+0.5)/n ProbNotOutlier <- pmin(TailP/EmpiricalTailProb,1) df2.shrunk <- rep.int(df2,n) if(any(ProbNotOutlier<1)) { ProbOutlier <- 1-ProbNotOutlier VarOutlier <- max(zresid)^2 VarOutlier <- VarOutlier-trigamma(df1/2) if(trace) cat("VarOutlier",VarOutlier,"\n") if(VarOutlier > 0) { df2.outlier <- 2*trigammaInverse(VarOutlier) if(trace) cat("df2.outlier",df2.outlier,"\n") if(df2.outlier < df2) { df2.shrunk <- ProbNotOutlier*df2+ProbOutlier*df2.outlier o <- order(TailP) df2.ordered <- df2.shrunk[o] df2.ordered[1] <- min(df2.ordered[1],NonRobust$df2) m <- cumsum(df2.ordered) m <- m/(1:n) imin <- which.min(m) df2.ordered[1:imin] <- m[imin] df2.shrunk[o] <- cummax(df2.ordered) } } } list(scale=s20,df2=df2,df2.shrunk=df2.shrunk) } limma/R/loessFit.R0000644007451300017500000000472712127125240014132 0ustar charlescharles# LOESS FUNCTIONS loessFit <- function(y, x, weights=NULL, span=0.3, bin=NULL, iterations=4, min.weight=1e-5, max.weight=1e5, equal.weights.as.null=TRUE) # Fast loess fit for simple x and y # This function uses stats:::lowess if no weights and stats:::loess otherwise. # It is intended to give a streamlined common interface to the two functions. # Gordon Smyth # 28 June 2003. Last revised 8 Oct 2012. { n <- length(y) out <- list(fitted=rep(NA,n),residuals=rep(NA,n)) obs <- is.finite(y) & is.finite(x) xobs <- x[obs] yobs <- y[obs] nobs <- length(yobs) if(nobs==0) return(out) if(is.null(weights)) { iter <- iterations-1 if(is.null(bin)) bin <- 0.01 delta = bin * diff(range(xobs)) o <- order(xobs) # The .C("lowess" call is copied from stats:::lowess # lo <- .C("lowess", x = as.double(xobs[o]), as.double(yobs[o]), # nobs, as.double(span), as.integer(iter), as.double(delta), # y = double(nobs), double(nobs), double(nobs), PACKAGE = "stats") # out$fitted[obs][o] <- lo$y # out$residuals[obs][o] <- lo[[9]] # For R 2.16.X lo <- lowess(x=xobs,y=yobs,f=span,iter=iter,delta=delta) out$fitted[obs][o] <- lo$y out$residuals[obs] <- yobs-out$fitted[obs] } else { if(is.null(bin)) bin <- 0.005 wobs <- weights[obs] wobs[is.na(wobs)] <- 0 wobs <- pmax(wobs,min.weight) wobs <- pmin(wobs,max.weight) # Test whether weights are equal if(equal.weights.as.null) { r <- range(wobs) if(r[2]-r[1] < 1e-15) return(Recall(y,x,span=span,bin=bin,iterations=iterations)) } # Count number of observations with positive weights if(min.weight>0) nwobs <- nobs else nwobs <- sum(wobs>0) if(nwobs < 4+1/span) { if(nwobs>1) { fit <- lm.wfit(cbind(1,xobs),yobs,wobs) } else { fit <- list() fit$fitted <- rep(sum(wobs*yobs)/sum(wobs),nobs) fit$residuals <- yobs-fit$fitted } } else { # Suppress warning "k-d tree limited by memory" # oldopt <- options(warning.expression=expression()) oldopt <- options(warn=-1) on.exit(options(oldopt)) # fit <- .vsimpleLoess(y=yobs, x=xobs, weights=wobs, span=span, degree=1, cell=bin/span, iterations=iterations) # For R 2.16.X fit <- stats:::simpleLoess(y=yobs,x=xobs,weights=wobs,span=span,degree=1,parametric=FALSE,normalize=FALSE,statistics="none",surface="interpolate",cell=bin/span,iterations=iterations,trace.hat="approximate") } out$fitted[obs] <- fit$fitted out$residuals[obs] <- fit$residuals } out } limma/R/genas.R0000644007451300017500000001512012127125240013424 0ustar charlescharles## GENAS.R genas <- function(fit,coef=c(1,2),chooseMethod=NULL,plot=FALSE,alpha=0.4) # Genuine association of gene expression profiles # Belinda Phipson and Gordon Smyth # 21 September 2009. Last modified 2 December 2012. { if(ncol(fit)>2) fit<-fit[,coef] if(length(fit$s2.prior)==1) trend<-FALSE else trend<-TRUE fit <- eBayes(fit,trend=trend) if(is.null(chooseMethod)) chooseMethod <- "n" x1<-fitGammaIntercept(fit$coeff[,1]^2/fit$s2.post,offset=fit$cov.coeff[1,1]) x2<-fitGammaIntercept(fit$coeff[,2]^2/fit$s2.post,offset=fit$cov.coeff[2,2]) if(x1 > 0 & x2 > 0){ v0null<-matrix(c(x1,0,0,x2),2,2) C<-chol(v0null) x<-log(diag(C)) } else x<-c(0,0) m<-2 fit.plot <- fit fit <- .whichGenes(fit,chooseMethod) fit <- eBayes(fit,trend=trend) Q2 <- optim(x, .multTLogLikNull, fit = fit, m = m) Q1 <- optim(c(Q2$par[1], Q2$par[2], 0),.multTLogLik,fit=fit,m=m) L<-matrix(c(1,Q1$par[3],0,1),2,2) D<-matrix(c(exp(Q1$par[1]),0,0,exp(Q1$par[2])),2,2) V0<-L%*%D%*%t(L) rhobiol<-V0[2,1]/sqrt(V0[1,1]*V0[2,2]) V<-fit$cov.coefficients rhotech<-V[2,1]/sqrt(V[1,1]*V[2,2]) if(plot){ require(ellipse) lim<-mean(c(sd(fit.plot$coeff[,1]),sd(fit.plot$coeff[,2]))) if(nrow(fit)<500) lim <- 1.5*lim else lim <- 2*lim max<-max(c(fit.plot$coeff[,1],fit.plot$coeff[,2])) min<-min(c(fit.plot$coeff[,1],fit.plot$coeff[,2])) max<-sign(max)*max(abs(min),abs(max)) min<-sign(min)*max(abs(min),abs(max)) if(abs(rhobiol)>abs(rhotech)){ plot(fit.plot$coeff[,1],fit.plot$coeff[,2],pch=16,cex=0.4,ylim=c(min,max),xlim=c(min,max),xlab=colnames(fit.plot$coeff)[1],ylab=colnames(fit.plot$coeff)[2]) polygon(ellipse(rhotech,scale=c(lim,lim)),col=rgb(0,0,1,alpha=alpha),border=rgb(0,0,1,alpha=alpha)) polygon(ellipse(rhobiol,scale=c(lim,lim)),col=rgb(0,1,0,alpha=alpha),border=rgb(0,1,0,alpha=alpha)) points(fit.plot$coeff[,1],fit.plot$coeff[,2],pch=16,cex=0.4) abline(h=0,v=0) legend(min,max,legend=bquote(rho[biol]==.(round(rhobiol,3))),col=rgb(0,1,0,alpha=alpha),pch=16,bty="n",cex=0.8) legend(min,max-lim/2,legend=bquote(rho[tech]==.(round(rhotech,3))),col=rgb(0,0,1,alpha=alpha),pch=16,bty="n",cex=0.8) } else{ plot(fit.plot$coeff[,1],fit.plot$coeff[,2],pch=16,cex=0.4,ylim=c(min,max),xlim=c(min,max),xlab=colnames(fit.plot$coeff)[1],ylab=colnames(fit.plot$coeff)[2]) polygon(ellipse(rhobiol,scale=c(lim,lim)),col=rgb(0,1,0,alpha=alpha),border=rgb(0,1,0,alpha=alpha)) polygon(ellipse(rhotech,scale=c(lim,lim)),col=rgb(0,0,1,alpha=alpha),border=rgb(0,0,1,alpha=alpha)) points(fit.plot$coeff[,1],fit.plot$coeff[,2],pch=16,cex=0.4) abline(h=0,v=0) legend(min,max,legend=bquote(rho[biol]==.(round(rhobiol,3))),col=rgb(0,1,0,alpha=alpha),pch=16,bty="n",cex=0.8) legend(min,max-lim/2,legend=bquote(rho[tech]==.(round(rhotech,3))),col=rgb(0,0,1,alpha=alpha),pch=16,bty="n",cex=0.8) } } D<-abs(2*(Q2$value-Q1$value)) p.val<-pchisq(D,df=1,lower.tail=FALSE) list(technical.correlation=rhotech,covariance.matrix=V0,biological.correlation=rhobiol,deviance=D,p.value=p.val,n=nrow(fit)) } .multTLogLikNull <- function(x,fit,m) # Calculate the log-likelihood under the null hypothesis of no biological correlation # Belinda Phipson and Gordon Smyth # 21 September 2009. Last modified 21 September 2009. { d0<-fit$df.prior d<-fit$df.residual if(d0==Inf) d0 <- 999*d[1] s<-fit$s2.post B<-fit$coefficients m<-m V<-fit$cov.coefficients a1<-x[1] a2<-x[2] chol<-matrix(c(exp(a1),0,0,exp(a2)),2,2) V0<-t(chol) %*% chol R<-chol(V0+V) Second<-sum(log(diag(R))) W<-backsolve(R,t(B),transpose=TRUE) Q <- colSums(W^2) Third<-0.5*(m+d0+d)*log(1+Q/(s*(d0+d))) sum(Second+Third) } .multTLogLik <- function(x,fit,m) # Calculate the log-likelihood with biological correlation # Belinda Phipson and Gordon Smyth # 21 September 2009. Last modified 21 September 2009. { d0<-fit$df.prior d<-fit$df.residual if(d0==Inf) d0 <- 999*d[1] s<-fit$s2.post B<-fit$coefficients m<-m V<-fit$cov.coefficients a1<-x[1] a2<-x[2] b<-x[3] L<-matrix(c(1,b,0,1),2,2) D<-matrix(c(exp(a1),0,0,exp(a2)),2,2) V0<-L %*% D %*% t(L) R<-chol(V0+V) Second<-sum(log(diag(R))) W<-backsolve(R,t(B),transpose=TRUE) Q<-colSums(W^2) Third<-0.5*(m+d0+d)*log(1+Q/(s*(d0+d))) sum(Second+Third) } .whichGenes <- function(fit,chooseMethod){ if(chooseMethod=="Fpval"){ p <- 1-propTrueNull(fit$F.p.value) R <- rank(fit$F.p.value) cut <- p*nrow(fit) genes <- R <= cut if(sum(genes)==0){ # message("There is no evidence of differential expression. LogFC cut-off used instead.") chooseMethod<-"logFC" } else { if(sum(genes)<500) message("Less than 500 DE genes. Correlation estimate may be inaccurate.") } } if(chooseMethod=="p.union"){ p1 <- 1-propTrueNull(fit$p.value[,1]) p2 <- 1-propTrueNull(fit$p.value[,2]) cut1 <- p1*nrow(fit) cut2 <- p2*nrow(fit) if(p1==0 & p2==0){ # message("There is no evidence of differential expression. LogFC cut-off used instead.") chooseMethod<-"logFC" } else { if(cut1+cut2 < 500) message("Less than 500 DE genes. Correlation estimate may be inaccurate.") R1 <- rank(fit$p.value[,1]) R2 <- rank(fit$p.value[,2]) genes <- R1 <= cut1 | R2 <= cut2 } } if(chooseMethod=="p.int"){ p1 <- 1-propTrueNull(fit$p.value[,1]) p2 <- 1-propTrueNull(fit$p.value[,2]) R1 <- rank(fit$p.value[,1]) R2 <- rank(fit$p.value[,2]) cut1 <- p1*nrow(fit) cut2 <- p2*nrow(fit) genes <- R1 <= cut1 & R2 <= cut2 if(sum(genes)==0){ # message("There is no evidence of differential expression. LogFC cut-off used instead.") chooseMethod<-"logFC" } else { if(sum(genes)<500) message("Less than 500 DE genes. Correlation estimate may be inaccurate.") } } if(chooseMethod=="logFC"){ q1 <- quantile(abs(fit$coeff[,1]),probs=0.9) q2 <- quantile(abs(fit$coeff[,2]),probs=0.9) genes <- abs(fit$coeff[,1]) > q1 | abs(fit$coeff[,2]) > q2 fit$coeff[,1] <- sign(fit$coeff[,1]) * (abs(fit$coeff[,1])-q1) fit$coeff[,2] <- sign(fit$coeff[,2]) * (abs(fit$coeff[,2])-q2) } if(chooseMethod=="predFC"){ pfc1 <- predFCm(fit, coef=1) pfc2 <- predFCm(fit, coef=2) q1 <- quantile(abs(pfc1),probs=0.9) q2 <- quantile(abs(pfc2),probs=0.9) genes <- abs(pfc1) > q1 | abs(pfc2) > q2 fit$coeff[,1] <- pfc1 fit$coeff[,2] <- pfc2 fit$coeff[,1] <- sign(fit$coeff[,1]) * (abs(fit$coeff[,1])-q1) fit$coeff[,2] <- sign(fit$coeff[,2]) * (abs(fit$coeff[,2])-q2) } if(chooseMethod=="n") genes <- c(rep(TRUE,nrow(fit))) if(length(fit$df.prior)!=1) fit$df.prior <- fit$df.prior[genes] fit[genes,] } limma/R/mergeScans.R0000644007451300017500000001637312127125240014431 0ustar charlescharles# limma package /R/mergeScans.R # Functions in this file contributed by "Dongseok Choi" # Slight modifications for limma version by Gordon Smyth 10 Jan 2007 #-----------------------------------------------------------------------------------------required for mergeScans .hockey <- function(x,alpha1,beta1,beta2,brk,eps=diff(range(x))/200) ## alpha1 is the intercept of the left line segment ## beta1 is the slope of the left line segment ## beta2 is the slope of the right line segment ## brk is location of the break point ## 2*eps is the length of the connecting quadratic piece ## reference: Bacon & Watts "Estimating the Transition Between ## Two Intersecting Straight Lines", Biometrika, 1971 ## Original function coded by Mary Lindstrom ## and taken from ## S-NEWS Archive (Mon, 24 Apr 2000) available ## from (http://lib.stat.cmu.edu/s-news/Burst/15642). { x1 <- brk-eps x2 <- brk+eps b <- (x2*beta1-x1*beta2)/(2*eps) cc <- (beta2-b)/(2*x2) a <- alpha1+beta1*x1-b*x1-cc*x1^2 alpha2 <- (a + b*x2 + cc*x2^2) - beta2*x2 lebrk <- (x <= x1) gebrk <- (x >= x2) eqbrk <- (x > x1 & x < x2) result <- rep(0,length(x)) result[lebrk] <- alpha1 + beta1*x[lebrk] result[eqbrk] <- a + b*x[eqbrk] + cc*x[eqbrk]^2 result[gebrk] <- alpha2 + beta2*x[gebrk] result } #--------------------------------------------------------------------------------------------required for mergeScans .mergeScans1 <- function(lowScan, highScan, AboveNoise, outp) { getInitPars <- function(x,y) { lowLeg <- (x <= quantile(x,probs=0.95)) init.lsfit <- lm(y~x, subset=lowLeg)$coef b0 <- init.lsfit[1]; b1 <- init.lsfit[2]; b3 <- (y[x==max(x)]-b0)/b1; return(c(b0, b1, 0.0, b3)) } findThreshold <- function(x,y) { n <- length(x) pars <- getInitPars(x=x,y=y) ########################################### # if(pars[1]>10)pars[1]<-7 # if(pars[4]>200)pars[4]<-190 # print(pars); ###################################### alpha1 <- pars[1]; beta1 <- pars[2]; beta2 <- pars[3]; brk <- pars[4]; fit1 <- nls(y ~ .hockey(x=x,alpha1,beta1,beta2,brk), start=list(alpha1=alpha1,beta1=beta1,beta2=beta2,brk=brk), control=nls.control(maxiter=100)) resid.scale <- sqrt(fit1$m$deviance()/(n-4)) yhat <- fit1$m$fitted() Coeff <- fit1$m$getPars() # cat("\nCoefficients are: ",Coeff,"\n") brk <- Coeff[4]; beta2 <- Coeff[3]; beta1 <- Coeff[2]; alpha1 <- Coeff[1]; Saturated <- y >= -(x - alpha1*beta1 - brk*(beta1*beta1 + 1))/beta1 # Saturated <- Saturated | (x >= brk) high.row <- c(1:length(x))[Saturated] High.fit <- alpha1 + beta1*x[high.row] return(list(x=x,y=y,yhat=yhat,high.row=high.row,resid.scale = resid.scale, High.fit=High.fit)) } findOutlier <- function(x,y,yhat,outp2) { n <- length(x) xBar <- mean(x) Sxx <- (n-1)*var(x) resid <- (y-yhat) h.ii <- 1/n + (x-xBar)*(x-xBar)/Sxx SSE <- sum(resid*resid) Rstudent <- resid*sqrt( (n-3)/(SSE*(1-h.ii) - resid^2) ) pval <- 2*pt(-abs(Rstudent),n-3) wksp <- cbind(c(1:n),pval) wksp <- wksp[order(wksp[,2]),] wksp[1,2] <- min( 1, n*wksp[1,2] ) i <- 2 while(i <= n) { wksp[i,2] <- min(1, (n+1-i)*wksp[i,2]) wksp[i,2] <- max(wksp[i,2],wksp[i-1,2]) i <- i+1 if (wksp[i-1,2] > outp2) break } wksp[,2] <- ((1:n) <= (i-2))*1 wksp <- wksp[order(wksp[,1]),] return(wksp[,2]) } tmp <- findThreshold(x=lowScan,y=highScan) high.row <- tmp$high.row High.fit <- tmp$High.fit yhat <- tmp$yhat sigma2 <- tmp$resid.scale^2 rm(tmp) if(outp>0) tmp2 <- findOutlier(x=lowScan[-high.row], y=highScan[-high.row], yhat=yhat[-high.row],outp2=outp) else tmp2<-0 tmp <- matrix(0,nrow=length(yhat),ncol=2) tmp[high.row,1] <- 1 tmp[-high.row,2] <- tmp2 rm(tmp2) dataOut <- cbind(lowScan,highScan,yhat,tmp) Merged <- yhat*0 - 999 ################################################################# ## To Undo a power transformation ( y^lambda) you must use: ## Mean(y) ~ (fit^(1/lambda))*( 1 + sigma^2(1-lambda)/(2*lambda^2*fit^2) ) ## var(y) ~ (fit^(2/lambda))*(sigma^2/(lambda^2*fit^2)) ################################################################# ok <- dataOut[,4]==1 Merged[ok] <- High.fit^2 + sigma2 ok <- (dataOut[,4]==0 & dataOut[,5]==0) Merged[ok] <- highScan[ok]^2 ok <- (dataOut[,4]==0 & dataOut[,5]==1 & AboveNoise==1) Merged[ok] <- NA ok <- (dataOut[,4]==0 & dataOut[,5]==1 & AboveNoise==0) if(sum(ok)!=0) Merged[ok] <- highScan[ok]^2 rm(yhat,high.row,tmp) dataOut <- cbind(dataOut,Merged) dimnames(dataOut) <- list(NULL,c("Low","High","yhat","Saturated","Outlier","Merged")) return(dataOut) } #-------------------------------------------------------------------------------------------handle missing when merging mergeScansRG <- function(RGlow, RGhigh, AboveNoiseLowG=NULL,AboveNoiseLowR=NULL,outlierp=0.01){ Glow<-RGlow$G Rlow<-RGlow$R Ghigh<-RGhigh$G Rhigh<-RGhigh$R if (is.null(AboveNoiseLowG)) {AboveNoiseLowG<-matrix(1,nrow=nrow(Glow),ncol=ncol(Glow))} if (is.null(AboveNoiseLowR)) {AboveNoiseLowR<-matrix(1,nrow=nrow(Rlow),ncol=ncol(Rlow))} if(ncol(Glow)!=ncol(Ghigh)) { stop("Number of arrays in low scans and high scans are different") } if(ncol(Rlow)!=ncol(Rhigh)) { stop("Number of arrays in low scans and high scans are different") } if(ncol(Ghigh)!=ncol(AboveNoiseLowG)) { stop("Number of arrays in Green and the number of columns in AboveNoiseHighG are different") } if(ncol(Rhigh)!=ncol(AboveNoiseLowR)) { stop("Number of arrays in Red and the number of columns in AboveNoiseHighR are different") } noarrays<-ncol(Glow) nogenes<-nrow(Glow) Rmerge<-Gmerge<-matrix(NA, nrow=nogenes,ncol=noarrays) Rout<-Gout<-matrix(NA, nrow=nogenes,ncol=noarrays) Rsat<-Gsat<-matrix(NA, nrow=nogenes,ncol=noarrays) for(i in 1:noarrays){ ok <- apply(sqrt(cbind(Glow[,i],Ghigh[,i])),1,function(x) all(!is.na(x)) ) tmpG <- .mergeScans1(sqrt(Glow[ok,i]),sqrt(Ghigh[ok,i]),AboveNoiseLowG[ok,i],outp=outlierp) Gmerge[ok,i]<-tmpG[,6] Gout[ok,i]<-tmpG[,5] Gsat[ok,i]<-tmpG[,4] ok <- apply(sqrt(cbind(Rlow[,i],Rhigh[,i])),1,function(x) all(!is.na(x)) ) tmpR <- .mergeScans1(sqrt(Rlow[ok,i]),sqrt(Rhigh[ok,i]),AboveNoiseLowR[ok,i],outp=outlierp) Rmerge[ok,i]<-tmpR[,6] Rout[ok,i]<-tmpR[,5] Rsat[ok,i]<-tmpR[,4] } RGmerge<-list(G=Gmerge, R=Rmerge, Gb=RGhigh$Gb, Rb=RGhigh$Gb,other=list(Goutlier=Gout,Routlier=Rout,Gsaturated=Gsat,Rsaturated=Rsat)) new("RGList",RGmerge) } limma/R/convest.R0000644007451300017500000000572512127125240014022 0ustar charlescharlesconvest <- function(p,niter=100,plot=FALSE,report=FALSE,file="",tol=1e-06) # Estimates pi0 using a convex decreasing density estimate # Input: p=observed p-values,k=number of iterations, # plot=TRUE plots and report=TRUE writes results of each iteration. # Returns: An estimate of pi0 # The methology underlying the function can be found in the # preprint: "Estimating the proportion of true null hypotheses, # with application to DNA microarray data." that can be downloaded # from http://www.math.ntnu.no/~mettela/ # Written by Egil Ferkingstad. # Received from Mette Langaas 26 Jun 2004. # Modified for limma by Gordon Smyth, 29 Oct 2004, 28 May 2005. # Report modified by Marcus Davy, 24 June 2007. Implemented and edited by Gordon Smyth, 9 Sep 2012. { if(!length(p)) return(NA) if(any(is.na(p))) stop("Missing values in p not allowed") if(any(p<0 | p>1)) stop("All p-values must be between 0 and 1") k <- niter # accuracy of the bisectional search for finding a new # convex combination of the current iterate and the mixing density ny <- tol p <- sort(p) m <- length(p) p.c <- ceiling(100*p)/100 p.f <- floor(100*p)/100 t.grid <- (1:100)/100 x.grid <- (0:100)/100 t.grid.mat <- matrix(t.grid,ncol=1) f.hat <- rep(1,101) #f.hat at the x-grid f.hat.p <- rep(1,m) #f.hat at the p-values theta.hat <- 0.01*which.max(apply(t.grid.mat,1,function(theta) sum((2*(theta-p)*(p 0) eps <- 0 else { l <- 0 u <- 1 while (abs(u-l)>ny) { eps <- (l+u)/2 if(sum((f.hat.diff/((1-eps)*f.hat.p+eps*f.theta.hat.p))[f.hat.p>0])<0) l <- eps else u <- eps } } f.hat <- (1-eps)*f.hat + eps*f.theta.hat pi.0.hat <- f.hat[101] d <- sum(f.hat.diff/f.hat.p) if(report) cat(j, "\t",pi.0.hat, "\t",theta.hat,"\t",eps, "\t",d, "\n", file=file, append=TRUE) f.hat.p <- 100*(f.hat[100*p.f+1]-f.hat[100*p.c+1])*(p.c-p)+f.hat[100*p.c+1] theta.hat <- 0.01*which.max(apply(t.grid.mat,1,function(theta) sum((2*(theta-p)*(p 0 & Rsbg[i] > 0) { RGmodel$R[i] <- .expectedBayesianAdjustedFG(fg = RG$R[i,k], bg = RG$Rb[i,k], sfg = Rsfg[i], sbg = Rsbg[i]) } else { RGmodel$R[i] <- RG$R[i,k] } if (RG$G[i,k] > 0 & Gsbg[i] > 0) { RGmodel$G[i] <- .expectedBayesianAdjustedFG(fg = RG$G[i,k], bg = RG$Gb[i,k], sfg = Gsfg[i], sbg = Gsbg[i]) } else { RGmodel$G[i] <- RG$G[i,k] } } RGmodel$R[RGmodel$R > 2^16] <- NA RGmodel$G[RGmodel$G > 2^16] <- NA RGmodel } .getas <- function (RG, j) { b1 <- .varaux1(RG$other$"B532 Mean"[,j], RG$printer) b2 <- .varaux1(RG$other$"B635 Mean"[,j], RG$printer) c1 <- RG$other$"B532 SD"[,j]/sqrt(RG$other$"B Pixels"[,j]) c2 <- RG$other$"B635 SD"[,j]/sqrt(RG$other$"B Pixels"[,j]) m1 <- lm(b1 ~ c1 - 1, weights = 1/(c1 + 1)) m2 <- lm(b2 ~ c2 - 1, weights = 1/(c2 + 1)) c(m1$coef, m2$coef) } # Calculate empirical standard deviation for each spot (based on average of spot and 4 neighbours) .varaux1 <- function (bg, layout) { numblocks <- layout$ngrid.c * layout$ngrid.r block <- rep(1:numblocks, each=layout$nspot.r*layout$nspot.c) uu <- .varaux2(bg, block, 1, layout$nspot.c, layout$nspot.r) if (numblocks > 1) { for (i in 2:numblocks) { uu <- c(uu, .varaux2(bg, block, i, layout$nspot.c, layout$nspot.r)) } } uu } # Average the standard deviations .varaux2 <- function (bg, block, i, ncols, nrows) { v1 <- bg[block == i] v2 <- matrix(v1, ncol = ncols) # mid grid spot variances v4a <- v2[c(-1, -nrows), c(-1, -ncols)] v4b <- v2[c(-1, -2), c(-1, -ncols)] v4c <- v2[c(-1, -nrows), c(-1, -2)] v4d <- v2[c(-(nrows - 1), -nrows), c(-1, -ncols)] v4e <- v2[c(-1, -nrows), c(-(ncols - 1), -ncols)] v4x <- cbind(as.vector(v4a), as.vector(v4b), as.vector(v4c), as.vector(v4d), as.vector(v4e)) VAR <- matrix(0, ncol = ncols, nrow = nrows) mid.var <- apply(v4x, 1, FUN = var) VAR[2:(nrows - 1), 2:(ncols - 1)] <- sqrt(mid.var) # edge spot variances # top v4a <- v2[1, c(-1, -ncols)] v4b <- v2[1, c(-(ncols - 1), -ncols)] v4c <- v2[2, c(-1, -ncols)] v4d <- v2[1, c(-1, -2)] v4x <- cbind(as.vector(v4a), as.vector(v4b), as.vector(v4c), as.vector(v4d)) edge <- apply(v4x, 1, FUN = var) VAR[1, 2:(ncols - 1)] <- sqrt(edge) # bottom v4a <- v2[nrows, c(-1, -ncols)] v4b <- v2[nrows, c(-(ncols - 1), -ncols)] v4c <- v2[nrows - 1, c(-1, -ncols)] v4d <- v2[nrows, c(-1, -2)] v4x <- cbind(as.vector(v4a), as.vector(v4b), as.vector(v4c), as.vector(v4d)) edge <- apply(v4x, 1, FUN = var) VAR[nrows, 2:(ncols - 1)] <- sqrt(edge) # left v4a <- v2[c(-1, -nrows), 1] v4b <- v2[c(-(nrows - 1), -nrows), 1] v4c <- v2[c(-1, -nrows), 2] v4d <- v2[c(-1, -2), 1] v4x <- cbind(as.vector(v4a), as.vector(v4b), as.vector(v4c), as.vector(v4d)) edge <- apply(v4x, 1, FUN = var) VAR[2:(nrows - 1), 1] <- sqrt(edge) # right v4a <- v2[c(-1, -nrows), ncols] v4b <- v2[c(-(nrows - 1), -nrows), ncols] v4c <- v2[c(-1, -nrows), ncols - 1] v4d <- v2[c(-1, -2), ncols] v4x <- cbind(as.vector(v4a), as.vector(v4b), as.vector(v4c), as.vector(v4d)) edge <- apply(v4x, 1, FUN = var) VAR[2:(nrows - 1), ncols] <- sqrt(edge) # corners v4x <- cbind(c(v2[1, 1], v2[1, ncols], v2[nrows, 1], v2[nrows, ncols]), c(v2[1, 2], v2[1, ncols - 1], v2[nrows, 2], v2[nrows, ncols - 1]), c(v2[2, 1], v2[2, ncols], v2[nrows - 1, 1], v2[nrows - 1, ncols]), c(v2[2, 2], v2[2, ncols - 1], v2[nrows - 1, 2], v2[nrows - 1, ncols - 1])) corner <- apply(v4x, 1, FUN = var) VAR[1, 1] <- sqrt(corner[1]) VAR[1, ncols] <- sqrt(corner[2]) VAR[nrows, 1] <- sqrt(corner[3]) VAR[nrows, ncols] <- sqrt(corner[4]) as.vector(VAR) } .expectedBayesianAdjustedFG <- function(fg, bg, sfg, sbg) { integrate(.numeratorBayesianAdjustedFG, ifelse((fg-bg-4*sqrt(sbg^2+sfg^2))<0, 0, fg-bg-4*sqrt(sbg^2+sfg^2)), ifelse((fg-bg+4*sqrt(sfg^2+sbg^2))<0, 1000, fg-bg+4*sqrt(sfg^2+sbg^2)) , fg=fg, bg=bg, sfg=sfg, sbg=sbg, subdivisions=10000)$value/.denominatorBayesianAdjustedFG(fg, bg, sfg, sbg) } .numeratorBayesianAdjustedFG <- function(ut, fg, bg, sfg, sbg) ut*exp(dnorm((fg-ut-bg)/sqrt(sfg^2+sbg^2), log=TRUE)+pnorm(((fg-ut)*sbg^2+bg*sfg^2)/(sbg*sfg*sqrt(sfg^2+sbg^2)), log.p=TRUE)) .denominatorBayesianAdjustedFG <- function(fg, bg, sfg, sbg) { sqrt(sfg^2+sbg^2) / sbg * integrate(.normalConvolution, ifelse((bg-4*sbg)<0, 0, bg-4*sbg), bg+4*sbg, fg=fg, bg=bg, sfg=sfg, sbg=sbg, subdivisions=10000)$value } .normalConvolution <- function(v, fg, bg, sfg, sbg) exp(pnorm((fg-v)/sfg, log.p=TRUE)+dnorm((bg-v)/sbg, log=TRUE)) limma/R/geneset-wilcox.R0000644007451300017500000000416512127125240015273 0ustar charlescharles## GENESET.R geneSetTest <- function(index,statistics,alternative="mixed",type="auto",ranks.only=TRUE,nsim=9999) # Competitive gene set test using either rank sum test or simulation. # Gordon Smyth # 3 September 2004. Last modified 11 Feb 2012. { alternative <- match.arg(alternative,c("mixed","either","down","up","less","greater","two.sided")) if(alternative=="two.sided") alternative <- "either" if(alternative=="less") alternative <- "down" if(alternative=="greater") alternative <- "up" type <- match.arg(tolower(type),c("auto","t","f")) allsamesign <- all(statistics >= 0) || all(statistics <= 0) if(type=="auto") { if(allsamesign) type <- "f" else type <- "t" } if(type=="f" & alternative!="mixed") stop("Only alternative=\"mixed\" is possible with F-like statistics.") if(alternative=="mixed") statistics <- abs(statistics) if(alternative=="down") { statistics <- -statistics alternative <- "up" } if(ranks.only) { # The test statistic is the mean rank of the selected genewise statistics # and the p-value is obtained explicitly from the rank sum test pvalues <- rankSumTestWithCorrelation(index=index,statistics=statistics,df=Inf) p.value <- switch(alternative, "down" = pvalues["less"], "up" = pvalues["greater"], "either" = 2*min(pvalues), "mixed" = pvalues["greater"]) } else { # The global test statistic is the mean of the selected genewise statistics # and the p-value is obtained by random permutation ssel <- statistics[index] ssel <- ssel[!is.na(ssel)] nsel <- length(ssel) if(nsel==0) return(1) stat <- statistics[!is.na(statistics)] msel <- mean(ssel) if(alternative=="either") posstat <- abs else posstat <- function(x) x msel <- posstat(msel) ntail <- 1 for (i in 1:nsim) if(posstat(mean(sample(stat,nsel))) >= msel) ntail <- ntail+1 p.value <- ntail/(nsim+1) } as.vector(p.value) } wilcoxGST <- function(index,statistics,...) # Mean-rank gene set test using Wilcox test. # Gordon Smyth # 27 July 2009. Last modified 3 Sep 2011. geneSetTest(index=index,statistics=statistics,...,ranks.only=TRUE) limma/R/plotFG.R0000644007451300017500000000143112127125240013522 0ustar charlescharlesplotFB <- function(RG, array=1, lim="separate", pch=16, cex=0.2, ...) # Foreground-background plot # Gordon Smyth # 5 March 2006. Last modified 5 April 2006. { lim <- match.arg(lim,c("separate","common")) oldpar <- par(mfrow=c(1,2)) on.exit(par(oldpar)) x <- RG[,array] g1 <- log2(x$Gb) g2 <- log2(x$G) r1 <- log2(x$Rb) r2 <- log2(x$R) if(lim=="separate") { lim1 <- lim2 <- NULL } else { lim1 <- range(c(g1,r1)) lim2 <- range(c(g2,r2)) } plot(g1,g2,xlim=lim1,ylim=lim2,pch=pch,cex=cex,xlab="log2 Background",ylab="log2 Foreground",main=paste("Array",array,"Green"),...) abline(0,1,col="blue") plot(r1,r2,xlim=lim1,ylim=lim2,pch=pch,cex=cex,xlab="log2 Background",ylab="",main=paste("Array",array,"Red"),...) abline(0,1,col="blue") invisible() } limma/R/sepchannel.R0000755007451300017500000001423212127125240014455 0ustar charlescharles# SEPARATE CHANNEL ANALYSIS lmscFit <- function(object,design,correlation) # Fit single channel linear model for each gene to a series of microarrays # allowing for known correlation between the channels on each spot. # Gordon Smyth # 14 March 2004. Last modified 26 June 2004. { # Check input M <- as.matrix(object$M) A <- as.matrix(object$A) if(is.null(M) || is.null(A)) stop("object must have components M and A") dimM <- dim(M) dimA <- dim(A) if(any(dimM != dimA)) stop("dimensions of M and A don't match") if(!all(is.finite(M)) || !all(is.finite(A))) stop("Missing or infinite values found in M or A") if(missing(design)) stop("design matrix must be specified") narrays <- dimM[2] ny <- 2*narrays design <- as.matrix(design) if(nrow(design) != ny) stop("The number of rows of the design matrix should match the number of channel intensities, i.e., twice the number of arrays") if(missing(correlation)) stop("intra-spot correlation must be specified") if(abs(correlation) >= 1) stop("correlation must be strictly between -1 and 1") # Dimensions nbeta <- ncol(design) coef.names <- colnames(design) ngenes <- dimM[1] # Main computation sdM <- sqrt(2*(1-correlation)) sdA <- sqrt((1+correlation)/2) y <- rbind(t(M)/sdM, t(A)/sdA) designM <- (diag(narrays) %x% matrix(c(-1,1),1,2)) %*% design designA <- (diag(narrays) %x% matrix(c(0.5,0.5),1,2)) %*% design X <- rbind(designM/sdM, designA/sdA) # In future it may be necessary to allow for quality weights, this call does not fit <- lm.fit(X,y) fit$sigma <- sqrt(colSums(fit$effects[(fit$rank+1):ny,,drop=FALSE]^2) / fit$df.residual) fit$fitted.values <- fit$residuals <- fit$effects <- NULL fit$coefficients <- t(fit$coefficients) stdev.unscaled <- sqrt(diag(chol2inv(fit$qr$qr))) fit$stdev.unscaled <- matrix(stdev.unscaled,ngenes,nbeta,byrow=TRUE) fit$df.residual <- rep.int(fit$df.residual,ngenes) dimnames(fit$stdev.unscaled) <- dimnames(fit$stdev.unscaled) <- dimnames(fit$coefficients) fit$design <- design fit$correlation <- correlation fit$genes <- object$genes fit$Amean <- rowMeans(A,na.rm=TRUE) fit$cov.coefficients <- chol2inv(fit$qr$qr,size=fit$qr$rank) fit$pivot <- fit$qr$pivot new("MArrayLM",fit) } intraspotCorrelation <- function(object,design,trim=0.15) # Estimate intra-spot correlation between channels for two channel data # Gordon Smyth # 19 April 2004. Last modified 13 Nov 2005. { # Check input M <- as.matrix(object$M) A <- as.matrix(object$A) if(is.null(M) || is.null(A)) stop("object should have components M and A") dimM <- dim(M) dimA <- dim(A) if(any(dimM != dimA)) stop("dimensions of M and A don't match") if(!all(is.finite(M)) || !all(is.finite(A))) stop("Missing or infinite values found in M or A") if(missing(design)) stop("design matrix must be specified") ngenes <- dimM[1] narrays <- dimM[2] ny <- 2*narrays design <- as.matrix(design) if(nrow(design) != ny) stop("The number of rows of the design matrix should match the number of channel intensities, i.e., twice the number of arrays") # Fit heteroscedastic regression for each gene Ident <- diag(narrays) designM <- (Ident %x% matrix(c(-1,1),1,2)) %*% design designA <- (Ident %x% matrix(c(0.5,0.5),1,2)) %*% design X <- rbind(designM, designA) Z <- diag(2) %x% rep(1,narrays) if(!require(statmod)) stop("statmod package required but is not available") arho <- rep(NA,ngenes) degfre <- matrix(0,ngenes,2,dimnames=list(rownames(M),c("df.M","df.A"))) for (i in 1:ngenes) { y <- c(M[i,],A[i,]) fit <- try(remlscore(y,X,Z),silent=TRUE) if(is.list(fit)) { arho[i] <- 0.5*(fit$gamma[2]-fit$gamma[1]) degfre[i,] <- crossprod(Z,1-fit$h) } } arho <- arho+log(2) degfreNA <- degfre degfreNA[degfre==0] <- NA arhobias <- digamma(degfreNA[,1]/2)-log(degfreNA[,1]/2)-digamma(degfreNA[,2]/2)+log(degfreNA[,2]/2) list(consensus.correlation=tanh(mean(arho-arhobias,trim=trim,na.rm=TRUE)), atanh.correlations=arho, df=degfre) } targetsA2C <- function(targets,channel.codes=c(1,2),channel.columns=list(Target=c("Cy3","Cy5")),grep=FALSE) # Convert data.frame with one row for each two-color array # into data.frame with one row for each channel # Gordon Smyth # 16 March 2004. Last modified 8 Feb 2008. { targets <- as.data.frame(targets) narrays <- nrow(targets) nchannelcol <- 0 nothercol <- ncol(targets) if(narrays==0 || nothercol==0) return(targets) lcc <- length(channel.columns) if(lcc) { hyb <- channel.columns cheaders <- names(channel.columns) for (i in 1:lcc) { aheaders <- channel.columns[[i]] if(grep) { k <- grep(tolower(aheaders[1]),tolower(names(targets))) if(length(k)==1) aheaders[1] <- names(targets)[k] k <- grep(tolower(aheaders[2]),tolower(names(targets))) if(length(k)==1) aheaders[2] <- names(targets)[k] } if(all(aheaders %in% names(targets))) { hyb[[i]] <- as.vector(as.matrix((targets[,aheaders]))) targets[[ aheaders[1] ]] <- NULL targets[[ aheaders[2] ]] <- NULL nchannelcol <- nchannelcol+1 nothercol <- nothercol-2 } else { hyb[[ cheaders[i] ]] <- NULL } } } channel.col <- rep(channel.codes,each=narrays) out <- data.frame(channel.col=channel.col,row.names=paste(row.names(targets),channel.col,sep="."),stringsAsFactors=FALSE) if(nothercol) out <- cbind(out,rbind(targets,targets)) if(nchannelcol) out <- cbind(out,hyb) o <- as.vector(t(matrix(1:(2*narrays),narrays,2))) out[o,] } designI2M <- function(design) # Convert individual channel design matrix to design matrix for log-ratios # Gordon Smyth # 22 June 2004 { design <- as.matrix(design) narrays <- nrow(design)/2 (diag(narrays) %x% matrix(c(-1,1),1,2)) %*% design } designI2A <- function(design) # Convert individual channel design matrix to design matrix for A-values # Gordon Smyth # 22 June 2004 { design <- as.matrix(design) narrays <- nrow(design)/2 (diag(narrays) %x% matrix(c(0.5,0.5),1,2)) %*% design } exprs.MA <- function(MA) # Extract matrix of log-expression data from MAList object # Gordon Smyth, 29 August 2006 { y <- rbind(as.matrix(MA$A-MA$M/2),as.matrix(MA$A+MA$M/2)) dim(y) <- c(nrow(y)/2,ncol(y)*2) y } limma/R/write.R0000755007451300017500000000322412127125240013466 0ustar charlescharles# OUTPUT write.fit <- function(fit, results=NULL, file, digits=3, adjust="none", method="separate", F.adjust="none", sep="\t", ...) { # Write an MArrayLM fit to a file # Gordon Smyth # 14 Nov 2003. Last modified 16 June 2008. if(!is(fit, "MArrayLM")) stop("fit should be an MArrayLM object") if(!is.null(results) && !is(results,"TestResults")) stop("results should be a TestResults object") if(is.null(fit$t) || is.null(fit$p.value)) fit <- eBayes(fit) method <- match.arg(method, c("separate","global")) p.value <- as.matrix(fit$p.value) if(adjust=="none") { p.value.adj <- NULL } else { p.value.adj <- p.value if(method=="separate") for (j in 1:ncol(p.value)) p.value.adj[,j] <- p.adjust(p.value[,j],method=adjust) if(method=="global") p.value.adj <- p.adjust(p.value,method=adjust) } if(F.adjust=="none" || is.null(fit$F.p.value)) F.p.value.adj <- NULL else F.p.value.adj <- p.adjust(fit$F.p.value,method=F.adjust) rn <- function(x,digits=digits) if(is.null(x)) NULL else { if(is.matrix(x) && ncol(x)==1) x <- x[,1] round(x,digits=digits) } tab <- list() tab$A <- rn(fit$Amean,digits=digits-1) tab$Coef <- rn(fit$coef,digits=digits) tab$t <- rn(fit$t,digits=digits-1) tab$p.value <- rn(p.value,digits=digits+2) tab$p.value.adj <- rn(p.value.adj,digits=digits+3) tab$F <- rn(fit$F,digits=digits-1) tab$F.p.value <- rn(fit$F.p.value,digits=digits+2) tab$F.p.value.adj <-tab$F.p.value.adj <- rn(F.p.value.adj,digits=digits+3) tab$Res <- unclass(results) tab$Genes <- fit$genes tab <- data.frame(tab,check.names=FALSE) write.table(tab,file=file,quote=FALSE,row.names=FALSE,sep=sep,...) } limma/R/utility.R0000755007451300017500000000567712127125240014055 0ustar charlescharles# UTILITY FUNCTIONS .matvec <- function(M,v) { # Multiply the columns of matrix by the elements of a vector, # i.e., compute M %*% diag(v) # Gordon Smyth # 5 July 1999 # v <- as.vector(v) M <- as.matrix(M) if(length(v)!=dim(M)[2]) stop("Dimensions do not match") t(v * t(M)) } .vecmat <- function(v,M) { # Multiply the rows of matrix by the elements of a vector, # i.e., compute diag(v) %*% M # Gordon Smyth # 5 July 1999 # v <- as.vector(v) M <- as.matrix(M) if(length(v)!=dim(M)[1]) stop("Dimensions do not match") v * M } isNumeric <- function(x) { # Test for numeric argument or data.frame with numeric columns # Gordon Smyth # 12 April 2003 is.numeric(x) || (is.data.frame(x) && length(x)>0 && all(unlist(lapply(x,is.numeric)))) } blockDiag <- function(...) # Block diagonal matrix # Gordon Smyth # 8 Feb 2004 { e <- list(...) d <- matrix(unlist(lapply(e,dim)),ncol=2,byrow=TRUE) if(nrow(d) != length(e)) stop("all arguments must be matrices") dsum <- apply(d,2,sum) z <- array(0,dsum) dimnames(z) <- list(character(dsum[1]),character(dsum[2])) coord <- c(0,0) for (i in 1:length(e)) { coord1 <- coord[1]+1:d[i,1] coord2 <- coord[2]+1:d[i,2] z[coord1,coord2] <- e[[i]] rownames(z)[coord1] <- rownames(e[[i]],do.NULL=FALSE,prefix="") colnames(z)[coord2] <- colnames(e[[i]],do.NULL=FALSE,prefix="") coord <- coord+d[i,] } z } helpMethods <- function(genericFunction) { # Prompt user for help topics on methods for generic function # Gordon Smyth # 21 April 2003. Last revised 28 Oct 2003. objectclass <- class(genericFunction) if(objectclass != "standardGeneric") { if(objectclass == "character" && isGeneric(genericFunction)) genericFunction <- getGeneric(genericFunction) else { cat("Not a generic function\n") return(invisible()) } } functionname <- genericFunction@generic methodnames <- names(getMethods(genericFunction)@methods) nmethods <- length(methodnames) if(nmethods == 0) { cat("No available methods\n") return(invisible()) } aliasnames <- paste(functionname,",",methodnames,"-method",sep="") for (i in 1:nmethods) cat(i,": ",aliasnames[i],"\n",sep="") cat("Type number to choose help topic: ") n <- as.integer(readline()) if(n > 0 && n <= nmethods) eval(parse(text=paste("help(\"",aliasnames[n],"\")",sep=""))) else { cat("No topic chosen\n") return(invisible()) } } limmaUsersGuide <- function(view=TRUE) # Find and optionally view limma User's Guide # Gordon Smyth # 25 Oct 2004. { f <- system.file("doc","usersguide.pdf",package="limma") if(view) { if(.Platform$OS.type == "windows") shell.exec(f) else system(paste(Sys.getenv("R_PDFVIEWER"),f,"&")) } return(f) } changeLog <- function(n=20) # Write first n lines of limma changelog # Gordon Smyth # 20 Sep 2004. Last modified 30 Oct 2004. { writeLines(readLines(system.file("doc","changelog.txt",package="limma"),n=n)) } limma/R/read-ilmn.R0000644007451300017500000000714112127125240014203 0ustar charlescharles# READ-ILMN.R read.ilmn <- function(files=NULL, ctrlfiles=NULL, path=NULL, ctrlpath=NULL, probeid="Probe", annotation=c("TargetID", "SYMBOL"), expr="AVG_Signal", other.columns="Detection",sep="\t", quote="\"", verbose=TRUE, ...) # Read one or more files of Illumina BeadStudio output # Wei Shi and Gordon Smyth. # Created 15 July 2009. Last modified 27 October 2010. { if(!is.null(files)){ f <- unique(files) if(!is.null(path)) f <- file.path(path, f) n <- length(f) for(i in 1:n){ if(verbose) cat("Reading file", f[i], "... ...\n") elist1 <- .read.oneilmnfile(f[i], probeid, annotation, expr, other.columns, sep, quote, verbose, ...) if(i==1) elist <- elist1 else elist <- cbind(elist, elist1) } if(!is.null(ctrlfiles)) elist$genes$Status <- "regular" } if(!is.null(ctrlfiles)){ cf <- unique(ctrlfiles) if(!is.null(ctrlpath)) cf <- file.path(ctrlpath, cf) n <- length(cf) for(i in 1:n){ if(verbose) cat("Reading file", cf[i], "... ...\n") elist.ctrl1 <- .read.oneilmnfile(cf[i], probeid, annotation, expr, other.columns, sep, quote, verbose, ...) if(i==1) elist.ctrl <- elist.ctrl1 else elist.ctrl <- cbind(elist.ctrl, elist.ctrl1) } elist.ctrl$genes$Status <- elist.ctrl$genes[,ncol(elist.ctrl$genes)] } if(!is.null(files)) if(!is.null(ctrlfiles)){ colnames(elist.ctrl$genes) <- colnames(elist$genes) return(rbind(elist, elist.ctrl)) } else return(elist) else if(!is.null(ctrlfiles)) return(elist.ctrl) } read.ilmn.targets <- function(targets, ...) # Read Illumina BeadStudio output using targets frame # Wei Shi # 15 July 2009 { if(is.null(targets$files) && is.null(targets$ctrlfiles)) stop("Can not find column \"files\" or \"ctrlfiles\" in targets\n") x <- read.ilmn(targets$files, targets$ctrlfiles, ...) x$targets <- targets x } .read.oneilmnfile <- function(fname, probeid, annotation, expr, other.columns, sep, quote, verbose, ...) # Read a single file of Illumina BeadStudio output # Wei Shi and Gordon Smyth # Created 15 July 2009. Last modified 5 Jan 2011. { h <- readGenericHeader(fname,columns=expr) skip <- h$NHeaderRecords header <- h$ColumnNames elist <- new("EListRaw") elist$source <- "illumina" reqcol <- header[grep(tolower(paste(c(probeid, annotation, expr, other.columns), collapse="|")), tolower(header))] reqcol <- trimWhiteSpace(reqcol) x <- read.columns(file=fname, required.col=reqcol, skip=skip, sep=sep, quote=quote, stringsAsFactors=FALSE, ...) nprobes <- nrow(x) pids <- x[, grep(tolower(probeid), tolower(colnames(x)))] snames <- colnames(x)[grep(tolower(expr), tolower(colnames(x)))] snames <- unlist(strsplit(snames, paste("[.]*", expr, "-*", sep=""))) snames <- snames[snames != ""] nsamples <- length(snames) elist$E <- data.matrix(x[, grep(tolower(expr), tolower(colnames(x)))]) colnames(elist$E) <- snames rownames(elist$E) <- pids elist$genes <- x[, c(grep(tolower(probeid), tolower(colnames(x))), grep(tolower(paste(annotation,collapse="|")), tolower(colnames(x)))), drop=FALSE] elist$targets <- data.frame(SampleNames=snames, stringsAsFactors=FALSE) if(!is.null(other.columns)){ elist$other <- vector("list", length(other.columns)) for(i in 1:length(other.columns)){ if(length(co <- grep(tolower(other.columns[i]), tolower(colnames(x))))) elist$other[[i]] <- as.matrix(x[, co]) else elist$other[[i]] <- matrix(NA, nprobes, nsamples) colnames(elist$other[[i]]) <- snames rownames(elist$other[[i]]) <- pids } names(elist$other) <- other.columns } elist } limma/R/plots-ma.R0000755007451300017500000001342512170636047014106 0ustar charlescharles# M-A PLOTS plotMA <- function(MA, array=1, xlab="A", ylab="M", main=colnames(MA)[array], xlim=NULL, ylim=NULL, status, values, pch, col, cex, legend=TRUE, zero.weights=FALSE, ...) # MA-plot with color coding for controls # Gordon Smyth 7 April 2003, James Wettenhall 27 June 2003. # Last modified 23 April 2013. { # Convert to MAList if possible if(class(MA)=="list") MA <- new("MAList",MA) if(is(MA,"RGList")) { MA <- MA.RG(MA[,array]) array <- 1 } if(is(MA,"EListRaw")) { MA <- normalizeBetweenArrays(MA,method="none") } # Check legend legend.position <- "topleft" if(!is.logical(legend)) { legend.position <- legend legend <- TRUE } legend.position <- match.arg(legend.position,c("bottomright","bottom","bottomleft","left","topleft","top","topright","right","center")) if(is(MA,"MAList")) { # Data is two-color x <- as.matrix(MA$A)[,array] y <- as.matrix(MA$M)[,array] if(is.null(MA$weights)) w <- NULL else w <- as.matrix(MA$weights)[,array] if(missing(status)) status <- MA$genes$Status } else if(is(MA,"MArrayLM")) { if(is.null(MA$Amean)) stop("MA-plot not possible because Amean component is absent.") x <- MA$Amean y <- as.matrix(MA$coef)[,array] if(is.null(MA$weights)) w <- NULL else w <- as.matrix(MA$weights)[,array] if(missing(status)) status <- MA$genes$Status } else if(is(MA,"EList")) { MA$E <- as.matrix(MA$E) narrays <- ncol(MA$E) if(narrays < 2) stop("Need at least two arrays") if(narrays > 5) x <- apply(MA$E,1,median,na.rm=TRUE) else x <- rowMeans(MA$E,na.rm=TRUE) y <- MA$E[,array]-x if(is.null(MA$weights)) w <- NULL else w <- as.matrix(MA$weights)[,array] if(missing(status)) status <- MA$genes$Status } else { # Data is assumed to be single-channel MA <- as.matrix(MA) narrays <- ncol(MA) if(narrays < 2) stop("Need at least two arrays") if(narrays > 5) x <- apply(MA,1,median,na.rm=TRUE) else x <- rowMeans(MA,na.rm=TRUE) y <- MA[,array]-x w <- NULL if(missing(status)) status <- NULL } if(!is.null(w) && !zero.weights) { i <- is.na(w) | (w <= 0) y[i] <- NA } if(is.null(xlim)) xlim <- range(x,na.rm=TRUE) if(is.null(ylim)) ylim <- range(y,na.rm=TRUE) plot(x,y,xlab=xlab,ylab=ylab,main=main,xlim=xlim,ylim=ylim,type="n",...) if(is.null(status) || all(is.na(status))) { if(missing(pch)) pch=16 if(missing(cex)) cex=0.3 points(x,y,pch=pch[[1]],cex=cex[1]) } else { if(missing(values)) { if(is.null(attr(status,"values"))) values <- names(sort(table(status),decreasing=TRUE)) else values <- attr(status,"values") } # Non-highlighted points sel <- !(status %in% values) nonhi <- any(sel) if(nonhi) points(x[sel],y[sel],pch=16,cex=0.3) nvalues <- length(values) if(missing(pch)) { if(is.null(attr(status,"pch"))) pch <- rep(16,nvalues) else pch <- attr(status,"pch") } if(missing(cex)) { if(is.null(attr(status,"cex"))) { cex <- rep(1,nvalues) if(!nonhi) cex[1] <- 0.3 } else cex <- attr(status,"cex") } if(missing(col)) { if(is.null(attr(status,"col"))) { col <- nonhi + 1:nvalues } else col <- attr(status,"col") } pch <- rep(pch,length=nvalues) col <- rep(col,length=nvalues) cex <- rep(cex,length=nvalues) for (i in 1:nvalues) { sel <- status==values[i] points(x[sel],y[sel],pch=pch[[i]],cex=cex[i],col=col[i]) } if(legend) { if(is.list(pch)) legend(legend.position,legend=values,fill=col,col=col,cex=0.9) else legend(legend.position,legend=values,pch=pch,,col=col,cex=0.9) } } invisible() } plotMA3by2 <- function(MA, prefix="MA", path=NULL, main=colnames(MA), zero.weights=FALSE, common.lim=TRUE, device="png", ...) # Make files of MA-plots, six to a page # Gordon Smyth 27 May 2004. Last modified 9 June 2007. { if(is(MA,"RGList")) MA <- MA.RG(MA) if(is.null(path)) path <- "." prefix <- file.path(path,prefix) narrays <- ncol(MA) npages <- ceiling(narrays/6) device <- match.arg(device, c("png","jpeg","pdf","postscript")) if(device=="png" & !capabilities(what="png")) stop("png not available. Try another device.") if(device=="jpeg" & !capabilities(what="jpeg")) stop("jpeg not available. Try another device.") fdevice <- get(device) if(device=="postscript") ext <- "ps" else ext <- device width <- 6.5 height <- 10 if(device %in% c("png","jpeg")) { width <- width * 140 height <- height * 140 } if(!zero.weights && !is.null(MA$weights)) MA$M[MA$weights<=0] <- NA if(common.lim) { xlim <- range(MA$A,na.rm=TRUE) ylim <- range(MA$M,na.rm=TRUE) } else { xlim <- ylim <- NULL } for (ipage in 1:npages) { i1 <- ipage*6-5 i2 <- min(ipage*6,narrays) fdevice(file=paste(prefix,"-",i1,"-",i2,".",ext,sep=""),width=width,height=height) par(mfrow=c(3,2)) for (i in i1:i2) { plotMA(MA,array=i,xlim=xlim,ylim=ylim,legend=(i%%6==1),zero.weights=TRUE,main=main[i],...) } dev.off() } invisible() } plotPrintTipLoess <- function(object,layout,array=1,span=0.4,...) { # MA-plots by print-tip group # Gordon Smyth # 7 April 2003. Last revised 19 March 2004. if(is(object,"RGList")) { object <- MA.RG(object[,array]) array <- 1 } if(!is.null(object$printer) && missing(layout)) layout <- object$printer y <- object$M[,array] x <- object$A[,array] if(dev.cur()==1) plot.new() df <- data.frame(y=object$M[,array],x=object$A[,array],gr=factor(gridc(layout)),gc=factor(layout$ngrid.r-gridr(layout)+1)) coplot(y~x|gr*gc,data=na.omit(df),xlab=c("A","Tip Column"),ylab=c("M","Tip Row"),pch=".",span=span,show.given=FALSE,panel=panel.smooth) } mdplot <- function(x,...) # Mean-different plot # Gordon Smyth # 16 March 2005 { d <- x[,1]-x[,2] m <- (x[,1]+x[,2])/2 plot(m,d,xlab="Mean",ylab="Difference",...) } limma/R/weightedmedian.R0000644007451300017500000000122512127125240015306 0ustar charlescharlesweighted.median <- function (x, w, na.rm = FALSE) # Weighted median # Gordon Smyth # 30 June 2005 { if (missing(w)) w <- rep.int(1, length(x)) else { if(length(w) != length(x)) stop("'x' and 'w' must have the same length") if(any(is.na(w))) stop("NA weights not allowed") if(any(w<0)) stop("Negative weights not allowed") } if(is.integer(w)) w <- as.numeric(w) if(na.rm) { w <- w[i <- !is.na(x)] x <- x[i] } if(all(w==0)) { warning("All weights are zero") return(NA) } o <- order(x) x <- x[o] w <- w[o] p <- cumsum(w)/sum(w) n <- sum(p<0.5) if(p[n+1] > 0.5) x[n+1] else (x[n+1]+x[n+2])/2 } limma/R/lmfit.R0000644007451300017500000003422412127125240013450 0ustar charlescharles# LINEAR MODELS lmFit <- function(object,design=NULL,ndups=1,spacing=1,block=NULL,correlation,weights=NULL,method="ls",...) # Fit linear model # Gordon Smyth # 30 June 2003. Last modified 6 Feb 2009. { # Check arguments y <- getEAWP(object) if(is.null(design)) if(is.null(y$design)) design <- matrix(1,ncol(y$exprs),1) else design <- as.matrix(object$design) else design <- as.matrix(design) if(mode(design) != "numeric") stop("design must be a numeric matrix") ne <- nonEstimable(design) if(!is.null(ne)) cat("Coefficients not estimable:",paste(ne,collapse=" "),"\n") if(missing(ndups) && !is.null(y$printer$ndups)) ndups <- y$printer$ndups if(missing(spacing) && !is.null(y$printer$spacing)) spacing <- y$printer$spacing if(missing(weights) && !is.null(y$weights)) weights <- y$weights method <- match.arg(method,c("ls","robust")) # If duplicates are present, reduce probe-annotation and Amean to correct length if(ndups>1) { if(!is.null(y$probes)) y$probes <- uniquegenelist(y$probes,ndups=ndups,spacing=spacing) if(!is.null(y$Amean)) y$Amean <- rowMeans(unwrapdups(as.matrix(y$Amean),ndups=ndups,spacing=spacing),na.rm=TRUE) } # Dispath fitting algorithms if(method=="robust") fit <- mrlm(y$exprs,design=design,ndups=ndups,spacing=spacing,weights=weights,...) else if(ndups < 2 && is.null(block)) fit <- lm.series(y$exprs,design=design,ndups=ndups,spacing=spacing,weights=weights) else { if(missing(correlation)) stop("the correlation must be set, see duplicateCorrelation") fit <- gls.series(y$exprs,design=design,ndups=ndups,spacing=spacing,block=block,correlation=correlation,weights=weights,...) } # Possible warning on missing coefs if(NCOL(fit$coef)>1) { i <- is.na(fit$coef) i <- apply(i[,1]==i[,-1,drop=FALSE],1,all) n <- sum(!i) if(n>0) warning("Partial NA coefficients for ",n," probe(s)",call.=FALSE) } # Output fit$genes <- y$probes fit$Amean <- y$Amean fit$method <- method fit$design <- design new("MArrayLM",fit) } lm.series <- function(M,design=NULL,ndups=1,spacing=1,weights=NULL) { # Fit linear model for each gene to a series of arrays # Gordon Smyth # 18 Apr 2002. Revised 10 July 2008. M <- as.matrix(M) narrays <- ncol(M) if(is.null(design)) design <- matrix(1,narrays,1) design <- as.matrix(design) nbeta <- ncol(design) coef.names <- colnames(design) if(!is.null(weights)) { weights <- asMatrixWeights(weights,dim(M)) weights[weights <= 0] <- NA M[!is.finite(weights)] <- NA } if(ndups>1) { M <- unwrapdups(M,ndups=ndups,spacing=spacing) design <- design %x% rep(1,ndups) if(!is.null(weights)) weights <- unwrapdups(weights,ndups=ndups,spacing=spacing) } ngenes <- nrow(M) stdev.unscaled <- beta <- matrix(NA,ngenes,nbeta,dimnames=list(rownames(M),coef.names)) sigma <- rep(NA,ngenes) df.residual <- rep(0,ngenes) NoProbeWts <- !any(is.na(M)) && (is.null(weights) || !is.null(attr(weights,"arrayweights"))) if(NoProbeWts) { if(is.null(weights)) fit <- lm.fit(design, t(M)) else { fit <- lm.wfit(design, t(M), weights[1,]) fit$weights <- NULL } if(fit$df.residual>0) fit$sigma <- sqrt(colMeans(fit$effects[(fit$rank + 1):narrays,,drop=FALSE]^2)) else fit$sigma <- rep(NA,ngenes) fit$fitted.values <- fit$residuals <- fit$effects <- NULL fit$coefficients <- t(fit$coefficients) fit$cov.coefficients <- chol2inv(fit$qr$qr,size=fit$qr$rank) est <- fit$qr$pivot[1:fit$qr$rank] dimnames(fit$cov.coefficients) <- list(coef.names[est],coef.names[est]) stdev.unscaled[,est] <- matrix(sqrt(diag(fit$cov.coefficients)),ngenes,fit$qr$rank,byrow = TRUE) fit$stdev.unscaled <- stdev.unscaled fit$df.residual <- rep.int(fit$df.residual,ngenes) dimnames(fit$stdev.unscaled) <- dimnames(fit$stdev.unscaled) <- dimnames(fit$coefficients) fit$pivot <- fit$qr$pivot return(fit) } for (i in 1:ngenes) { y <- as.vector(M[i,]) obs <- is.finite(y) if(sum(obs) > 0) { X <- design[obs,,drop=FALSE] y <- y[obs] if(is.null(weights)) out <- lm.fit(X,y) else { w <- as.vector(weights[i,obs]) out <- lm.wfit(X,y,w) } est <- !is.na(out$coef) beta[i,] <- out$coef stdev.unscaled[i,est] <- sqrt(diag(chol2inv(out$qr$qr,size=out$rank))) df.residual[i] <- out$df.residual if(df.residual[i] > 0) if(is.null(weights)) sigma[i] <- sqrt(sum(out$residuals^2)/out$df.residual) else sigma[i] <- sqrt(sum(w*out$residuals^2)/out$df.residual) } } QR <- qr(design) cov.coef <- chol2inv(QR$qr,size=QR$rank) est <- QR$pivot[1:QR$rank] dimnames(cov.coef) <- list(coef.names[est],coef.names[est]) list(coefficients=drop(beta),stdev.unscaled=drop(stdev.unscaled),sigma=sigma,df.residual=df.residual,cov.coefficients=cov.coef,pivot=QR$pivot) } mrlm <- function(M,design=NULL,ndups=1,spacing=1,weights=NULL,...) # Robustly fit linear model for each gene to a series of arrays # Gordon Smyth # 20 Mar 2002. Last revised 22 Feb 2007. { require(MASS) # need rlm.default M <- as.matrix(M) narrays <- ncol(M) if(is.null(design)) design <- matrix(1,narrays,1) design <- as.matrix(design) coef.names <- colnames(design) nbeta <- ncol(design) if(!is.null(weights)) { weights <- asMatrixWeights(weights,dim(M)) weights[weights <= 0] <- NA M[!is.finite(weights)] <- NA } if(ndups>1) { M <- unwrapdups(M,ndups=ndups,spacing=spacing) design <- design %x% rep(1,ndups) if(!is.null(weights)) weights <- unwrapdups(weights,ndups=ndups,spacing=spacing) } ngenes <- nrow(M) stdev.unscaled <- beta <- matrix(NA,ngenes,nbeta,dimnames=list(rownames(M),coef.names)) sigma <- rep(NA,ngenes) df.residual <- rep(0,ngenes) for (i in 1:ngenes) { y <- as.vector(M[i,]) obs <- is.finite(y) X <- design[obs,,drop=FALSE] y <- y[obs] if(is.null(weights)) w <- rep(1,length(y)) else w <- as.vector(weights[i,obs]) if(length(y) > nbeta) { out <- rlm(x=X,y=y,weights=w,...) beta[i,] <- coef(out) stdev.unscaled[i,] <- sqrt(diag(chol2inv(out$qr$qr))) df.residual[i] <- length(y) - out$rank if(df.residual[i] > 0) sigma[i] <- out$s } } QR <- qr(design) cov.coef <- chol2inv(QR$qr,size=QR$rank) est <- QR$pivot[1:QR$rank] dimnames(cov.coef) <- list(coef.names[est],coef.names[est]) list(coefficients=drop(beta),stdev.unscaled=drop(stdev.unscaled),sigma=sigma,df.residual=df.residual,cov.coefficients=cov.coef,pivot=QR$pivot) } gls.series <- function(M,design=NULL,ndups=2,spacing=1,block=NULL,correlation=NULL,weights=NULL,...) # Fit linear model for each gene to a series of microarrays. # Fit is by generalized least squares allowing for correlation between duplicate spots. # Gordon Smyth # 11 May 2002. Last revised 12 Dec 2010. { M <- as.matrix(M) narrays <- ncol(M) if(is.null(design)) design <- matrix(1,narrays,1) design <- as.matrix(design) if(nrow(design) != narrays) stop("Number of rows of design matrix does not match number of arrays") if(is.null(correlation)) correlation <- duplicateCorrelation(M,design=design,ndups=ndups,spacing=spacing,block=block,weights=weights,...)$consensus.correlation if(!is.null(weights)) { weights[is.na(weights)] <- 0 weights <- asMatrixWeights(weights,dim(M)) M[weights < 1e-15 ] <- NA weights[weights < 1e-15] <- NA } nbeta <- ncol(design) coef.names <- colnames(design) if(is.null(block)) { if(ndups<2) { warning("No duplicates: correlation between duplicates set to zero") ndups <- 1 correlation <- 0 } if(is.null(spacing)) spacing <- 1 cormatrix <- diag(rep(correlation,len=narrays),nrow=narrays,ncol=narrays) %x% array(1,c(ndups,ndups)) M <- unwrapdups(M,ndups=ndups,spacing=spacing) if(!is.null(weights)) weights <- unwrapdups(weights,ndups=ndups,spacing=spacing) design <- design %x% rep(1,ndups) colnames(design) <- coef.names } else { if(ndups>1) { stop("Cannot specify ndups>2 and non-null block argument") } else { ndups <- spacing <- 1 } block <- as.vector(block) if(length(block)!=narrays) stop("Length of block does not match number of arrays") ub <- unique(block) nblocks <- length(ub) Z <- matrix(block,narrays,nblocks)==matrix(ub,narrays,nblocks,byrow=TRUE) cormatrix <- Z%*%(correlation*t(Z)) } diag(cormatrix) <- 1 ngenes <- nrow(M) stdev.unscaled <- matrix(NA,ngenes,nbeta,dimnames=list(rownames(M),coef.names)) NoProbeWts <- !any(is.na(M)) && (is.null(weights) || !is.null(attr(weights,"arrayweights"))) if(NoProbeWts) { V <- cormatrix if(!is.null(weights)) { wrs <- 1/sqrt(weights[1,]) V <- wrs * t(wrs * t(V)) } cholV <- chol(V) y <- backsolve(cholV,t(M),transpose=TRUE) dimnames(y) <- rev(dimnames(M)) X <- backsolve(cholV,design,transpose=TRUE) dimnames(X) <- dimnames(design) fit <- lm.fit(X,y) if(fit$df.residual>0) fit$sigma <- sqrt(colMeans(fit$effects[-(1:fit$rank),,drop=FALSE]^2)) else fit$sigma <- rep(NA,ngenes) fit$fitted.values <- fit$residuals <- fit$effects <- NULL fit$coefficients <- t(fit$coefficients) fit$cov.coefficients <- chol2inv(fit$qr$qr,size=fit$qr$rank) est <- fit$qr$pivot[1:fit$qr$rank] dimnames(fit$cov.coefficients) <- list(coef.names[est],coef.names[est]) stdev.unscaled[,est] <- matrix(sqrt(diag(fit$cov.coefficients)),ngenes,fit$qr$rank,byrow = TRUE) fit$stdev.unscaled <- stdev.unscaled fit$df.residual <- rep.int(fit$df.residual,ngenes) dimnames(fit$stdev.unscaled) <- dimnames(fit$stdev.unscaled) <- dimnames(fit$coefficients) fit$pivot <- fit$qr$pivot fit$ndups <- ndups fit$spacing <- spacing fit$block <- block fit$correlation <- correlation return(fit) } beta <- stdev.unscaled sigma <- rep(NA,ngenes) df.residual <- rep(0,ngenes) for (i in 1:ngenes) { y <- drop(M[i,]) o <- is.finite(y) y <- y[o] n <- length(y) if(n > 0) { X <- design[o,,drop=FALSE] V <- cormatrix[o,o] if(!is.null(weights)) { wrs <- 1/sqrt(drop(weights[i,o])) V <- wrs * t(wrs * t(V)) } cholV <- chol(V) y <- backsolve(cholV,y,transpose=TRUE) if(all(X==0)) { df.residual[i] <- n sigma[i] <- sqrt( array(1/n,c(1,n)) %*% y^2 ) } else { X <- backsolve(cholV,X,transpose=TRUE) out <- lm.fit(X,y) est <- !is.na(out$coefficients) beta[i,] <- out$coefficients stdev.unscaled[i,est] <- sqrt(diag(chol2inv(out$qr$qr,size=out$rank))) df.residual[i] <- out$df.residual if(df.residual[i] > 0) sigma[i] <- sqrt( array(1/out$df.residual,c(1,n)) %*% out$residuals^2 ) } } } cholV <- chol(cormatrix) QR <- qr(backsolve(cholV,design,transpose=TRUE)) cov.coef <- chol2inv(QR$qr,size=QR$rank) est <- QR$pivot[1:QR$rank] dimnames(cov.coef) <- list(coef.names[est],coef.names[est]) list(coefficients=drop(beta),stdev.unscaled=drop(stdev.unscaled),sigma=sigma,df.residual=df.residual,ndups=ndups,spacing=spacing,block=block,correlation=correlation,cov.coefficients=cov.coef,pivot=QR$pivot) } is.fullrank <- function(x) # Check whether a numeric matrix has full column rank # Gordon Smyth # 18 August 2003. Last modified 9 March 2004. { x <- as.matrix(x) e <- eigen(crossprod(x),symmetric=TRUE,only.values=TRUE)$values e[1] > 0 && abs(e[length(e)]/e[1]) > 1e-13 } nonEstimable <- function(x) # Check whether a numeric matrix has full column rank # If not, return names of redundant columns # Gordon Smyth # 10 August 2004 { x <- as.matrix(x) p <- ncol(x) QR <- qr(x) if(QR$rank < p) { n <- colnames(x) if(is.null(n)) n <- as.character(1:p) notest <- n[QR$pivot[(QR$rank+1):p]] blank <- notest=="" if(any(blank)) notest[blank] <- as.character(((QR$rank+1):p)[blank]) return(notest) } else { return(NULL) } } fitted.MArrayLM <- function(object,design=object$design,...) # Fitted values from MArray linear model fit # Gordon Smyth # 29 November 2005 { object$coefficients %*% t(object$design) } residuals.MArrayLM <- function(object,y,...) # Residuals from MArray linear model fit # Gordon Smyth # 29 November 2005 { as.matrix(y) - fitted(object) } getEAWP <- function(object) # Given any microarray data object, extract basic information needed for # linear modelling. # Gordon Smyth # 9 March 2008. Last modified 9 Feb 2012. { y <- list() if(is(object,"list")) { # Method for MAList (classed or unclassed) or EList objects if(is(object,"EList")) { y$exprs <- as.matrix(object$E) y$Amean <- rowMeans(y$exprs,na.rm=TRUE) } else { y$printer <- object$printer y$exprs <- as.matrix(object$M) if(!is.null(object$A)) y$Amean <- rowMeans(as.matrix(object$A),na.rm=TRUE) } y$weights <- object$weights y$probes <- object$genes if(is.null(y$probes) && !is.null(rownames(y$exprs))) y$probes <- data.frame(ID=rownames(y$exprs),stringsAsFactors=FALSE) y$design <- object$design } else { if(is(object,"ExpressionSet")) { y$exprs <- exprs(object) if(length(object@featureData@data)) y$probes <- object@featureData@data else y$probes <- data.frame(ID=rownames(y$exprs),stringsAsFactors=FALSE) y$Amean <- rowMeans(y$exprs,na.rm=TRUE) } else { if(is(object,"PLMset")) { y$exprs <- object@chip.coefs if(length(y$exprs)==0) stop("chip.coefs has length zero") if(length(object@se.chip.coefs)) y$weights <- 1/pmax(object@se.chip.coefs,1e-5)^2 if(!is.null(rownames(y$exprs))) y$probes <- data.frame(ID=rownames(y$exprs),stringsAsFactors=FALSE) y$Amean <- rowMeans(y$exprs,na.rm=TRUE) } else { if(is(object,"marrayNorm")) { y$exprs <- object@maM if(length(object@maW)) y$weights <- object@maW if(length(object@maGnames@maInfo)) { y$probes <- object@maGnames@maInfo attr(y$probes, "Notes") <- object@maGnames@maNotes } if(length(object@maA)) y$Amean <- rowMeans(object@maA,na.rm=TRUE) } else { # Default method for matrices, data.frames, vsn objects etc. y$exprs <- as.matrix(object) if(!is.null(rownames(y$exprs))) y$probes <- data.frame(ID=rownames(y$exprs),stringsAsFactors=FALSE) # If exprs are positive, assume they are log-intensities rather than log-ratios if(all(y$exprs>=0,na.rm=TRUE)) y$Amean <- rowMeans(y$exprs,na.rm=TRUE) }}}} if(mode(y$exprs) != "numeric") stop("Data object doesn't contain numeric expression values") y } limma/R/arrayWeights.R0000644007451300017500000001576212127125240015014 0ustar charlescharlesarrayWeights <- function(object, design=NULL, weights=NULL, method="genebygene", maxiter=50, tol = 1e-10, trace = FALSE) # Compute array quality weights # Matt Ritchie # 7 Feb 2005. Last revised 16 Jan 2008. # Gordon Smyth simplified argument checking to use getEAWP, 9 Mar 2008. { # Check arguments y <- getEAWP(object) if(is.null(design)) design <- matrix(1,ncol(y$exprs),1) else design <- as.matrix(design) if(mode(design) != "numeric") stop("design must be a numeric matrix") ne <- nonEstimable(design) if(!is.null(ne)) cat("Coefficients not estimable:",paste(ne,collapse=" "),"\n") if(missing(weights) && !is.null(y$weights)) weights <- y$weights method <- match.arg(method,c("genebygene","reml")) M <- y$exprs p <- ncol(design) QR <- qr(design) nparams <- QR$rank # ncol(design) ngenes <- nrow(M) narrays <- ncol(M) if(narrays < 3) stop("too few arrays") if(ngenes < narrays) stop("too few probes") # Set up design matrix for array variance model Z <- contr.sum(narrays) # Intialise array variances to zero arraygammas <- rep(0, (narrays-1)) switch(method, genebygene = { # Estimate array variances via gene-by-gene update algorithm Zinfo <- 10*(narrays-nparams)/narrays*crossprod(Z, Z) for(i in 1:ngenes) { if(!all(is.finite(arraygammas))) stop("convergence problem at gene ", i, ": array weights not estimable") vary <- exp(Z%*%arraygammas) if(!is.null(weights)) { # combine spot weights with running weights if(max(weights[i,], na.rm=TRUE) > 1) { weights[i,] <- weights[i,]/max(weights[i,]) } w <- as.vector(1/vary*weights[i,]) } else { w <- as.vector(1/vary) } y <- as.vector(M[i,]) obs <- is.finite(y) & w!=0 if (sum(obs) > 1) { if(sum(obs) == narrays) { X <- design } else { # remove missing/infinite values X <- design[obs, , drop = FALSE] y <- y[obs] vary <- vary[obs] Z2 <- Z[obs,] } out <- lm.wfit(X, y, w[obs]) d <- rep(0, narrays) d[obs] <- w[obs]*out$residuals^2 s2 <- sum(d[obs])/out$df.residual Q <- qr.Q(out$qr) if(ncol(Q)!=out$rank) Q <- Q[,-((out$rank+1):ncol(Q)),drop=FALSE] # if(p!=out$rank) { # Q <- qr.Q(qr(X[,-cols[out$qr$pivot[(out$qr$rank + 1):p,drop=FALSE]]])) # Q <- qr.Q(out$qr) # Q <- Q[,-cols[(out$rank+1):ncol(Q)],drop=FALSE] # } # else # Q <- qr.Q(out$qr) h <- rep(1, narrays) h[obs] <- rowSums(Q^2) Agam <- crossprod(Z, (1-h)*Z) Agam.del <- crossprod(t(rep(h[narrays], narrays-1)-h[1:(length(narrays)-1)])) Agene.gam <- (Agam - 1/out$df.residual*Agam.del) # 1/(narrays-nparams) if(is.finite(sum(Agene.gam)) && sum(obs) == narrays) { Zinfo <- Zinfo + Agene.gam R <- chol(Zinfo) Zinfoinv <- chol2inv(R) zd <- d/s2 - 1 + h Zzd <- crossprod(Z, zd) gammas.iter <- Zinfoinv%*%Zzd arraygammas <- arraygammas + gammas.iter } if(is.finite(sum(Agene.gam)) && sum(obs) < narrays && sum(obs) > 2) { Zinfo <- Zinfo + Agene.gam A1 <- (diag(1, sum(obs))-1/sum(obs)*matrix(1, sum(obs), sum(obs)))%*%Z2 A1 <- A1[-sum(obs),] # remove last row R <- chol(Zinfo) Zinfoinv <- chol2inv(R) zd <- d/s2 - 1 + h Zzd <- A1%*%crossprod(Z, zd) Zinfoinv.A1 <- A1%*%Zinfoinv%*%t(A1) alphas.old <- A1%*%arraygammas alphas.iter <- Zinfoinv.A1%*%Zzd alphas.new <- alphas.old + alphas.iter Us <- rbind(diag(1, sum(obs)-1), -1) Usalphas <- Us%*%(alphas.new-alphas.old) Usgammas <- Z%*%arraygammas Usgammas[obs] <- Usgammas[obs] + Usalphas arraygammas <- Usgammas[1:(narrays-1)] } if(trace && (i==1 || i%%1001==0)) { x2 <- crossprod(Zzd, gammas.iter) / narrays cat("Iter =", i, " X2 =", x2, " Array gammas", arraygammas, "\n") } } } }, reml = { # Estimate array variances via reml # const <- narrays * log(2 * pi) iter <- 0 dev <- 0 repeat { # devold <- dev # dev <- 0 iter <- iter + 1 zd <- matrix(0, narrays, 1) sum1minush <- matrix(0, narrays, 1) K <- matrix(0, ngenes, narrays) for(i in 1:ngenes) { vary <- exp(Z%*%arraygammas) if(!is.null(weights)) { # combine spot weights with running weights if(max(weights[i,], na.rm=TRUE) > 1) { weights[i,] <- weights[i,]/max(weights[i,]) } w <- as.vector(1/vary*weights[i,]) } else { w <- as.vector(1/vary) } y <- as.vector(M[i,]) obs <- is.finite(y) & w!=0 n <- sum(obs) if (n > 0) { if(n == narrays) { X <- design #Z2 <- Z } else { # remove missing/infinite values X <- design[obs, , drop = FALSE] y <- y[obs] vary <- vary[obs] w <- w[obs] const <- sum(obs) * log(2 * pi) } # cat(i) out <- lm.wfit(X, y, w) d <- rep(0, narrays) d[obs] <- w*out$residuals^2 s2 <- sum(d[obs])/out$df.residual Q <- qr.Q(out$qr) if(ncol(Q)!=out$rank) Q <- Q[,-((out$rank+1):ncol(Q)),drop=FALSE] # if(p!=out$rank) # Q <- qr.Q(qr(X[,-cols[out$qr$pivot[(out$qr$rank + 1):p,drop=FALSE]]])) # else # Q <- qr.Q(out$qr) h <- rowSums(Q^2) zd[obs] <- zd[obs] + d[obs]/s2 - 1 + h sum1minush[obs,1] <- sum1minush[obs,1] + 1-h K[i,][obs] <- as.vector(h[n]-h) # dev <- dev + sum(d[obs]/vary) + sum(log(vary)) + const + 2 * log(prod(abs(diag(out$qr$qr)))) } } Zzd <- crossprod(Z, zd) Zinfo <- diag(sum1minush[1:(narrays-1)]) + sum1minush[narrays] - crossprod(K[,-narrays])/out$df.residual #(narrays-nparams) R <- chol(Zinfo) Zinfoinv <- chol2inv(R) gammas.iter <- Zinfoinv%*%Zzd arraygammas <- arraygammas + gammas.iter # arrayw <- drop(exp(Z %*% (-arraygammas))) x2 <- crossprod(Zzd, gammas.iter) / narrays if(trace) cat("Iter =", iter, " X2 =", x2, " Array gammas", arraygammas, "\n") if(!all(is.finite(arraygammas))) stop("convergence problem at iteration ", iter, ": array weights not estimable") # if (dev < devold - 1e-50) # break if (x2 < tol) break if (iter == maxiter) { warning("Maximum iterations ", maxiter, " reached", sep="") break } } }) # matrix(rep(1/exp(Z%*%arraygammas), each=ngenes), ngenes, narrays) drop(exp(Z %*% (-arraygammas))) } limma/R/squeezeVar.R0000644007451300017500000001131512127125240014463 0ustar charlescharles# EMPIRICAL BAYES SQUEEZING OF VARIANCES squeezeVar <- function(var, df, covariate=NULL, robust=FALSE, winsor.tail.p=c(0.05,0.1)) # Empirical Bayes posterior variances # Gordon Smyth # 2 March 2004. Last modified 29 Nov 2012. { n <- length(var) if(n == 0) stop("var is empty") if(n == 1) return(list(var.post=var,var.prior=var,df.prior=0)) if(length(df)==1) { df <- rep.int(df,n) } else { if(length(df) != n) stop("lengths differ") } if(robust) fit <- fitFDistRobustly(var, df1=df, covariate=covariate, winsor.tail.p=winsor.tail.p) else fit <- fitFDist(var, df1=df, covariate=covariate) var.prior <- fit$scale df.prior <- fit$df2.shrunk if(is.null(df.prior)) df.prior <- fit$df2 if(is.null(df.prior) || any(is.na(df.prior))) stop("Could not estimate prior df") df.total <- df + df.prior var[df==0] <- 0 # guard against missing or infinite values Infdf <- df.prior==Inf if(any(Infdf)) { var.post <- rep(var.prior,length.out=n) i <- which(!Infdf) if(length(i)) var.post[i] <- (df[i]*var[i] + df.prior[i]*var.prior[i]) / df.total[i] } else { var.post <- (df*var + df.prior*var.prior) / df.total } list(df.prior=df.prior,var.prior=var.prior,var.post=var.post) } fitFDist <- function(x,df1,covariate=NULL) # Moment estimation of the parameters of a scaled F-distribution # The first degrees of freedom are given # Gordon Smyth and Belinda Phipson # 8 Sept 2002. Last revised 27 Oct 2012. { # Check covariate if(!is.null(covariate)) { if(length(covariate) != length(x)) stop("covariate and x must be of same length") if(any(is.na(covariate))) stop("NA covariate values not allowed") isfin <- is.finite(covariate) if(!all(isfin)) { if(!any(isfin)) covariate <- sign(covariate) else { r <- range(covariate[isfin]) covariate[covariate == -Inf] <- r[1]-1 covariate[covariate == Inf] <- r[2]+1 } } splinedf <- min(4,length(unique(covariate))) if(splinedf < 2) covariate <- NULL } # Remove missing or infinite values and zero degrees of freedom ok <- is.finite(x) & is.finite(df1) & (x > -1e-15) & (df1 > 1e-15) notallok <- !all(ok) if(notallok) { x <- x[ok] df1 <- df1[ok] if(!is.null(covariate)) { covariate2 <- covariate[!ok] covariate <- covariate[ok] } } n <- length(x) if(n==0) return(list(scale=NA,df2=NA)) # Avoid exactly zero values x <- pmax(x,0) m <- median(x) if(m==0) { warning("More than half of residual variances are exactly zero: eBayes unreliable") m <- 1 } else { if(any(x==0)) warning("Zero sample variances detected, have been offset",call.=FALSE) } x <- pmax(x, 1e-5 * m) # Better to work on with log(F) z <- log(x) e <- z-digamma(df1/2)+log(df1/2) if(is.null(covariate)) { emean <- mean(e) evar <- sum((e-emean)^2)/(n-1) } else { require(splines) design <- try(ns(covariate,df=splinedf,intercept=TRUE),silent=TRUE) if(is(design,"try-error")) stop("Problem with covariate") fit <- lm.fit(design,e) if(notallok) { design2 <- predict(design,newx=covariate2) emean <- rep.int(0,n+length(covariate2)) emean[ok] <- fit$fitted emean[!ok] <- design2 %*% fit$coefficients } else { emean <- fit$fitted } evar <- mean(fit$residuals[-(1:fit$rank)]^2) } evar <- evar - mean(trigamma(df1/2)) if(evar > 0) { df2 <- 2*trigammaInverse(evar) s20 <- exp(emean+digamma(df2/2)-log(df2/2)) } else { df2 <- Inf s20 <- exp(emean) } list(scale=s20,df2=df2) } trigammaInverse <- function(x) { # Solve trigamma(y) = x for y # Gordon Smyth # 8 Sept 2002. Last revised 12 March 2004. # Non-numeric or zero length input if(!is.numeric(x)) stop("Non-numeric argument to mathematical function") if(length(x)==0) return(numeric(0)) # Treat out-of-range values as special cases omit <- is.na(x) if(any(omit)) { y <- x if(any(!omit)) y[!omit] <- Recall(x[!omit]) return(y) } omit <- (x < 0) if(any(omit)) { y <- x y[omit] <- NaN warning("NaNs produced") if(any(!omit)) y[!omit] <- Recall(x[!omit]) return(y) } omit <- (x > 1e7) if(any(omit)) { y <- x y[omit] <- 1/sqrt(x[omit]) if(any(!omit)) y[!omit] <- Recall(x[!omit]) return(y) } omit <- (x < 1e-6) if(any(omit)) { y <- x y[omit] <- 1/x[omit] if(any(!omit)) y[!omit] <- Recall(x[!omit]) return(y) } # Newton's method # 1/trigamma(y) is convex, nearly linear and strictly > y-0.5, # so iteration to solve 1/x = 1/trigamma is monotonically convergent y <- 0.5+1/x iter <- 0 repeat { iter <- iter+1 tri <- trigamma(y) dif <- tri*(1-tri/x)/psigamma(y,deriv=2) y <- y+dif if(max(-dif/y) < 1e-8) break if(iter > 50) { warning("Iteration limit exceeded") break } } y } limma/R/vooma.R0000644007451300017500000001063212127125240013453 0ustar charlescharlesvooma <- function(y,design=NULL,correlation,block=NULL,plot=FALSE,span=NULL) # Linear modelling of microarray data mean-variance modelling at the observational level. # Creates an EList object for entry to lmFit() etc in the limma pipeline. # Gordon Smyth and Charity Law # Created 31 July 2012. Last modified 5 Aug 2012. { # Check y if(!is(y,"EList")) y <- new("EList",list(E=as.matrix(y))) narrays <- ncol(y) ngenes <- nrow(y) # Check design if(is.null(design)) design <- y$design if(is.null(design)) { design <- matrix(1,narrays,1) rownames(design) <- colnames(y) colnames(design) <- "GrandMean" } # Fit linear model if(is.null(block)) { fit <- lm.fit(design,t(y$E)) mu <- fit$fitted.values } else { block <- as.vector(block) if(length(block)!=narrays) stop("Length of block does not match number of arrays") ub <- unique(block) nblocks <- length(ub) Z <- matrix(block,narrays,nblocks)==matrix(ub,narrays,nblocks,byrow=TRUE) cormatrix <- Z%*%(correlation*t(Z)) diag(cormatrix) <- 1 cholV <- chol(cormatrix) z <- backsolve(cholV,t(y$E),transpose=TRUE) X <- backsolve(cholV,design,transpose=TRUE) fit <- lm.fit(X,z) mu <- crossprod(cholV,fit$fitted.values) } s2 <- colMeans(fit$effects[-(1:fit$rank),,drop=FALSE]^2) # Fit lowess trend to sqrt-standard-deviations by ave log intensity sx <- rowMeans(y$E) sy <- sqrt(sqrt(s2)) if(is.null(span)) if(ngenes<=10) span <- 1 else span <- 0.3+0.7*(10/ngenes)^0.5 l <- lowess(sx,sy,f=span) if(plot) { plot(sx,sy,xlab="Average log2 expression",ylab="Sqrt( standard deviation )",pch=16,cex=0.25) title("voom: Mean-variance trend") lines(l,col="red") } # Make interpolating rule f <- approxfun(l, rule=2) # Apply trend to individual observations w <- 1/f(t(mu))^4 dim(w) <- dim(y) colnames(w) <- colnames(y) rownames(w) <- rownames(y) # Output y$meanvar.trend <- list(x=sx,y=sy) y$weights <- w y$design <- design y$span <- span y } voomaByGroup <- function(y,group,design=NULL,correlation,block=NULL,plot=FALSE,span=NULL,col=NULL) # Voom by group # Linear modelling of microarray data mean-variance modelling at the observational level by fitting group-specific trends. # Creates an EList object for entry to lmFit() etc in the limma pipeline. # Charity Law and Gordon Smyth # Created 13 February2013. { # Check y if(!is(y,"EList")) y <- new("EList",list(E=as.matrix(y))) # Check group group <- as.factor(group) # Check design if(is.null(design)) design <- y$design if(is.null(design)) { design <- model.matrix(~group) colnames(design) <- c("Int", levels(group)[-1]) } # Check color if(is.null(col)) col <- rainbow(nlevels(group)) color <- rep(col,length=nlevels(group)) w <- matrix(nrow=nrow(y), ncol=ncol(y)) colnames(w) <- colnames(y) rownames(w) <- rownames(y) sx <- matrix(nrow=nrow(y), ncol=nlevels(group)) colnames(sx) <- levels(group) rownames(sx) <- rownames(y) sy <- matrix(nrow=nrow(y), ncol=nlevels(group)) colnames(sy) <- levels(group) rownames(sy) <- rownames(y) for (lev in 1:nlevels(group)) { i <- group==levels(group)[lev] yi <- y[,i] designi <- design[i,,drop=FALSE] if(!is.null(block)) { blocki <- block[i] voomi <- vooma(y=yi,design=designi,correlation=correlation, block=blocki, plot=FALSE, span=span) } else { voomi <- vooma(y=yi,design=designi,plot=FALSE,span=span) } w[,i] <- voomi$weights sx[,lev] <- voomi$meanvar.trend$x sy[,lev] <- voomi$meanvar.trend$y } span <- voomi$span # Voom plot if(plot) { lev <- 1 colori <- color[lev] colori.transparent <- paste(rgb(col2rgb(colori)[1], col2rgb(colori)[2], col2rgb(colori)[3], maxColorValue=255), "10", sep="") plot(sx[,lev],sy[,lev],xlab="Average log2 expression",ylab="Sqrt( standard deviation )", xlim=c(min(as.vector(sx))*0.99, max(as.vector(sx))*1.01),ylim=c(min(as.vector(sy))*0.99, max(as.vector(sy))*1.01),pch=16, cex=0.25, col=colori.transparent) title("voom: Mean-variance trend") l <- lowess(sx[,lev],sy[,lev],f=span) lines(l,col=colori) for (lev in 2:nlevels(group)) { colori <- color[lev] colori.transparent <- paste(rgb(col2rgb(colori)[1], col2rgb(colori)[2], col2rgb(colori)[3], maxColorValue=255), "10", sep="") points(sx[,lev], sy[,lev], pch=15, cex=0.25, col=colori.transparent) l <- lowess(sx[,lev],sy[,lev],f=span) lines(l,col=colori) } legend("topright", levels(group), col=color, lty=1) } # Output y$meanvar.trend <- list(x=sx,y=sy) y$weights <- w y$design <- design y$span <- span y } limma/R/qqt.R0000644007451300017500000000151712127125240013141 0ustar charlescharlesqqt <- function(y,df=Inf,ylim=range(y),main="Student's t Q-Q Plot",xlab="Theoretical Quantiles",ylab="Sample Quantiles",plot.it=TRUE,...) # Student's t probability plot # Gordon Smyth # 3 Oct 2002 { y <- y[!is.na(y)] if(0 == (n <- length(y))) stop("y is empty") x <- qt(ppoints(n),df=df)[order(order(y))] if (plot.it) plot(x,y,main=main,xlab=xlab,ylab=ylab,ylim=ylim,...) invisible(list(x=x,y=y)) } qqf <- function(y, df1, df2, ylim=range(y), main="F Distribution Q-Q Plot", xlab="Theoretical Quantiles", ylab="Sample Quantiles", plot.it=TRUE,...) # F probability plot # Belinda Phipson # 14 May 2012 { y <- y[!is.na(y)] if(0 == (n <- length(y))) stop("y is empty") x <- qf(ppoints(n),df1=df1,df2=df2)[order(order(y))] if (plot.it) plot(x,y,main=main,xlab=xlab,ylab=ylab,ylim=ylim,...) invisible(list(x=x,y=y)) } limma/R/avearrays.R0000644007451300017500000000344412127125240014332 0ustar charlescharles# avearrays.R avearrays <- function(x,ID=NULL,weights=NULL) UseMethod("avearrays") # 24 Sept 2010 avearrays.default <- function(x,ID=colnames(x),weights=NULL) # Average over technical replicate columns, for matrices # Gordon Smyth # Created 24 Sept 2010. Last modified 1 Dec 2010. { if(is.null(x)) return(NULL) if(is.null(ID)) stop("No sample IDs") x <- as.matrix(x) ID <- as.character(ID) if(mode(x)=="character") { d <- duplicated(ID) if(!any(d)) return(x) y <- x[,!d,drop=FALSE] return(y) } ID <- factor(ID,levels=unique(ID)) if(is.null(weights)) { y <- t(rowsum(t(x),ID,reorder=FALSE,na.rm=TRUE)) n <- t(rowsum(t(1L-is.na(x)),ID,reorder=FALSE,na.rm=TRUE)) y <- y/n } else { design <- model.matrix(~0+ID) y <- lmFit(x,design,weights=weights)$coefficients } y } avearrays.MAList <- function(x,ID=colnames(x),weights=x$weights) # Average over technical replicate columns for MAList objects # Gordon Smyth # 24 Sept 2010. Last modified 24 Sep 2010. { ID <- as.character(ID) d <- duplicated(ID) if(!any(d)) return(x) y <- x[,!d] y$M <- avearrays(x$M,ID,weights=weights) y$A <- avearrays(x$A,ID,weights=weights) y$weights <- avearrays(x$weights,ID,weights=weights) other <- names(x$other) for (a in other) y$other[[a]] <- avearrays(x$other[[a]],ID=ID,weights=weights) y } avearrays.EList <- function(x,ID=colnames(x),weights=x$weights) # Average over irregular replicate columns for EList objects # Gordon Smyth # 24 Sept 2010. Last modified 27 Oct 2010. { d <- duplicated(ID) if(!any(d)) return(x) y <- x[,!d] y$E <- avearrays(x$E,ID,weights=weights) y$weights <- avearrays(x$weights,ID,weights=weights) other <- names(x$other) for (a in other) y$other[[a]] <- avearrays(x$other[[a]],ID=ID,weights=weights) y } limma/R/arrayWeightsSimple.R0000644007451300017500000000506012127125240016154 0ustar charlescharlesarrayWeightsQuick <- function(y, fit) # Compute approximate array quality weights # Gordon Smyth # 25 Oct 2004. Last revised 28 Oct 2004. { if(!is.null(fit$weights)) warning("spot quality weights found but not taken into account") res <- as.matrix(y)- fit$coef %*% t(fit$design) h <- hat(fit$design, intercept=FALSE) mures2 <- fit$sigma^2 %*% array(1-h,c(1,length(h))) 1/colMeans(res*res/mures2,na.rm=TRUE) } arrayWeightsSimple <- function(object,design=NULL,maxiter=100,tol=1e-6,maxratio=100,trace=FALSE) # Array weights by REML # Assumes no spot weights # Any probes with missing values are removed # Gordon Smyth, 13 Dec 2005 # Last revised 20 May 2009. { M <- as.matrix(object) allfin <- apply(is.finite(M),1,all) if(!all(allfin)) { nrowna <- sum(!allfin) M <- M[allfin,,drop=FALSE] warning(paste(as.integer(nrowna),"rows with missing values removed")) } ngenes <- nrow(M) narrays <- ncol(M) if(narrays < 3) stop("too few arrays") if(ngenes < narrays) stop("too few probes") if(is.null(design)) design <- matrix(1,narrays,1) p <- ncol(design) # For use with convergence criterion # The sqrt is used to reduce iterations with very large datasets m <- sqrt(ngenes)/narrays Z1 <- contr.sum(narrays) Z <- cbind(1,Z1) # Starting values gam <- rep(0,narrays-1) w <- drop(exp(Z1 %*% (-gam))) if(trace) cat("iter convcrit w\n") iter <- 0 p2 <- p*(p+1)/2 Q2 <- array(0,c(narrays,p2)) repeat { iter <- iter+1 fitm <- lm.wfit(design, t(M), w) Q <- qr.qy(fitm$qr,diag(1,nrow=narrays,ncol=p)) j0 <- 0 for (k in 0:(p-1)) { Q2[,(j0+1):(j0+p-k)] <- Q[,1:(p-k)]*Q[,(k + 1):p] j0 <- j0 + p - k } if(p > 1) Q2[,(p+1):p2] <- sqrt(2)*Q2[,(p+1):p2] h <- rowSums(Q2[,1:p,drop=FALSE]) info <- crossprod(Z,(1-2*h)*Z) + crossprod(crossprod(Q2,Z)) info1 <- info[-1,-1,drop=FALSE] - (info[-1,1,drop=FALSE]/info[1,1]) %*% info[1,-1,drop=FALSE] s2 <- colSums(fitm$effects[(fitm$rank+1):narrays,]^2) / fitm$df.residual fitvald <- matrix(1/w,narrays,1)%*%s2 dl1 <- crossprod(Z1, rowMeans(fitm$residuals^2/fitvald - (1-h)) ) # print(cbind(info1,dl1)) # cat(iter,drop(crossprod(ngenes*dl1)),"\n") gamstep <- solve(info1,dl1) gam <- gam + gamstep w <- drop(exp(Z1 %*% (-gam))) convcrit <- m*crossprod(dl1,gamstep) if(trace) cat(iter,convcrit,w,"\n") if(is.na(convcrit)) stop("tol not achievable, try trace or a larger tol value") if(convcrit < tol) break if(max(w)/min(w) > maxratio) break if(iter==maxiter) { warning("iteration limit reached") break } } w } limma/R/poolvar.R0000755007451300017500000000076012127125240014020 0ustar charlescharles# POOL VAR poolVar <- function(var, df=n-1, multiplier=1/n, n) # Pool sample variances for unequal variances # as for Welch's test # Gordon Smyth # 22 Jan 2004. { s2 <- as.vector(var) df <- as.vector(df) m <- as.vector(multiplier) if(any(m<0)) stop("Multipliers must be non-negative") if(all(m==0)) return(list(var=0,df=0,multiplier=0)) sm <- sum(m) m <- m/sm out <- list(var = sum(m * s2)) out$df <- out$var^2 / sum(m^2 * s2^2 / df) out$multiplier <- sm out } limma/R/classes.R0000755007451300017500000001677412127125240014007 0ustar charlescharles# CLASSES.R setClass("RGList", # Class to hold initial read-in two-color data representation("list") ) setClass("MAList", # Class to hold normalized, rotated two-color data representation("list") ) setClass("EListRaw", # Class to hold one channel data on raw scale representation("list") ) setClass("EList", # Class to hold one channel data on log scale representation("list") ) setClass("MArrayLM", # Linear model fit representation("list") ) printHead <- function(x) # Print leading 5 elements or rows of atomic object # Gordon Smyth # May 2003. Last modified 14 April 2009. { if(is.atomic(x)) { d <- dim(x) if(length(d)<2) which <- "OneD" if(length(d)==2) which <- "TwoD" if(length(d)>2) which <- "Array" } else { if(inherits(x,"data.frame")) { d <- dim(x) which <- "TwoD" } else { if(is.call(x)) which <- "Call" else { if(is.recursive(x)) which <- "Recursive" else which <- "Other" } } } switch(which, OneD={ n <- length(x) if(n > 20) { print(x[1:5]) cat(n-5,"more elements ...\n") } else print(x) }, TwoD={ n <- d[1] if(n > 10) { print(x[1:5,]) cat(n-5,"more rows ...\n") } else print(x) }, Array={ n <- d[1] if(n > 10) { dn <- dimnames(x) dim(x) <- c(d[1],prod(d[-1])) x <- x[1:5,] dim(x) <- c(5,d[-1]) if(!is.null(dn[[1]])) dn[[1]] <- dn[[1]][1:5] dimnames(x) <- dn print(x) cat(n-5,"more rows ...\n") } else print(x) }, Recursive={ n <- length(x) if(n) { i <- names(x) if(is.null(i)) i <- seq_len(n) for (what in i) { y <- x[[what]] cat("$",what,"\n",sep="") Recall(y) cat("\n") } } }, Call=,Other=print(x) ) } setClass("LargeDataObject") setIs("RGList","LargeDataObject") setIs("MAList","LargeDataObject") setIs("EListRaw","LargeDataObject") setIs("EList","LargeDataObject") setIs("MArrayLM","LargeDataObject") setMethod("show","LargeDataObject", # Print and show method large data objects # Gordon Smyth # May 2003 function(object) { cat("An object of class \"",class(object),"\"\n",sep="") for (what in names(object)) { x <- object[[what]] cat("$",what,"\n",sep="") printHead(x) cat("\n") } for (what in setdiff(slotNames(object),".Data")) { x <- slot(object,what) if(length(x) > 0) { cat("@",what,"\n",sep="") printHead(x) cat("\n") } } }) dim.RGList <- function(x) if(is.null(x$R)) c(0,0) else dim(as.matrix(x$R)) dim.MAList <- function(x) if(is.null(x$M)) c(0,0) else dim(as.matrix(x$M)) dim.EListRaw <- dim.EList <- function(x) if(is.null(x$E)) c(0,0) else dim(as.matrix(x$E)) dim.MArrayLM <- function(x) if(is.null(x$coefficients)) c(0,0) else dim(as.matrix(x$coefficients)) length.RGList <- length.MAList <- length.EListRaw <- length.EList <- length.MArrayLM <- function(x) prod(dim(x)) dimnames.RGList <- function(x) dimnames(x$R) dimnames.MAList <- function(x) dimnames(x$M) dimnames.EListRaw <- dimnames.EList <- function(x) dimnames(x$E) dimnames.MArrayLM <- function(x) dimnames(x$coefficients) .setdimnames <- function(x, value) # Dimension names for RGList-like objects # Gordon Smyth # 17 Dec 2005. Last modified 23 March 2009. { exprmatrices <- c("R","G","Rb","Gb","M","A","E","weights") for (a in exprmatrices) if(!is.null(x[[a]])) dimnames(x[[a]]) <- value for(a in names(x$other)) dimnames(x$other[[a]]) <- value if(!is.null(x$targets)) row.names(x$targets) <- value[[2]] if(!is.null(x$design)) rownames(x$design) <- value[[2]] x } #assign("dimnames<-.RGList",.setdimnames) #assign("dimnames<-.MAList",.setdimnames) "dimnames<-.RGList" <- .setdimnames "dimnames<-.MAList" <- .setdimnames "dimnames<-.EListRaw" <- "dimnames<-.EList" <- .setdimnames summary.MArrayLM <- summary.MAList <- summary.RGList <- summary.EListRaw <- summary.EList <- function(object,...) summary(unclass(object)) as.MAList <- function(object) { # Convert marrayNorm object to MAList # Gordon Smyth # 20 Sep 2003. Last modified 20 Dec 2003. MA <- new("MAList") ifposlen <- function(x) if(length(x)) return(x) else return(NULL) MA$A <- ifposlen(object@maA) MA$M <- ifposlen(object@maM) MA$weights <- ifposlen(object@maW) MA$printer$ngrid.r <- ifposlen(object@maLayout@maNgr) MA$printer$ngrid.c <- ifposlen(object@maLayout@maNgc) MA$printer$nspot.r <- ifposlen(object@maLayout@maNsr) MA$printer$nspot.c <- ifposlen(object@maLayout@maNsc) MA$printer$notes <- ifposlen(object@maLayout@maNotes) MA$genes <- ifposlen(object@maGnames@maInfo) MA$genes$Labels <- ifposlen(object@maGnames@maLabels) attr(MA$genes,"notes") <- ifposlen(object@maGnames@maNotes) MA$genes$Sub <- ifposlen(object@maLayout@maSub) MA$genes$Plate <- ifposlen(object@maLayout@maPlate) MA$genes$Controls <- ifposlen(object@maLayout@maControls) MA$targets <- ifposlen(object@maTargets@maInfo) MA$targets$Labels <- ifposlen(object@maTargets@maLabels) MA$notes <- ifposlen(object@maNotes) MA$maNormCall <- ifposlen(object@maNormCall) MA } # Gordon Smyth, 28 Oct 2004, 23 March 2009 as.matrix.RGList <- function(x,...) normalizeWithinArrays(x,method="none")$M as.matrix.MAList <- function(x,...) as.matrix(x$M) as.matrix.EListRaw <- as.matrix.EList <- function(x,...) as.matrix(x$E) as.matrix.MArrayLM <- function(x,...) x$coefficients as.matrix.marrayNorm <- function(x,...) x@maM # 13 July 2006 as.matrix.PLMset <- function(x,...) x@chip.coefs # 19 Dec 2006, 18 May 2007 as.matrix.ExpressionSet <- as.matrix.LumiBatch <- function(x,...) env=x@assayData[["exprs"]] # 16 Sep 2007 as.matrix.vsn <- function(x,...) x@hx as.data.frame.MAList <- function(x, row.names = NULL, optional = FALSE, ...) # Convert MAList object to data.frame # Gordon Smyth # 10 Dec 2009. { if(is.null(row.names) && !is.null(rownames(x$M))) row.names <- makeUnique(rownames(x$M)) if(is.null(x$genes)) { y <- as.data.frame(x$M,row.names=row.names,check.names=FALSE) } else { if(is.vector(x$genes)) x$genes <- data.frame(ID=x$genes,stringsAsFactors=FALSE) y <- data.frame(x$genes,x$M,row.names=row.names,check.names=FALSE,stringsAsFactors=FALSE) } y } as.data.frame.EList <- as.data.frame.EListRaw <- function(x, row.names = NULL, optional = FALSE, ...) # Convert EList object to data.frame # Gordon Smyth # 11 Dec 2009. { if(is.null(row.names) && !is.null(rownames(x$E))) row.names <- makeUnique(rownames(x$E)) if(is.null(x$genes)) { y <- as.data.frame(x$E,row.names=row.names,check.names=FALSE) } else { if(is.vector(x$genes)) x$genes <- data.frame(ID=x$genes,stringsAsFactors=FALSE) y <- data.frame(x$genes,x$E,row.names=row.names,check.names=FALSE,stringsAsFactors=FALSE) } y } as.data.frame.MArrayLM <- function(x, row.names = NULL, optional = FALSE, ...) # Convert MArrayLM object to data.frame # Gordon Smyth # 6 April 2005. Last modified 13 Jan 2006. { x <- unclass(x) if(is.null(x$coefficients)) { warning("NULL coefficients, returning empty data.frame") return(data.frame()) } cn <- names(x) nprobes <- NROW(x$coefficients) ncoef <- NCOL(x$coefficients) include.comp <- cn[unlist(lapply(x,NROW))==nprobes] other.comp <- setdiff(names(x),include.comp) if(length(other.comp)) for (a in other.comp) x[[a]] <- NULL # coef.comp <- c("coefficients","stdev.unscaled","t","p.value","lods") # for (a in coef.comp) if(!is.null(x[[a]]) && NCOL(x[[a]])==1) colnames(x[[a]]) <- paste(a,colnames(x[[a]]),sep=".") if(ncoef==1) x <- lapply(x,drop) as.data.frame(x,row.names=row.names,optional=optional) } limma/R/read-imagene.R0000644007451300017500000001007712127125240014653 0ustar charlescharlesread.imagene <- function(files,path=NULL,ext=NULL,names=NULL,columns=NULL,other.columns=NULL,wt.fun=NULL,verbose=TRUE,sep="\t",quote="\"",...) { # Extracts an RG list from a series of Imagene analysis output files. # Imagene requires special treatment because red and green channel # intensities are in different files. # Gordon Smyth # 14 Aug 2003. Last modified 30 Dec 2006. if(is.null(dim(files))) { if(length(files)%%2==0) files <- matrix(files, ncol=2, byrow=TRUE) else stop("Odd number of files: should be two data files for each array") } else { files <- as.matrix(files) if(ncol(files) != 2) stop("Need a two column matrix of file names") } if(!is.null(ext)) files <- array(paste(files,ext,sep="."),dim(files)) narrays <- nrow(files) if(is.null(names)) names <- paste(removeExt(files[,1]),removeExt(files[,2]),sep=".") # Read header information from first file to get nspots fullname <- files[1,1] if(!is.null(path)) fullname <- file.path(path,fullname) headers <- readImaGeneHeader(fullname) if(verbose) cat("Read header information\n") skip <- headers$NHeaderRecords FD <- headers$"Field Dimensions" if(is.null(FD)) stop("Can't find Field Dimensions in ImaGene header") nspots <- sum(apply(FD,1,prod)) # Set signal and background estimation method if(is.null(columns)) { SM <- headers$"Measurement parameters"$"Segmentation Method" if(is.null(SM)) SM <- "none" if(SM=="auto") columns <- list(f="Signal Mean",b="Background Mean") else columns <- list(f="Signal Mean",b="Background Median") } if(is.null(columns$f) || is.null(columns$b)) stop("'columns' should have components 'f' and 'b'") # Initialize data object Y <- matrix(0,nspots,narrays) colnames(Y) <- names RG <- list(R=Y,G=Y,Rb=Y,Gb=Y,source="imagene",Field.Dimensions=FD) if(!is.null(wt.fun)) RG$weights <- Y # Other columns if(!is.null(other.columns)) { other.columns <- as.character(other.columns) if(length(other.columns)) { RG$other <- list() G.other.columns <- paste("G",other.columns) colnames(Y) <- removeExt(files[,1]) for (a in G.other.columns) RG$other[[a]] <- Y R.other.columns <- paste("R",other.columns) colnames(Y) <- removeExt(files[,2]) for (a in R.other.columns) RG$other[[a]] <- Y } else { other.columns <- NULL } } printer <- list(ngrid.r=FD[1,"Metarows"],ngrid.c=FD[1,"Metacols"],nspot.r=FD[1,"Rows"],nspot.c=FD[1,"Cols"]) if(nrow(FD)==1) { RG$printer <- printer } else { printer$ngrid.r <- sum(FD[,"Metarows"]) if(all(printer$ngrid.c==FD[,"Metacols"]) && all(printer$nspot.r==FD[,"Rows"]) && all(printer$nspot.c==FD[,"Cols"]) ) RG$printer <- printer } # Now read data for (i in 1:narrays) { # Green channel fullname <- files[i,1] if(!is.null(path)) fullname <- file.path(path,fullname) if(i > 1) { headers <- readImaGeneHeader(fullname) if(any(headers[["Field Dimensions"]] != RG$Field.Dimensions)) stop(paste("Field dimensions of array",i,"not same as those of first array")) skip <- headers$NHeaderRecords } obj<- read.table(fullname,skip=skip,header=TRUE,sep=sep,quote=quote,check.names=FALSE,comment.char="",fill=TRUE,nrows=nspots,...) if(verbose) cat(paste("Read",fullname,"\n")) if(i==1) RG$genes <- obj[,c("Field","Meta Row","Meta Column","Row","Column","Gene ID")] RG$G[,i] <- obj[,columns$f] RG$Gb[,i] <- obj[,columns$b] if(!is.null(other.columns)) { for (j in 1:length(other.columns)) RG$other[[G.other.columns[j]]][,i] <- obj[,other.columns[j]] } # Red channel fullname <- files[i,2] if(!is.null(path)) fullname <- file.path(path,fullname) obj<- read.table(fullname,skip=skip,header=TRUE,sep=sep,quote=quote,check.names=FALSE,comment.char="",fill=TRUE,nrows=nspots,...) if(verbose) cat(paste("Read",fullname,"\n")) RG$R[,i] <- obj[,columns$f] RG$Rb[,i] <- obj[,columns$b] if(!is.null(wt.fun)) RG$weights[,i] <- wt.fun(obj) if(!is.null(other.columns)) { for (j in 1:length(other.columns)) RG$other[[R.other.columns[j]]][,i] <- obj[,other.columns[j]] } } new("RGList",RG) } limma/R/plotrldf.R0000644007451300017500000000443312127125240014162 0ustar charlescharles# Plot regularized linear discriminant functions plotRLDF <- function(y,design=NULL,z=NULL,labels.y=NULL,labels.z=NULL,col.y=1,col.z=1,df.prior=5,show.dimensions=c(1,2),main=NULL,nprobes=500,...) # Regularized linear discriminant function # Di Wu and Gordon Smyth # 29 June 2009. Last revised 30 June 2009. { y <- as.matrix(y) g <- nrow(y) n <- ncol(y) if(is.null(design)) { if(is.null(labels.y)) stop("groups not specified") f <- as.factor(labels.y) design <- model.matrix(~f) } design <- as.matrix(design) if(nrow(design) != n) stop("nrow(design) doesn't match ncol(y)") if(is.null(labels.y)) labels.y <- 1:n # Project onto between and within spaces # Discard first column as intercept qrd <- qr(design) p <- qrd$rank if(p==n) stop("No residual degrees of freedom") U <- qr.qty(qrd, t(y)) UB <- U[2:p,,drop=FALSE] UW <- U[(p+1):n,,drop=FALSE] # Prior variance s <- colMeans(UW*UW) s0 <- median(s) # Select probes by moderated F if(g>nprobes) { modF <- colMeans(UB*UB)/(s+df.prior*s0) o <- order(modF,decreasing=TRUE) top <- o[1:nprobes] y <- y[top,,drop=FALSE] if(!is.null(z)) z <- z[top,,drop=FALSE] UB <- UB[,top,drop=FALSE] UW <- UW[,top,drop=FALSE] g <- nprobes } # Within group SS W <- crossprod(UW) # Regularized within group SS Wreg <- W+diag(df.prior*s0,g,g) # Ratio of between to within SS WintoB <- backsolve(chol(Wreg),t(UB),transpose=TRUE) # Linear discriminant gene weights d1 <- show.dimensions[1] d2 <- show.dimensions[2] metagenes <- svd(WintoB,nu=max(d1,d2),nv=0)$u d1.y <- t(y)%*%metagenes[,d1] d2.y <- t(y)%*%metagenes[,d2] if(!is.null(z)) { z <- as.matrix(z) d1.z <- t(z)%*%metagenes[,d1] d2.z <- t(z)%*%metagenes[,d2] if(is.null(labels.z)) labels.z <- letters[1:ncol(z)] } else { d1.z <- d2.z <- numeric(0) labels.z <- character(0) } lab.y <- as.character(labels.y) lab.z <- as.character(labels.z) plot(c(d1.y,d1.z),c(d2.y,d2.z),type="n",main=main, xlab=paste("Discriminant Function",d1), ylab=paste("Discriminant Function",d2)) text(d1.y,d2.y,labels=lab.y,col=col.y,...) if(!is.null(z)) text(d1.z,d2.z,labels=lab.z,col=col.z,...) invisible(list(training=cbind(d1=d1.y,d2=d2.y),predicting=cbind(d1=d1.z,d2=d2.z),metagenes=metagenes,top=top)) } limma/R/barcodeplot.R0000644007451300017500000000327612127125240014636 0ustar charlescharles## BARCODEPLOT.R barcodeplot <- function(statistics,index,index2=NULL,labels=c("Group 1 (highest statistic)","Group 2 (lowest statistic)"),quantiles=c(-1,1),col.bars=NULL,offset.bars=!is.null(index2), ...) # Barcode plot of one or two gene sets. # Gordon Smyth and Di Wu # 20 October 2008. Last revised 11 Feb 2012. { TWO <- !is.null(index2) rankstat <- rank(statistics,na.last=TRUE) r <- rankstat[index] if(TWO) r2 <- rankstat[index2] isna <- is.na(statistics) n <- sum(!isna) if(any(isna)) { rankstat <- rankstat[1:n] r <- r[r<=n] if(TWO) r2 <- r2[r2<=n] } if(is.null(col.bars)) if(is.null(index2)) col.bars=c("black","black") else col.bars=c("red","blue") quantiles <- sort(quantiles) ylim <- c(-1,1) if(offset.bars) { ylim[2] <- ylim[2]+0.5 if(!is.null(index2)) ylim[1] <- ylim[1]-0.5 } n <- length(statistics) plot(1:n,xlim=c(0,n),ylim=ylim,type="n",axes=FALSE,xlab="",ylab="",...) npos <- sum(statistics > quantiles[2]) nneg <- sum(statistics < quantiles[1]) rect(npos+0.5,-0.5,n-nneg+0.5,0.5,col="lightgray",border=NA) if(npos) rect(0.5,-0.5,npos+0.5,0.5,col="pink",border=NA) if(nneg) rect(n-nneg+0.5,-0.5,n+0.5,0.5,col="lightblue",border=NA) r <- n+1-r lwd <- 50/length(r) lwd <- min(2,lwd) lwd <- max(0.1,lwd) barlim <- ylim[2]-c(1.5,0.5) segments(r,barlim[1],r,barlim[2],lwd=lwd,col=col.bars[1]) if(TWO) { r2 <- n+1-r2 lwd2 <- 50/length(r2) lwd2 <- min(2,lwd2) lwd2 <- max(0.1,lwd2) barlim2 <- ylim[1]+c(0.5,1.5) segments(r2,barlim2[1],r2,barlim2[2],lwd=lwd2,col=col.bars[2]) } mtext(labels[1],side=2,line=-0.5,col="black") mtext(labels[2],side=4,line=-1,col="black") invisible() } limma/R/decidetests.R0000755007451300017500000001526312127125240014642 0ustar charlescharles# DECIDETESTS.R setClass("TestResults",representation("matrix")) summary.TestResults <- function(object,...) # Gordon Smyth # 26 Feb 2004. Last modified 31 Jan 2005. { # apply(object,2,table) tab <- array(0,c(3,ncol(object)),dimnames=list(c("-1","0","1"),colnames(object))) tab[1,] <- colSums(object== -1,na.rm=TRUE) tab[2,] <- colSums(object== 0,na.rm=TRUE) tab[3,] <- colSums(object== 1,na.rm=TRUE) class(tab) <- "table" tab } setMethod("show","TestResults",function(object) { cat("TestResults matrix\n") printHead(object@.Data) }) decideTests <- function(object,method="separate",adjust.method="BH",p.value=0.05,lfc=0) # Accept or reject hypothesis tests across genes and contrasts # Gordon Smyth # 17 Aug 2004. Last modified 13 August 2010. { if(!is(object,"MArrayLM")) stop("Need MArrayLM object") if(is.null(object$p.value)) object <- eBayes(object) method <- match.arg(method,c("separate","global","hierarchical","nestedF")) adjust.method <- match.arg(adjust.method,c("none","bonferroni","holm","BH","fdr","BY")) if(adjust.method=="fdr") adjust.method <- "BH" switch(method,separate={ p <- as.matrix(object$p.value) for (j in 1:ncol(p)) { o <- !is.na(p[,j]) p[o,j] <- p.adjust(p[o,j],method=adjust.method) } s <- sign(as.matrix(object$coefficients)) results <- new("TestResults",s*(p0) { if(is.null(object$coefficients)) warning("lfc ignored because coefficients not found") else results@.Data <- results@.Data * (abs(object$coefficients)>lfc) } results } classifyTestsF <- function(object,cor.matrix=NULL,df=Inf,p.value=0.01,fstat.only=FALSE) { # Use F-tests to classify vectors of t-test statistics into outcomes # Gordon Smyth # 20 Mar 2003. Last revised 6 June 2009. # Method intended for MAList objects but accept unclassed lists as well if(is.list(object)) { if(is.null(object$t)) stop("tstat cannot be extracted from object") if(is.null(cor.matrix) && !is.null(object$cov.coefficients)) cor.matrix <- cov2cor(object$cov.coefficients) if(missing(df) && !is.null(object$df.prior) && !is.null(object$df.residual)) df <- object$df.prior+object$df.residual tstat <- as.matrix(object$t) } else { tstat <- as.matrix(object) } ngenes <- nrow(tstat) ntests <- ncol(tstat) if(ntests == 1) { if(fstat.only) { fstat <- tstat^2 attr(fstat,"df1") <- 1 attr(fstat,"df2") <- df return(fstat) } else { p <- 2 * pt(abs(tstat), df, lower.tail=FALSE) return(new("TestResults", sign(tstat) * (p < p.value) )) } } # cor.matrix is estimated correlation matrix of the coefficients # and also the estimated covariance matrix of the t-statistics if(is.null(cor.matrix)) { r <- ntests Q <- diag(r)/sqrt(r) } else { E <- eigen(cor.matrix,symmetric=TRUE) r <- sum(E$values/E$values[1] > 1e-8) Q <- .matvec( E$vectors[,1:r], 1/sqrt(E$values[1:r]))/sqrt(r) } # Return overall moderated F-statistic only if(fstat.only) { fstat <- drop( (tstat %*% Q)^2 %*% array(1,c(r,1)) ) attr(fstat,"df1") <- r attr(fstat,"df2") <- df return(fstat) } # Return TestResults matrix qF <- qf(p.value, r, df, lower.tail=FALSE) if(length(qF)==1) qF <- rep(qF,ngenes) result <- matrix(0,ngenes,ntests,dimnames=dimnames(tstat)) for (i in 1:ngenes) { x <- tstat[i,] if(any(is.na(x))) result[i,] <- NA else if( crossprod(crossprod(Q,x)) > qF[i] ) { ord <- order(abs(x),decreasing=TRUE) result[i,ord[1]] <- sign(x[ord[1]]) for (j in 2:ntests) { bigger <- ord[1:(j-1)] x[bigger] <- sign(x[bigger]) * abs(x[ord[j]]) if( crossprod(crossprod(Q,x)) > qF[i] ) result[i,ord[j]] <- sign(x[ord[j]]) else break } } } new("TestResults",result) } FStat <- function(object,cor.matrix=NULL) # Compute overall F-tests given a matrix of t-statistics # Gordon Smyth # 24 February 2004. Last modified 21 July 2004. { m <- as.list(match.call()) m[[1]] <- as.name("classifyTestsF") m$fstat.only <- TRUE eval(as.call(m)) } classifyTestsT <- function(object,t1=4,t2=3) { # TestResults by rows for a matrix of t-statistics using step-down cutoffs # Gordon Smyth # 1 July 2003. Last modified 25 Feb 2004. # Method intended for MAList objects but accept unclassed lists as well if(is.list(object)) { if(is.null(object$t)) stop("tstat cannot be extracted from object") tstat <- object$t } else { tstat <- object } if(is.null(dim(tstat))) dim(tstat) <- c(1,length(tstat)) result <- apply(tstat,1,function(x) any(abs(x)>t1,na.rm=TRUE)) * sign(tstat)*(abs(tstat)>t2) new("TestResults",result) } classifyTestsP <- function(object,df=Inf,p.value=0.05,method="holm") { # TestResults by rows for a matrix t-statistics using adjusted p-values # Gordon Smyth # 12 July 2003. Last modified 23 March 2004. # Method intended for MAList objects but accept unclassed lists as well if(is.list(object)) { if(is.null(object$t)) stop("tstat cannot be extracted from object") tstat <- object$t if(!is.null(object$df.residual)) df <- object$df.residual if(!is.null(object$df.prior)) df <- df+object$df.prior } else { tstat <- object } if(is.null(dim(tstat))) dim(tstat) <- c(1,length(tstat)) ngenes <- nrow(tstat) P <- 2*pt(-abs(tstat),df=df) result <- tstat for (i in 1:ngenes) { P[i,] <- p.adjust(P[i,],method=method) result[i,] <- sign(tstat[i,])*(P[i,]0) { FieldName <- txtsplit[1] if(n>1) FieldValue <- txtsplit[-1] else FieldValue <- "" a <- c(CompName,FieldName) out[[a]] <- FieldValue } } } } warning("End of file encountered before End Header") out } # readQuantArrayHeader <- function(file) # # Extracts header information from a QuantArray output file # # Gordon Smyth # # 20 May 2006. # { # con <- file(file, "r") # on.exit(close(con)) # out <- list(Header=list()) # iline <- 0 # CompName <- character(0) # repeat { # txt <- readLines(con,n=1) # if(!length(txt)) break # iline <- iline+1 # if (length(grep("^Begin",txt))) { # CompName <- c(CompName,sub("^Begin ","",txt)) # out[[CompName]] <- list() # } else { # if (length(grep("^End",txt))) { # CompName <- CompName[-length(CompName)] # if(txt=="End Header") { # out <- out$Header # out$NHeaderRecords <- iline+1 # return(out) # } # } else { # split <- "\t" # if(!length(grep(split,txt))) split <- ": " # txtsplit <- strsplit(txt,split=split)[[1]] # n <- length(txtsplit) # if(n>0) { # FieldName <- txtsplit[1] # if(n>1) FieldValue <- txtsplit[-1] else FieldValue <- "" # a <- c(CompName,FieldName) # out[[a]] <- FieldValue # } # } # } # } # warning("End of file encountered before End Header") # out # } readSMDHeader <- function(file) # Read header information from a Stanford Microarray Database (SMD) raw data file # Gordon Smyth # 3 June 2004 { con <- file(file, "r") on.exit(close(con)) out <- list() i <- 0 repeat { txt <- readLines(con,n=1) if(txt=="") stop("Not SMD data file: input stopped at blank line") if(substr(txt,1,1)=="!") { i <- i+1 txtsplit <- strsplit(substr(txt,2,500),split="=")[[1]] out[[i]] <- txtsplit[2] names(out)[i] <- txtsplit[1] } else { break } } out$NHeaderRecords <- i out } limma/R/geneset-camera.R0000644007451300017500000001313512127125240015213 0ustar charlescharles## CAMERA.R interGeneCorrelation <- function(y, design) # Estimate variance-inflation factor for means of correlated genes # Gordon Smyth and Di Wu # Created 2007. Last modified 11 Feb 2012 { m <- nrow(y) qrdesign <- qr(design) y <- qr.qty(qrdesign, t(y))[-(1:qrdesign$rank),] # Gives same result as the following # ny <- t(y) / sqrt(colSums(y^2)) # cormatrix <- tcrossprod(ny) # correlation <- mean(cormatrix[lower.tri(cormatrix)]) # 1+correlation*(n-1) y <- t(y) / sqrt(colMeans(y^2)) vif <- m * mean(colMeans(y)^2) correlation <- (vif-1)/(m-1) list(vif=vif,correlation=correlation) } camera <- function(y,index,design=NULL,contrast=ncol(design),weights=NULL,use.ranks=FALSE,allow.neg.cor=TRUE,trend.var=FALSE,sort=TRUE) UseMethod("camera") camera.EList <- function(y,index,design=NULL,contrast=ncol(design),weights=NULL,use.ranks=FALSE,allow.neg.cor=TRUE,trend.var=FALSE,sort=TRUE) # Gordon Smyth # Created 4 Jan 2013. Last modified 22 Jan 2013 { if(is.null(design)) design <- y$design if(is.null(weights)) weights <- y$weights y <- y$E camera(y=y,index=index,design=design,contrast=contrast,weights=weights,use.ranks=use.ranks,allow.neg.cor=allow.neg.cor,trend.var=trend.var,sort=sort) } camera.MAList <- function(y,index,design=NULL,contrast=ncol(design),weights=NULL,use.ranks=FALSE,allow.neg.cor=TRUE,trend.var=FALSE,sort=TRUE) # Gordon Smyth # Created 4 Jan 2013. Last modified 22 Jan 2013 { if(is.null(design)) design <- y$design if(is.null(weights)) weights <- y$weights y <- y$M camera(y=y,index=index,design=design,contrast=contrast,weights=weights,use.ranks=use.ranks,allow.neg.cor=allow.neg.cor,trend.var=trend.var,sort=sort) } camera.default <- function(y,index,design=NULL,contrast=ncol(design),weights=NULL,use.ranks=FALSE,allow.neg.cor=TRUE,trend.var=FALSE,sort=TRUE) # Competitive gene set test allowing for correlation between genes # Gordon Smyth and Di Wu # Created 2007. Last modified 22 Jan 2013 { # Check y y <- as.matrix(y) G <- nrow(y) n <- ncol(y) # Check index if(!is.list(index)) index <- list(set1=index) # Check design if(is.null(design)) stop("no design matrix") p <- ncol(design) df.residual <- n-p df.camera <- min(df.residual,G-2) # Check weights if(!is.null(weights)) { if(any(weights<=0)) stop("weights must be positive") if(length(weights)==n) { sw <- sqrt(weights) y <- t(t(y)*sw) design <- design*sw weights <- NULL } } if(!is.null(weights)) { if(length(weights)==G) weights <- matrix(weights,G,n) weights <- as.matrix(weights) if(any( dim(weights) != dim(y) )) stop("weights not conformal with y") } # Reform design matrix so that contrast of interest is last column if(is.character(contrast)) { contrast <- which(contrast==colnames(design)) if(length(contrast)==0) stop("coef ",contrast," not found") } if(length(contrast)==1) { j <- c((1:p)[-contrast], contrast) if(contrast1) { Uset <- U[iset,,drop=FALSE] vif <- m * mean(colMeans(Uset)^2) correlation <- (vif-1)/(m-1) } else { vif <- 1 correlation <- NA } tab[i,1] <- m tab[i,2] <- correlation if(use.ranks) { if(!allow.neg.cor) correlation <- max(0,correlation) tab[i,3:4] <- rankSumTestWithCorrelation(iset,statistics=Stat,correlation=correlation,df=df.camera) } else { if(!allow.neg.cor) vif <- max(1,vif) meanStatInSet <- mean(StatInSet) delta <- G/m2*(meanStatInSet-meanStat) varStatPooled <- ( (G-1)*varStat - delta^2*m*m2/G ) / (G-2) two.sample.t <- delta / sqrt( varStatPooled * (vif/m + 1/m2) ) tab[i,3] <- pt(two.sample.t,df=df.camera) tab[i,4] <- pt(two.sample.t,df=df.camera,lower.tail=FALSE) } } tab[,5] <- 2*pmin(tab[,3],tab[,4]) # New column names (Jan 2013) tab <- data.frame(tab,stringsAsFactors=FALSE) Direction <- rep.int("Up",nsets) Direction[tab$Down < tab$Up] <- "Down" tab$Direction <- Direction tab$PValue <- tab$TwoSided tab$Down <- tab$Up <- tab$TwoSided <- NULL # Add FDR if(nsets>1) tab$FDR <- p.adjust(tab$PValue,method="BH") # Sort by p-value if(sort && nsets>1) { o <- order(tab$PValue) tab <- tab[o,] } tab } limma/R/treat.R0000644007451300017500000001054612130404410013446 0ustar charlescharles### treat.R treat <- function(fit, lfc=0, trend=FALSE) # Moderated t-statistics with threshold # Davis McCarthy, Gordon Smyth # 25 July 2008. Last revised 7 April 2013. { # Check fit if(!is(fit,"MArrayLM")) stop("fit must be an MArrayLM object") if(is.null(fit$coefficients)) stop("coefficients not found in fit object") if(is.null(fit$stdev.unscaled)) stop("stdev.unscaled not found in fit object") coefficients <- as.matrix(fit$coefficients) stdev.unscaled <- as.matrix(fit$stdev.unscaled) sigma <- fit$sigma df.residual <- fit$df.residual if (is.null(coefficients) || is.null(stdev.unscaled) || is.null(sigma) || is.null(df.residual)) stop("No data, or argument is not a valid lmFit object") if (all(df.residual == 0)) stop("No residual degrees of freedom in linear model fits") if (all(!is.finite(sigma))) stop("No finite residual standard deviations") if(trend) { covariate <- fit$Amean if(is.null(covariate)) stop("Need Amean component in fit to estimate trend") } else { covariate <- NULL } sv <- squeezeVar(sigma^2, df.residual, covariate=covariate) fit$df.prior <- sv$df.prior fit$s2.prior <- sv$var.prior fit$s2.post <- sv$var.post df.total <- df.residual + sv$df.prior df.pooled <- sum(df.residual,na.rm=TRUE) df.total <- pmin(df.total,df.pooled) fit$df.total <- df.total lfc <- abs(lfc) acoef <- abs(coefficients) se <- stdev.unscaled*sqrt(fit$s2.post) tstat.right <- (acoef-lfc)/se tstat.left <- (acoef+lfc)/se fit$t <- array(0,dim(coefficients),dimnames=dimnames(coefficients)) fit$p.value <- pt(tstat.right, df=df.total,lower.tail=FALSE) + pt(tstat.left,df=df.total,lower.tail=FALSE) tstat.right <- pmax(tstat.right,0) fc.up <- (coefficients > lfc) fc.down <- (coefficients < -lfc) fit$t[fc.up] <- tstat.right[fc.up] fit$t[fc.down] <- -tstat.right[fc.down] fit } topTreat <- function(fit,coef=1,number=10,genelist=fit$genes,adjust.method="BH",sort.by="p",resort.by=NULL,p.value=1) # Summary table of top genes by treat # Gordon Smyth # 15 June 2009. Last modified 17 March 2010. { # Check input if(length(coef)>1) coef <- coef[1] M <- as.matrix(fit$coefficients)[,coef] A <- fit$Amean if(is.null(A)) { if(sort.by=="A") stop("Cannot sort by A-values as these have not been given") } else { if(NCOL(A)>1) A <- rowMeans(A,na.rm=TRUE) } tstat <- as.matrix(fit$t)[,coef] P.Value <- as.matrix(fit$p.value)[,coef] if(!is.null(genelist) && is.null(dim(genelist))) genelist <- data.frame(ID=genelist,stringsAsFactors=FALSE) sort.by <- match.arg(sort.by,c("logFC","M","A","Amean","AveExpr","P","p","T","t","none")) if(sort.by=="M") sort.by="logFC" if(sort.by=="A" || sort.by=="Amean") sort.by <- "AveExpr" if(sort.by=="T") sort.by <- "t" if(sort.by=="p") sort.by <- "P" # Apply multiple testing adjustment adj.P.Value <- p.adjust(P.Value,method=adjust.method) # Apply p.value threshold if(p.value < 1) { sig <- (adj.P.Value < p.value) if(any(is.na(sig))) sig[is.na(sig)] <- FALSE if(all(!sig)) return(data.frame()) genelist <- genelist[sig,,drop=FALSE] M <- M[sig] A <- A[sig] tstat <- tstat[sig] P.Value <- P.Value[sig] adj.P.Value <- adj.P.Value[sig] } ord <- switch(sort.by, logFC=order(abs(M),decreasing=TRUE), AveExpr=order(A,decreasing=TRUE), P=order(P.Value,decreasing=FALSE), t=order(abs(tstat),decreasing=TRUE), none=1:length(M) ) if(length(M) < number) number <- length(M) if(number < 1) return(data.frame()) top <- ord[1:number] if(is.null(genelist)) tab <- data.frame(logFC=M[top]) else { tab <- data.frame(genelist[top,,drop=FALSE],logFC=M[top],stringsAsFactors=FALSE) } if(!is.null(A)) tab <- data.frame(tab,AveExpr=A[top]) tab <- data.frame(tab,t=tstat[top],P.Value=P.Value[top],adj.P.Val=adj.P.Value[top]) rownames(tab) <- as.character(1:length(M))[top] if(!is.null(resort.by)) { resort.by <- match.arg(resort.by,c("logFC","M","A","Amean","AveExpr","P","p","T","t")) if(resort.by=="M") resort.by <- "logFC" if(resort.by=="A" || resort.by=="Amean") resort.by <- "AveExpr" if(resort.by=="p") resort.by <- "P" if(resort.by=="T") resort.by <- "t" ord <- switch(resort.by, logFC=order(tab$logFC,decreasing=TRUE), AveExpr=order(tab$AveExpr,decreasing=TRUE), P=order(tab$P.Value,decreasing=FALSE), t=order(tab$t,decreasing=TRUE) ) tab <- tab[ord,] } tab } limma/R/voom.R0000644007451300017500000000546512170636047013334 0ustar charlescharlesvoom <- function(counts,design=NULL,lib.size=NULL,normalize.method="none",plot=FALSE,span=0.5,...) # Linear modelling of count data mean-variance modelling at the observational level. # Creates an EList object for entry to lmFit() etc in the limma pipeline. # Gordon Smyth and Charity Law # Created 22 June 2011. Last modified 5 June 2013. { out <- list() # Check counts if(is(counts,"DGEList")) { out$genes <- counts$genes out$targets <- counts$samples if(is.null(design) && diff(range(as.numeric(counts$sample$group)))>0) design <- model.matrix(~group,data=counts$samples) if(is.null(lib.size)) lib.size <- with(counts$samples,lib.size*norm.factors) counts <- counts$counts } else { isExpressionSet <- suppressPackageStartupMessages(is(counts,"ExpressionSet")) if(isExpressionSet) { if(length(fData(counts))) out$genes <- fData(counts) if(length(pData(counts))) out$targets <- pData(counts) counts <- exprs(counts) } else { counts <- as.matrix(counts) } } # Check design if(is.null(design)) { design <- matrix(1,ncol(counts),1) rownames(design) <- colnames(counts) colnames(design) <- "GrandMean" } # Check lib.size if(is.null(lib.size)) lib.size <- colSums(counts) # Fit linear model to log2-counts-per-million y <- t(log2(t(counts+0.5)/(lib.size+1)*1e6)) y <- normalizeBetweenArrays(y,method=normalize.method) fit <- lmFit(y,design,...) if(is.null(fit$Amean)) fit$Amean <- rowMeans(y,na.rm=TRUE) # Fit lowess trend to sqrt-standard-deviations by log-count-size sx <- fit$Amean+mean(log2(lib.size+1))-log2(1e6) sy <- sqrt(fit$sigma) allzero <- rowSums(counts)==0 if(any(allzero)) { sx <- sx[!allzero] sy <- sy[!allzero] } l <- lowess(sx,sy,f=span) if(plot) { plot(sx,sy,xlab="log2( count size + 0.5 )",ylab="Sqrt( standard deviation )",pch=16,cex=0.25) title("voom: Mean-variance trend") lines(l,col="red") } # Make interpolating rule # Special treatment of zero counts is now removed; # instead zero counts get same variance as smallest gene average. # l$x <- c(0.5^0.25, l$x) # l$x <- c(log2(0.5), l$x) # var0 <- var(log2(0.5*1e6/(lib.size+0.5)))^0.25 # var0 <- max(var0,1e-6) # l$y <- c(var0, l$y) f <- approxfun(l, rule=2) # Find individual quarter-root fitted counts if(fit$rank < ncol(design)) { j <- fit$pivot[1:fit$rank] fitted.values <- fit$coef[,j,drop=FALSE] %*% t(fit$design[,j,drop=FALSE]) } else { fitted.values <- fit$coef %*% t(fit$design) } fitted.cpm <- 2^fitted.values fitted.count <- 1e-6 * t(t(fitted.cpm)*(lib.size+1)) fitted.logcount <- log2(fitted.count) # Apply trend to individual observations w <- 1/f(fitted.logcount)^4 dim(w) <- dim(fitted.logcount) # Output out$E <- y out$weights <- w out$design <- design if(is.null(out$targets)) out$targets <- data.frame(lib.size=lib.size) else out$targets$lib.size <- lib.size new("EList",out) } limma/R/combine.R0000644007451300017500000001642412170636047013765 0ustar charlescharles# CBIND, RBIND AND MERGE cbind.RGList <- function(..., deparse.level=1) # Combine RGList objects assuming same genelists # Gordon Smyth # 27 June 2003. Last modified 6 Nov 2005. { objects <- list(...) nobjects <- length(objects) out <- objects[[1]] other <- names(objects[[1]]$other) if(nobjects > 1) for (i in 2:nobjects) { out$R <- cbind(out$R,objects[[i]]$R) out$G <- cbind(out$G,objects[[i]]$G) out$Rb <- cbind(out$Rb,objects[[i]]$Rb) out$Gb <- cbind(out$Gb,objects[[i]]$Gb) out$weights <- cbind(out$weights,objects[[i]]$weights) out$targets <- rbind(out$targets,objects[[i]]$targets) for (a in other) out$other[[a]] <- cbind(out$other[[a]],objects[[i]]$other[[a]]) } out } cbind.MAList <- function(..., deparse.level=1) # Combine MAList objects assuming same genelists # Gordon Smyth # 27 June 2003. Last modified 6 Nov 2005. { objects <- list(...) nobjects <- length(objects) out <- objects[[1]] other <- names(objects[[1]]$other) if(nobjects > 1) for (i in 2:nobjects) { out$M <- cbind(out$M,objects[[i]]$M) out$A <- cbind(out$A,objects[[i]]$A) out$weights <- cbind(out$weights,objects[[i]]$weights) out$targets <- rbind(out$targets,objects[[i]]$targets) for (a in other) out$other[[a]] <- cbind(out$other[[a]],objects[[i]]$other[[a]]) } out } cbind.EListRaw <- cbind.EList <- function(..., deparse.level=1) # Combine EList objects assuming same genelists # Gordon Smyth # 23 March 2009. Last modified 5 June 2013. { objects <- list(...) nobjects <- length(objects) out <- objects[[1]] other <- names(objects[[1]]$other) if(nobjects > 1) for (i in 2:nobjects) { out$E <- cbind(out$E,objects[[i]]$E) out$Eb <- cbind(out$Eb,objects[[i]]$Eb) out$weights <- cbind(out$weights,objects[[i]]$weights) out$targets <- rbind(out$targets,objects[[i]]$targets) out$design <- rbind(out$design,objects[[i]]$design) for (a in other) out$other[[a]] <- cbind(out$other[[a]],objects[[i]]$other[[a]]) } out } rbind.RGList <- function(..., deparse.level=1) # Combine RGList objects assuming same array lists # Gordon Smyth # 6 Dec 2003. Last modified 6 Nov 2005. { objects <- list(...) nobjects <- length(objects) out <- objects[[1]] other <- names(objects[[1]]$other) if(nobjects > 1) for (i in 2:nobjects) { out$R <- rbind(out$R,objects[[i]]$R) out$G <- rbind(out$G,objects[[i]]$G) out$Rb <- rbind(out$Rb,objects[[i]]$Rb) out$Gb <- rbind(out$Gb,objects[[i]]$Gb) out$weights <- rbind(out$weights,objects[[i]]$weights) out$genes <- rbind(out$genes,objects[[i]]$genes) for (a in other) out$other[[a]] <- rbind(out$other[[a]],objects[[i]]$other[[a]]) } out } rbind.MAList <- function(..., deparse.level=1) # Combine MAList objects assuming same array lists # Gordon Smyth # 7 Dec 2003. Last modified 6 Nov 2005. { objects <- list(...) nobjects <- length(objects) out <- objects[[1]] other <- names(objects[[1]]$other) if(nobjects > 1) for (i in 2:nobjects) { out$M <- rbind(out$M,objects[[i]]$M) out$A <- rbind(out$A,objects[[i]]$A) out$weights <- rbind(out$weights,objects[[i]]$weights) out$genes <- rbind(out$genes,objects[[i]]$genes) for (a in other) out$other[[a]] <- rbind(out$other[[a]],objects[[i]]$other[[a]]) } out } rbind.EListRaw <- rbind.EList <- function(..., deparse.level=1) # Combine EList objects assuming same array lists # Gordon Smyth # 23 March 2009. Last modified 26 October 2010. { objects <- list(...) nobjects <- length(objects) out <- objects[[1]] other <- names(objects[[1]]$other) am <- function(x) if(is.null(x)) NULL else as.matrix(x) if(nobjects > 1) for (i in 2:nobjects) { out$E <- rbind(am(out$E),am(objects[[i]]$E)) out$Eb <- rbind(am(out$Eb),am(objects[[i]]$Eb)) out$weights <- rbind(am(out$weights),am(objects[[i]]$weights)) out$genes <- rbind(out$genes,objects[[i]]$genes) for (a in other) out$other[[a]] <- rbind(am(out$other[[a]]),am(objects[[i]]$other[[a]])) } out } makeUnique <- function(x) # Add characters to the elements of a character vector to make all values unique # Gordon Smyth # 10 April 2003 { x <- as.character(x) tab <- table(x) tab <- tab[tab>1] lentab <- length(tab) if(lentab > 0) { u <- names(tab) for (i in 1:lentab) { n <- tab[i] x[x==u[i]] <- paste(x[x==u[i]],formatC(1:n,width=1+floor(log(n,10)),flag="0"),sep="") } } x } merge.RGList <- function(x,y,...) # Merge RGList y into x aligning by row names # Gordon Smyth # 11 April 2003. Last modified 28 Oct 2005. { if(!is(y,"RGList")) stop("both x and y must be RGList objects") genes1 <- rownames(x$R) if(is.null(genes1)) genes1 <- rownames(x$G) if(is.null(genes1)) genes1 <- x$genes$ID genes2 <- rownames(y$R) if(is.null(genes2)) genes2 <- rownames(y$G) if(is.null(genes2)) genes2 <- y$genes$ID if(is.null(genes1) || is.null(genes2)) stop("Need row names to align on") fields1 <- names(x) fields2 <- names(y) if(!identical(fields1,fields2)) stop("The two RGLists have different components") ord2 <- match(makeUnique(genes1), makeUnique(genes2)) cbind(x,y[ord2,]) } merge.MAList <- function(x,y,...) # Merge MAList y into x aligning by row names # Gordon Smyth # 7 May 2004. Last modified 28 Oct 2005. { if(!is(y,"MAList")) stop("both x and y must be MAList objects") genes1 <- rownames(x$M) if(is.null(genes1)) genes1 <- rownames(x$A) if(is.null(genes1)) genes1 <- x$genes$ID genes2 <- rownames(y$M) if(is.null(genes2)) genes2 <- rownames(y$A) if(is.null(genes2)) genes2 <- y$genes$ID if(is.null(genes1) || is.null(genes2)) stop("Need row names to align on") fields1 <- names(x) fields2 <- names(y) if(!identical(fields1,fields2)) stop("The two MALists have different components") ord2 <- match(makeUnique(genes1), makeUnique(genes2)) cbind(x,y[ord2,]) } merge.EListRaw <- function(x,y,...) # Merge EListRaw y into x aligning by row names # Gordon Smyth # 9 May 2013. Last modified 9 May 2013. { if(!is(y,"EListRaw")) stop("both x and y must be EListRaw objects") genes1 <- rownames(x$E) if(is.null(genes1)) genes1 <- row.names(x$genes) if(is.null(genes1)) genes1 <- x$genes$ID genes2 <- rownames(y$E) if(is.null(genes2)) genes2 <- row.names(y$genes) if(is.null(genes2)) genes2 <- y$genes$ID if(is.null(genes1) || is.null(genes2)) stop("Need row names to align on") fields1 <- names(x) fields2 <- names(y) if(!identical(fields1,fields2)) stop("The two MALists have different components") ord2 <- match(makeUnique(genes1), makeUnique(genes2)) cbind(x,y[ord2,]) } merge.EList <- function(x,y,...) # Merge EList y into x aligning by row names # Gordon Smyth # 9 May 2013. Last modified 9 May 2013. { if(!is(y,"EList")) stop("both x and y must be EList objects") genes1 <- rownames(x$E) if(is.null(genes1)) genes1 <- row.names(x$genes) if(is.null(genes1)) genes1 <- x$genes$ID genes2 <- rownames(y$E) if(is.null(genes2)) genes2 <- row.names(y$genes) if(is.null(genes2)) genes2 <- y$genes$ID if(is.null(genes1) || is.null(genes2)) stop("Need row names to align on") fields1 <- names(x) fields2 <- names(y) if(!identical(fields1,fields2)) stop("The two MALists have different components") ord2 <- match(makeUnique(genes1), makeUnique(genes2)) cbind(x,y[ord2,]) } limma/R/plotlines.R0000644007451300017500000000105712127125240014344 0ustar charlescharles# plotlines.R plotlines <- function(x,first.column.origin=FALSE,xlab="Column",ylab="x",col="black",lwd=1,...) # Time-course-style plot # Plot expression data as a line for each probe # Gordon Smyth # 27 August 2006. Last revised 30 August 2006. { x <- as.matrix(x) ntime <- ncol(x) ngenes <- nrow(x) if(first.column.origin) x <- x - array(x[,1],dim(x)) time <- matrix(1:ntime,ngenes,ntime,byrow=TRUE) plot(time,x,type="n",xlab=xlab,ylab=ylab,...) col <- rep(col,ngenes) for (i in 1:ngenes) lines(1:ntime,x[i,],col=col[i],lwd=lwd) } limma/R/selmod.R0000644007451300017500000000350712127125240013620 0ustar charlescharles## selmod.R selectModel <- function(y, designlist, criterion="aic", df.prior=0, s2.prior=NULL, s2.true=NULL, ...) # y is a data matrix to be fitted, with rows as genes and columns as arrays. # designlist is a list of design matrices to be compared. # The function returns AIC or BIC values for each design # and the prefered model for each gene with minimim criterion value. # Written 17/7/08 Alicia Oshlack # Last revised 2 Oct 2008, Gordon Smyth { ym <- as.matrix(y) if(any(is.na(ym))) stop("NAs not allowed") narrays <- ncol(ym) rm(ym) nmodels <- length(designlist) models <- names(designlist) if(is.null(models)) models <- as.character(1:nmodels) if(df.prior>0 & is.null(s2.prior)) stop("s2.prior must be set") if(df.prior==0) s2.prior <- 0 criterion <- match.arg(criterion,c("aic","bic","mallowscp")) if(criterion=="mallowscp") { if(is.null(s2.true)) stop("Need s2.true values") for(i in 1:nmodels) { fit <- lmFit(y, designlist[[i]], ...) npar <- narrays-fit$df.residual[1] if(i==1) { IC <- matrix(nrow=nrow(fit),ncol=nmodels,dimnames=list(Probes=rownames(fit),Models=models)) if(length(s2.true)!=nrow(fit) && length(s2.true)!=1) stop("s2.true wrong length") } IC[,i] <- fit$df.residual*fit$sigma^2/s2.true+npar*2-narrays } } else { ntotal <- df.prior+narrays penalty <- switch(criterion,bic=log(narrays),aic=2) for(i in 1:nmodels) { fit <- lmFit(y, designlist[[i]], ...) npar <- narrays-fit$df.residual[1]+1 s2.post <- (df.prior*s2.prior+fit$df.residual*fit$sigma^2)/ntotal if(i==1) IC <- matrix(nrow=nrow(fit),ncol=nmodels,dimnames=list(Probes=rownames(fit),Models=models)) IC[,i] <- ntotal*log(s2.post)+npar*penalty } } pref <- factor(apply(IC,1,which.min),levels=1:nmodels,labels=models) list(IC=IC,pref=pref,criterion=criterion) } limma/R/norm.R0000755007451300017500000004313412127125240013313 0ustar charlescharles# WITHIN ARRAY NORMALIZATION MA.RG <- function(object, bc.method="subtract", offset=0) { # Convert RGList to MAList # Gordon Smyth # 2 March 2003. Last revised 9 Dec 2004. if(is.null(object$R) || is.null(object$G)) stop("Object doesn't contain R and G components") object <- backgroundCorrect(object, method=bc.method, offset=offset) R <- object$R G <- object$G # Log R[R <= 0] <- NA G[G <= 0] <- NA R <- log(R,2) G <- log(G,2) # Minus and Add object$R <- object$G <- object$Rb <- object$Gb <- object$other <- NULL object$M <- as.matrix(R-G) object$A <- as.matrix((R+G)/2) new("MAList",unclass(object)) } RG.MA <- function(object) { # Convert MAList to RGList # Gordon Smyth # 5 September 2003. Last modified 9 Dec 2004. object$R <- 2^( object$A+object$M/2 ) object$G <- 2^( object$A-object$M/2 ) object$M <- NULL object$A <- NULL new("RGList",unclass(object)) } normalizeWithinArrays <- function(object,layout=object$printer,method="printtiploess",weights=object$weights,span=0.3,iterations=4,controlspots=NULL,df=5,robust="M",bc.method="subtract",offset=0) # Within array normalization # Gordon Smyth # 2 March 2003. Last revised 16 March 2013. { # Check input arguments # and get non-intensity dependent methods out of the way if(!is(object,"MAList")) object <- MA.RG(object,bc.method=bc.method,offset=offset) choices <- c("none","median","loess","printtiploess","composite","control","robustspline") method <- match.arg(method,choices) if(method=="none") return(object) if(is.vector(object$M)) object$M <- as.matrix(object$M) nprobes <- nrow(object$M) narrays <- ncol(object$M) if(!is.null(weights)) weights <- asMatrixWeights(weights,dim=c(nprobes,narrays)) if(method=="median") { if(is.null(weights)) for (j in 1:narrays) object$M[,j] <- object$M[,j] - median(object$M[,j],na.rm=TRUE) else for (j in 1:narrays) object$M[,j] <- object$M[,j] - weighted.median(object$M[,j],weights[,j],na.rm=TRUE) return(object) } # All remaining methods use regression of M-values on A-values if(is.vector(object$A)) object$A <- as.matrix(object$A) if(nrow(object$A) != nprobes) stop("row dimension of A doesn't match M") if(ncol(object$A) != narrays) stop("col dimension of A doesn't match M") switch(method, loess = { for (j in 1:narrays) { y <- object$M[,j] x <- object$A[,j] w <- weights[,j] object$M[,j] <- loessFit(y,x,w,span=span,iterations=iterations)$residuals } }, printtiploess = { if(is.null(layout)) stop("Layout argument not specified") ngr <- layout$ngrid.r ngc <- layout$ngrid.c nspots <- layout$nspot.r * layout$nspot.c nprobes2 <- ngr*ngc*nspots if(nprobes2 != nprobes) stop("printer layout information does not match M row dimension") for (j in 1:narrays) { spots <- 1:nspots for (gridr in 1:ngr) for (gridc in 1:ngc) { y <- object$M[spots,j] x <- object$A[spots,j] w <- weights[spots,j] object$M[spots,j] <- loessFit(y,x,w,span=span,iterations=iterations)$residuals spots <- spots + nspots } } }, composite = { if(is.null(layout)) stop("Layout argument not specified") if(is.null(controlspots)) stop("controlspots argument not specified") ntips <- layout$ngrid.r * layout$ngrid.c nspots <- layout$nspot.r * layout$nspot.c for (j in 1:narrays) { y <- object$M[,j] x <- object$A[,j] w <- weights[,j] f <- is.finite(y) & is.finite(x) if(!is.null(w)) f <- f & is.finite(w) y[!f] <- NA fit <- loess(y~x,weights=w,span=span,subset=controlspots,na.action=na.exclude,degree=0,surface="direct",family="symmetric",trace.hat="approximate",iterations=iterations) alpha <- global <- y global[f] <- predict(fit,newdata=x[f]) alpha[f] <- (rank(x[f])-1) / sum(f) spots <- 1:nspots for (tip in 1:ntips) { y <- object$M[spots,j] x <- object$A[spots,j] w <- weights[spots,j] local <- loessFit(y,x,w,span=span,iterations=iterations)$fitted object$M[spots,j] <- object$M[spots,j] - alpha[spots]*global[spots]-(1-alpha[spots])*local spots <- spots + nspots } } }, control = { # if(is.null(layout)) stop("Layout argument not specified") if(is.null(controlspots)) stop("controlspots argument not specified") # ntips <- layout$ngrid.r * layout$ngrid.c # nspots <- layout$nspot.r * layout$nspot.c for (j in 1:narrays) { y <- object$M[,j] x <- object$A[,j] w <- weights[,j] f <- is.finite(y) & is.finite(x) if(!is.null(w)) f <- f & is.finite(w) y[!f] <- NA fit <- loess(y~x,weights=w,span=span,subset=controlspots,na.action=na.exclude,degree=1,surface="direct",family="symmetric",trace.hat="approximate",iterations=iterations) y[f] <- y[f]-predict(fit,newdata=x[f]) object$M[,j] <- y } }, robustspline = { # if(is.null(layout)) stop("Layout argument not specified") for (j in 1:narrays) object$M[,j] <- normalizeRobustSpline(object$M[,j],object$A[,j],layout,df=df,method=robust) } ) object } normalizeRobustSpline <- function(M,A,layout=NULL,df=5,method="M") { # Robust spline normalization # Gordon Smyth # 27 April 2003. Last revised 29 Nov 2012. require(MASS) require(splines) if(is.null(layout)) { ngrids <- 1 nspots <- length(M) } else { ngrids <- round(layout$ngrid.r * layout$ngrid.c) nspots <- round(layout$nspot.r * layout$nspot.c) if(ngrids < 1) stop("layout incorrectly specified") if(nspots < df+1) stop("too few spots in each print-tip block") } # Global splines O <- is.finite(M) & is.finite(A) X <- matrix(NA,ngrids*nspots,df) X[O,] <- ns(A[O],df=df,intercept=TRUE) x <- X[O,,drop=FALSE] y <- M[O] w <- rep(1,length(y)) s0 <- summary(rlm(x,y,weights=w,method=method),method="XtWX",correlation=FALSE) beta0 <- s0$coefficients[,1] covbeta0 <- s0$cov * s0$stddev^2 # Case with only one tip-group if(ngrids <= 1) { M[O] <- s0$residuals M[!O] <- NA return(M) } # Tip-wise splines beta <- array(1,c(ngrids,1)) %*% array(beta0,c(1,df)) covbeta <- array(0,c(ngrids,df,df)) spots <- 1:nspots for (i in 1:ngrids) { o <- O[spots] y <- M[spots][o] if(length(y)) { x <- X[spots,][o,,drop=FALSE] r <- qr(x)$rank if(r2) targets <- targets[,c("Cy3","Cy5")] targets <- as.vector(targets) Z <- cbind(object$A-object$M/2,object$A+object$M/2) for (u in unique(targets)) { j <- targets==u Z[,j] <- normalizeQuantiles(Z[,j],...) } G <- Z[,1:narrays] R <- Z[,narrays+(1:narrays)] object$M <- R-G object$A <- (R+G)/2 }) object } normalizeVSN <- function(x,...) { require("vsn") UseMethod("normalizeVSN") } normalizeVSN.RGList <- function(x,...) # vsn background correction and normalization for RGList objects # Gordon Smyth # 9 Sep 2010. { x <- backgroundCorrect(x,method="subtract") y <- cbind(x$G,x$R) x$G <- x$R <- NULL y <- exprs(vsnMatrix(x=y,...)) n2 <- ncol(y)/2 G <- y[,1:n2] R <- y[,n2+(1:n2)] x$M <- R-G x$A <- (R+G)/2 new("MAList",unclass(x)) } normalizeVSN.EListRaw <- function(x,...) # vsn background correction and normalization for EListRaw objects # Gordon Smyth # 9 Sep 2010. { x <- backgroundCorrect(x,method="subtract") x$E <- exprs(vsnMatrix(x=x$E,...)) new("EList",unclass(x)) } normalizeVSN.default <- function(x,...) # vsn background correction and normalization for matrices # Gordon Smyth # 9 Sep 2010. { exprs(vsnMatrix(x=as.matrix(x),...)) } normalizeQuantiles <- function(A, ties=TRUE) { # Normalize columns of a matrix to have the same quantiles, allowing for missing values. # Gordon Smyth # 25 June 2002. Last revised 8 June 2006. n <- dim(A) if(is.null(n)) return(A) if(n[2]==1) return(A) O <- S <- array(,n) nobs <- rep(n[1],n[2]) i <- (0:(n[1]-1))/(n[1]-1) for (j in 1:n[2]) { Si <- sort(A[,j], method="quick", index.return=TRUE) nobsj <- length(Si$x) if(nobsj < n[1]) { nobs[j] <- nobsj isna <- is.na(A[,j]) S[,j] <- approx((0:(nobsj-1))/(nobsj-1), Si$x, i, ties="ordered")$y O[!isna,j] <- ((1:n[1])[!isna])[Si$ix] } else { S[,j] <- Si$x O[,j] <- Si$ix } } m <- rowMeans(S) for (j in 1:n[2]) { if(ties) r <- rank(A[,j]) if(nobs[j] < n[1]) { isna <- is.na(A[,j]) if(ties) A[!isna,j] <- approx(i, m, (r[!isna]-1)/(nobs[j]-1), ties="ordered")$y else A[O[!isna,j],j] <- approx(i, m, (0:(nobs[j]-1))/(nobs[j]-1), ties="ordered")$y } else { if(ties) A[,j] <- approx(i, m, (r-1)/(n[1]-1), ties="ordered")$y else A[O[,j],j] <- m } } A } normalizeMedianAbsValues <- function(x) # Normalize columns of a matrix to have the same median absolute value # Gordon Smyth # 12 April 2003. Last modified 19 Oct 2005. { narrays <- NCOL(x) if(narrays==1) return(x) cmed <- log(apply(abs(x), 2, median, na.rm=TRUE)) cmed <- exp(cmed - mean(cmed)) t(t(x)/cmed) } normalizeMedianValues <- function(x) # Normalize columns of a matrix to have the same median value # Gordon Smyth # 24 Jan 2011. Last modified 24 Jan 2011. { narrays <- NCOL(x) if(narrays==1) return(x) cmed <- log(apply(x, 2, median, na.rm=TRUE)) cmed <- exp(cmed - mean(cmed)) t(t(x)/cmed) } normalizeCyclicLoess <- function(x, weights = NULL, span=0.7, iterations = 3, method="fast") # Cyclic loess normalization of columns of matrix # incorporating probes weights. # Yunshun (Andy) Chen and Gordon Smyth # 14 April 2010. Last modified 24 Feb 2012. { x <- as.matrix(x) method <- match.arg(method, c("fast","affy","pairs")) n <- ncol(x) if(method=="pairs") { for (k in 1:iterations) for (i in 1:(n-1)) for (j in (i+1):n) { m <- x[,j] - x[,i] a <- .5*(x[,j] + x[,i]) f <- loessFit(m, a, weights=weights, span=span)$fitted x[,i] <- x[,i] + f/2 x[,j] <- x[,j] - f/2 } } if(method=="fast") { for (k in 1:iterations) { a <- rowMeans(x,na.rm=TRUE) for (i in 1:n){ m <- x[,i] - a f <- loessFit(m, a, weights=weights, span=span)$fitted x[,i] <- x[,i] - f } } } if(method=="affy") { g <- nrow(x) for (k in 1:iterations) { adjustment <- matrix(0,g,n) for (i in 1:(n-1)) for (j in (i+1):n) { m <- x[,j] - x[,i] a <- .5*(x[,j] + x[,i]) f <- loessFit(m, a, weights=weights, span=span)$fitted adjustment[,j] <- adjustment[,j] + f adjustment[,i] <- adjustment[,i] - f } x <- x-adjustment/n } } x } limma/R/background.R0000755007451300017500000001045312127125240014455 0ustar charlescharles# BACKGROUND.R # BACKGROUND CORRECTION backgroundCorrect <- function(RG, method="auto", offset=0, printer=RG$printer, normexp.method="saddle", verbose=TRUE) { # Apply background correction to microarray data # Gordon Smyth # 12 April 2003. Last modified 30 August 2010. if(is.null(method)) method <- "auto" if(is(RG,"EListRaw")) { RG$E <- backgroundCorrect.matrix(RG$E,RG$Eb,method=method,offset=offset,normexp.method=normexp.method,verbose=verbose) RG$Eb <- NULL return(RG) } if(class(RG)=="list" && !is.null(RG$R)) RG <- new("RGList",RG) if(is(RG,"RGList")) { RG$R <- backgroundCorrect.matrix(RG$R,RG$Rb,method=method,offset=offset,normexp.method=normexp.method,verbose=verbose) RG$Rb <- NULL RG$G <- backgroundCorrect.matrix(RG$G,RG$Gb,method=method,offset=offset,normexp.method=normexp.method,verbose=verbose) RG$Gb <- NULL return(RG) } RG <- as.matrix(RG) if(!(method %in% c("none","normexp"))) stop(method,"correction requires background intensities") RG <- backgroundCorrect.matrix(RG,method=method,offset=offset,normexp.method=normexp.method,verbose=verbose) return(RG) } backgroundCorrect.matrix <- function(E, Eb=NULL, method="auto", offset=0, printer=NULL, normexp.method="saddle", verbose=TRUE) { # Apply background correction to microarray data # in the form of foreground and background matrices # Gordon Smyth # 30 August 2010. Last modified 30 August 2010. E <- as.matrix(E) if(method=="auto") method <- ifelse(is.null(Eb),"normexp","subtract") method <- match.arg(method, c("none","subtract","half","minimum","movingmin","edwards","normexp")) if(is.null(Eb)) { if(method %in% c("subtract","half","minimum","movingmin","edwards")) method <- "none" } else { Eb <- as.matrix(Eb) } switch(method, subtract={ E <- E-Eb }, half={ E <- pmax(E-Eb, 0.5) }, minimum={ E <- E-Eb for (slide in 1:ncol(E)) { i <- E[,slide] < 1e-18 if(any(i,na.rm=TRUE)) { m <- min(E[!i,slide],na.rm=TRUE) E[i,slide] <- m/2 } } }, movingmin={ if(is.null(printer)) { E <- E-ma3x3.matrix(Eb,FUN=min,na.rm=TRUE) } else { E <- E-ma3x3.spottedarray(Eb,printer=printer,FUN=min,na.rm=TRUE) } }, edwards={ # Log-linear interpolation for dull spots as in Edwards (2003). # The threshold values (delta) are chosen such that the number of # spots with (0 < R-Rb < delta) is f=10% of the number spots # with (R-Rb <= 0) for each channel and array. # Note slight change from Edwards (2003). one <- matrix(1,nrow(E),1) delta.vec <- function(d, f=0.1) { quantile(d, mean(d<1e-16,na.rm=TRUE)*(1+f), na.rm=TRUE) } sub <- E-Eb delta <- one %*% apply(sub, 2, delta.vec) E <- ifelse(sub < delta, delta*exp(1-(Eb+delta)/E), sub) }, normexp={ if(!is.null(Eb)) E <- E-Eb for (j in 1:ncol(E)) { if(verbose) cat("Array",j) x <- E[,j] out <- normexp.fit(x,method=normexp.method) E[,j] <- normexp.signal(out$par,x) if(verbose) cat(" corrected\n") } } ) if(offset) E <- E+offset E } ma3x3.matrix <- function(x,FUN=mean,na.rm=TRUE,...) # 2-dimensional moving average for 3x3 blocks # Gordon Smyth # 11 April 2004 { # Pad out x with NA so that original values have 8 neighbors d1 <- nrow(x) d2 <- ncol(x) y <- matrix(NA,d1+2,d2+2) y[1+(1:d1),1+(1:d2)] <- x # Index vector for original values i <- 1:length(y) dim(i) <- dim(y) i <- i[1+(1:d1),1+(1:d2)] dim(i) <- NULL # Rows are original obs, columns are neighbors x <- matrix(x,d1*d2,9) ry <- nrow(y) x[,1] <- y[i-ry-1] x[,2] <- y[i-ry] x[,3] <- y[i-ry+1] x[,4] <- y[i-1] x[,6] <- y[i+1] x[,7] <- y[i+ry-1] x[,8] <- y[i+ry] x[,9] <- y[i+ry+1] y <- apply(x,MARGIN=1,FUN=FUN,na.rm=na.rm,...) dim(y) <- c(d1,d2) y } ma3x3.spottedarray <- function(x,printer,FUN=mean,na.rm=TRUE,...) # Gordon Smyth # 11 April 2004 { x <- as.matrix(x) narrays <- ncol(x) gr <- printer$ngrid.r gc <- printer$ngrid.c sr <- printer$nspot.r sc <- printer$nspot.c dim(x) <- c(sc, sr, gc, gr, narrays) x <- aperm(x, perm = c(2, 4, 1, 3, 5)) dim(x) <- c(gr * sr, gc * sc, narrays) for (j in 1:narrays) x[,,j] <- ma3x3.matrix(x[,,j],FUN=FUN,na.rm=TRUE,...) dim(x) <- c(sr, gr, sc, gc, narrays) x <- aperm(x, perm = c(3, 1, 4, 2, 5)) dim(x) <- c(sc*sr*gc*gr, narrays) x } limma/R/contrasts.R0000644007451300017500000001012012127125240014342 0ustar charlescharles# CONTRASTS contrasts.fit <- function(fit,contrasts=NULL,coefficients=NULL) { # Convert coefficients and std deviations in fit object to reflect contrasts of interest # Note: does not completely take probe-wise weights into account # because this would require refitting the linear model for each probe # Gordon Smyth # 13 Oct 2002. Last modified 10 Oct 2012. ncoef <- NCOL(fit$coefficients) if(is.null(contrasts) == is.null(coefficients)) stop("Must specify only one of contrasts or coefficients") if(!is.null(contrasts)) { contrasts <- as.matrix(contrasts) rn <- rownames(contrasts) cn <- colnames(fit$coefficients) if(!is.null(rn) && !is.null(cn) && any(rn != cn)) warning("row names of contrasts don't match col names of coefficients") } if(!is.null(coefficients)) { ncont <- length(coefficients) contrasts <- diag(ncoef) rownames(contrasts) <- colnames(contrasts) <- colnames(fit$coefficients) contrasts <- contrasts[,coefficients,drop=FALSE] } if(NROW(contrasts)!=ncoef) stop("Number of rows of contrast matrix must match number of coefficients") fit$contrasts <- contrasts if(is.null(fit$cov.coefficients)) { warning("no coef correlation matrix found in fit - assuming orthogonal") cormatrix <- diag(ncoef) } else cormatrix <- cov2cor(fit$cov.coefficients) # If design matrix was singular, reduce to estimable coefficients r <- nrow(cormatrix) if(r < ncoef) { if(is.null(fit$pivot)) stop("cor.coef not full rank but pivot column not found in fit") est <- fit$pivot[1:r] if(any(contrasts[-est,]!=0)) stop("trying to take contrast of non-estimable coefficient") contrasts <- contrasts[est,,drop=FALSE] fit$coefficients <- fit$coefficients[,est,drop=FALSE] fit$stdev.unscaled <- fit$stdev.unscaled[,est,drop=FALSE] ncoef <- r } fit$coefficients <- fit$coefficients %*% contrasts # Test whether design was orthogonal if(length(cormatrix) < 2) { orthog <- TRUE } else { orthog <- all(abs(cormatrix[lower.tri(cormatrix)]) < 1e-14) } # Contrast correlation matrix R <- chol(fit$cov.coefficients) fit$cov.coefficients <- crossprod(R %*% contrasts) fit$pivot <- NULL if(orthog) fit$stdev.unscaled <- sqrt(fit$stdev.unscaled^2 %*% contrasts^2) else { R <- chol(cormatrix) ngenes <- NROW(fit$stdev.unscaled) ncont <- NCOL(contrasts) U <- matrix(1,ngenes,ncont,dimnames=list(rownames(fit$stdev.unscaled),colnames(contrasts))) o <- array(1,c(1,ncoef)) for (i in 1:ngenes) { RUC <- R %*% .vecmat(fit$stdev.unscaled[i,],contrasts) U[i,] <- sqrt(o %*% RUC^2) } fit$stdev.unscaled <- U } fit } #contrasts.fit0 <- function(fit,contrasts,design=NULL) { ## Convert coefficients and std deviations in fit object to reflect contrasts of interest ## Gordon Smyth ## 13 Oct 2002. Last modified 20 May 2004. # # ncoef <- NCOL(fit$coefficients) # if(nrow(contrasts)!=ncoef) stop("Number of rows of contrast matrix must match number of coefficients") # fit$coefficients <- fit$coefficients %*% contrasts # if(is.null(design)) design <- fit$design # if(!is.null(design) && ncoef > 1) { # A <- crossprod( abs(design) > 1e-14 ) # orthog <- all(A[lower.tri(A)]==0) # } # if(is.null(design) || ncoef==1 || orthog) # fit$stdev.unscaled <- sqrt(fit$stdev.unscaled^2 %*% contrasts^2) # else { # A <- chol2inv(chol(crossprod(design))) # s <- sqrt(diag(A)) # R <- chol(t(A/s)/s) # ngenes <- NROW(fit$stdev.unscaled) # ncont <- NCOL(contrasts) # U <- matrix(1,ngenes,ncont,dimnames=list(rownames(fit$stdev.unscaled),colnames(contrasts))) # o <- array(1,c(1,ncoef)) # for (i in 1:ngenes) { # RUC <- R %*% .vecmat(fit$stdev.unscaled[i,],contrasts) # U[i,] <- sqrt(o %*% RUC^2) # } # fit$stdev.unscaled <- U # } # fit$contrasts <- contrasts # fit #} #contrasts.fit <- function(fit,contrasts) { ## Extract contrast information from oneway linear model fit ## Gordon Smyth ## 13 Oct 2002. Last modified 1 July 2003. # # fit$coefficients <- fit$coefficients %*% contrasts # fit$stdev.unscaled <- sqrt(fit$stdev.unscaled^2 %*% contrasts^2) # fit$contrasts <- contrasts # fit #} limma/R/plotMDS.R0000644007451300017500000000642012170636047013666 0ustar charlescharles## PLOTMDS.R # Class to hold multidimensional scaling output setClass("MDS",representation("list")) setMethod("show","MDS",function(object) { cat("An object of class MDS\n") print(unclass(object)) }) plotMDS <- function(x,...) UseMethod("plotMDS") plotMDS.MDS <- function(x,labels=colnames(x$distance.matrix),col=NULL,cex=1,dim.plot=x$dim.plot,xlab=paste("Dimension",dim.plot[1]),ylab=paste("Dimension",dim.plot[2]),...) # Method for MDS objects # Create a new plot using MDS coordinates or distances previously created # Gordon Smyth # 21 May 2011. Last modified 6 Sep 2012. { # Are new dimensions requested? if(!all(dim.plot==x$dim.plot)) { ndim <- max(dim.plot) if(ndim > ncol(x$cmdscale.out)) x$cmdscale.out <- cmdscale(as.dist(x$distance.matrix),k=ndim) x$x <- x$cmdscale.out[,dim.plot[1]] x$y <- x$cmdscale.out[,dim.plot[2]] } # Estimate width of labels in plot coordinates. # Estimate will be ok for default plot width, but maybe too small for smaller plots. if(is.null(labels)) labels <- 1:length(x$x) labels <- as.character(labels) StringRadius <- 0.01*cex*nchar(labels) left.x <- x$x-StringRadius right.x <- x$x+StringRadius # Redo plot plot(c(left.x,right.x),c(x$y,x$y),type="n",xlab=xlab,ylab=ylab,...) text(x$x,x$y,labels=labels,col=col,cex=cex) return(invisible(x)) } plotMDS.default <- function(x,top=500,labels=colnames(x),col=NULL,cex=1,dim.plot=c(1,2),ndim=max(dim.plot),gene.selection="pairwise",xlab=paste("Dimension",dim.plot[1]),ylab=paste("Dimension",dim.plot[2]),...) # Multi-dimensional scaling with top-distance # Di Wu and Gordon Smyth # 19 March 2009. Last modified 29 May 2013. { # Check x x <- as.matrix(x) nsamples <- ncol(x) if(nsamples < 3) stop("Need at least 3 columns") cn <- colnames(x) # Remove rows with missing or Inf values bad <- rowSums(is.finite(x)) < nsamples if(any(bad)) x <- x[!bad,,drop=FALSE] nprobes <- nrow(x) # Check top top <- min(top,nprobes) # Check labels if(is.null(labels)) labels <- 1:nsamples labels <- as.character(labels) # Check dim if(ndim < 2) stop("Need at least two dim.plot") if(nsamples < ndim) stop("Two few samples") if(nprobes < ndim) stop("Too few rows") # Check gene.selection gene.selection <- match.arg(gene.selection,c("pairwise","common")) # Distance matrix from pairwise leading fold changes dd <- matrix(0,nrow=nsamples,ncol=nsamples,dimnames=list(cn,cn)) topindex <- nprobes-top+1 if(gene.selection=="pairwise") { # Distance measure is mean of top squared deviations for each pair of arrays for (i in 2:(nsamples)) for (j in 1:(i-1)) dd[i,j]=sqrt(mean(sort.int((x[,i]-x[,j])^2,partial=topindex)[topindex:nprobes])) } else { # Same genes used for all comparisons s <- rowMeans((x-rowMeans(x))^2) q <- quantile(s,p=(topindex-1.5)/(nprobes-1)) x <- x[s>=q,] for (i in 2:(nsamples)) dd[i,1:(i-1)]=sqrt(colMeans((x[,i]-x[,1:(i-1),drop=FALSE])^2)) } # Multi-dimensional scaling a1 <- cmdscale(as.dist(dd),k=ndim) # Make MDS object and call plotMDS method mds <- new("MDS",list(dim.plot=dim.plot,distance.matrix=dd,cmdscale.out=a1,top=top,gene.selection=gene.selection)) mds$x <- a1[,dim.plot[1]] mds$y <- a1[,dim.plot[2]] plotMDS(mds,labels=labels,col=col,cex=cex,xlab=xlab,ylab=ylab,...) } limma/R/ebayes.R0000755007451300017500000001210612170636047013615 0ustar charlescharles# EMPIRICAL BAYES FUNCTIONS eBayes <- function(fit,proportion=0.01,stdev.coef.lim=c(0.1,4),trend=FALSE,robust=FALSE,winsor.tail.p=c(0.05,0.1)) # Empirical Bayes statistics to select differentially expressed genes # Object orientated version # Gordon Smyth # 4 August 2003. Last modified 20 November 2012. { if(trend) if(is.null(fit$Amean)) stop("Need Amean component in fit to estimate trend") eb <- ebayes(fit=fit,proportion=proportion,stdev.coef.lim=stdev.coef.lim,trend=trend,robust=robust,winsor.tail.p=winsor.tail.p) fit$df.prior <- eb$df.prior fit$s2.prior <- eb$s2.prior fit$var.prior <- eb$var.prior fit$proportion <- proportion fit$s2.post <- eb$s2.post fit$t <- eb$t fit$df.total <- eb$df.total fit$p.value <- eb$p.value fit$lods <- eb$lods if(!is.null(fit$design) && is.fullrank(fit$design)) { F.stat <- classifyTestsF(fit,fstat.only=TRUE) fit$F <- as.vector(F.stat) df1 <- attr(F.stat,"df1") df2 <- attr(F.stat,"df2") if(df2[1] > 1e6) # Work around bug in R 2.1 fit$F.p.value <- pchisq(df1*fit$F,df1,lower.tail=FALSE) else fit$F.p.value <- pf(fit$F,df1,df2,lower.tail=FALSE) } fit } ebayes <- function(fit,proportion=0.01,stdev.coef.lim=c(0.1,4),trend=FALSE,robust=FALSE,winsor.tail.p=c(0.05,0.1)) # Empirical Bayes statistics to select differentially expressed genes # Gordon Smyth # 8 Sept 2002. Last revised 1 May 2013. { coefficients <- fit$coefficients stdev.unscaled <- fit$stdev.unscaled sigma <- fit$sigma df.residual <- fit$df.residual if(is.null(coefficients) || is.null(stdev.unscaled) || is.null(sigma) || is.null(df.residual)) stop("No data, or argument is not a valid lmFit object") if(all(df.residual==0)) stop("No residual degrees of freedom in linear model fits") if(all(!is.finite(sigma))) stop("No finite residual standard deviations") if(trend) { covariate <- fit$Amean if(is.null(covariate)) stop("Need Amean component in fit to estimate trend") } else { covariate <- NULL } # Moderated t-statistic out <- squeezeVar(sigma^2, df.residual, covariate=covariate, robust=robust, winsor.tail.p=winsor.tail.p) out$s2.prior <- out$var.prior out$s2.post <- out$var.post out$var.prior <- out$var.post <- NULL out$t <- coefficients / stdev.unscaled / sqrt(out$s2.post) df.total <- df.residual + out$df.prior df.pooled <- sum(df.residual,na.rm=TRUE) df.total <- pmin(df.total,df.pooled) out$df.total <- df.total out$p.value <- 2*pt(-abs(out$t),df=df.total) # B-statistic var.prior.lim <- stdev.coef.lim^2/median(out$s2.prior) out$var.prior <- tmixture.matrix(out$t,stdev.unscaled,df.total,proportion,var.prior.lim) if(any(is.na(out$var.prior))) { out$var.prior[ is.na(out$var.prior) ] <- 1/out$s2.prior warning("Estimation of var.prior failed - set to default value") } r <- rep(1,NROW(out$t)) %o% out$var.prior r <- (stdev.unscaled^2+r) / stdev.unscaled^2 t2 <- out$t^2 Infdf <- out$df.prior > 10^6 if(any(Infdf)) { kernel <- t2*(1-1/r)/2 if(any(!Infdf)) { t2.f <- t2[!Infdf] r.f <- r[!Infdf] df.total.f <- df.total[!Infdf] kernel[!Infdf] <- (1+df.total.f)/2*log((t2.f+df.total.f) / (t2.f/r.f+df.total.f)) } } else kernel <- (1+df.total)/2*log((t2+df.total) / (t2/r+df.total)) out$lods <- log(proportion/(1-proportion))-log(r)/2+kernel out } tmixture.matrix <- function(tstat,stdev.unscaled,df,proportion,v0.lim=NULL) { # Estimate the prior variance of the coefficients for DE genes # Gordon Smyth # 18 Nov 2002. Last modified 12 Dec 2003. tstat <- as.matrix(tstat) stdev.unscaled <- as.matrix(stdev.unscaled) if(any(dim(tstat) != dim(stdev.unscaled))) stop("Dims of tstat and stdev.unscaled don't match") if(!is.null(v0.lim)) if(length(v0.lim) != 2) stop("v0.lim must have length 2") ncoef <- ncol(tstat) v0 <- rep(0,ncoef) for (j in 1:ncoef) v0[j] <- tmixture.vector(tstat[,j],stdev.unscaled[,j],df,proportion,v0.lim) v0 } tmixture.vector <- function(tstat,stdev.unscaled,df,proportion,v0.lim=NULL) { # Estimate scale factor in mixture of two t-distributions # tstat is assumed to follow (v0+v1)/v1*t(df) with probability proportion and t(df) otherwise # v1 is stdev.unscaled^2 and v0 is to be estimated # Gordon Smyth # 18 Nov 2002. Last modified 13 Dec 2003. if(any(is.na(tstat))) { o <- !is.na(tstat) tstat <- tstat[o] stdev.unscaled <- stdev.unscaled[o] df <- df[o] } ngenes <- length(tstat) ntarget <- ceiling(proportion/2*ngenes) if(ntarget < 1) return(NA) # If ntarget is v small, ensure p at least matches selected proportion # This ensures ptarget < 1 p <- max(ntarget/ngenes,proportion) tstat <- abs(tstat) ttarget <- quantile(tstat,(ngenes-ntarget)/(ngenes-1)) top <- (tstat >= ttarget) tstat <- tstat[top] v1 <- stdev.unscaled[top]^2 df <- df[top] r <- ntarget-rank(tstat)+1 p0 <- pt(-tstat,df=df) ptarget <- ( (r-0.5)/2/ngenes - (1-p)*p0 ) / p pos <- ptarget > p0 v0 <- rep(0,ntarget) if(any(pos)) { qtarget <- qt(ptarget[pos],df=df[pos]) v0[pos] <- v1[pos]*((tstat[pos]/qtarget)^2-1) } if(!is.null(v0.lim)) v0 <- pmin(pmax(v0,v0.lim[1]),v0.lim[2]) mean(v0) } limma/man/0000755007451300017500000000000012175540776012601 5ustar charlescharleslimma/man/tmixture.Rd0000755007451300017500000000276312127125247014751 0ustar charlescharles\name{tmixture} \alias{tmixture.vector} \alias{tmixture.matrix} \title{Estimate Scale Factor in Mixture of t-Distributions} \description{ This function estimates the unscaled standard deviation of the log fold change for differentially expressed genes. It is called by the function \code{ebayes} and is not intended to be called by users. } \usage{ tmixture.vector(tstat,stdev.unscaled,df,proportion,v0.lim=NULL) tmixture.matrix(tstat,stdev.unscaled,df,proportion,v0.lim=NULL) } \arguments{ \item{tstat}{numeric vector or matrix of t-statistics} \item{stdev.unscaled}{numeric matrix conformal with \code{tstatf} containing the unscaled standard deviations for the coefficient estimators} \item{df}{numeric vector giving the degrees of freedom associated with \code{tstat}} \item{proportion}{assumed proportion of genes which are differentially expressed} \item{v0.lim}{numeric vector of length 2, assumed lower and upper limits for the estimated unscaled standard deviation} } \details{ The values in each column of \code{tstat} are assumed to follow a mixture of an ordinary t-distribution, with mixing proportion \code{1-proportion}, and \code{(v0+v1)/v1} times a t-distribution, with mixing proportion \code{proportion}. Here \code{v1=stdev.unscaled^2} and \code{v0} is the value to be estimated. } \value{ Numeric vector of length equal to the number of columns of \code{tstat} and \code{stdev.unscaled}. } \seealso{ \code{\link{ebayes}} } \author{Gordon Smyth} \keyword{htest} limma/man/isnumeric.Rd0000755007451300017500000000151112127125247015054 0ustar charlescharles\name{isNumeric} \alias{isNumeric} \title{Test for Numeric Argument} \description{ Test whether argument is numeric or a data.frame with numeric columns. } \usage{ isNumeric(x) } \arguments{ \item{x}{any object} } \value{\code{TRUE} or \code{FALSE}} \details{ This function is used to check the validity of arguments for numeric functions. It is an attempt to emulate the behavior of internal generic math functions. \code{isNumeric} differs from \code{is.numeric} in that data.frames with all columns numeric are accepted as numeric. } \author{Gordon Smyth} \examples{ isNumeric(3) isNumeric("a") x <- data.frame(a=c(1,1),b=c(0,1)) isNumeric(x) # TRUE is.numeric(x) # FALSE } \seealso{ \code{\link[base:numeric]{is.numeric}}, \code{\link[base:groupGeneric]{Math}} } \keyword{programming} limma/man/LargeDataObject.Rd0000755007451300017500000000145412127125247016037 0ustar charlescharles\name{LargeDataObject-class} \docType{class} \alias{LargeDataObject-class} \alias{show,LargeDataObject-method} \title{Large Data Object - class} \description{ A virtual class including the data classes \code{RGList}, \code{MAList} and \code{MArrayLM}, all of which typically contain large quantities of numerical data in vector, matrices and data.frames. } \section{Methods}{ A \code{show} method is defined for objects of class \code{LargeDataObject} which uses \code{printHead} to print only the leading elements or rows of components or slots which contain large quantities of data. } \author{Gordon Smyth} \seealso{ \link{02.Classes} gives an overview of all the classes defined by this package. } \examples{ # see normalizeBetweenArrays } \keyword{classes} \keyword{data} limma/man/lmscFit.Rd0000755007451300017500000000542712150771760014474 0ustar charlescharles\name{lmscFit} \alias{lmscFit} \title{Fit Linear Model to Individual Channels of Two-Color Data} \description{Fit a linear model to the individual log-intensities for each gene given a series of two-color arrays} \usage{ lmscFit(object, design, correlation) } \arguments{ \item{object}{an \code{\link[limma:malist]{MAList}} object or a list from which \code{M} and \code{A} values may be extracted} \item{design}{a numeric matrix containing the design matrix for linear model in terms of the individual channels. The number of rows should be twice the number of arrays. The number of columns will determine the number of coefficients estimated for each gene.} \item{correlation}{numeric value giving the intra-spot correlation} } \value{ An object of class \code{\link[limma:marraylm]{MArrayLM}} } \details{ For two color arrays, the channels measured on the same set of arrays are correlated. The \code{M} and \code{A} however are uncorrelated for each gene. This function fits a linear model to the set of M and A-values for each gene after re-scaling the M and A-values to have equal variances. The input correlation determines the scaling required. The input correlation is usually estimated using \code{\link{intraspotCorrelation}} before using \code{lmscFit}. Missing values in \code{M} or \code{A} are not allowed. } \author{Gordon Smyth} \seealso{ \code{\link[stats:lmfit]{lm.fit}}. An overview of methods for single channel analysis in limma is given by \link{07.SingleChannel}. } \references{ Smyth, GK (2005). Individual channel analysis of two-colour microarray data. \emph{Proceedings of the 55th Session of the International Statistics Institute}, 5-12 April 2005, Sydney, Australia; Internatational Statistics Institute; Paper 116. \url{http://www.statsci.org/smyth/pubs/ISI2005-116.pdf} Smyth, GK, and Altman, NS (2013). Separate-channel analysis of two-channel microarrays: recovering inter-spot information. \emph{BMC Bioinformatics} 14, 165. \url{http://www.biomedcentral.com/1471-2105/14/165} } \examples{ \dontrun{ # Subset of data from ApoAI case study in Limma User's Guide # Avoid non-positive intensities RG <- backgroundCorrect(RG,method="normexp") MA <- normalizeWithinArrays(RG) MA <- normalizeBetweenArrays(MA,method="Aq") targets <- data.frame(Cy3=I(rep("Pool",6)),Cy5=I(c("WT","WT","WT","KO","KO","KO"))) targets.sc <- targetsA2C(targets) targets.sc$Target <- factor(targets.sc$Target,levels=c("Pool","WT","KO")) design <- model.matrix(~Target,data=targets.sc) corfit <- intraspotCorrelation(MA,design) fit <- lmscFit(MA,design,correlation=corfit$consensus) cont.matrix <- cbind(KOvsWT=c(0,-1,1)) fit2 <- contrasts.fit(fit,cont.matrix) fit2 <- eBayes(fit2) topTable(fit2,adjust="fdr") } } \keyword{models} \keyword{regression} limma/man/lmFit.Rd0000755007451300017500000001533212150771760014142 0ustar charlescharles\name{lmFit} \alias{lmFit} \title{Linear Model for Series of Arrays} \description{Fit linear model for each gene given a series of arrays} \usage{ lmFit(object,design=NULL,ndups=1,spacing=1,block=NULL,correlation,weights=NULL,method="ls",...) } \arguments{ \item{object}{object of class \code{numeric}, \code{matrix}, \code{MAList}, \code{EList}, \code{marrayNorm}, \code{ExpressionSet} or \code{PLMset} containing log-ratios or log-values of expression for a series of microarrays} \item{design}{the design matrix of the microarray experiment, with rows corresponding to arrays and columns to coefficients to be estimated. Defaults to the unit vector meaning that the arrays are treated as replicates.} \item{ndups}{positive integer giving the number of times each gene is printed on an array} \item{spacing}{positive integer giving the spacing between duplicate spots, \code{spacing=1} for consecutive spots} \item{block}{vector or factor specifying a blocking variable on the arrays. Has length equal to the number of arrays. Must be \code{NULL} if \code{ndups>2}.} \item{correlation}{the inter-duplicate or inter-technical replicate correlation} \item{weights}{optional numeric matrix containing weights for each spot} \item{method}{character string, \code{"ls"} for least squares or \code{"robust"} for robust regression} \item{...}{other optional arguments to be passed to \code{lm.series}, \code{gls.series} or \code{mrlm}} } \value{ An \code{\link[limma:marraylm]{MArrayLM}} object containing the result of the fits. } \details{ This function fits multiple linear models by weighted or generalized least squares. It accepts data from a experiment involving a series of microarrays with the same set of probes. A linear model is fitted to the expression data for each probe. The expression data should be log-ratios for two-color array platforms or log-expression values for one-channel platforms. (To fit linear models to the individual channels of two-color array data, see \code{\link{lmscFit}}.) The coefficients of the fitted models describe the differences between the RNA sources hybridized to the arrays. The probe-wise fitted model results are stored in a compact form suitable for further processing by other functions in the limma package. The function allows for missing values and accepts quantitative weights through the \code{weights} argument. It also supports two different correlation structures. If \code{block} is not \code{NULL} then different arrays are assumed to be correlated. If \code{block} is \code{NULL} and \code{ndups} is greater than one then replicate spots on the same array are assumed to be correlated. It is not possible at this time to fit models with both a block structure and a duplicate-spot correlation structure simultaneously. If \code{object} is a matrix then it should contain log-ratios or log-expression data with rows corresponding to probes and columns to arrays. (A numeric vector is treated the same as a matrix with one column.) For objects of other classes, a matrix of expression values is taken from the appropriate component or slot of the object. If \code{object} is of class \code{MAList} or \code{marrayNorm}, then the matrix of log-ratios (M-values) is extracted. If \code{object} is of class \code{ExpressionSet}, then the expression matrix is extracted. (This may contain log-expression or log-ratio values, depending on the platform.) If \code{object} is of class \code{PLMset} then the matrix of chip coefficients \code{chip.coefs} is extracted. The arguments \code{design}, \code{ndups}, \code{spacing} and \code{weights} will be extracted from the data \code{object} if available and do not normally need to set explicitly in the call. On the other hand, if any of these are set in the function call then they will over-ride the slots or components in the data \code{object}. If \code{object} is an \code{PLMset}, then weights are computed as \code{1/pmax(object@se.chip.coefs, 1e-05)^2}. If \code{object} is an \code{ExpressionSet} object, then weights are not computed. If the argument \code{block} is used, then it is assumed that \code{ndups=1}. The \code{correlation} argument has a default value of \code{0.75}, but in normal use this default value should not be relied on and the correlation value should be estimated using the function \code{duplicateCorrelation}. The default value is likely to be too high in particular if used with the \code{block} argument. The actual linear model computations are done by passing the data to one the lower-level functions \code{lm.series}, \code{gls.series} or \code{mrlm}. The function \code{mrlm} is used if \code{method="robust"}. If \code{method="ls"}, then \code{gls.series} is used if a correlation structure has been specified, i.e., if \code{ndups>1} or \code{block} is non-null and \code{correlation} is different from zero. If \code{method="ls"} and there is no correlation structure, \code{lm.series} is used. } \seealso{ \code{lmFit} uses \code{\link{getEAWP}} to extract expression values, gene annotation and so from the data \code{object}. An overview of linear model functions in limma is given by \link{06.LinearModels}. } \author{Gordon Smyth} \examples{ # Simulate gene expression data for 100 probes and 6 microarrays # Microarray are in two groups # First two probes are differentially expressed in second group # Std deviations vary between genes with prior df=4 sd <- 0.3*sqrt(4/rchisq(100,df=4)) y <- matrix(rnorm(100*6,sd=sd),100,6) rownames(y) <- paste("Gene",1:100) y[1:2,4:6] <- y[1:2,4:6] + 2 design <- cbind(Grp1=1,Grp2vs1=c(0,0,0,1,1,1)) options(digits=3) # Ordinary fit fit <- lmFit(y,design) fit <- eBayes(fit) topTable(fit,coef=2) dim(fit) colnames(fit) rownames(fit)[1:10] names(fit) # Fold-change thresholding fit2 <- treat(fit,lfc=0.1) topTreat(fit2,coef=2) # Volcano plot volcanoplot(fit,coef=2,highlight=2) # Q-Q plot of moderated t-statistics qqt(fit$t[,2],df=fit$df.residual+fit$df.prior) abline(0,1) # Various ways of writing results to file \dontrun{write.fit(fit,file="exampleresults.txt")} \dontrun{write.table(fit,file="exampleresults2.txt")} # Fit with correlated arrays # Suppose each pair of arrays is a block block <- c(1,1,2,2,3,3) dupcor <- duplicateCorrelation(y,design,block=block) dupcor$consensus.correlation fit3 <- lmFit(y,design,block=block,correlation=dupcor$consensus) # Fit with duplicate probes # Suppose two side-by-side duplicates of each gene rownames(y) <- paste("Gene",rep(1:50,each=2)) dupcor <- duplicateCorrelation(y,design,ndups=2) dupcor$consensus.correlation fit4 <- lmFit(y,design,ndups=2,correlation=dupcor$consensus) dim(fit4) fit4 <- eBayes(fit3) topTable(fit4,coef=2) } \keyword{models} \keyword{regression} limma/man/02classes.Rd0000644007451300017500000000551312127125247014660 0ustar charlescharles\name{02.Classes} \alias{02.Classes} \title{Classes Defined by this Package} \description{ This package defines the following data classes. \describe{ \item{ \code{\link[limma:rglist]{RGList}} }{ A class used to store raw intensities as they are read in from an image analysis output file, usually by \code{read.maimages}.} \item{ \code{\link[limma:malist]{MAList}} }{ Intensities converted to M-values and A-values, i.e., to with-spot and whole-spot contrasts on the log-scale. Usually created from an \code{RGList} using \code{MA.RG} or \code{normalizeWithinArrays}. Objects of this class contain one row for each spot. There may be more than one spot and therefore more than one row for each probe.} \item{ \code{\link[limma:EList]{EListRaw}} }{ A class to store raw intensities for one-channel microarray data. May or may not be background corrected. Usually created by \code{read.maimages}.} \item{ \code{\link[limma:EList]{EList}} }{ A class to store normalized log2 expression values for one-channel microarray data. Usually created by \code{normalizeBetweenArrays}.} \item{ \code{\link[limma:marraylm]{MArrayLM}} }{ Store the result of fitting gene-wise linear models to the normalized intensities or log-ratios. Usually created by \code{lmFit}. Objects of this class normally contain only one row for each unique probe.} \item{ \code{\link[limma:TestResults]{TestResults}} }{ Store the results of testing a set of contrasts equal to zero for each probe. Usually created by \code{decideTests}. Objects of this class normally contain one row for each unique probe.} } All these data classes obey many analogies with matrices. In the case of \code{RGList}, \code{MAList}, \code{EListRaw} and \code{EList}, rows correspond to spots or probes and columns to arrays. In the case of \code{MarrayLM}, rows correspond to unique probes and the columns to parameters or contrasts. The functions \code{summary}, \code{dim}, \code{length}, \code{ncol}, \code{nrow}, \code{dimnames}, \code{rownames}, \code{colnames} have methods for these classes. Objects of any of these classes may be \link[limma:subsetting]{subsetted}. Multiple data objects may be \link[limma:cbind]{combined} by rows (to add extra probes) or by columns (to add extra arrays). Furthermore all of these classes may be coerced to actually be of class \code{matrix} using \code{as.matrix}, although this entails loss of information. Fitted model objects of class \code{MArrayLM} can be coerced to class \code{data.frame} using \code{\link[limma:asdataframe]{as.data.frame}}. The first three classes belong to the virtual class \code{\link[limma:LargeDataObject]{LargeDataObject}}. A \code{show} method is defined for \code{LargeDataOject}s which uses the utility function \code{\link{printHead}}. } \author{Gordon Smyth} \keyword{documentation} limma/man/anova-method.Rd0000755007451300017500000000400212127125247015436 0ustar charlescharles\name{anova.MAList-method} \docType{methods} \alias{anova.MAList} \title{ANOVA Table - method} \description{ Analysis of variance method for objects of class \code{MAList}. Produces an ANOVA table useful for quality assessment by decomposing between and within gene sums of squares for a series of replicate arrays. This method produces a single ANOVA Table rather than one for each gene and is not used to identify differentially expressed genes. } \section{Usage}{ \code{anova(object,design=NULL,ndups=2,...)} } \section{Arguments}{ \describe{ \item{\code{object}}{object of class \code{MAList}. Missing values in the M-values are not allowed.} \item{\code{design}}{numeric vector or single-column matrix containing the design matrix for linear model. The length of the vector or the number of rows of the matrix should agree with the number of columns of M.} \item{\code{ndups}}{number of duplicate spots. Each gene is printed ndups times in adjacent spots on each array.} \item{\code{...}}{other arguments are not used} } } \section{Details}{ This function aids in quality assessment of microarray data and in the comparison of normalization methodologies. It applies only to replicated two-color experiments in which all the arrays are hybridized with the same RNA targets, possibly with dye-swaps, so the design matrix should have only one column. The function has not been heavily used and is somewhat experimental. } \section{Value}{ An object of class \code{anova} containing rows for between genes, between arrays, gene x array interaction, and between duplicate with array sums of squares. Variance components are estimated for each source of variation. } \note{ This function does not give valid results in the presence of missing M-values. } \seealso{ \code{\link{MAList-class}}, \code{\link{bwss.matrix}}, \code{\link[stats:anova]{anova}}. An overview of quality assessment and diagnostic functions in LIMMA is given by \link{09.Diagnostics}. } \author{Gordon Smyth} \keyword{models} limma/man/roast.Rd0000644007451300017500000002354712170636050014215 0ustar charlescharles\name{roast} \alias{roast} \alias{roast.EList} \alias{roast.MAList} \alias{roast.default} \alias{mroast} \alias{mroast.EList} \alias{mroast.MAList} \alias{mroast.default} \alias{Roast-class} \alias{show,Roast-method} \title{Rotation Gene Set Tests} \description{ Rotation gene set testing for linear models. } \usage{ \method{roast}{EList}(y, index=NULL, design=NULL, contrast=ncol(design), set.statistic="mean", gene.weights=NULL, array.weights=NULL, weights=NULL, block=NULL, correlation, var.prior=NULL, df.prior=NULL, trend.var=FALSE, nrot=999) \method{mroast}{EList}(y, index=NULL, design=NULL, contrast=ncol(design), set.statistic="mean", gene.weights=NULL, array.weights=NULL, weights=NULL, block=NULL, correlation, var.prior=NULL, df.prior=NULL, trend.var=FALSE, nrot=999, adjust.method="BH", midp=TRUE, sort="directional") } \arguments{ \item{y}{numeric matrix giving log-expression or log-ratio values for a series of microarrays, or any object that can coerced to a matrix including \code{ExpressionSet}, \code{MAList}, \code{EList} or \code{PLMSet} objects. Rows correspond to probes and columns to samples. If either \code{var.prior} or \code{df.prior} are null, then \code{y} should contain values for all genes on the arrays. If both prior parameters are given, then only \code{y} values for the test set are required.} \item{index}{index vector specifying which rows (probes) of \code{y} are in the test set. This can be a vector of indices, or a logical vector of the same length as \code{statistics}, or any vector such as \code{y[index,]} contains the values for the gene set to be tested. For \code{mroast}, \code{index} is a list of index vectors.} \item{design}{design matrix} \item{contrast}{contrast for which the test is required. Can be an integer specifying a column of \code{design}, or else a contrast vector of length equal to the number of columns of \code{design}.} \item{set.statistic}{summary set statistic. Possibilities are \code{"mean"},\code{"floormean"},\code{"mean50"} or \code{"msq"}.} \item{gene.weights}{optional numeric vector of weights for genes in the set. Can be positive or negative. For \code{mroast} this vector must have length equal to \code{nrow(y)}. For \code{roast}, can be of length \code{nrow(y)} or of length equal to the number of genes in the test set.} \item{array.weights}{optional numeric vector of array weights.} \item{weights}{optional matrix of observation weights. If supplied, should be of same dimensions as \code{y} and all values should be positive. If \code{y} is an \code{EList} or \code{MAList} object containing weights, then those weights will be used.} \item{block}{optional vector of blocks.} \item{correlation}{correlation between blocks.} \item{var.prior}{prior value for residual variances. If not provided, this is estimated from all the data using \code{squeezeVar}.} \item{df.prior}{prior degrees of freedom for residual variances. If not provided, this is estimated using \code{squeezeVar}.} \item{trend.var}{logical, should a trend be estimated for \code{var.prior}? See \code{eBayes} for details. Only used if \code{var.prior} or \code{df.prior} are \code{NULL}.} \item{nrot}{number of rotations used to estimate the p-values.} \item{adjust.method}{method used to adjust the p-values for multiple testing. See \code{\link{p.adjust}} for possible values.} \item{midp}{logical, should mid-p-values be used in instead of ordinary p-values when adjusting for multiple testing?} \item{sort}{character, whether to sort output table by directional p-values (\code{"directional"}), non-directional p-value (\code{"mixed"}), or not at all (\code{"none"}).} } \value{ \code{roast} produces an object of class \code{"Roast"}. This consists of a list with the following components: \item{p.value}{data.frame with columns \code{Active.Prop} and \code{P.Value}, giving the proportion of genes in the set contributing meaningfully to significance and estimated p-values, respectively. Rows correspond to the alternative hypotheses mixed, up or down.} \item{var.prior}{prior value for residual variances.} \item{df.prior}{prior degrees of freedom for residual variances.} \code{mroast} produces a data.frame with a row for each set and the following columns: \item{NGenes}{number of genes in set} \item{PropDown}{proportion of genes in set with \code{z < -sqrt(2)}} \item{PropUp}{proportion of genes in set with \code{z > sqrt(2)}} \item{Direction}{direction of change, \code{"Up"} or \code{"Down"}} \item{PValue}{two-sided directional p-value} \item{FDR}{two-sided directional false discovery rate} \item{PValue.Mixed}{non-directional p-value} \item{FDR.Mixed}{non-directional false discovery rate} } \details{ These functions implement the ROAST gene set tests proposed by Wu et al (2010). They perform \emph{self-contained} gene set tests in the sense defined by Goeman and Buhlmann (2007). For \emph{competitive} gene set tests, see \code{\link{camera}}. For a gene set enrichment analysis style analysis using a database of gene sets, see \code{\link{romer}}. \code{roast} and \code{mroast} test whether any of the genes in the set are differentially expressed. They can be used for any microarray experiment which can be represented by a linear model. The design matrix for the experiment is specified as for the \code{\link{lmFit}} function, and the contrast of interest is specified as for the \code{\link{contrasts.fit}} function. This allows users to focus on differential expression for any coefficient or contrast in a linear model. If \code{contrast} is not specified, then the last coefficient in the linear model will be tested. The argument \code{gene.weights} allows directional weights to be set for individual genes in the set. This is often useful, because it allows each gene to be flagged as to its direction and magnitude of change based on prior experimentation. A typical use is to make the \code{gene.weights} \code{1} or \code{-1} depending on whether the gene is up or down-regulated in the pathway under consideration. The arguments \code{array.weights}, \code{block} and \code{correlation} have the same meaning as for the \code{\link{lmFit}} function. The arguments \code{df.prior} and \code{var.prior} have the same meaning as in the output of the \code{\link{eBayes}} function. If these arguments are not supplied, they are estimated exactly as is done by \code{eBayes}. The gene set statistics \code{"mean"}, \code{"floormean"}, \code{"mean50"} and \code{msq} are defined by Wu et al (2010). The different gene set statistics have different sensitivities to small number of genes. If \code{set.statistic="mean"} then the set will be statistically significantly only when the majority of the genes are differentially expressed. \code{"floormean"} and \code{"mean50"} will detect as few as 25\% differentially expressed. \code{"msq"} is sensitive to even smaller proportions of differentially expressed genes, if the effects are reasonably large. The output gives p-values three possible alternative hypotheses, \code{"Up"} to test whether the genes in the set tend to be up-regulated, with positive t-statistics, \code{"Down"} to test whether the genes in the set tend to be down-regulated, with negative t-statistics, and \code{"Mixed"} to test whether the genes in the set tend to be differentially expressed, without regard for direction. \code{roast} estimates p-values by simulation, specifically by random rotations of the orthogonalized residuals (Langsrud, 2005), so p-values will vary slightly from run to run. To get more precise p-values, increase the number of rotations \code{nrot}. The p-value is computed as \code{(b+1)/(nrot+1)} where \code{b} is the number of rotations giving a more extreme statistic than that observed (Phipson and Smyth, 2010). This means that the smallest possible p-value is \code{1/(nrot+1)}. \code{mroast} does roast tests for multiple sets, including adjustment for multiple testing. By default, \code{mroast} reports ordinary p-values but uses mid-p-values (Routledge, 1994) at the multiple testing stage. Mid-p-values are probably a good choice when using false discovery rates (\code{adjust.method="BH"}) but not when controlling the family-wise type I error rate (\code{adjust.method="holm"}). } \note{ The default setting for the set statistic was changed in limma 3.5.9 (3 June 2010) from \code{"msq"} to \code{"mean"}. } \seealso{ \code{\link{camera}}, \code{\link{romer}}, \code{\link{geneSetTest}}. An overview of tests in limma is given in \link{08.Tests}. } \author{Gordon Smyth and Di Wu} \references{ Goeman, JJ, and Buhlmann, P (2007). Analyzing gene expression data in terms of gene sets: methodological issues. \emph{Bioinformatics} 23, 980-987. Langsrud, O (2005). Rotation tests. \emph{Statistics and Computing} 15, 53-60. Phipson B, and Smyth GK (2010). Permutation P-values should never be zero: calculating exact P-values when permutations are randomly drawn. \emph{Statistical Applications in Genetics and Molecular Biology}, Volume 9, Article 39. Routledge, RD (1994). Practicing safe statistics with the mid-p. \emph{Canadian Journal of Statistics} 22, 103-110. Wu, D, Lim, E, Francois Vaillant, F, Asselin-Labat, M-L, Visvader, JE, and Smyth, GK (2010). ROAST: rotation gene set tests for complex microarray experiments. \emph{Bioinformatics} 26, 2176-2182. \url{http://bioinformatics.oxfordjournals.org/content/26/17/2176} } \examples{ y <- matrix(rnorm(100*4),100,4) design <- cbind(Intercept=1,Group=c(0,0,1,1)) # First set of 5 genes contains 3 that are genuinely differentially expressed index1 <- 1:5 y[index1,3:4] <- y[index1,3:4]+3 # Second set of 5 genes contains none that are DE index2 <- 6:10 roast(y,index1,design,contrast=2) mroast(y,index1,design,contrast=2) mroast(y,list(set1=index1,set2=index2),design,contrast=2) } \keyword{htest} limma/man/genas.Rd0000644007451300017500000001152512127125247014156 0ustar charlescharles\name{genas} \alias{genas} \alias{genas} \title{Genuine Association of Gene Expression Profiles} \description{ Calculates biological correlation between two gene expression profiles. } \usage{ genas(fit, coef=c(1,2), chooseMethod=NULL,plot=FALSE,alpha=0.4) } \arguments{ \item{fit}{an \code{MArrayLM} fitted model object produced by \code{lmFit} or \code{contrasts.fit} and followed by \code{eBayes}} \item{coef}{numeric vector of length 2 to indicate which contrasts/columns in the fit object are to be used} \item{chooseMethod}{character string, "n" for none, "Fpval" to subset using the F p-value, "p.union" to subset based on the union of the two contrasts' significant moderated t p-value, "p.int" to subset based on the intersection of the two contrasts' significant moderated t p-value, "logFC" to subset based on genes that have absolute logFC greater than the 90th quantile, "predFC" to subset based on genes that have absolute predictive logFC greater than the 90th quantile} \item{plot}{logical, if true a logFC versus logFC plot is outputted with biological and technical correlation represented by ellipses} \item{alpha}{plot option, a numeric value between 0 and 1 which determines the transparency of the ellipses} } \details{ The biological correlation between the log fold changes of pairs of comparisons is computed. This method is to be applied when multiple groups (such as treatment groups, mutants or knock-outs) are compared back to the same control group. This method is an extension of the empirical Bayes method of \code{limma}. It aims to separate the technical correlation, which comes from comparing multiple treatment/mutant/knock-out groups to the same control group, from biological correlation, which is the true correlation of the gene expression profiles between two treatment/mutant/knock-out groups. The \code{chooseMethod} argument specifies whether and how the fit object should be subsetted. The default is "n", which uses all genes in the fit object to estimate the biological correlation. Only genes that display evidence of differential expression can be used to estimate the biological correlation. The option "Fpval" chooses genes based on how many F p-values are estimated to be truly significant using the method \code{propNotDE}. This should capture genes that display any evidence of differential expression in either of the two contrasts. The options "p.union" and "p.int" are based on the moderated t p-values from both contrasts. From the \code{propNotDE} method an estimate of the number of p-values truly significant in either of the two contrasts can be obtained. "p.union" takes the union of these genes and "p.int" takes the intersection of these genes. The other options, "logFC" and "predFC" subsets on genes that attain a logFC or predFC at least as large as the 90th percentile of the log fold changes or predictive log fold changes on the absolute scale. The \code{plot} option is a logical argument that specifies whether or not to plot the log fold changes of the two contrasts. The biological and technical correlations are overlaid on the log fold change versus log fold change scatterplot using transparent ellipses. \code{library(ellipse)} is required to enable the plotting of ellipses. The \code{alpha} argument takes values between 0 and 1 and controls how transparent the ellipses are. } \value{ \code{genas} produces a list with the following components. \item{technical.correlation}{estimate of the technical correlation} \item{covariance.matrix}{estimate of the covariance matrix from which the biological correlation is obtained} \item{biological.correlation}{estimate of the biological correlation} \item{deviance}{the likelihood ratio test statistic used to test whether the biological correlation is equal to 0} \item{p.value}{the p.value associated with \code{deviance}} \item{n}{the number of genes used to estimate the biological correlation} } \seealso{ \code{\link{lmFit}}, \code{\link{eBayes}}, \code{\link{contrasts.fit}} } \author{Belinda Phipson and Gordon Smyth} \references{ Phipson, B. (2013). \emph{Empirical Bayes modelling of expression profiles and their associations}. PhD Thesis. University of Melbourne, Australia. } \examples{ library(limma) # Simulate gene expression data, # 6 microarrays with 1000 genes on each array set.seed(2004) y<-matrix(rnorm(6000),ncol=6) # two experimental groups and one control group with two replicates each group<-factor(c("A","A","B","B","control","control")) design<-model.matrix(~0+group) colnames(design)<-c("A","B","control") # fit a linear model fit<-lmFit(y,design) contrasts<-makeContrasts(A-control,B-control,levels=design) fit2<-contrasts.fit(fit,contrasts) fit2<-eBayes(fit2) # calculate biological correlation between the gene expression profiles of (A vs control) and (B vs control) genas(fit2) }limma/man/normexpfit.Rd0000644007451300017500000001061112127125247015247 0ustar charlescharles\name{normexp.fit} \alias{normexp.fit} \title{Fit Normal+Exp Convolution Model to Observed Intensities} \description{ Fit the normal+exponential convolution model to a vector of observed intensities. The normal part represents the background and the exponential part represents the signal intensities. This function is called by \code{backgroundCorrect} and is not normally called directly by users. } \usage{ normexp.fit(x, method="saddle", n.pts=NULL, trace=FALSE) } \arguments{ \item{x}{numeric vector of (background corrected) intensities} \item{method}{method used to estimate the three parameters. Choices for \code{normexp.fit} are \code{"mle"}, \code{"saddle"}, \code{"rma"} and \code{"rma75"}.} \item{n.pts}{number of quantiles of \code{x} to use for the fit. If \code{NULL} then all values of \code{x} will be used.} \item{trace}{logical, if \code{TRUE}, tracing information on the progress of the optimization is given.} } \details{ The Normal+Exp (normexp) convolution model is a mathematical model representing microarray intensity data for the purposes of background correction. It was proposed originally as part of the RMA algorithm for Affymetrix microarray data. For two-color microarry data, the normexp background correction method was introduced and compared with other methods by Ritchie et al (2007). This function uses maximum likelihood estimation to fit the normexp model to background-corrected intensities. The model assumes that the observed intensities are the sum of background and signal components, the background being normal and the signal being exponential distributed. The likelihood may be computed exactly (\code{method="mle"}) or approximated using a saddle-point approximation (\code{method="saddle"}). The saddle-point approximation was proposed by Ritchie et al (2007). Silver et al (2008) added some computational refinements to the saddle-point approximation, making it more reliable in practice, and developed the exact likelihood maximization algorithm. The \code{"mle"} method uses the best performing algorithm from Silver et al (2008), which calls the optimization function \code{\link{nlminb}} with analytic first and second derivatives. Derivatives are computed with respect to the normal-mean, the log-normal-variance and the log-exponential-mean. Two ad-hoc estimators are also available which do not require iterative estimation. \code{"rma"} results in a call to the \code{bg.parameters} function of the affy package. This provides the kernel estimation method that is part of the RMA algorithm for Affymetrix data. \code{"rma75"} uses the similar but less biased RMA-75 method from McGee and Chen (2006). If the length \code{x} is very large, it may be worth saving computation time by setting \code{n.pts} to a value less than the total number of probes, for example \code{n.pts=2^14}. } \value{ A list containing the components \item{par}{numeric vector giving estimated values of the mean and log-standard-deviation of the background-normal part and the log-mean of the signal-exponential part.} \item{m2loglik}{numeric scalar giving minus twice the maximized log-likelihood} \item{convergence}{integer code indicating successful convergence or otherwise of the optimization.} } \author{Gordon Smyth and Jeremy Silver} \references{ McGee, M., and Chen, Z. (2006). Parameter estimation for the exponential-normal convolution model for background correction of Affymetrix GeneChip data. \emph{Stat Appl Genet Mol Biol}, 5(1), Article 24. Ritchie, M. E., Silver, J., Oshlack, A., Silver, J., Holmes, M., Diyagama, D., Holloway, A., and Smyth, G. K. (2007). A comparison of background correction methods for two-colour microarrays. \emph{Bioinformatics} \url{http://bioinformatics.oxfordjournals.org/cgi/content/abstract/btm412} Silver, JD, Ritchie, ME, and Smyth, GK (2009). Microarray background correction: maximum likelihood estimation for the normal-exponential convolution. \emph{Biostatistics} 10, 352-363. \url{http://biostatistics.oxfordjournals.org/cgi/content/abstract/kxn042} } \seealso{ \code{\link{normexp.signal}}, \code{\link{normexp.fit.control}}. Also \code{\link[affy:bg.adjust]{bg.parameters} in the affy package. } An overview of background correction functions is given in \code{\link{04.Background}}. } \examples{ x <- c(2,3,1,10,3,20,5,6) out <- normexp.fit(x) normexp.signal(out$par, x=x) } \keyword{models} limma/man/rankSumTestwithCorrelation.Rd0000644007451300017500000000551412127125247020440 0ustar charlescharles\name{rankSumTestWithCorrelation} \alias{rankSumTestWithCorrelation} \title{Two Sample Wilcoxon-Mann-Whitney Rank Sum Test Allowing For Correlation} \description{ A extension of the well-known rank-based test, but allowing for correlations between cases. } \usage{ rankSumTestWithCorrelation(index, statistics, correlation=0, df=Inf) } \arguments{ \item{index}{any index vector such that \code{statistics[index]} contains the values of the statistic for the test group.} \item{statistics}{numeric vector giving values of the test statistic.} \item{correlation}{numeric scalar, average correlation between cases in the test group. Cases in the second group are assumed independent of each other and other the first group.} \item{df}{degrees of freedom which the correlation has been estimated.} } \value{ Numeric vector containing \code{left.tail} and \code{right.tail} p-values respectively. } \details{ This function implements a correlation-adjusted version of the Wilcoxon-Mann-Whitney test proposed by Wu and Smyth (2012). It tests whether the mean rank of statistics in the test group is greater or less than the mean rank of the remaining statistic values. When the correlation (or variance inflation factor) is zero, the function performs the usual two-sample Wilcoxon-Mann-Whitney rank sum test. The Wilcoxon-Mann-Whitney test is implemented following the formulas given in Zar (1999) Section 8.10, including corrections for ties and for continuity. The test allows for the possibility that cases in the test group may be more highly correlated on average than cases not in the group. When the correlation is non-zero, the variance of the rank-sum statistic is computing using a formula derived from equation (4.5) of Barry et al (2008). When the correlation is positive, the variance is increased and test will become more conservative. } \seealso{ \code{\link{wilcox.test}} performs the usual Wilcoxon-Mann-Whitney test assuming independence. An overview of tests in limma is given in \link{08.Tests}. } \author{Gordon Smyth and Di Wu} \references{ Barry, W.T., Nobel, A.B., and Wright, F.A. (2008). A statistical framework for testing functional categories in microarray data. \emph{Annals of Applied Statistics} 2, 286-315. Wu, D, and Smyth, GK (2012). Camera: a competitive gene set test accounting for inter-gene correlation. \emph{Nucleic Acids Research}. (Accepted 1 May 2012) Zar, JH (1999). \emph{Biostatistical Analysis 4th Edition}. Prentice-Hall International, Upper Saddle River, New Jersey. } \examples{ stat <- rnorm(100) index <- 1:10 stat[index] <- stat[1:10]+1 rankSumTestWithCorrelation(index, stat) rankSumTestWithCorrelation(index, stat, correlation=0.1) group <- rep(1,100) group[index] <- 2 group <- factor(group) wilcox.test(stat ~ group) } \keyword{htest} limma/man/EList.Rd0000644007451300017500000000510112150771760014075 0ustar charlescharles\name{EList-class} \docType{class} \alias{EList-class} \alias{EListRaw-class} \title{Expression List - class} \description{ A list-based S4 classes for storing expression values (E-values) for a set of one-channel microarrays. \code{EListRaw} holds expression values on the raw scale. \code{EList} holds expression values on the log scale, usually after background correction and normalization. \code{EListRaw} objects are usually created by \code{\link{read.maimages}}. \code{EList} objects are usually created by \code{\link{normalizeBetweenArrays}}. } \section{Components}{ \code{EList} objects can be created by \code{new("EList",E)} where \code{E} is a list. These classes contains no slots (other than \code{.Data}), but objects should contain a list component \code{E} as follows: \tabular{ll}{ \code{E} \tab numeric matrix containing the E-values (raw or log-2 expression ratios). Rows correspond to probes and columns to arrays. } Optional components include: \tabular{ll}{ \code{weights} \tab numeric matrix of same dimensions as \code{E} containing relative spot quality weights. Elements should be non-negative.\cr \code{other} \tab list containing other matrices, all of the same dimensions as \code{E}.\cr \code{genes} \tab data.frame containing probe information. Should have one row for each probe. May have any number of columns.\cr \code{targets} \tab data.frame containing information on the target RNA samples. Rows correspond to arrays. May have any number of columns. } Valid \code{EList} or \code{EListRaw} objects may contain other optional components, but all probe or array information should be contained in the above components. } \section{Methods}{ These classes inherit directly from class \code{list} so any operation appropriate for lists will work on objects of this class. In addition, \code{EList} objects can be \link[limma:subsetting]{subsetted} and \link[limma:cbind]{combined}. \code{EList} objects will return dimensions and hence functions such as \code{\link[limma:dim]{dim}}, \code{\link[base:nrow]{nrow}} and \code{\link[base:nrow]{ncol}} are defined. \code{ELists} also inherit a \code{\link[methods]{show}} method from the virtual class \code{\link[limma:LargeDataObject]{LargeDataObject}}, which means that \code{ELists} will print in a compact way. } \author{Gordon Smyth} \seealso{ \link{02.Classes} gives an overview of all the classes defined by this package. \code{\link[Biobase:class.ExpressionSet]{ExpressionSet}} is a more formal class in the Biobase package. } \keyword{classes} \keyword{data} limma/man/plotprinttiploess.Rd0000755007451300017500000000257312127125247016705 0ustar charlescharles\title{MA Plots by Print-Tip Group} \name{plotPrintTipLoess} \alias{plotPrintTipLoess} \description{ Creates a coplot giving MA-plots with loess curves by print-tip groups. } \usage{ plotPrintTipLoess(object,layout,array=1,span=0.4,...) } \arguments{ \item{object}{\code{MAList} or \code{RGList} object or list with components \code{M} containing log-ratios and \code{A} containing average intensities} \item{layout}{a list specifying the number of tip rows and columns and the number of spot rows and columns printed by each tip. Defaults to \code{MA$printer} if that is non-null.} \item{array}{integer giving the array to be plotted. Corresponds to columns of \code{M} and \code{A}.} \item{span}{span of window for \code{lowess} curve} \item{...}{other arguments passed to \code{panel.smooth}} } \details{ Note that spot quality weights in \code{object} are not used for computing the loess curves for this plot even though such weights would be used for loess normalization using \code{normalizeWithinArrays}. } \value{ A plot is created on the current graphics device. If there are missing values in the data, then the vector of row numbers for spots with missing values is invisibly returned, as for \code{coplot}. } \seealso{ An overview of diagnostic functions available in LIMMA is given in \link{09.Diagnostics}. } \author{Gordon Smyth} \keyword{hplot} limma/man/plotMDS.Rd0000644007451300017500000000772612127125247014413 0ustar charlescharles\title{Multidimensional scaling plot of microarray data} \name{plotMDS} \alias{plotMDS} \alias{plotMDS.MDS} \alias{plotMDS.default} \alias{MDS-class} \alias{show,MDS-method} \description{ Plot the sample relations based on MDS. Distances on the plot can be interpreted in terms of \emph{leading log2-fold-change}. } \usage{ \method{plotMDS}{default}(x, top=500, labels=colnames(x), col=NULL, cex=1, dim.plot=c(1,2), ndim=max(dim.plot), gene.selection="pairwise", xlab=paste("Dimension",dim.plot[1]), ylab=paste("Dimension",dim.plot[2]), ...) \method{plotMDS}{MDS}(x, labels=colnames(x$distance.matrix), col=NULL, cex=1, dim.plot=x$dim.plot, xlab=paste("Dimension",dim.plot[1]), ylab=paste("Dimension",dim.plot[2]),...) } \arguments{ \item{x}{any data object which can be coerced to a matrix, such as \code{ExpressionSet} or \code{EList}.} \item{top}{number of top genes used to calculate pairwise distances.} \item{labels}{character vector of sample names or labels. If \code{x} has no column names, then defaults the index of the samples.} \item{col}{numeric or character vector of colors for the plotting characters.} \item{cex}{numeric vector of plot symbol expansions.} \item{dim.plot}{which two dimensions should be plotted, numeric vector of length two.} \item{ndim}{number of dimensions in which data is to be represented} \item{gene.selection}{character, \code{"pairwise"} to choose the top genes separately for each pairwise comparison between the samples or \code{"common"} to select the same genes for all comparisons} \item{xlab}{title for the x-axis} \item{ylab}{title for the y-axis} \item{...}{any other arguments are passed to \code{plot}.} } \details{ This function is a variation on the usual multdimensional scaling (or principle coordinate) plot, in that a distance measure particularly appropriate for the microarray context is used. The distance between each pair of samples (columns) is the root-mean-square deviation (Euclidean distance) for the top \code{top} genes. Distances on the plot can be interpreted as \emph{leading log2-fold-change}, meaning the typical (root-mean-square) log2-fold-change between the samples for the genes that distinguish those samples. If \code{gene.selection} is \code{"common"}, then the top genes are those with the largest standard deviations between samples. If \code{gene.selection} is \code{"pairwise"}, then a different set of top genes is selected for each pair of samples. The pairwise feature selection may be appropriate for microarray data when different molecular pathways are relevant for distinguishing different pairs of samples. See \code{\link[graphics]{text}} for possible values for \code{col} and \code{cex}. } \value{ A plot is created on the current graphics device. An object of class \code{"MDS"} is invisibly returned. This is a list containing the following components: \item{distance.matrix}{numeric matrix of pairwise distances between columns of \code{x}} \item{cmdscale.out}{output from the function \code{cmdscale} given the distance matrix} \item{dim.plot}{dimensions plotted} \item{x}{x-xordinates of plotted points} \item{y}{y-cordinates of plotted points} \item{gene.selection}{gene selection method} } \author{Di Wu and Gordon Smyth} \seealso{ \code{\link{cmdscale}} An overview of diagnostic functions available in LIMMA is given in \link{09.Diagnostics}. } \examples{ # Simulate gene expression data for 1000 probes and 6 microarrays. # Samples are in two groups # First 50 probes are differentially expressed in second group sd <- 0.3*sqrt(4/rchisq(1000,df=4)) x <- matrix(rnorm(1000*6,sd=sd),1000,6) rownames(x) <- paste("Gene",1:1000) x[1:50,4:6] <- x[1:50,4:6] + 2 # without labels, indexes of samples are plotted. mds <- plotMDS(x, col=c(rep("black",3), rep("red",3)) ) # or labels can be provided, here group indicators: plotMDS(mds, col=c(rep("black",3), rep("red",3)), labels= c(rep("Grp1",3), rep("Grp2",3))) } \keyword{hplot} limma/man/avedups.Rd0000644007451300017500000000276612127125247014537 0ustar charlescharles\name{avedups} \alias{avedups} \alias{avedups.default} \alias{avedups.MAList} \alias{avedups.EList} \title{Average Over Duplicate Spots} \description{ Condense a microarray data object so that values for within-array replicate spots are replaced with their average. } \usage{ \method{avedups}{default}(x, ndups=2, spacing=1, weights=NULL) \method{avedups}{MAList}(x, ndups=x$printer$ndups, spacing=x$printer$spacing, weights=x$weights) \method{avedups}{EList}(x, ndups=x$printer$ndups, spacing=x$printer$spacing, weights=x$weights) } \arguments{ \item{x}{a matrix-like object, usually a matrix, \code{MAList} or \code{EList} object.} \item{ndups}{number of within-array replicates for each probe.} \item{spacing}{number of spots to step from a probe to its duplicate.} \item{weights}{numeric matrix of spot weights.} } \details{ A new data object is computed in which each probe is represented by the (weighted) average of its duplicate spots. For an \code{MAList} object, the components \code{M} and \code{A} are both averaged in this way. For an \code{EList} object, the component \code{E} is averaged in this way. If \code{x} is of mode \code{"character"}, then the duplicate values are assumed to be equal and the first is taken as the average. } \value{ A data object of the same class as \code{x} with \code{1/ndups} as many rows. } \author{Gordon Smyth} \seealso{ \code{\link{avereps}}. \link{02.Classes} gives an overview of data classes used in LIMMA. } \keyword{array} limma/man/selectmodel.Rd0000644007451300017500000000461112127125247015357 0ustar charlescharles\name{selectModel} \alias{selectModel} \title{Select Appropriate Linear Model} \description{Select the best fitting linear model for each gene by minimizing an information criterion.} \usage{ selectModel(y, designlist, criterion="aic", df.prior=0, s2.prior=NULL, s2.true=NULL, ...) } \arguments{ \item{y}{a matrix-like data object, containing log-ratios or log-values of expression for a series of microarrays. Any object class which can be coerced to matrix is acceptable including \code{numeric}, \code{matrix}, \code{MAList}, \code{marrayNorm}, \code{ExpressionSet} or \code{PLMset}.} \item{designlist}{list of design matrices} \item{criterion}{information criterion to be used for model selection, \code{"aic"}, \code{"bic"} or \code{"mallowscp"}.} \item{df.prior}{prior degrees of freedom for residual variances. See \code{\link{squeezeVar}}} \item{s2.prior}{prior value for residual variances, to be used if \code{df.prior}>0.} \item{s2.true}{numeric vector of true variances, to be used if \code{criterion="mallowscp"}.} \item{...}{other optional arguments to be passed to \code{lmFit}} } \value{ List with components \item{IC}{matrix of information criterion scores, rows for probes and columns for models} \item{pref}{factor indicating the model with best (lowest) information criterion score} } \details{ This function chooses, for each probe, the best fitting model out of a set of alternative models represented by a list of design matrices. Selection is by Akaike's Information Criterion (AIC), Bayesian Information Criterion (BIC) or by Mallow's Cp. The criteria have been generalized slightly to accommodate an information prior on the variances represented by \code{s2.prior} and \code{df.prior} or by \code{s2.post}. Suitable values for these parameters can be estimated using \code{\link{squeezeVar}}. } \seealso{ An overview of linear model functions in limma is given by \link{06.LinearModels}. } \author{Alicia Oshlack and Gordon Smyth} \examples{ nprobes <- 100 narrays <- 5 y <- matrix(rnorm(nprobes*narrays),nprobes,narrays) A <- c(0,0,1,1,1) B <- c(0,1,0,1,1) designlist <- list( None=cbind(Int=c(1,1,1,1,1)), A=cbind(Int=1,A=A), B=cbind(Int=1,B=B), Both=cbind(Int=1,AB=A*B), Add=cbind(Int=1,A=A,B=B), Full=cbind(Int=1,A=A,B=B,AB=A*B) ) out <- selectModel(y,designlist) table(out$pref) } \keyword{models} \keyword{regression} limma/man/venn.Rd0000755007451300017500000000613012127125247014026 0ustar charlescharles\name{venn} \alias{vennCounts} \alias{vennDiagram} \title{Venn Diagrams} \description{ Compute Classification Counts and Make Venn Diagram. } \usage{ vennCounts(x, include="both") vennDiagram(object, include="both", names=NULL, mar=rep(1,4), cex=c(1.5,1,0.7), lwd=1, circle.col=NULL, counts.col=NULL, show.include=NULL, \dots) } \arguments{ \item{x}{numeric matrix of 0's and 1's indicating significance of a test. Usually created by \code{\link{decideTests}}.} \item{object}{either a \code{TestResults} matrix from \code{decideTests} or a \code{VennCounts} object produced by \code{vennCounts}.} \item{include}{character vector specifying whether all differentially expressed genes should be counted, or whether the counts should be restricted to genes changing in a certain direction. Choices are \code{"both"} for all differentially expressed genes, \code{"up"} for up-regulated genes only or \code{"down"} for down-regulated genes only. If \code{include=c("up","down")} then both the up and down counts will be shown. This argument is ignored if \code{object} if \code{object} is already a \code{vennCounts} object.} \item{names}{character vector giving names for the sets or contrasts} \item{mar}{numeric vector of length 4 specifying the width of the margins around the plot. This argument is passed to \code{par}.} \item{cex}{numerical vector of length 3 giving scaling factors for large, medium and small text on the plot.} \item{lwd}{numerical value giving the amount by which the circles should be scaled on the plot. See \code{par}.} \item{circle.col}{vector of color specifications defining the colors by which the circles should be drawn. See \code{par}.} \item{counts.col}{vector of color specifications, of same length as \code{include}, defining the colors by which the counts should be drawn. See \code{par}.} \item{show.include}{logical value whether the value of \code{include} should be printed on the plot. Defaults to \code{FALSE} if \code{include} is a single value and \code{TRUE} otherwise} \item{\dots}{any other arguments are passed to \code{plot}} } \details{ \code{vennDiagram} can plot up to five sets. \code{vennCounts} can collate intersection counts for any number of sets. } \value{ \code{vennCounts} produces a \code{VennCounts} object, which is a numeric matrix with last column \code{"Counts"} giving counts for each possible vector outcome. \code{vennDiagram} causes a plot to be produced on the current graphical device. } \seealso{ An overview of linear model functions in limma is given by \link{06.LinearModels}. } \author{Gordon Smyth, James Wettenhall, Francois Pepin, Steffen Moeller and Yifang Hu} \examples{ Y <- matrix(rnorm(100*6),100,6) Y[1:10,3:4] <- Y[1:10,3:4]+3 Y[1:20,5:6] <- Y[1:20,5:6]+3 design <- cbind(1,c(0,0,1,1,0,0),c(0,0,0,0,1,1)) fit <- eBayes(lmFit(Y,design)) results <- decideTests(fit) a <- vennCounts(results) print(a) mfrow.old <- par()$mfrow par(mfrow=c(1,2)) vennDiagram(a) vennDiagram(results,include=c("up","down"),counts.col=c("red","green")) par(mfrow=mfrow.old) } \keyword{hplot} limma/man/bwss.Rd0000755007451300017500000000132412127125247014036 0ustar charlescharles\name{bwss} \alias{bwss} \title{Between and within sums of squares} \description{Sums of squares between and within groups. Allows for missing values.} \usage{bwss(x,group)} \arguments{ \item{x}{a numeric vector giving the responses.} \item{group}{a vector or factor giving the grouping variable.} } \value{ A list with components \item{bss}{sums of squares between the group means.} \item{wss}{sums of squares within the groups.} \item{bdf}{degrees of freedom corresponding to \code{bss}.} \item{wdf}{degrees of freedom corresponding to \code{wss}.} } \details{This is equivalent to one-way analysis of variance.} \author{Gordon Smyth} \seealso{\code{\link{bwss.matrix}}} \keyword{models} limma/man/ebayes.Rd0000755007451300017500000001663512130404410014325 0ustar charlescharles\name{ebayes} \alias{ebayes} \alias{eBayes} \alias{treat} \title{Empirical Bayes Statistics for Differential Expression} \description{Given a microarray linear model fit, compute moderated t-statistics, moderated F-statistic, and log-odds of differential expression by empirical Bayes moderation of the standard errors towards a common value.} \usage{ ebayes(fit, proportion=0.01, stdev.coef.lim=c(0.1,4), trend=FALSE, robust=FALSE, winsor.tail.p=c(0.05,0.1)) eBayes(fit, proportion=0.01, stdev.coef.lim=c(0.1,4), trend=FALSE, robust=FALSE, winsor.tail.p=c(0.05,0.1)) treat(fit, lfc=0, trend=FALSE) } \arguments{ \item{fit}{an \code{MArrayLM} fitted model object produced by \code{lmFit} or \code{contrasts.fit}. For \code{ebayes} only, \code{fit} can alternatively be an unclassed list produced by \code{lm.series}, \code{gls.series} or \code{mrlm} containing components \code{coefficients}, \code{stdev.unscaled}, \code{sigma} and \code{df.residual}.} \item{proportion}{numeric value between 0 and 1, assumed proportion of genes which are differentially expressed} \item{stdev.coef.lim}{numeric vector of length 2, assumed lower and upper limits for the standard deviation of log2-fold-changes for differentially expressed genes} \item{trend}{logical, should an intensity-trend be allowed for the prior variance? Default is that the prior variance is constant.} \item{robust}{logical, should the estimation of \code{df.prior} and \code{var.prior} be robustified against outlier sample variances?} \item{winsor.tail.p}{numeric vector of length 1 or 2, giving left and right tail proportions of \code{x} to Winsorize. Used only when \code{robust=TRUE}.} \item{lfc}{the minimum log2-fold-change that is considered scientifically meaningful} } \value{ \code{eBayes} produces an object of class \code{MArrayLM} (see \code{\link{MArrayLM-class}}) containing everything found in \code{fit} plus the following added components: \item{t}{numeric vector or matrix of moderated t-statistics} \item{p.value}{numeric vector of p-values corresponding to the t-statistics} \item{s2.prior}{estimated prior value for \code{sigma^2}. A vector if \code{covariate} is non-\code{NULL}, otherwise a scalar.} \item{df.prior}{degrees of freedom associated with \code{s2.prior}} \item{df.total}{numeric vector of total degrees of freedom associated with t-statistics and p-values. Equal to \code{df.prior+df.residual} or \code{sum(df.residual)}, whichever is smaller.} \item{s2.post}{numeric vector giving the posterior values for \code{sigma^2}} \item{lods}{numeric vector or matrix giving the log-odds of differential expression} \item{var.prior}{estimated prior value for the variance of the log2-fold-change for differentially expressed gene} \item{F}{numeric vector of moderated F-statistics for testing all contrasts defined by the columns of \code{fit} simultaneously equal to zero} \item{F.p.value}{numeric vector giving p-values corresponding to \code{F}} \code{treat} a produces an \code{MArrayLM} object similar to \code{eBayes} but without \code{lods}, \code{var.prior}, \code{F} or \code{F.p.value}. \code{ebayes} produces an ordinary list containing the above components except for \code{F} and \code{F.p.value}. } \details{ These functions is used to rank genes in order of evidence for differential expression. They use an empirical Bayes method to shrink the probe-wise sample variances towards a common value and to augmenting the degrees of freedom for the individual variances (Smyth, 2004). The functions accept as input argument \code{fit} a fitted model object from the functions \code{lmFit}, \code{lm.series}, \code{mrlm} or \code{gls.series}. The fitted model object may have been processed by \code{contrasts.fit} before being passed to \code{eBayes} to convert the coefficients of the design matrix into an arbitrary number of contrasts which are to be tested equal to zero. The columns of \code{fit} define a set of contrasts which are to be tested equal to zero. The empirical Bayes moderated t-statistics test each individual contrast equal to zero. For each probe (row), the moderated F-statistic tests whether all the contrasts are zero. The F-statistic is an overall test computed from the set of t-statistics for that probe. This is exactly analogous the relationship between t-tests and F-statistics in conventional anova, except that the residual mean squares and residual degrees of freedom have been moderated between probes. The estimates \code{s2.prior} and \code{df.prior} are computed by \code{fitFDist}. \code{s2.post} is the weighted average of \code{s2.prior} and \code{sigma^2} with weights proportional to \code{df.prior} and \code{df.residual} respectively. The \code{lods} is sometimes known as the B-statistic. The F-statistics \code{F} are computed by \code{classifyTestsF} with \code{fstat.only=TRUE}. \code{eBayes} doesn't compute ordinary (unmoderated) t-statistics by default, but these can be easily extracted from the linear model output, see the example below. \code{ebayes} is the earlier and leaner function, kept for background capatability, while \code{eBayes} is the later more object-orientated version. The difference is that \code{ebayes} outputs only the empirical Bayes statistics whereas \code{eBayes} adds them to the fitted model object \code{fit}. \code{eBayes} is recommended for routine use as it produces objects containing all the necessary components for downstream analysis \code{treat} computes empirical Bayes moderated-t p-values relative to a minimum required fold-change threshold. Use \code{\link{topTreat}} to summarize output from \code{treat}. Instead of testing for genes which have log-fold-changes different from zero, it tests whether the log2-fold-change is greater than \code{lfc} in absolute value (McCarthy and Smyth, 2009). \code{treat} is concerned with p-values rather than posterior odds, so it does not compute the B-statistic \code{lods}. The idea of thresholding doesn't apply to F-statistics in a straightforward way, so moderated F-statistics are also not computed. } \seealso{ \code{\link{squeezeVar}}, \code{\link{fitFDist}}, \code{\link{tmixture.matrix}}. An overview of linear model functions in limma is given by \link{06.LinearModels}. } \author{Gordon Smyth and Davis McCarthy} \references{ McCarthy, D. J., and Smyth, G. K. (2009). Testing significance relative to a fold-change threshold is a TREAT. \emph{Bioinformatics}. \url{http://bioinformatics.oxfordjournals.org/cgi/content/abstract/btp053} Loennstedt, I., and Speed, T. P. (2002). Replicated microarray data. \emph{Statistica Sinica} \bold{12}, 31-46. Smyth, G. K. (2004). Linear models and empirical Bayes methods for assessing differential expression in microarray experiments. \emph{Statistical Applications in Genetics and Molecular Biology}, Volume \bold{3}, Article 3. \url{http://www.bepress.com/sagmb/vol3/iss1/art3} } \examples{ # See also lmFit examples # Simulate gene expression data, # 6 microarrays and 100 genes with one gene differentially expressed set.seed(2004); invisible(runif(100)) M <- matrix(rnorm(100*6,sd=0.3),100,6) M[1,] <- M[1,] + 1 fit <- lmFit(M) # Moderated t-statistic fit <- eBayes(fit) topTable(fit) # Ordinary t-statistic ordinary.t <- fit$coef / fit$stdev.unscaled / fit$sigma # Q-Q plots of t statistics # Points off the line may be differentially expressed par(mfrow=c(1,2)) qqt(ordinary.t, df=fit$df.residual, main="Ordinary t") abline(0,1) qqt(fit$t, df=fit$df.total,main="Moderated t") abline(0,1) par(mfrow=c(1,1)) } \keyword{htest} limma/man/PrintLayout.Rd0000755007451300017500000000431012127125247015350 0ustar charlescharles\name{PrintLayout} \docType{class} \alias{PrintLayout-class} \title{Print Layout - class} \description{ A list-based class for storing information about the process used to print spots on a microarray. \code{PrintLayout} objects can be created using \code{\link{getLayout}}. The \code{printer} component of an \code{RGList} or \code{MAList} object is of this class. } \section{Slots/List Components}{ Objects of this class contains no slots but should contain the following list components: \tabular{ll}{ \code{ngrid.r}:\tab number of grid rows on the arrays\cr \code{ngrid.c}:\tab number of grid columns on the arrays\cr \code{nspot.r}:\tab number of rows of spots in each grid\cr \code{nspot.c}:\tab number of columns of spots in each grid\cr \code{ndups}:\tab number of duplicates of each DNA clone, i.e., number of times print-head dips into each well of DNA\cr \code{spacing}:\tab number of spots between duplicate spots. Only applicable if \code{ndups>1}. \code{spacing=1} for side-by-side spots by rows, \code{spacing=nspot.c} for side-by-side spots by columns, \code{spacing=ngrid.r*ngrid.c*nspot.r*nspot.c/2} for duplicate spots in top and bottom halves of each array.\cr \code{npins}:\tab actual number of pins or tips on the print-head\cr \code{start}:\tab character string giving position of the spot printed first in each grid. Choices are \code{"topleft"} or \code{"topright"} and partial matches are accepted. } } \author{Gordon Smyth} \seealso{ \link{02.Classes} gives an overview of all the classes defined by this package. } \examples{ # Settings for Swirl and ApoAI example data sets in User's Guide printer <- list(ngrid.r=4, ngrid.c=4, nspot.r=22, nspot.c=24, ndups=1, spacing=1, npins=16, start="topleft") # Typical settings at the Australian Genome Research Facility # Full pin set, duplicates side-by-side on same row printer <- list(ngrid.r=12, ngrid.c=4, nspot.r=20, nspot.c=20, ndups=2, spacing=1, npins=48, start="topright") # Half pin set, duplicates in top and lower half of slide printer <- list(ngrid.r=12, ngrid.c=4, nspot.r=20, nspot.c=20, ndups=2, spacing=9600, npins=24, start="topright") } \keyword{classes} \keyword{data} limma/man/limmaUsersGuide.Rd0000755007451300017500000000245612127125247016166 0ustar charlescharles\name{limmaUsersGuide} \alias{limmaUsersGuide} \title{View Limma User's Guide} \description{Finds the location of the Limma User's Guide and optionally opens it.} \usage{ limmaUsersGuide(view=TRUE) } \arguments{ \item{view}{logical, should the document be opened using the default PDF document reader?} } \value{Character string giving the file location.} \details{ The function \code{vignette("limma")} will find the short limma Vignette which describes how to obtain the Limma User's Guide. The User's Guide is not itself a true vignette because it is not automatically generated using \code{\link{Sweave}} during the package build process. This means that it cannot be found using \code{vignette}, hence the need for this special function. If the operating system is other than Windows, then the PDF viewer used is that given by \code{Sys.getenv("R_PDFVIEWER")}. The PDF viewer can be changed using \code{Sys.putenv(R_PDFVIEWER=)}. This function is used by drop-down Vignettes menu when the Rgui interface for Windows is used. } \seealso{ \code{\link{vignette}}, \code{\link[Biobase]{openPDF}}, \code{\link[Biobase]{openVignette}}, \code{\link{Sys.getenv}}, \code{\link{Sys.putenv}} } \author{Gordon Smyth} \examples{ limmaUsersGuide(view=FALSE) } \keyword{documentation} limma/man/makeContrasts.Rd0000755007451300017500000000345012127125247015700 0ustar charlescharles\name{makeContrasts} \alias{makeContrasts} \title{Construct Matrix of Custom Contrasts} \description{ Construct the contrast matrix corresponding to specified contrasts of a set of parameters. } \usage{ makeContrasts(\dots, contrasts=NULL, levels) } \arguments{ \item{\dots}{expressions, or character strings which can be parsed to expressions, specifying contrasts} \item{contrasts}{character vector specifying contrasts} \item{levels}{character vector or factor giving the names of the parameters of which contrasts are desired, or a design matrix or other object with the parameter names as column names.} } \value{ Matrix which columns corresponding to contrasts. } \details{ This function expresses contrasts between a set of parameters as a numeric matrix. The parameters are usually the coefficients from a linear model fit, so the matrix specifies which comparisons between the coefficients are to be extracted from the fit. The output from this function is usually used as input to \code{\link{contrasts.fit}}. The contrasts can be specified either as expressions using \code{\dots} or as a character vector through \code{contrasts}. (Trying to specify contrasts both ways will cause an error.) The parameter names must be syntactically valid variable names in R and so, for example, must begin with a letter rather than a numeral. See \code{\link{make.names}} for a complete specification of what is a valid name. } \seealso{ An overview of linear model functions in limma is given by the help page \link{06.LinearModels}. } \author{Gordon Smyth} \examples{ makeContrasts(B-A,C-B,C-A,levels=c("A","B","C")) makeContrasts(contrasts="A-(B+C)/2",levels=c("A","B","C")) x <- c("B-A","C-B","C-A") makeContrasts(contrasts=x,levels=c("A","B","C")) } \keyword{regression} limma/man/readTargets.Rd0000755007451300017500000000345112127125247015330 0ustar charlescharles\name{readTargets} \alias{readTargets} \title{Read Targets File} \description{ Read targets file for a microarray experiment into a dataframe. } \usage{ readTargets(file="Targets.txt", path=NULL, sep="\t", row.names=NULL, quote="\"",...) } \arguments{ \item{file}{character string giving the name of the targets file.} \item{path}{character string giving the directory containing the file. Can be omitted if the file is in the current working irectory.} \item{sep}{field separator character} \item{row.names}{character string giving the name of a column from which to obtain row names} \item{quote}{the set of quoting characters} \item{...}{other arguments are passed to \code{\link{read.table}}} } \details{ The targets file is a text file containing information about the RNA samples used as targets in the microarray experiment. Rows correspond to arrays and columns to covariates associated with the targets. For a two-color experiment, the targets file will normally include columns labelled \code{Cy3} and \code{Cy5} or similar specifying which RNA samples are hybridized to each channel of each array. Other columns may contain any other covariate information associated with the arrays or targets used in the experiment. If \code{row.names} is non-null and there is a column by that name with unique values, then those values will be used as row names for the dataframe. If \code{row.names} is null, then the column \code{Label} will be used if such exists or, failing that, the column \code{FileName}. See the Limma User's Guide for examples of this function. } \value{ A dataframe. Character columns are not converted into factors. } \author{Gordon Smyth} \seealso{ An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \keyword{IO} limma/man/readgal.Rd0000755007451300017500000000520212127125247014456 0ustar charlescharles\name{readGAL} \alias{readGAL} \title{Read a GAL file} \description{ Read a GenePix Array List (GAL) file into a dataframe. } \usage{ readGAL(galfile=NULL,path=NULL,header=TRUE,sep="\t",quote="\"",skip=NULL,as.is=TRUE,...) } \arguments{ \item{galfile}{character string giving the name of the GAL file. If \code{NULL} then a file with extension \code{.gal} is found in the directory specified by \code{path}.} \item{path}{character string giving the directory containing the files. If \code{NULL} then assumed to be the current working directory.} \item{header}{logical variable, if \code{TRUE} then the first line after \code{skip} is assumed to contain column headings. If \code{FALSE} then a value should specified for \code{skip}.} \item{sep}{the field separator character} \item{quote}{the set of quoting characters} \item{skip}{number of lines of the GAL file to skip before reading data. If \code{NULL} then this number is determined by searching the file for column headings.} \item{as.is}{logical variable, if \code{TRUE} then read in character columns as vectors rather than factors.} \item{...}{any other arguments are passed to \code{read.table}} } \details{ A GAL file is a list of genes IDs and associated information produced by an Axon microarray scanner. Apart from header information, the file must contain data columns labeled \code{Block}, \code{Column}, \code{Row} and \code{ID}. A \code{Name} column is usually included as well. Other columns are optional. See the Axon URL below for a detaile description of the GAL file format. This function reads in the data columns with a minimum of user information. In most cases the function can be used without specifying any of the arguments. } \value{ A data frame with columns \item{Block}{numeric vector containing the print tip indices} \item{Column}{numeric vector containing the spot columns} \item{Row}{numeric vector containing the spot rows} \item{ID}{character vector, for factor if \code{as.is=FALSE}, containing gene library identifiers} \item{Name}{character vector, for factor if \code{as.is=FALSE}, containing gene names} The data frame will be sorted so that \code{Column} is the fastest moving index, then \code{Row}, then \code{Block}. } \author{Gordon Smyth} \seealso{ \link[marray:read.Galfile]{read.Galfile} in the marray package. An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \references{ \url{http://www.axon.com/gn_GenePix_File_Formats.html} } \examples{ # readGAL() # will read in the first GAL file (with suffix ".gal") # found in the current working directory } \keyword{IO} limma/man/strsplit2.Rd0000644007451300017500000000272312127125247015027 0ustar charlescharles\name{strsplit2} \alias{strsplit2} \title{Split Composite Names} \description{ Split a vector of composite names into a matrix of simple names.} \usage{ strsplit2(x, split, ...) } \arguments{ \item{x}{character vector} \item{split}{character to split each element of vector on, see \code{strsplit}} \item{\dots}{other arguments are passed to \code{strsplit}} } \value{ A list containing components \item{Name}{character vector of the same length as \code{x} contain first splits of each element} \item{Annotation}{character vector of the same length as \code{x} contain second splits of each element} } \details{ This function is the same as \code{\link[base]{strsplit}} except that the output value is a matrix instead of a list. The first column of the matrix contains the first component from each element of \code{x}, the second column contains the second components etc. The number of columns is equal to the maximum number of components for any element of \code{x}. The motivation for this function in the limma package is handle input columns which are composites of two or more annotation fields. } \seealso{ \code{\link[base]{strsplit}}. An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \examples{ x <- c("AA196000;actinin, alpha 3", "AA464163;acyl-Coenzyme A dehydrogenase, very long chain", "3E7;W15277;No Annotation") strsplit2(x,split=";") } \author{Gordon Smyth} \keyword{character} limma/man/qualwt.Rd0000755007451300017500000000425512127125247014403 0ustar charlescharles\name{QualityWeights} \alias{QualityWeights} \alias{wtarea} \alias{wtflags} \alias{wtIgnore.Filter} \title{Spot Quality Weights} \description{ Functions to calculate quality weights for individual spots based on image analyis output file. } \usage{ wtarea(ideal=c(160,170)) wtflags(weight=0,cutoff=0) wtIgnore.Filter } \arguments{ \item{ideal}{numeric vector giving the ideal area or range of areas for a spot in pixels} \item{weight}{weight to be given to flagged spots} \item{cutoff}{cutoff value for \code{Flags} below which spots will be downweighted} } \details{ These functions can be passed as an argument to \code{read.maimages} to construct quality weights as the microarray data is read in. \code{wtarea} downweights unusually small or large spots and is designed for SPOT output. It gives weight 1 to spots which have areas in the ideal range, given in pixels, and linearly downweights spots which are smaller or larger than this range. \code{wtflags} is designed for GenePix output and gives the specified weight to spots with \code{Flags} value less than the \code{cutoff} value. Choose \code{cutoff=0} to downweight all flagged spots. Choose \code{cutoff=-50} to downweight bad or absent spots or \code{cutoff=-75} to downweight only spots which have been manually flagged as bad. \code{wtIgnore.Filter} is designed for QuantArray output and sets the weights equal to the column \code{Ignore Filter} produced by QuantArray. These weights are 0 for spots to be ignored and 1 otherwise. } \value{ A function which takes a dataframe or matrix as argument and produces a numeric vector of weights between 0 and 1 } \author{Gordon Smyth} \seealso{ An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \examples{ # Read in spot output files from current directory and give full weight to 165 # pixel spots. Note: for this example to run you must set fnames to the names # of actual spot output files (data not provided). \dontrun{ RG <- read.maimages(fnames,source="spot",wt.fun=wtarea(165)) # Spot will be downweighted according to weights found in RG MA <- normalizeWithinArrays(RG,layout) } } \keyword{regression} limma/man/mrlm.Rd0000644007451300017500000000527312127125247014033 0ustar charlescharles\name{mrlm} \alias{mrlm} \title{Fit Linear Model to Microrray Data by Robust Regression} \description{Fit a linear model genewise to expression data from a series of arrays. The fit is by robust M-estimation allowing for a small proportion of outliers. This is a utility function for \code{lmFit}.} \usage{ mrlm(M,design=NULL,ndups=1,spacing=1,weights=NULL,...) } \arguments{ \item{M}{numeric matrix containing log-ratio or log-expression values for a series of microarrays, rows correspond to genes and columns to arrays.} \item{design}{numeric design matrix defining the linear model, with rows corresponding to arrays and columns to comparisons to be estimated. The number of rows must match the number of columns of \code{M}. Defaults to the unit vector meaning that the arrays are treated as replicates.} \item{ndups}{a positive integer giving the number of times each gene is printed on an array. \code{nrow(M)} must be divisible by \code{ndups}.} \item{spacing}{the spacing between the rows of \code{M} corresponding to duplicate spots, \code{spacing=1} for consecutive spots.} \item{weights}{numeric matrix of the same dimension as \code{M} containing weights. If it is of different dimension to \code{M}, it will be filled out to the same size. \code{NULL} is equivalent to equal weights.} \item{...}{any other arguments are passed to \code{rlm.default}.} } \value{ A list with components \item{coefficients}{numeric matrix containing the estimated coefficients for each linear model. Same number of rows as \code{M}, same number of columns as \code{design}.} \item{stdev.unscaled}{numeric matrix conformal with \code{coef} containing the unscaled standard deviations for the coefficient estimators. The standard errors are given by \code{stdev.unscaled * sigma}.} \item{sigma}{numeric vector containing the residual standard deviation for each gene.} \item{df.residual}{numeric vector giving the degrees of freedom corresponding to \code{sigma}.} \item{qr}{QR decomposition of \code{design}.} } \details{ This is a utility function used by the higher level function \code{\link{lmFit}}. Most users should not use this function directly but should use \code{\link{lmFit}} instead. This function fits a linear model for each gene by calling the function \code{rlm} from the MASS library. Warning: don't use weights with this function unless you understand how \code{rlm} treats weights. The treatment of weights is somewhat different from that of \code{lm.series} and \code{gls.series}. } \seealso{ \code{\link[MASS]{rlm}}. An overview of linear model functions in limma is given by \link{06.LinearModels}. } \author{Gordon Smyth} \keyword{models} \keyword{regression} limma/man/mdplot.Rd0000644007451300017500000000214212127125247014353 0ustar charlescharles\title{mdplot} \name{mdplot} \alias{mdplot} \description{ Creates a mean-difference plot. } \usage{ mdplot(x, ...) } \arguments{ \item{x}{numeric \code{matrix} with at least two columns} \item{...}{any other arguments are passed to \code{plot}} } \details{ Plots differences vs means for a set of bivariate values. This is useful to contrast expression values for two microarrays. Note that an MA-plot \code{\link{plotMA}} is a type of mean-difference plot. } \value{A plot is created on the current graphics device.} \references{Chambers, J. M., Cleveland, W. S., Kleiner, B., and Tukey, P. A. (1983). Graphical Methods of Data Analysis. Wadsworth (pp. 48-57). Cleveland, W. S., (1993). Visualizing Data. Hobart Press. Bland, J. M., and Altman, D. G. (1986). Statistical methods for assessing agreement between two methods of clinical measurement. Lancet i, 307-310. See also \url{http://www.statsci.org/micrarra/refs/maplots.html} } \author{Gordon Smyth} \seealso{ An overview of diagnostic functions available in LIMMA is given in \link{09.Diagnostics}. } \keyword{hplot} limma/man/symbols2indices.Rd0000644007451300017500000000212512127125247016166 0ustar charlescharles\name{symbols2indices} \alias{symbols2indices} \title{Convert Gene Set Symbols to Indices} \description{ Make a list of gene set symbols into a list of gene sets indices. } \usage{ symbols2indices(gene.sets, symbols, remove.empty=TRUE) } \arguments{ \item{gene.sets}{list of character vectors, each vector containing the symbols for a set of genes.} \item{symbols}{character vector of gene symbols.} \item{remove.empty}{logical, should sets of size zero be removed from the output?} } \value{ list of integer vectors, each vector containing the indices of a gene set in the vector \code{symbols}. } \details{ This function used to create input for \code{romer} function. Typically, \code{symbols} is the vector of symbols of genes on a microarray, and \code{gene.sets} is obtained constructed from a database of gene sets, for example a representation of the Molecular Signatures Database (MSigDB) downloaded from \url{http://bioinf.wehi.edu.au/software/MSigDB}. } \seealso{ \code{\link{romer}}, \code{\link{mroast}}, \code{\link{camera}} } \author{Gordon Smyth and Yifang Hu}limma/man/residuals.MArrayLM.Rd0000644007451300017500000000136412127125247016477 0ustar charlescharles\name{residuals.MArrayLM} \title{Extract Residuals from MArrayLM Fit} \usage{ \S3method{residuals}{MArrayLM}(object, y, \dots) } \alias{residuals.MArrayLM} \arguments{ \item{object}{a fitted model object inheriting from class \code{MarrayLM}.} \item{y}{a data object containing the response data used to compute the fit. This can be of any class for which \code{as.matrix} is defined, including \code{MAList}, \code{ExpressionSet}, \code{marrayNorm} etc.} \item{\dots}{other arguments are not used} } \description{ This method extracts the residuals from all the probewise linear model fits and returns them in a matrix. } \value{ Numeric matrix of residuals. } \seealso{ \code{\link[stats]{residuals}}. } \keyword{models} \keyword{regression} limma/man/targetsA2C.Rd0000755007451300017500000000447612127125247015032 0ustar charlescharles\name{targetsA2C} \alias{targetsA2C} \alias{array2channel} \title{Convert Two-Color Targets Dataframe from One-Row-Per-Array to One-Row-Per-Channel} \description{ Convert a two-color targets dataframe with one row per array to one with one row per channel. } \usage{ targetsA2C(targets, channel.codes=c(1,2), channel.columns=list(Target=c("Cy3","Cy5")), grep=FALSE) } \arguments{ \item{targets}{data.frame with one row per array giving information about target samples associated covariates.} \item{channel.codes}{numeric or character vector of length 2 giving codes for the channels} \item{channel.columns}{named list of character vectors of length 2. Each entry gives a pair of names of columns in \code{targets} which contain channel-specific information. This pair of columns should be assembled into one column in the output.} \item{grep}{logical, if \code{TRUE} then the channel column names are found by \code{grep}ing, i.e., the actual column names need only contain the names given by \code{channel.columns} as substrings} } \details{ The \code{targets} dataframe holds information about the RNA samples used as targets in the microarray experiment. It is often read from a file using \code{\link{readTargets}}. This function is used to convert the dataframe from an array-orientated format with one row for each array and two columns for the two channels into a channel-orientated format with one row for each individual channel observations. In statistical terms, the first format treats the arrays as cases and treats the channels as repeated measurements. The second format treats the individual channel observations as cases. The second format may be more appropriate if the data is to be analyzed in terms of individual log-intensities. } \value{ data.frame with twice as many rows as \code{targets}. Any pair of columns named by \code{channel.columns} will now be one column. } \seealso{ \code{targetsA2C} is used by the \code{\link[convert:coerce]{coerce}} method from \code{RGList} for \code{ExpressionSet} in the convert package. An overview of methods for single channel analysis in limma is given by \link{07.SingleChannel}. } \examples{ targets <- data.frame(FileName=c("file1.gpr","file2.gpr"),Cy3=c("WT","KO"),Cy5=c("KO","WT")) targetsA2C(targets) } \author{Gordon Smyth} \keyword{htest} limma/man/summary.Rd0000755007451300017500000000142512127125247014557 0ustar charlescharles\name{summary} \alias{summary.RGList} \alias{summary.MAList} \alias{summary.EListRaw} \alias{summary.EList} \alias{summary.MArrayLM} \title{Summaries of Microarray Data Objects} \description{ Briefly summarize microarray data objects. } \usage{ \method{summary}{RGList}(object, ...) } \arguments{ \item{object}{an object of class \code{RGList}, \code{MAList} or \code{MArrayLM}} \item{...}{other arguments are not used} } \details{ The data objects are summarized as if they were lists, i.e., brief information about the length and type of the components is given. } \value{ A table. } \author{Gordon Smyth} \seealso{ \code{\link[base]{summary}} in the base package. \link{02.Classes} gives an overview of data classes used in LIMMA. } \keyword{methods} limma/man/writefit.Rd0000755007451300017500000000337512127125247014725 0ustar charlescharles\name{write.fit} \alias{write.fit} \title{Write MArrayLM Object to a File} \description{ Write a microarray linear model fit to a file. } \usage{ write.fit(fit, results=NULL, file, digits=3, adjust="none", method="separate", F.adjust="none", sep="\t", ...) } \arguments{ \item{fit}{object of class \code{MArrayLM} containing the results of a linear model fit} \item{results}{object of class \code{TestResults}} \item{file}{character string giving name of file} \item{digits}{integer indicating precision to be used} \item{adjust}{character string specifying multiple-testing adjustment method for the t-statistic P-values, e.g., \code{"BH"}. See \code{\link[stats]{p.adjust}} for the available options. If \code{NULL} or \code{"none"} then the P-values are not adjusted.} \item{method}{character string, should the P-value adjustment be \code{"global"} or \code{"separate"} for each contrast.} \item{F.adjust}{character string specifying adjustment method for the F-statistic P-values.} \item{sep}{the field separator string. Values in the output file will be separated by this string.} \item{\dots}{other arguments are passed to \code{write.table}} } \value{ No value is produced but a file is written to the current working directory. } \details{ This function writes a tab-delimited text file containing for each gene (1) the average log-intensity, (2) the log-ratios, (3) moderated t-statistics, (4) t-statistic P-values, (5) F-statistic if available, (6) F-statistic P-values if available, (7) classification if available and (8) gene names and annotation. } \author{Gordon Smyth} \seealso{ \code{\link[base]{write}} in the base library. An overview of linear model functions in limma is given by \link{06.LinearModels}. } \keyword{IO} limma/man/asMatrixWeights.Rd0000644007451300017500000000271312127125247016203 0ustar charlescharles\title{asMatrixWeights} \name{asMatrixWeights} \alias{asMatrixWeights} \description{ Convert probe-weights or array-weights to a matrix of weights. } \usage{ asMatrixWeights(weights, dim) } \arguments{ \item{weights}{numeric matrix of weights, rows corresponding to probes and columns to arrays. Or vector of probe weights. Or vector of array weights.} \item{dim}{numeric dimension vector of length 2, i.e., the number of probes and the number of arrays.} } \details{ This function converts a vector or probe-weights or a vector of array-weights to a matrix of the correct size. Probe-weights are repeated across rows while array-weights are repeated down the columns. If \code{weights} has length equal to the number of probes, it is assumed to contain probe-weights. If it has length equal to the number of arrays, it is assumed to contain array-weights. If the number of probes is equal to the number of arrays, then \code{weights} is assumed to contain array-weights if it is a row-vector of the correct size, i.e., if it is a matrix with one row. This function is used internally by the linear model fitting functions in limma. } \value{ Numeric matrix of dimension \code{dim}. } \author{Gordon Smyth} \examples{ asMatrixWeights(1:3,c(4,3)) asMatrixWeights(1:4,c(4,3)) } \seealso{ \code{\link{modifyWeights}}. An overview of functions in LIMMA used for fitting linear models is given in \link{06.LinearModels}. } \keyword{hplot} limma/man/kooperberg.Rd0000755007451300017500000000567512127125247015234 0ustar charlescharles\title{Kooperberg Model-Based Background Correction for GenePix data} \name{kooperberg} \alias{kooperberg} \description{ This function uses a Bayesian model to background correct GenePix microarray data. } \usage{ kooperberg(RG, a=TRUE, layout=RG$printer, verbose=TRUE) } \arguments{ \item{RG}{an RGList of GenePix data, read in using \code{read.maimages}, with \code{other.columns=c("F635 SD","B635 SD","F532 SD","B532 SD","B532 Mean","B635 Mean","F Pixels","B Pixels")}.} \item{a}{logical. If \code{TRUE}, the 'a' parameters in the model (equation 3 and 4) are estimated for each slide. If \code{FALSE} the 'a' parameters are set to unity.} \item{layout}{list containing print layout with components \code{ngrid.r}, \code{ngrid.c}, \code{nspot.r} and \code{nspot.c}. Defaults to \code{RG$printer}.} \item{verbose}{logical. If \code{TRUE}, progress is reported to standard output.} } \details{ This function is for use with GenePix data and is designed to cope with the problem of large numbers of negative intensities and hence missing values on the log-intensity scale. It avoids missing values in most cases and at the same time dampens down the variability of log-ratios for low intensity spots. See Kooperberg et al (2002) for more details. \code{kooperberg} uses the foreground and background intensities, standard deviations and number of pixels to compute empirical estimates of the model parameters as described in equation 2 of Kooperberg et al (2002). } \value{ An \code{RGList} containing the components \item{R}{matrix containing the background adjusted intensities for the red channel for each spot for each array} \item{G}{matrix containing the background adjusted intensities for the green channel for each spot for each array} \item{printer}{list containing print layout} } \author{Matthew Ritchie} \references{ Kooperberg, C., Fazzio, T. G., Delrow, J. J., and Tsukiyama, T. (2002) Improved background correction for spotted DNA microarrays. \emph{Journal of Computational Biology} \bold{9}, 55-66. Ritchie, M. E., Silver, J., Oshlack, A., Silver, J., Holmes, M., Diyagama, D., Holloway, A., and Smyth, G. K. (2007). A comparison of background correction methods for two-colour microarrays. \emph{Bioinformatics} 23, 2700-2707. \url{http://bioinformatics.oxfordjournals.org/cgi/content/abstract/btm412} } \seealso{ \link{04.Background} gives an overview of background correction functions defined in the LIMMA package. } \examples{ # This is example code for reading and background correcting GenePix data # given GenePix Results (gpr) files in the working directory (data not # provided). \dontrun{ genepixFiles <- dir(pattern="*\\\\.gpr$") # get the names of the GenePix image analysis output files in the current directory RG <- read.maimages(genepixFiles, source="genepix", other.columns=c("F635 SD","B635 SD","F532 SD","B532 SD","B532 Mean","B635 Mean","F Pixels","B Pixels")) RGmodel <- kooperberg(RG) MA <- normalizeWithinArrays(RGmodel) } } \keyword{models} limma/man/marraylm.Rd0000755007451300017500000000675612150771760014725 0ustar charlescharles\name{MArrayLM-class} \docType{class} \alias{MArrayLM-class} \title{Microarray Linear Model Fit - class} \description{ A list-based S4 class for storing the results of fitting gene-wise linear models to a set of microarrays. Objects are normally created by \code{\link{lmFit}}, and additional components are added by \code{\link{eBayes}}. } \section{Components}{ \code{MArrayLM} objects do not contain any slots (apart from \code{.Data}) but they should contain the following list components: \tabular{ll}{ {\code{coefficients}} \tab {matrix containing fitted coefficients or contrasts}\cr {\code{stdev.unscaled}} \tab {matrix containing unscaled standard deviations of the coefficients or contrasts}\cr {\code{sigma}} \tab {numeric vector containing residual standard deviations for each gene}\cr {\code{df.residual}} \tab {numeric vector containing residual degrees of freedom for each gene} } The following additional components may be created by \code{lmFit}: \tabular{ll}{ {\code{Amean}} \tab {numeric vector containing the average log-intensity for each probe over all the arrays in the original linear model fit. Note this vector does not change when a contrast is applied to the fit using \code{contrasts.fit}.}\cr {\code{genes}} \tab {data.frame containing probe annotation.}\cr {\code{design}} \tab {design matrix.}\cr {\code{cov.coefficients}} \tab {numeric matrix giving the unscaled covariance matrix of the estimable coefficients}\cr {\code{pivot}} \tab {integer vector giving the order of coefficients in \code{cov.coefficients}. Is computed by the QR-decomposition of the design matrix.}\cr \code{qr} \tab QR-decomposition of the design matrix (if the fit involved no weights or missing values).\cr \dots \tab other components returned by \code{lm.fit} (if the fit involved no weights or missing values). } The following component may be added by \code{contrasts.fit}: \tabular{ll}{ {\code{contrasts}} \tab {numeric matrix defining contrasts of coefficients for which results are desired.} } The following components may be added by \code{eBayes}: \tabular{ll}{ {\code{s2.prior}} \tab {numeric value giving empirical Bayes estimated prior value for residual variances}\cr {\code{df.prior}} \tab {numeric vector giving empirical Bayes estimated degrees of freedom associated with \code{s2.prior} for each gene}\cr {\code{s2.post}} \tab {numeric vector giving posterior residual variances}\cr {\code{var.prior}} \tab {numeric vector giving empirical Bayes estimated prior variance for each true coefficient}\cr {\code{F}} \tab {numeric vector giving moderated F-statistics for testing all contrasts equal to zero}\cr {\code{F.p.value}} \tab {numeric vector giving p-value corresponding to \code{F.stat}}\cr {\code{t}} \tab {numeric matrix containing empirical Bayes t-statistics}\cr } } \section{Methods}{ \code{MArrayLM} objects will return dimensions and hence functions such as \code{\link[limma:dim]{dim}}, \code{\link[base:nrow]{nrow}} and \code{\link[base:nrow]{ncol}} are defined. \code{MArrayLM} objects inherit a \code{show} method from the virtual class \code{LargeDataObject}. The functions \code{\link{eBayes}}, \code{\link{decideTests}} and \code{\link{classifyTestsF}} accept \code{MArrayLM} objects as arguments. } \author{Gordon Smyth} \seealso{ \link{02.Classes} gives an overview of all the classes defined by this package. } \keyword{classes} \keyword{regression} limma/man/gls.series.Rd0000755007451300017500000000664712127125247015153 0ustar charlescharles\name{gls.series} \alias{gls.series} \title{Fit Linear Model to Microarray Data by Generalized Least Squares} \description{ Fit a linear model genewise to expression data from a series of microarrays. The fit is by generalized least squares allowing for correlation between duplicate spots or related arrays. This is a utility function for \code{lmFit}. } \usage{gls.series(M,design=NULL,ndups=2,spacing=1,block=NULL,correlation=NULL,weights=NULL,...)} \arguments{ \item{M}{numeric matrix containing log-ratio or log-expression values for a series of microarrays, rows correspond to genes and columns to arrays.} \item{design}{numeric design matrix defining the linear model, with rows corresponding to arrays and columns to comparisons to be estimated. The number of rows must match the number of columns of \code{M}. Defaults to the unit vector meaning that the arrays are treated as replicates.} \item{ndups}{positive integer giving the number of times each gene is printed on an array. \code{nrow(M)} must be divisible by \code{ndups}.} \item{spacing}{the spacing between the rows of \code{M} corresponding to duplicate spots, \code{spacing=1} for consecutive spots} \item{block}{vector or factor specifying a blocking variable on the arrays. Same length as \code{ncol(M)}.} \item{correlation}{numeric value specifying the inter-duplicate or inter-block correlation.} \item{weights}{an optional numeric matrix of the same dimension as \code{M} containing weights for each spot. If it is of different dimension to \code{M}, it will be filled out to the same size.} \item{...}{other optional arguments to be passed to \code{dupcor.series}.} } \value{ A list with components \item{coefficients}{numeric matrix containing the estimated coefficients for each linear model. Same number of rows as \code{M}, same number of columns as \code{design}.} \item{stdev.unscaled}{numeric matrix conformal with \code{coef} containing the unscaled standard deviations for the coefficient estimators. The standard errors are given by \code{stdev.unscaled * sigma}.} \item{sigma}{numeric vector containing the residual standard deviation for each gene.} \item{df.residual}{numeric vector giving the degrees of freedom corresponding to \code{sigma}} \item{correlation}{inter-duplicate or inter-block correlation} \item{qr}{QR decomposition of the generalized linear squares problem, i.e., the decomposition of \code{design} standardized by the Choleski-root of the correlation matrix defined by \code{correlation}} } \details{ This is a utility function used by the higher level function \code{\link{lmFit}}. Most users should not use this function directly but should use \code{\link{lmFit}} instead. This function is for fitting gene-wise linear models when some of the expression values are correlated. The correlated groups may arise from replicate spots on the same array (duplicate spots) or from a biological or technical replicate grouping of the arrays. This function is normally called by \code{lmFit} and is not normally called directly by users. Note that the correlation is assumed to be constant across genes. If \code{correlation=NULL} then a call is made to \code{duplicateCorrelation} to estimated the correlation. } \seealso{ \code{\link{duplicateCorrelation}}. An overview of linear model functions in limma is given by \link{06.LinearModels}. } \author{Gordon Smyth} \keyword{models} \keyword{regression} limma/man/05Normalization.Rd0000644007451300017500000000544312175540776016071 0ustar charlescharles\name{05.Normalization} \alias{05.Normalization} \title{Normalization of Microarray Data} \description{ This page gives an overview of the LIMMA functions available to normalize data from single-channel or two-colour microarrays. Smyth and Speed (2003) give an overview of the normalization techniques implemented in the functions for two-colour arrays. Usually data from spotted microarrays will be normalized using \code{\link{normalizeWithinArrays}}. A minority of data will also be normalized using \code{\link{normalizeBetweenArrays}} if diagnostic plots suggest a difference in scale between the arrays. In rare circumstances, data might be normalized using \code{\link{normalizeForPrintorder}} before using \code{\link{normalizeWithinArrays}}. All the normalization routines take account of spot quality weights which might be set in the data objects. The weights can be temporarily modified using \code{\link{modifyWeights}} to, for example, remove ratio control spots from the normalization process. If one is planning analysis of single-channel information from the microarrays rather than analysis of differential expression based on log-ratios, then the data should be normalized using a single channel-normalization technique. Single channel normalization uses further options of the \code{\link{normalizeBetweenArrays}} function. For more details see the \link[=limmaUsersGuide]{LIMMA User's Guide} which includes a section on single-channel normalization. \code{normalizeWithinArrays} uses utility functions \code{\link{MA.RG}}, \code{\link{loessFit}} and \code{\link{normalizeRobustSpline}}. \code{normalizeBetweenArrays} is the main normalization function for one-channel arrays, as well as an optional function for two-colour arrays. \code{normalizeBetweenArrays} uses utility functions \code{\link{normalizeMedianAbsValues}}, \code{\link{normalizeMedianAbsValues}}, \code{\link{normalizeQuantiles}} and \code{\link{normalizeCyclicLoess}}, none of which need to be called directly by users. \code{\link{neqc}} is a between array normalization function customized for Illumina BeadChips. The function \code{\link{normalizeVSN}} is also provided as a interface to the vsn package. It performs variance stabilizing normalization, an algorithm which includes background correction, within and between normalization together, and therefore doesn't fit into the paradigm of the other methods. \code{\link{removeBatchEffect}} can be used to remove a batch effect, associated with hybridization time or some other technical variable, prior to unsupervised analysis. } \author{Gordon Smyth} \references{ Smyth, G. K., and Speed, T. P. (2003). Normalization of cDNA microarray data. \emph{Methods} 31, 265-273. \url{http://www.statsci.org/smyth/pubs/normalize.pdf} } \keyword{documentation} limma/man/07SingleChannel.Rd0000644007451300017500000000204112127125247015733 0ustar charlescharles\name{07.SingleChannel} \alias{07.SingleChannel} \title{Individual Channel Analysis of Two-Color Microarrays} \description{ This page gives an overview of the LIMMA functions fit linear models to two-color microarray data in terms of the log-intensities rather than log-ratios. The function \code{\link{intraspotCorrelation}} estimates the intra-spot correlation between the two channels. The regression function \code{\link{lmscFit}} takes the correlation as an argument and fits linear models to the two-color data in terms of the individual log-intensities. The output of \code{lmscFit} is an \code{MArrayLM} object just the same as from \code{lmFit}, so inference proceeds in the same way as for log-ratios once the linear model is fitted. See \link{06.LinearModels}. The function \code{\link{targetsA2C}} converts two-color format target data frames to single channel format, i.e, converts from array-per-line to channel-per-line, to facilitate the formulation of the design matrix. } \author{Gordon Smyth} \keyword{documentation} limma/man/normalizeMedianAbsValues.Rd0000644007451300017500000000260312127125247020002 0ustar charlescharles\name{normalizeMedianAbsValues} \alias{normalizeMedianValues} \alias{normalizeMedianAbsValues} \title{Normalize Columns of a Matrix to have the Median Absolute Value} \description{ Performs scale normalization of an M-value matrix or an A-value matrix across a series of arrays. Users do not normally need to call these functions directly - use \code{normalizeBetweenArrays} instead. } \usage{ normalizeMedianValues(x) normalizeMedianAbsValues(x) } \arguments{ \item{x}{numeric matrix} } \value{ A numeric matrix of the same size as that input which has been scaled so that each column has the same median value (for \code{normalizeMedianValues}) or median-absolute value (for \code{normalizeMedianAbsValues}). } \details{ If \code{x} is a matrix of log-ratios of expression (M-values) then \code{normalizeMedianAbsValues} is very similar to scaling to equalize the median absolute deviation (MAD) as in Yang et al (2001, 2002). Here the median-absolute value is used for preference to as to not re-center the M-values. \code{normalizeMedianAbsValues} is also used to scale the A-values when scale-normalization is applied to an \code{MAList} object. } \author{Gordon Smyth} \seealso{ An overview of LIMMA functions for normalization is given in \link{05.Normalization}. } \examples{ M <- cbind(Array1=rnorm(10),Array2=2*rnorm(10)) normalizeMedianAbsValues(M) } \keyword{array} limma/man/backgroundcorrect.Rd0000755007451300017500000001512412127125247016564 0ustar charlescharles\name{backgroundCorrect} \alias{backgroundCorrect} \alias{backgroundCorrect.matrix} \title{Correct Intensities for Background} \description{ Background correct microarray expression intensities. } \usage{ backgroundCorrect(RG, method="auto", offset=0, printer=RG$printer, normexp.method="saddle", verbose=TRUE) backgroundCorrect.matrix(E, Eb=NULL, method="auto", offset=0, printer=NULL, normexp.method="saddle", verbose=TRUE) } \arguments{ \item{RG}{a numeric matrix, \code{\link[limma:EList]{EListRaw}} or \code{\link[limma:rglist]{RGList}} object.} \item{E}{numeric matrix containing foreground intensities.} \item{Eb}{numeric matrix containing background intensities.} \item{method}{character string specifying correction method. Possible values are \code{"auto"}, \code{"none"}, \code{"subtract"}, \code{"half"}, \code{"minimum"}, \code{"movingmin"}, \code{"edwards"} or \code{"normexp"}. If \code{RG} is a matrix, possible values are restricted to \code{"none"} or \code{"normexp"}. The default \code{"auto"} is interpreted as \code{"subtract"} if background intensities are available or \code{"normexp"} if they are not.} \item{offset}{numeric value to add to intensities} \item{printer}{a list containing printer layout information, see \code{\link{PrintLayout-class}}. Ignored if \code{RG} is a matrix.} \item{normexp.method}{character string specifying parameter estimation strategy used by normexp, ignored for other methods. Possible values are \code{"saddle"}, \code{"mle"}, \code{"rma"} or \code{"rma75"}.} \item{verbose}{logical. If \code{TRUE}, progress messages are sent to standard output} } \details{ This function implements the background correction methods reviewed or developed in Ritchie et al (2007) and Silver at al (2009). Ritchie et al (2007) recommend \code{method="normexp"} whenever \code{RG} contains local background estimates. Silver et al (2009) shows that either \code{normexp.method="mle"} or \code{normexp.method="saddle"} are excellent options for normexp. If \code{RG} contains morphological background estimates instead (available from SPOT or GenePix image analysis software), then \code{method="subtract"} performs well. If \code{method="none"} then no correction is done, i.e., the background intensities are treated as zero. If \code{method="subtract"} then the background intensities are subtracted from the foreground intensities. This is the traditional background correction method, but is not necessarily recommended. If \code{method="movingmin"} then the background estimates are replaced with the minimums of the backgrounds of the spot and its eight neighbors, i.e., the background is replaced by a moving minimum of 3x3 grids of spots. The remaining methods are all designed to produce positive corrected intensities. If \code{method="half"} then any intensity which is less than 0.5 after background subtraction is reset to be equal to 0.5. If \code{method="minimum"} then any intensity which is zero or negative after background subtraction is set equal to half the minimum of the positive corrected intensities for that array. If \code{method="edwards"} a log-linear interpolation method is used to adjust lower intensities as in Edwards (2003). If \code{method="normexp"} a convolution of normal and exponential distributions is fitted to the foreground intensities using the background intensities as a covariate, and the expected signal given the observed foreground becomes the corrected intensity. This results in a smooth monotonic transformation of the background subtracted intensities such that all the corrected intensities are positive. The normexp method is available in a number of variants depending on how the model parameters are estimated, and these are selected by \code{normexp.method}. Here \code{"saddle"} gives the saddle-point approximation to maximum likelihood from Ritchie et al (2007) and improved by Silver et al (2009), \code{"mle"} gives exact maximum likelihood from Silver at al (2009), \code{"rma"} gives the background correction algorithm from the RMA-algorithm for Affymetrix microarray data as implemented in the affy package, and \code{"rma75"} gives the RMA-75 method from McGee and Chen (2006). In practice \code{"mle"} performs well and is nearly as fast as \code{"saddle"}, but \code{"saddle"} is the default for backward compatibility. See \code{\link{normexp.fit}} for more details. The \code{offset} can be used to add a constant to the intensities before log-transforming, so that the log-ratios are shrunk towards zero at the lower intensities. This may eliminate or reverse the usual 'fanning' of log-ratios at low intensities associated with local background subtraction. Background correction (background subtraction) is also performed by the \code{\link{normalizeWithinArrays}} method for \code{RGList} objects, so it is not necessary to call \code{backgroundCorrect} directly unless one wants to use a method other than simple subtraction. Calling \code{backgroundCorrect} before \code{normalizeWithinArrays} will over-ride the default background correction. } \value{ A matrix, \code{EListRaw} or \code{RGList} object in which foreground intensities have been background corrected and any components containing background intensities have been removed. } \references{ Edwards, D. E. (2003). Non-linear normalization and background correction in one-channel cDNA microarray studies \emph{Bioinformatics} 19, 825-833. McGee, M., and Chen, Z. (2006). Parameter estimation for the exponential-normal convolution model for background correction of Affymetrix GeneChip data. \emph{Stat Appl Genet Mol Biol}, Volume 5, Article 24. Ritchie, M. E., Silver, J., Oshlack, A., Silver, J., Holmes, M., Diyagama, D., Holloway, A., and Smyth, G. K. (2007). A comparison of background correction methods for two-colour microarrays. \emph{Bioinformatics} 23, 2700-2707. \url{http://bioinformatics.oxfordjournals.org/cgi/content/abstract/btm412} Silver, J., Ritchie, M. E., and Smyth, G. K. (2009). Microarray background correction: maximum likelihood estimation for the normal-exponential convolution model. \emph{Biostatistics} 10, 352-363. \url{http://biostatistics.oxfordjournals.org/cgi/content/abstract/kxn042} } \author{Gordon Smyth} \examples{ RG <- new("RGList", list(R=c(1,2,3,4),G=c(1,2,3,4),Rb=c(2,2,2,2),Gb=c(2,2,2,2))) backgroundCorrect(RG) backgroundCorrect(RG, method="half") backgroundCorrect(RG, method="minimum") backgroundCorrect(RG, offset=5) } \seealso{ \code{\link{kooperberg}}, \code{\link{neqc}}. An overview of background correction functions is given in \code{\link{04.Background}}. } \keyword{models} limma/man/lm.series.Rd0000755007451300017500000000451712127125247014770 0ustar charlescharles\name{lm.series} \alias{lm.series} \title{Fit Linear Model to Microrray Data by Ordinary Least Squares} \description{Fit a linear model genewise to expression data from a series of arrays. This function uses ordinary least squares and is a utility function for \code{lmFit}.} \usage{lm.series(M,design=NULL,ndups=1,spacing=1,weights=NULL)} \arguments{ \item{M}{numeric matrix containing log-ratio or log-expression values for a series of microarrays, rows correspond to genes and columns to arrays} \item{design}{numeric design matrix defining the linear model. The number of rows should agree with the number of columns of M. The number of columns will determine the number of coefficients estimated for each gene.} \item{ndups}{number of duplicate spots. Each gene is printed ndups times in adjacent spots on each array.} \item{spacing}{the spacing between the rows of \code{M} corresponding to duplicate spots, \code{spacing=1} for consecutive spots} \item{weights}{an optional numeric matrix of the same dimension as \code{M} containing weights for each spot. If it is of different dimension to \code{M}, it will be filled out to the same size.} } \value{ A list with components \item{coefficients}{numeric matrix containing the estimated coefficients for each linear model. Same number of rows as \code{M}, same number of columns as \code{design}.} \item{stdev.unscaled}{numeric matrix conformal with \code{coef} containing the unscaled standard deviations for the coefficient estimators. The standard errors are given by \code{stdev.unscaled * sigma}.} \item{sigma}{numeric vector containing the residual standard deviation for each gene.} \item{df.residual}{numeric vector giving the degrees of freedom corresponding to \code{sigma}.} \item{qr}{QR-decomposition of \code{design}} } \details{ This is a utility function used by the higher level function \code{\link{lmFit}}. Most users should not use this function directly but should use \code{\link{lmFit}} instead. The linear model is fit for each gene by calling the function \code{lm.fit} or \code{lm.wfit} from the base library. } \author{Gordon Smyth} \examples{ # See lmFit for examples } \seealso{ \code{\link[stats:lmfit]{lm.fit}}. An overview of linear model functions in limma is given by \link{06.LinearModels}. } \keyword{models} \keyword{regression} limma/man/malist.Rd0000755007451300017500000000565012127125247014357 0ustar charlescharles\name{MAList-class} \docType{class} \alias{MAList-class} \title{M-value, A-value Expression List - class} \description{ A simple list-based class for storing M-values and A-values for a batch of spotted microarrays. \code{MAList} objects are usually created during normalization by the functions \code{\link{normalizeWithinArrays}} or \code{\link{MA.RG}}. } \section{Slots/List Components}{ \code{MAList} objects can be created by \code{new("MAList",MA)} where \code{MA} is a list. This class contains no slots (other than \code{.Data}), but objects should contain the following components: \tabular{ll}{ \code{M}:\tab numeric matrix containing the M-values (log-2 expression ratios). Rows correspond to spots and columns to arrays.\cr \code{A}:\tab numeric matrix containing the A-values (average log-2 expression values). } Optional components include: \tabular{ll}{ \code{weights}:\tab numeric matrix of same dimensions as \code{M} containing relative spot quality weights. Elements should be non-negative.\cr \code{other}:\tab list containing other matrices, all of the same dimensions as \code{M}.\cr \code{genes}:\tab data.frame containing probe information. Should have one row for each spot. May have any number of columns.\cr \code{targets}:\tab data.frame containing information on the target RNA samples. Rows correspond to arrays. May have any number of columns. Usually includes columns \code{Cy3} and \code{Cy5} specifying which RNA was hybridized to each array.\cr \code{printer}:\tab list containing information on the process used to print the spots on the arrays. See \link[limma:PrintLayout]{PrintLayout}. } Valid \code{MAList} objects may contain other optional components, but all probe or array information should be contained in the above components. } \section{Methods}{ This class inherits directly from class \code{list} so any operation appropriate for lists will work on objects of this class. In addition, \code{MAList} objects can be \link[=subsetting]{subsetted} and \link[=cbind]{combined}. \code{RGList} objects will return dimensions and hence functions such as \code{\link[limma:dim]{dim}}, \code{\link[base:nrow]{nrow}} and \code{\link[base:nrow]{ncol}} are defined. \code{MALists} also inherit a \code{\link[methods]{show}} method from the virtual class \code{\link[limma:LargeDataObject]{LargeDataObject}}, which means that \code{RGLists} will print in a compact way. Other functions in LIMMA which operate on \code{MAList} objects include \code{\link{normalizeWithinArrays}}, \code{\link{normalizeBetweenArrays}}, \code{\link{normalizeForPrintorder}}, \code{\link{plotMA}} and \code{\link{plotPrintTipLoess}}. } \author{Gordon Smyth} \seealso{ \link{02.Classes} gives an overview of all the classes defined by this package. \code{\link[marray:marrayNorm-class]{marrayNorm}} is the corresponding class in the marray package. } \keyword{classes} \keyword{data} limma/man/readSpotTypes.Rd0000755007451300017500000000312712127125247015671 0ustar charlescharles\name{readSpotTypes} \alias{readSpotTypes} \title{Read Spot Types File} \description{ Read a table giving regular expressions to identify different types of spots in the gene-dataframe. } \usage{ readSpotTypes(file="SpotTypes.txt",path=NULL,sep="\t",check.names=FALSE,...) } \arguments{ \item{file}{character string giving the name of the file specifying the spot types.} \item{path}{character string giving the directory containing the file. Can be omitted if the file is in the current working irectory.} \item{sep}{the field separator character} \item{check.names}{logical, if \code{FALSE} column names will not be converted to valid variable names, for example spaces in column names will not be left as is} \item{\dots}{any other arguments are passed to \code{read.table}} } \details{ The file is a text file with rows corresponding to types of spots and the following columns: \code{SpotType} gives the name for the spot type, \code{ID} is a regular expression matching the ID column, \code{Name} is a regular expression matching the Name column, and \code{Color} is the R name for the color to be associated with this type. } \value{ A data frame with columns \item{SpotType}{character vector giving names of the spot types} \item{ID}{character vector giving regular expressions} \item{Name}{character vector giving regular expressions} \item{Color}{character vector giving names of colors} } \author{Gordon Smyth following idea of James Wettenhall} \seealso{ An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \keyword{IO} limma/man/decideTests.Rd0000755007451300017500000000546712127125247015334 0ustar charlescharles\name{decideTests} \alias{decideTests} \title{Multiple Testing Across Genes and Contrasts} \description{ Classify a series of related t-statistics as up, down or not significant. A number of different multiple testing schemes are offered which adjust for multiple testing down the genes as well as across contrasts for each gene. } \usage{ decideTests(object,method="separate",adjust.method="BH",p.value=0.05,lfc=0) } \arguments{ \item{object}{\code{MArrayLM} object output from \code{eBayes} from which the t-statistics may be extracted.} \item{method}{character string specify how probes and contrasts are to be combined in the multiple testing strategy. Choices are \code{"separate"}, \code{"global"}, \code{"hierarchical"}, \code{"nestedF"} or any partial string.} \item{adjust.method}{character string specifying p-value adjustment method. Possible values are \code{"none"}, \code{"BH"}, \code{"fdr"} (equivalent to \code{"BH"}), \code{"BY"} and \code{"holm"}. See \code{\link[stats]{p.adjust}} for details.} \item{p.value}{numeric value between 0 and 1 giving the desired size of the test} \item{lfc}{minimum log2-fold-change required} } \value{ An object of class \code{\link[=TestResults-class]{TestResults}}. This is essentially a numeric matrix with elements \code{-1}, \code{0} or \code{1} depending on whether each t-statistic is classified as significantly negative, not significant or significantly positive respectively. If \code{lfc>0} then contrasts are judged significant only when the log2-fold change is at least this large in absolute value. For example, one might choose \code{lfc=log2(1.5)} to restrict to 50\% changes or \code{lfc=1} for 2-fold changes. In this case, contrasts must satisfy both the p-value and the fold-change cutoff to be judged significant. } \details{ These functions implement multiple testing procedures for determining whether each statistic in a matrix of t-statistics should be considered significantly different from zero. Rows of \code{tstat} correspond to genes and columns to coefficients or contrasts. The setting \code{method="separate"} is equivalent to using \code{topTable} separately for each coefficient in the linear model fit, and will give the same lists of probes if \code{adjust.method} is the same. \code{method="global"} will treat the entire matrix of t-statistics as a single vector of unrelated tests. \code{method="hierarchical"} adjusts down genes and then across contrasts. \code{method="nestedF"} adjusts down genes and then uses \code{classifyTestsF} to classify contrasts as significant or not for the selected genes. Please see the limma User's Guide for a discussion of the statistical properties of these methods. } \seealso{ An overview of multiple testing functions is given in \link{08.Tests}. } \author{Gordon Smyth} \keyword{htest} limma/man/imageplot3by2.Rd0000755007451300017500000000251612127125247015545 0ustar charlescharles\title{Write Imageplots to Files} \name{imageplot3by2} \alias{imageplot3by2} \description{ Write imageplots to files in PNG format, six plots to a file in a 3 by 2 grid arrangement. } \usage{ imageplot3by2(RG, z="Gb", prefix=paste("image",z,sep="-"), path=NULL, zlim=NULL, common.lim=TRUE, ...) } \arguments{ \item{RG}{an \code{RGList} or \code{MAList} object, or any list with component named by \code{z}} \item{z}{character string giving name of component of \code{RG} to plot} \item{prefix}{character string giving prefix to attach to file names} \item{path}{character string specifying directory for output files} \item{zlim}{numeric vector of length 2, giving limits of response vector to be associated with saturated colors} \item{common.lim}{logical, should all plots on a page use the same axis limits} \item{...}{any other arguments are passed to \code{imageplot}} } \details{ At the time of writing, this function writes plots in PNG format in an arrangement optimized for A4-sized paper. } \value{ No value is returned, but one or more files are written to the working directory. The number of files is determined by the number of columns of \code{RG}. } \author{Gordon Smyth} \seealso{ An overview of diagnostic functions available in LIMMA is given in \link{09.Diagnostics}. } \keyword{hplot} limma/man/TestResults.Rd0000755007451300017500000000322412127125247015362 0ustar charlescharles\name{TestResults-class} \docType{class} \alias{TestResults-class} \alias{show,TestResults-method} \alias{summary.TestResults} \title{Matrix of Test Results - class} \description{ A matrix-based class for storing the results of simultanous tests. \code{TestResults} objects are normally created by \code{\link{classifyTestsF}}, \code{\link{classifyTestsT}} or \code{\link{classifyTestsP}}. } \usage{ \S3method{summary}{TestResults}(object, ...) } \arguments{ \item{object}{object of class \code{TestResults}} \item{\dots}{other arguments are not used} } \section{Slots/List Components}{ \code{TestResults} objects can be created by \code{new("TestResults",results)} where \code{results} is a matrix. Objects of this class contain no slots (other than \code{.Data}), although the attributes \code{dim} and \code{dimnames} may be treated as slots. } \section{Methods}{ This class inherits directly from class \code{matrix} so any operation appropriate for matrices will work on objects of this class. \code{\link[methods]{show}} and \code{summary} methods are also implemented. Functions in LIMMA which operate on \code{TestResults} objects include \code{\link{heatDiagram}}, \code{\link{vennCounts}}, \code{\link{vennDiagram}}, \code{\link{write.fit}}. } \author{Gordon Smyth} \seealso{ \link{02.Classes} gives an overview of all the classes defined by this package. \link{08.Tests} gives an overview of multiple testing. } \examples{\dontrun{ # Assume a data object MA and a design matrix fit <- lmFit(MA, design) fit <- eBayes(fit) results <- decideTests(fit) summary(results) }} \keyword{classes} \keyword{htest} limma/man/read.maimages.Rd0000755007451300017500000002630412127125247015562 0ustar charlescharles\name{read.maimages} \alias{read.maimages} \alias{read.imagene} \title{Read RGList or EListRaw from Image Analysis Output Files} \description{ Reads an RGList from a set of two-color microarray image analysis output files, or an EListRaw from a set of one-color files. } \usage{ read.maimages(files=NULL, source="generic", path=NULL, ext=NULL, names=NULL, columns=NULL, other.columns=NULL, annotation=NULL, green.only=FALSE, wt.fun=NULL, verbose=TRUE, sep="\t", quote=NULL, \dots) read.imagene(files, path=NULL, ext=NULL, names=NULL, columns=NULL, other.columns=NULL, wt.fun=NULL, verbose=TRUE, sep="\t", quote="\"", \dots) } \arguments{ \item{files}{character vector giving the names of the files containing image analysis output or, for Imagene data, a character matrix of names of files. If omitted, then all files with extension \code{ext} in the specified directory will be read in alphabetical order.} \item{source}{character string specifying the image analysis program which produced the output files. Choices are \code{"generic"}, \code{"agilent"}, \code{"agilent.median"}, \code{"agilent.mean"}, \code{"arrayvision"}, \code{"arrayvision.ARM"}, \code{"arrayvision.MTM"}, \code{"bluefuse"}, \code{"genepix"}, \code{"genepix.custom"}, \code{"genepix.median"}, \code{"imagene"}, \code{"imagene9"}, \code{"quantarray"}, \code{"scanarrayexpress"}, \code{"smd.old"}, \code{"smd"}, \code{"spot"} or \code{"spot.close.open"}.} \item{path}{character string giving the directory containing the files. The default is the current working directory.} \item{ext}{character string giving optional extension to be added to each file name} \item{names}{character vector of names to be associated with each array as column name. Defaults to \code{removeExt(files)}.} \item{columns}{list, or named character vector. For two color data, this should have fields \code{R}, \code{G}, \code{Rb} and \code{Gb} giving the column names to be used for red and green foreground and background or, in the case of Imagene data, a list with fields \code{f} and \code{b}. For single channel data, the fields are usually \code{E} and \code{Eb}. This argument is optional if \code{source} is specified, otherwise it is required.} \item{other.columns}{character vector of names of other columns to be read containing spot-specific information} \item{annotation}{character vector of names of columns containing annotation information about the probes} \item{green.only}{logical, for use with \code{source}, should the green (Cy3) channel only be read, or are both red and green required?} \item{wt.fun}{function to calculate spot quality weights} \item{verbose}{logical, \code{TRUE} to report each time a file is read} \item{sep}{the field separator character} \item{quote}{character string of characters to be treated as quote marks} \item{\dots}{any other arguments are passed to \code{read.table}} } \details{ These are the main data input functions for the LIMMA package. \code{read.maimages} reads either single channel or two-color microarray intensity data from text files. \code{read.imagene} is specifically for two-color ImaGene intensity data created by ImaGene versions 1 through 8, and is called by \code{read.maimages} to read such data. \code{read.maimages} is designed to read data from any microarray platform except for Illumina BeadChips, which are read by \code{\link{read.ilmn}}, and Affymetrix GeneChip data, which is best read and pre-processed by specialist packages designed for that platform. \code{read.maimages} extracts the foreground and background intensities from a series of files, produced by an image analysis program, and assembles them into the components of one list. The image analysis programs Agilent Feature Extraction, ArrayVision, BlueFuse, GenePix, ImaGene, QuantArray (Version 3 or later), Stanford Microarray Database (SMD) and SPOT are supported explicitly. Almost all these programs write the intensity data for each microarray to one file. The exception is ImaGene, early versions of which wrote the red and green channels of each microarray to different files. Data from some other image analysis programs not mentioned above can be read if the appropriate column names containing the foreground and background intensities are specified using the \code{columns} argument. (Reading custom columns will work provided the column names are unique and there are no rows in the file after the last line of data. Header lines are ok.) For Agilent files, two possible foreground estimators are supported: \code{source="agilent.median"} use median foreground while \code{source="agilent.mean"} uses mean foreground. Background estimates are always medians. The use of \code{source="agilent"} defaults to \code{"agilent.median"}. Note that this behavior is new from 9 March 2012. Previously, in limma 3.11.16 or earlier, \code{"agilent"} had the same meaning as \code{"agilent.mean"}. For GenePix files, two possible foreground estimators are supported as well as custom background: \code{source="genepix.median"} uses the median foreground estimates while \code{source="genepix.mean"} uses mean foreground estimates. The use of \code{source="genepix"} defaults to \code{"genepix.mean"}. Background estimates are always medians unless \code{source="genepix.custom"} is specified. GenePix 6.0 and later supply some custom background options, notably morphological background. If the GPR files have been written using a custom background, then \code{source="genepix.custom"} will cause it to be read and used. For SPOT files, two possible background estimators are supported: \code{source="spot"} uses background intensities estimated from the morphological opening algorithm. If \code{source="spot.close.open"} then background intensities are estimated from morphological closing followed by opening. ArrayVision reports spot intensities in a number of different ways. \code{read.maimages} caters for ArrayVision's Artifact-removed (ARM) density values using \code{source="arrayvision.ARM"} or for Median-based Trimmed Mean (MTM) density values with \code{"arrayvision.MTM"}. ArrayVision users may find it useful to read the top two lines of their data file to check which version of density values they have. SMD data should consist of raw data files from the database, in tab-delimited text form. There are two possible sets of column names depending on whether the data was entered into the database before or after September 2003. \code{source="smd.old"} indicates that column headings in use prior to September 2003 should be used. Intensity data from ImaGene versions 1 to 8 (\code{source="imagene"}) is different from other image analysis programs in that the read and green channels were written to separate files. \code{read.maimages} handles the special behaviour of the early ImaGene versions by requiring that the argument \code{files} should be a matrix with two columns instead of a vector. The first column should contain the names of the files containing green channel (cy3) data and the second column should contain names of files containing red channel (cy5) data. Alternately, \code{files} can be entered as a vector of even length instead of a matrix. In that case, each consecutive pair of file names is assumed to contain the green (cy3) and red (cy5) intensities respectively from the same array. The function \code{read.imagene} is called by \code{read.maimages} when \code{source="imagene"}, so \code{read.imagene} does not need to be called directly by users. ImaGene version~9 (\code{source="imagene9"}) reverts to the same behavior as the other image analysis programs. For ImaGene~9, \code{files} is a vector of length equal to the number of microarrays, same as for other image analysis programs. Spot quality weights may be extracted from the image analysis files using a weight function wt.fun. \code{wt.fun} may be any user-supplied function which accepts a data.frame argument and returns a vector of non-negative weights. The columns of the data.frame are as in the image analysis output files. There is one restriction, which is that the column names should be refered to in full form in the weight function, i.e., do not rely on name expansion for partial matches when refering to the names of the columns. See \code{\link{QualityWeights}} for suggested weight functions. The argument \code{other.columns} allows arbitrary columns of the image analysis output files to be preserved in the data object. These become matrices in the component \code{other} component. For ImaGene data, the other column headings should be prefixed with \code{"R "} or \code{"G "} as appropriate. } \section{Warnings}{ All image analysis files being read are assumed to contain data for the same genelist in the same order. No checking is done to confirm that this is true. Probe annotation information is read from the first file only. } \value{ For one-color data, an \code{\link[limma:EList]{EListRaw}} object. For two-color data, an \code{\link[limma:rglist]{RGList}} object containing the components \item{R}{matrix containing the red channel foreground intensities for each spot for each array.} \item{Rb}{matrix containing the red channel background intensities for each spot for each array.} \item{G}{matrix containing the green channel foreground intensities for each spot for each array.} \item{Gb}{matrix containing the green channel background intensities for each spot for each array.} \item{weights}{spot quality weights, if \code{wt.fun} is given} \item{other}{list containing matrices corresponding to \code{other.columns} if given} \item{genes}{data frame containing annotation information about the probes, for example gene names and IDs and spatial positions on the array, currently set only if \code{source} is \code{"agilent"}, \code{"genepix"} or \code{source="imagene"} or if the \code{annotation} argument is set} \item{targets}{data frame with column \code{FileName} giving the names of the files read} \item{source}{character string giving the image analysis program name} \item{printer}{list of class \code{\link[=PrintLayout-class]{PrintLayout}}, currently set only if \code{source="imagene"}} } \author{Gordon Smyth, with speed improvements suggested by Marcus Davy} \references{ Web pages for the image analysis software packages mentioned here are listed at \url{http://www.statsci.org/micrarra/image.html} } \seealso{ \code{read.maimages} uses \code{\link{read.columns}} for efficient reading of text files. As far as possible, it is has similar behavior to \code{\link[utils]{read.table}} in the base package. \code{\link{read.ilmn}} reads probe or gene summary profile files from Illumina BeadChips. An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \examples{ # Read all .gpr files from current working directory # and give weight 0.1 to spots with negative flags \dontrun{files <- dir(pattern="*\\\\.gpr$") RG <- read.maimages(files,"genepix",wt.fun=wtflags(0.1))} # Read all .spot files from current working director and down-weight # spots smaller or larger than 150 pixels \dontrun{files <- dir(pattern="*\\\\.spot$") RG <- read.maimages(files,"spot",wt.fun=wtarea(150))} } \keyword{file} limma/man/propexpr.Rd0000644007451300017500000000446512127125247014745 0ustar charlescharles\name{propexpr} \alias{propexpr} \title{Estimate Proportion of Expressed Probes} \description{Estimate the proportion of microarray probes which are expressed in each array.} \usage{ propexpr(x, neg.x=NULL, status=x$genes$Status, labels=c("negative","regular")) } \arguments{ \item{x}{matrix or similar object containing raw intensities for a set of arrays.} \item{neg.x}{matrix or similar object containing raw intensities for negative control probes for the same arrays. If \code{NULL}, then negative controls must be provided in \code{x}.} \item{status}{character vector giving probe types.} \item{labels}{character vector giving probe type identifiers.} } \details{ This function estimates the proportion of expressed in a microarray by utilizing the negative control probes. Illumina BeadChip arrays contain 750~1600 negative control probes. The expression profile of these control probes can be saved to a separate file by the Illumina BeadStudio software when using it to output the expression profile for regular probes. The control probe profile could be re-generated if it was not generated when the regular probe profile was created by BeadStudio. Other microarray platforms can also use this function to estimate the proportion of expressed probes in each array, provided that they have a set of negative control probes. \code{labels} can include one or two probe type identifiers. Its first element should be the identifier for negative control probes (\code{negative} by default). If \code{labels} only contains one identifier, then it will be assumed to contain the identifier for negative control probes. By default, \code{regular} is the identifier for regular probes. } \value{ Numeric vector giving the proportions of expressed probes in each array. } \references{ Shi, W, de Graaf, C, Kinkel, S, Achtman, A, Baldwin, T, Schofield, L, Scott, H, Hilton, D, Smyth, GK (2010). Estimating the proportion of microarray probes expressed in an RNA sample. Nucleic Acids Research 38, 2168-2176. } \author{Wei Shi and Gordon Smyth} \seealso{ Description to the control probes in Illumina BeadChips can be found in \code{\link{read.ilmn}}. } \examples{ \dontrun{ x <- read.ilmn(files="sample probe profile.txt",ctrlfiles="control probe profile.txt") propexpr(x, ) } } \keyword{models}limma/man/normalizeRobustSpline.Rd0000755007451300017500000000620712127125247017437 0ustar charlescharles\name{normalizeRobustSpline} \alias{normalizeRobustSpline} \title{Normalize Single Microarray Using Shrunk Robust Splines} \description{ Normalize the M-values for a single microarray using robustly fitted regression splines and empirical Bayes shrinkage. } \usage{ normalizeRobustSpline(M,A,layout=NULL,df=5,method="M") } \arguments{ \item{M}{numeric vector of M-values} \item{A}{numeric vector of A-values} \item{layout}{list specifying the dimensions of the spot matrix and the grid matrix. Defaults to a single group for the whole array.} \item{df}{degrees of freedom for regression spline, i.e., the number of regression coefficients and the number of knots} \item{method}{choices are \code{"M"} for M-estimation or \code{"MM"} for high breakdown point regression} } \details{ This function implements an idea similar to print-tip loess normalization but uses regression splines in place of the loess curves and uses empirical Bayes ideas to shrink the individual print-tip curves towards a common value. This allows the technique to introduce less noise into good quality arrays with little spatial variation while still giving good results on arrays with strong spatial variation. The original motivation for the robustspline method was to use whole-array information to moderate the normalization curves used for the individual print-tip groups. This was an important issue for academically printed spotted two-color microarrays, especially when some of the print-tip groups contained relatively few spots. In these situations, robust spline normalization ensures stable results even for print-tip groups with few spots. Modern commercial two colour arrays do not usually have print tips, so in effect the whole array is a single print-tip group, and so the need for moderating individual curves is gone. Robustspline normalization can still be used for data from these arrays, in which case a single normalization curve is estimated. In this situation, the method is closely analogous to global loess, with a regression spline replacing the loess curve and with robust regression replacing the loess robustifying weights. Robust spline normalization with \code{method="MM"} has potential advantages over global loess normalization when there a lot of differential expression or the differential expression is assymetric, because of the increased level of robustness. The potential advantages of this approach have not been fully explored in a refereed publication however. } \value{ Numeric vector containing normalized M-values. } \author{Gordon Smyth} \references{ The function is based on unpublished work by the author. } \seealso{ \code{normalizeRobustSpline} uses \code{ns} in the splines package to specify regression splines and \code{rlm} in the MASS package for robust regression. This function is usually accessed through \code{\link{normalizeWithinArrays}}. An overview of LIMMA functions for normalization is given in \link{05.Normalization}. } \examples{ A <- 1:100 M <- rnorm(100) normalized.M <- normalizeRobustSpline(M,A) # Usual usage \dontrun{MA <- normalizeWithinArrays(RG, method="robustspline")} } \keyword{models} limma/man/controlStatus.Rd0000755007451300017500000000642312127125247015751 0ustar charlescharles\name{controlStatus} \alias{controlStatus} \title{Set Status of each Spot from List of Spot Types} \description{ Determine the type (or status) of each spot in the gene list. } \usage{ controlStatus(types, genes, spottypecol="SpotType", regexpcol, verbose=TRUE) } \arguments{ \item{types}{dataframe containing spot type specifiers, usually input using \code{readSpotTypes}} \item{genes}{dataframe containing the microarray gene list, or an \code{RGList}, \code{MAList} or \code{MArrayList} containing \code{genes}} \item{spottypecol}{integer or name specifying column of \code{types} containing spot type names} \item{regexpcol}{vector of integers or column names specifying columns of types containing regular expressions. Defaults to any column names in common between \code{types} and \code{genes}.} \item{verbose}{logical, if \code{TRUE} then progess on pattern matching is reported to the standard output channel} } \details{ This function constructs a vector of status codes by searching for patterns in the gene list. The data frame \code{genes} contains gene IDs and should have as many rows as there are spots on the microarrays. Such a data frame is often read using \code{\link{readGAL}}. The data frame \code{types} has as many rows as you want to distinguish types of spots in the gene list. This data frame should contain a column or columns, the \code{regexpcol} columns, which have the same names as columns in \code{genes} and which contain patterns to match in the gene list. Another column, the \code{spottypecol}, contains the names of the spot types. Any other columns are assumed to contain plotting parameters, such as colors or symbols, to be associated with the spot types. The patterns in the \code{regexpcol} columns are simplified regular expressions. For example, \code{AA*} means any string starting with \code{AA}, \code{*AA} means any code ending with \code{AA}, \code{AA} means exactly these two letters, \code{*AA*} means any string containing \code{AA}, \code{AA.} means \code{AA} followed by exactly one other character and \code{AA\.} means exactly \code{AA} followed by a period and no other characters. Any other regular expressions are allowed but the codes \code{^} for beginning of string and \code{$} for end of string should not be included. Note that the patterns are matched sequentially from first to last, so more general patterns should be included first. For example, it is often a good idea to include a default spot-type as the first line in \code{types} with pattern \code{*} for all \code{regexpcol} columns and default plotting parameters. } \value{ Character vector specifying the type (or status) of each spot on the array. Attributes contain plotting parameters associated with each spot type. } \author{Gordon Smyth} \seealso{ An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \examples{ genes <- data.frame(ID=c("Control","Control","Control","Control","AA1","AA2","AA3","AA4"), Name=c("Ratio 1","Ratio 2","House keeping 1","House keeping 2","Gene 1","Gene 2","Gene 3","Gene 4")) types <- data.frame(SpotType=c("Gene","Ratio","Housekeeping"),ID=c("*","Control","Control"),Name=c("*","Ratio*","House keeping*"),col=c("black","red","blue")) status <- controlStatus(types,genes) } \keyword{IO} limma/man/blockDiag.Rd0000755007451300017500000000071112127125247014736 0ustar charlescharles\name{blockDiag} \alias{blockDiag} \title{Block Diagonal Matrix} \description{Form a block diagonal matrix from the given blocks.} \usage{ blockDiag(...) } \arguments{ \item{...}{numeric matrices} } \value{A block diagonal matrix with dimensions equal to the sum of the input dimensions} \examples{ a <- matrix(1,3,2) b <- matrix(2,2,2) blockDiag(a,b) } \author{Gordon Smyth} \seealso{ \link{10.Other} } \keyword{array} limma/man/normalizeCyclicLoess.Rd0000644007451300017500000000677412127125247017230 0ustar charlescharles\name{normalizeCyclicLoess} \alias{normalizeCyclicLoess} \title{Normalize Columns of a Matrix by Cyclic Loess} \description{ Normalize the columns of a matrix, cyclicly applying loess normalization to normalize each pair of columns to each other. } \usage{ normalizeCyclicLoess(x, weights = NULL, span=0.7, iterations = 3, method = "fast") } \arguments{ \item{x}{numeric matrix, or object which can be coerced to a numeric matrix, containing log-expression values.} \item{weights}{numeric vector of probe weights. Must be non-negative.} \item{span}{span of loess smoothing window, between 0 and 1.} \item{iterations}{number of times to cycle through all pairs of columns.} \item{method}{character string specifying which variant of the cyclic loess method to use. Options are \code{"fast"}, \code{"affy"} or \code{"pairs"}.} } \details{ This function is intended to normalize single channel or A-value microarray intensities between arrays. Cyclic loess normalization is similar effect and intention to quantile normalization, but with some advantages, in particular the ability to incorporate probe weights. A number of variants of cylic loess have been suggested. \code{method="pairs"} implements the intuitive idea that each pair of arrays is subjected to loess normalization as for two-color arrays. This process is simply cycled through all possible pairs of arrays, then repeated for several \code{iterations}. This is the method described by Ballman et al (2004) as ordinary cyclic loess normalization. \code{method="affy"} implements a method similar to \code{normalize.loess} in the affy package, except that here we call \code{lowess} instead of \code{loess} and avoid the use of probe subsets and the \code{predict} function. In this approach, no array is modified until a complete cycle of all pairs has been completed. The adjustments are stored for a complete iteration, then averaged, and finally used to modify the arrays. The \code{"affy"} method is invariant to the order of the columns of \code{x}, whereas the \code{"pairs"} method is not. The affy approach is presumably that used by Bolstad et al (2003), although the algorithm was not explicitly described in that article. \code{method="fast"} implements the "fast linear loess" method of Ballman et al (2004), whereby each array is simply normalized to a reference array, the reference array being the average of all the arrays. This method is relatively fast because computational time is linear in the number of arrays, whereas \code{"pairs"} and \code{"affy"} are quadratic in the number of arrays. \code{"fast"} requires n lowess fits per iteration, where n is the number of arrays, whereas \code{"pairs"} and \code{"affy"} require n*(n-1)/2 lowess fits per iteration. } \value{ A matrix of the same dimensions as \code{x} containing the normalized values. } \references{ 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. \emph{Bioinformatics} \bold{19}, 185-193. Ballman, KV Grill, DE, Oberg, AL and Therneau, TM (2004). Faster cyclic loess: normalizing RNA arrays via linear models. \emph{Bioinformatics} 20, 2778-2786. } \author{Yunshun (Andy) Chen and Gordon Smyth} \seealso{ An overview of LIMMA functions for normalization is given in \link{05.Normalization}. \link[affy]{normalize.loess} in the affy package also implements cyclic loess normalization, without weights. } \keyword{models} limma/man/normalizeVSN.Rd0000644007451300017500000000435212127125247015450 0ustar charlescharles\name{normalizeVSN} \alias{normalizeVSN} \alias{normalizeVSN.RGList} \alias{normalizeVSN.EListRaw} \alias{normalizeVSN.default} \title{Variance Stabilizing Normalization (vsn)} \description{ Apply variance stabilizing normalization (vsn) to limma data objects. } \usage{ normalizeVSN(x, ...) } \arguments{ \item{x}{a numeric \code{matrix}, \code{EListRaw} or \code{\link[limma:rglist]{RGList}} object.} \item{...}{other arguments are passed to \code{vsn}} } \details{ This is an interface to the \code{vsnMatrix} function from the vsn package. The input \code{x} should contain raw intensities. If \code{x} contains background and well as foreground intensities, these will be subtracted from the foreground intensities before \code{vsnMatrix} is called. Note that the vsn algorithm performs background correction and normalization simultaneously. If the data are from two-color microarrays, then the red and green intensities are treated as if they were single channel data, i.e., red and green channels from the same array are treated as unpaired. This algorithm is therefore separate from the backgroundCorrection, normalizeWithinArrays, then normalizeBetweenArrays paradigm used elsewhere in the limma package. } \value{ The class of the output depends on the input. If \code{x} is a matrix, then the result is a matrix of the same size. If \code{x} is an \code{EListRaw} object, then an \code{EList} object with expression values on the log2 scale is produced. For \code{x} is an \code{RGList}, then an \code{\link[limma:malist]{MAList}} object with M and A-values on the log2 scale is produced. } \author{Gordon Smyth} \references{ Huber, W, von Heydebreck, A, Sueltmann, H, Poustka, A, Vingron, M (2002). Variance stabilization applied to microarray data calibration and to the quantification of differential expression. Bioinformatics 18 Supplement 1, S96-S104. } \seealso{ An overview of LIMMA functions for normalization is given in \link{05.Normalization}. See also \code{\link[vsn:vsn]{vsn}} and \code{\link[vsn:vsn2]{vsnMatrix}} in the vsn package. } \examples{ ngenes <- 100 narrays <- 4 x <- matrix(rnorm(ngenes*narrays),100,4) y <- normalizeVSN(x) } \keyword{models} \keyword{multivariate} limma/man/trigammainverse.Rd0000755007451300017500000000141212127125247016253 0ustar charlescharles\name{trigammaInverse} \alias{trigammaInverse} \title{Inverse Trigamma Function} \description{ The inverse of the trigamma function. } \usage{ trigammaInverse(x) } \arguments{ \item{x}{numeric vector or array} } \details{ The function uses Newton's method with a clever starting value to ensure monotonic convergence. } \value{ Numeric vector or array \code{y} satisfying \code{trigamma(y)==x}. } \author{Gordon Smyth} \seealso{ This function is the inverse of \code{\link{trigamma}} in the base package. This function is called by \code{\link{fitFDist}}. } \note{ This function does not accept a data.frame as argument although the base package function \code{trigamma} does. } \examples{ y <- trigammaInverse(5) trigamma(y) } \keyword{math} limma/man/makeunique.Rd0000755007451300017500000000122312127125247015222 0ustar charlescharles\name{makeUnique} \alias{makeUnique} \title{Make Values of Character Vector Unique} \description{ Paste characters on to values of a character vector to make them unique. } \usage{ makeUnique(x) } \arguments{ \item{x}{object to be coerced to a character vector} } \details{ Repeat values of \code{x} are labelled with suffixes "1", "2" etc. } \value{ A character vector of the same length as \code{x} } \author{Gordon Smyth} \seealso{ \code{makeUnique} is called by \code{\link{merge.RGList}}. Compare with \code{\link[base]{make.unique}} in the base package. } \examples{ x <- c("a","a","b") makeUnique(x) } \keyword{character} limma/man/readGPRHeader.Rd0000755007451300017500000000361612127125247015463 0ustar charlescharles\name{readHeader} \alias{readGenericHeader} \alias{readGPRHeader} \alias{readSMDHeader} \title{Read Header Information from Image Analysis Raw Data File} \description{ Read the header information from a GenePix Results (GPR) file or from an SMD raw data file. These functions are used internally by \code{read.maimages} and are not usually called directly by users. } \usage{ readGenericHeader(file, columns, sep="\t") readGPRHeader(file) readSMDHeader(file) } \arguments{ \item{file}{character string giving file name. If it does not contain an absolute path, the file name is relative to the current working directory.} \item{columns}{character vector specifying data column headings expected to be in file} \item{sep}{the character string separating column names} } \details{ Raw data files exported by image analysis programs include a number of header lines which contain information about the scanning process. This function extracts that information and locates the line where the intensity data begins. \code{readGPRHeader} is for GenePix output and \code{readSMDHeader} is for files from the Stanford Microarray Database (SMD). \code{readGenericHeader} finds the line in the file on which the data begins by searching for specified column headings. } \value{ A list with components corresponds to lines of header information. A key component is \code{NHeaderRecords} which gives the number of lines in the file before the intensity data begins. All other components are character vectors. } \references{ See \url{http://www.axon.com/gn_GenePix_File_Formats.html} for GenePix formats. See \url{http://www.bluegnome.co.uk} for information on BlueFuse. See \url{http://genome-www.stanford.edu/Microarray} for the SMD. } \author{Gordon Smyth} \seealso{\code{\link{read.maimages}} An overview of LIMMA functions to read data is given in \link{03.ReadingData}. } \keyword{file} limma/man/plotDensities.Rd0000755007451300017500000001101612127125247015705 0ustar charlescharles\title{Individual-channel Densities Plot} \name{plotDensities} \alias{plotDensities} \description{ Plots the densities of individual-channel intensities for two-color microarray data. } \usage{ plotDensities(object, log=TRUE, arrays=NULL, singlechannels=NULL, groups=NULL, col=NULL) } \arguments{ \item{object}{an \code{RGList} or \code{MAList} object. \code{RGList} objects containing logged or unlogged intensities can be accommodated using the \code{log.transform} argument.} \item{log}{logical, should densities be formed and plotted for the log-intensities (\code{TRUE}) or raw intensities (\code{FALSE})?} \item{arrays}{vector of integers giving the arrays from which the individual-channels will be selected to be plotted. Corresponds to columns of \code{M} and \code{A} (or \code{R} and \code{G}). Defaults to all arrays.} \item{singlechannels}{vector of integers indicating which individual-channels will be selected to be plotted. Values correspond to the columns of the matrix of \code{cbind(R,G)} and range between \code{1:ncol(R)} for red channels and \code{( (ncol(R)+1):(ncol(R)+ncol(G)) )} for the green channels in \code{object}. Defaults to all channels.} \item{groups}{vector of consecutive integers beginning at 1 indicating the groups of arrays or individual-channels (depending on which of \code{arrays} or \code{singlechannels} are non \code{NULL}). This is used to color any groups of the individual-channel densities. If \code{NULL} (default), \code{groups} correspond to the red and green channels. If both \code{arrays} and \code{singlechannels} are \code{NULL} all arrays are selected and groups (if specified) must correspond to the arrays.} \item{col}{vector of colors of the same length as the number of different groups. If \code{NULL} (default) the \code{col} equals \code{c("red","green")}. See details for more specifications.} } \details{ This function is used as a data display technique associated with between-array normalization, especially individual-channel normalization methods such as quantile-normalization. See the section on between-array normalization in the LIMMA User's Guide. If no \code{col} is specified, the default is to color individual channels according to red and green. If both \code{arrays} and \code{groups} are non-\code{NULL}, then the length of \code{groups} must equal the length of \code{arrays} and the maximum of \code{groups} (i.e. the number of groups) must equal the length of \code{col} otherwise the default color of black will be used for all individual-channels. If \code{arrays} is \code{NULL} and both \code{singlechannels} and \code{groups} are non-\code{NULL}, then the length of \code{groups} must equal the length of \code{singlechannels} and the maximum of \code{groups} (i.e. the number of groups) must equal the length of \code{col} otherwise the default color of black will be used for all individual-channels. } \value{A plot is created on the current graphics device.} \author{Natalie Thorne} \seealso{ An overview of diagnostic plots in LIMMA is given in \link{09.Diagnostics}. There is a section using \code{plotDensities} in conjunction with between-array normalization in the \link[=limmaUsersGuide]{LIMMA User's Guide}. } \examples{ \dontrun{ # Default settings for plotDensities. plotDensities(MA) # One can reproduce the default settings. plotDensities(MA,arrays=c(1:6),groups=c(rep(1,6),rep(2,6)), col=c("red","green")) # Color R and G individual-channels by blue and purple. plotDensities(MA,arrays=NULL,groups=NULL,col=c("blue","purple")) # Indexing individual-channels using singlechannels (arrays=NULL). plotDensities(MA,singlechannels=c(1,2,7)) # Change the default colors from c("red","green") to c("pink","purple") plotDensities(MA,singlechannels=c(1,2,7),col=c("pink","purple")) # Specified too many colors since groups=NULL defaults to two groups. plotDensities(MA,singlechannels=c(1,2,7),col=c("pink","purple","blue")) # Three individual-channels, three groups, three colors. plotDensities(MA,singlechannels=c(1,2,7),groups=c(1,2,3), col=c("pink","purple","blue")) # Three individual-channels, one group, one color. plotDensities(MA,singlechannels=c(1,2,7),groups=c(1,1,1), col=c("purple")) # All individual-channels, three groups (ctl,tmt,reference), three colors. plotDensities(MA,singlechannels=c(1:12), groups=c(rep(1,3),rep(2,3),rep(3,6)),col=c("darkred","red","green")) } } \keyword{hplot} limma/man/read.ilmn.Rd0000644007451300017500000001002512127125247014724 0ustar charlescharles\name{read.ilmn} \alias{read.ilmn} \title{Read Illumina Expression Data} \description{Read Illumina summary probe profile files and summary control probe profile files} \usage{ read.ilmn(files=NULL, ctrlfiles=NULL, path=NULL, ctrlpath=NULL, probeid="Probe", annotation=c("TargetID", "SYMBOL"), expr="AVG_Signal", other.columns="Detection", sep="\t", quote="\"", verbose=TRUE, ...) } \arguments{ \item{files}{ character vector giving the names of the summary probe profile files.} \item{ctrlfiles}{ character vector giving the names of the summary control probe profile files.} \item{path}{ character string giving the directory containing the summary probe profile files. The default is the current working directory.} \item{ctrlpath}{ character string giving the directory containing the summary control probe profile files. The default is the current working directory.} \item{probeid}{ character string giving the name of the probe identifier column.} \item{annotation}{ character vector giving possible names of the annotation column. It could be called "TargetID" or "SYMBOL" depending on which version of BeadStudio is used.} \item{expr}{ character string giving the keyword in the names of the expression intensity columns.} \item{other.columns}{ character vector giving the keywords in the names of extra columns required, such as "Detection", "Avg_NBEADS", "BEAD_STDEV" etc. Each keyword corresponds to one type of columns. The detection p value columns will be read in by default.} \item{sep}{ the field separator character.} \item{quote}{ character string of characters to be treated as quote marks.} \item{verbose}{ logical, \code{TRUE} to report names of profile files being read.} \item{...}{ any other parameters are passed on to \code{\link{read.columns}}.} } \details{ Illumina BeadStudio ouputs probe intensities (regular probe intensities) and control probe intensities to summary probe profile files (containing regular probes) and summary control probe profile files, respectively. If both \code{files} and \code{ctrlfiles} are not \code{NULL}, this function will combine the data read from the two file types and save them to an \code{\link{EListRaw-class}} object. If one of them is \code{NULL}, then only the required data are read in. Probe types are indicated in the \code{Status} column of \code{genes}, a component of the returned \code{\link{EListRaw-class}} object. There are totally seven types of control probes including \code{negative}, \code{biotin}, \code{labeling}, \code{cy3_hyb}, \code{housekeeping}, \code{high_stringency_hyb} or \code{low_stringency_hyb}. Regular probes have the probe type \code{regular}. The \code{Status} column will not be created if \code{ctrlfiles} is \code{NULL}. To read in columns other than \code{probeid}, \code{annotation} and \code{expr}, users needs to specify keywords in \code{other.columns}. One keyword corresponds to one type of columns. Examples of keywords are "Detection", "Avg_NBEADS", "BEAD_STDEV" etc. } \value{ An \code{\link{EListRaw-class}} object with the following components: \item{E}{ numeric matrix of raw intensities.} \item{genes}{ data.frame of probe annotation.} \item{targets}{ data.frame of sample information.} \item{other}{ list of other column data.} } \author{Wei Shi and Gordon K Smyth} \seealso{ \code{\link{read.ilmn.targets}} reads in Illumina expression data using the file information extracted from a target data frame which is often created by the \code{\link{readTargets}} function. \code{\link{neqc}} performs normexp by control background correction, log transformation and quantile between-array normalization for Illumina expression data. \code{\link{normexp.fit.control}} estimates the parameters of the normal+exponential convolution model with the help of negative control probes. \code{\link{propexpr}} estimates the proportion of expressed probes in a microarray. } \examples{ \dontrun{ x <- read.ilmn(files="sample probe profile.txt",ctrlfiles="control probe profile.txt") } } \keyword{IO} limma/man/04Background.Rd0000644007451300017500000000276312127125247015310 0ustar charlescharles\name{04.Background} \alias{04.Background} \title{Background Correction} \description{ This page deals with background correction methods provided by the \code{\link{backgroundCorrect}}, \code{\link{kooperberg}} or \code{\link{neqc}} functions. Microarray data is typically background corrected by one of these functions before normalization and other downstream analysis. \code{backgroundCorrect} works on matrices, \code{EListRaw} or \code{RGList} objects, and calls \code{\link{backgroundCorrect.matrix}}. The \code{movingmin} method of \code{backgroundCorrect} uses utility functions \code{\link{ma3x3.matrix}} and \code{\link{ma3x3.spottedarray}}. The \code{normexp} method of \code{backgroundCorrect} uses utility functions \code{\link{normexp.fit}} and \code{\link{normexp.signal}}. \code{\link{kooperberg}} is a Bayesian background correction tool designed specifically for two-color GenePix data. It is computationally intensive and requires several additional columns from the GenePix data files. These can be read in using \code{read.maimages} and specifying the \code{other.columns} argument. \code{\link{neqc}} is for single-color data. It performs normexp background correction and quantile normalization using control probes. It uses utility functions \code{\link{normexp.fit.control}} and \code{\link{normexp.signal}}. If \code{robust=TRUE}, then \code{normexp.fit.control} uses the function \code{huber} in the MASS package. } \author{Gordon Smyth} \keyword{documentation} limma/man/channel2M.Rd0000755007451300017500000000257712127125247014702 0ustar charlescharles\name{designI2M} \alias{designI2M} \alias{designI2A} \title{Convert Individual Channel Design Matrix to M-A Format} \description{ Convert a design matrix in terms of individual channels to ones in terms of M-values or A-values for two-color microarray data. } \usage{ designI2M(design) designI2A(design) } \arguments{ \item{design}{numeric model matrix with one row for each channel observation, i.e., twice as many rows as arrays} } \details{ If \code{design} is a model matrix suitable for modelling individual log-intensities for two color microarray data, then \code{designI2M} computes the corresponding model matrix for modelling M-values (log-ratios) and \code{designI2A} computes the model matrix for modelling A-values (average log-intensities). Note that the matrices \code{designI2M(design)} or \code{designI2A(design)} may be singular if not all of the coefficients are estimable from the M or A-values. In that case there will be columns containing entirely zeros. } \value{ numeric model matrix with half as many rows as \code{design} } \seealso{ \code{\link[stats]{model.matrix}} in the stats package. An overview of individual channel linear model functions in limma is given by \link{07.SingleChannel}. } \author{Gordon Smyth} \examples{ X <- cbind(1,c(1,1,1,1,0,0,0,0),c(0,0,0,0,1,1,1,1)) designI2M(X) designI2A(X) } \keyword{regression} limma/man/removeBatchEffect.Rd0000644007451300017500000000306512127125247016435 0ustar charlescharles\name{removeBatchEffect} \alias{removeBatchEffect} \title{Remove Batch Effect} \description{ Remove batch effects from expression data. } \usage{ removeBatchEffect(x,batch=NULL,batch2=NULL,covariates=NULL,design=matrix(1,ncol(x),1)) } \arguments{ \item{x}{numeric matrix, or any object that can be coerced to a matrix by \code{as.matrix(x)}, containing log-expression intensities for a series of microarrays. Rows correspond to probes and columns to arrays.} \item{batch}{factor or vector indicating batches.} \item{batch2}{factor or vector indicating batches.} \item{covariates}{matrix or vector of covariates to be adjusted for.} \item{design}{optional design matrix relating to treatment conditions to be preserved} } \value{ A numeric matrix of log-expression values with batch and covariate effects removed. } \details{ This function is useful for removing batch effects, associated with hybridization time or other technical variables, prior to clustering or unsupervised analysis such as PCA or heatmaps. It is not intended to use with linear modelling. For linear modelling, it is better to include the batch factors in the linear model. The design matrix is used to describe comparisons between the samples, for example treatment effects, which should not be removed. The function (in effect) fits a linear model to the data, including both batches and regular treatments, then removes the component due to the batch effects. } \seealso{ \link{05.Normalization} } \author{Gordon Smyth and Carolyn de Graaf} \keyword{regression} limma/man/normalizebetweenarrays.Rd0000755007451300017500000001677212175540776017704 0ustar charlescharles\name{normalizeBetweenArrays} \alias{normalizeBetweenArrays} \title{Normalize Between Arrays} \description{ Normalizes expression intensities so that the intensities or log-ratios have similar distributions across a set of arrays. } \usage{ normalizeBetweenArrays(object, method=NULL, targets=NULL, cyclic.method="fast", ...) } \arguments{ \item{object}{a numeric \code{matrix}, \code{\link[limma:EList]{EListRaw}}, \code{\link[limma:rglist]{RGList}} or \code{\link[limma:malist]{MAList}} object containing un-normalized expression data. \code{matrix} or \code{EListRaw} objects will be assumed to contain single-channel data, usually log-intensities, whereas \code{RGList} or \code{MAList} objects should contain two-color data.} \item{method}{character string specifying the normalization method to be used. Choices for single-channel data are \code{"none"}, \code{"scale"}, \code{"quantile"} or \code{"cyclicloess"}. Choices for two-color data are those previously mentioned plus \code{"Aquantile"}, \code{"Gquantile"}, \code{"Rquantile"} or \code{"Tquantile"}. A partial string sufficient to uniquely identify the choice is permitted. The default is \code{"Aquantile"} for two-color data objects or \code{"quantile"} for single-channel objects.} \item{targets}{vector, factor or matrix of length twice the number of arrays, used to indicate target groups if \code{method="Tquantile"}} \item{cyclic.method}{character string indicating the variant of \code{normalizeCyclicLoess} to be used if \code{method=="cyclicloess"}, see \code{\link{normalizeCyclicLoess}} for possible values.} \item{...}{other arguments are passed to \code{normalizeQuantiles} or \code{normalizeCyclicLoess}} } \details{ \code{normalizeBetweenArrays} normalizes expression values to achieve consistency between arrays. For two-color arrays, normalization between arrays is usually a follow-up step after normalization within arrays using \code{normalizeWithinArrays}. For single-channel arrays, within array normalization is not usually relevant and so \code{normalizeBetweenArrays} is the sole normalization step. For single-channel data, the scale, quantile or cyclic loess normalization methods can be applied to the columns of data. Trying to apply other normalization methods when \code{object} is a \code{matrix} or \code{EListRaw} object will produce an error. If \code{object} is an \code{EListRaw} object, then normalization will be applied to the matrix \code{object$E} of expression values, which will then be log2-transformed. Scale (\code{method="scale"}) scales the columns to have the same median. Quantile and cyclic loess normalization was originally proposed by Bolstad et al (2003) for Affymetrix-style single-channel arrays. Quantile normalization forces the entire empirical distribution of each column to be identical. Cyclic loess normalization applies loess normalization to all possible pairs of arrays, usually cycling through all pairs several times. Cyclic loess is slower than quantile, but allows probe-wise weights and is more robust to unbalanced differential expression. The other normalization methods are for two-color arrays. Scale normalization was proposed by Yang et al (2001, 2002) and is further explained by Smyth and Speed (2003). The idea is simply to scale the log-ratios to have the same median-absolute-deviation (MAD) across arrays. This idea has also been implemented by the \code{maNormScale} function in the marray package. The implementation here is slightly different in that the MAD scale estimator is replaced with the median-absolute-value and the A-values are normalized as well as the M-values. Quantile normalization was explored by Yang and Thorne (2003) for two-color cDNA arrays. \code{method="quantile"} ensures that the intensities have the same empirical distribution across arrays and across channels. \code{method="Aquantile"} ensures that the A-values (average intensities) have the same empirical distribution across arrays leaving the M-values (log-ratios) unchanged. These two methods are called "q" and "Aq" respectively in Yang and Thorne (2003). \code{method="Tquantile"} performs quantile normalization separately for the groups indicated by \code{targets}. \code{targets} may be a target frame such as read by \code{readTargets} or can be a vector indicating green channel groups followed by red channel groups. \code{method="Gquantile"} ensures that the green (first) channel has the same empirical distribution across arrays, leaving the M-values (log-ratios) unchanged. This method might be used when the green channel is a common reference throughout the experiment. In such a case the green channel represents the same target throughout, so it makes compelling sense to force the distribution of intensities to be same for the green channel on all the arrays, and to adjust to the red channel accordingly. \code{method="Rquantile"} ensures that the red (second) channel has the same empirical distribution across arrays, leaving the M-values (log-ratios) unchanged. Both \code{Gquantile} and \code{Rquantile} normalization have the implicit effect of changing the red and green log-intensities by equal amounts. See the limma User's Guide for more examples of use of this function. } \value{ If \code{object} is a matrix then \code{normalizeBetweenArrays} produces a matrix of the same size. If \code{object} is an \code{EListRaw} object, then an \code{EList} object with expression values on the log2 scale is produced. For two-color data, \code{normalizeBetweenArrays} produces an \code{\link[limma:malist]{MAList}} object with M and A-values on the log2 scale. } \author{Gordon Smyth} \references{ 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. \emph{Bioinformatics} \bold{19}, 185-193. Smyth, G. K., and Speed, T. P. (2003). Normalization of cDNA microarray data. \emph{Methods} \bold{31}, 265-273. Yang, Y. H., Dudoit, S., Luu, P., and Speed, T. P. (2001). Normalization for cDNA microarray data. In \emph{Microarrays: Optical Technologies and Informatics}, M. L. Bittner, Y. Chen, A. N. Dorsel, and E. R. Dougherty (eds), Proceedings of SPIE, Volume 4266, pp. 141-152. Yang, Y. H., Dudoit, S., Luu, P., Lin, D. M., Peng, V., Ngai, J., and Speed, T. P. (2002). Normalization for cDNA microarray data: a robust composite method addressing single and multiple slide systematic variation. \emph{Nucleic Acids Research} \bold{30}(4):e15. Yang, Y. H., and Thorne, N. P. (2003). Normalization for two-color cDNA microarray data. In: D. R. Goldstein (ed.), \emph{Science and Statistics: A Festschrift for Terry Speed}, IMS Lecture Notes - Monograph Series, Volume 40, pp. 403-418. } \seealso{ An overview of LIMMA functions for normalization is given in \link{05.Normalization}. The \code{\link{neqc}} function provides a variation of quantile normalization that is customized for Illumina BeadChips. This method uses control probes to refine the background correction and normalization steps. Note that vsn normalization, previously offered as a method of this function, is now performed by the \code{\link{normalizeVSN}} function. See also \code{\link[marray:maNormScale]{maNormScale}} in the marray package and \code{\link[affy:normalize]{normalize}} in the affy package. } \examples{ ngenes <- 100 narrays <- 4 x <- matrix(rnorm(ngenes*narrays),100,4) y <- normalizeBetweenArrays(x) } \keyword{models} \keyword{multivariate} limma/man/vooma.Rd0000644007451300017500000000457212150771760014211 0ustar charlescharles\name{vooma} \alias{vooma} \alias{voomaByGroup} \title{Convert Mean-Variance Trend to Observation-specific Precision Weights for Microarray Data} \description{ Estimate the mean-variance relationship and use this to compute appropriate observational-level weights. } \usage{ vooma(y, design=NULL, correlation, block=NULL, plot=FALSE, span=NULL) voomaByGroup(y, group, design=NULL, correlation, block=NULL, plot=FALSE, span=NULL, col=NULL) } \arguments{ \item{y}{numeric \code{matrix}, \code{EList} object, or any similar object containing expression data that can be coerced to a matrix.} \item{design}{design matrix with rows corresponding to samples and columns to coefficients to be estimated. Defaults to the unit vector meaning that samples are treated as replicates.} \item{block}{vector or factor specifying a blocking variable on the arrays. Has length equal to the number of arrays.} \item{correlation}{intra-block correlation} \item{span}{width of the smoothing window, as a proportion of the data set.} \item{plot}{\code{logical} value indicating whether a plot of mean-variance trend should be displayed.} \item{group}{categorical vector or factor giving group membership of columns of \code{y}.} \item{col}{vector of colors for plotting group trends} } \details{ \code{vooma} is an acronym for mean-variance modelling at the observational level for arrays. \code{vooma} estimates the mean-variance relationship in the data, and uses this to compute appropriate weights for each observation. This done by estimating a mean-variance trend, then interpolating this trend to obtain a precision weight (inverse variance) for each observation. The weights can then used by other functions such as \code{lmFit} to adjust for heteroscedasticity. \code{voomaByGroup} estimates precision weights separately for each group. In other words, it allows for different mean-variance curves in different groups. } \value{ An EList object with the following components: \item{E}{numeric matrix of as input} \item{weights}{numeric matrix of weights} \item{design}{numeric matrix of experimental design} \item{genes}{dataframe of gene annotation, only if \code{counts} was a \code{DGEList} object} } \seealso{ \code{\link{voom}} } \author{Charity Law and Gordon Smyth} \references{ Law, C. (2013). \emph{Precision weights for gene expression analysis}. PhD Thesis. University of Melbourne, Australia. } limma/man/printorder.Rd0000755007451300017500000000555512127125247015262 0ustar charlescharles\name{printorder} \alias{printorder} \title{Identify Order in which Spots were Printed} \description{ Identify order in which spots were printed and the 384-well plate from which they were printed. } \usage{ printorder(layout, ndups=1, spacing="columns", npins, start="topleft") } \arguments{ \item{layout}{list with the components \code{ngrid.r}, \code{ngrid.c}, \code{nspot.r} and \code{nspot.c}, or an \code{RGList} or \code{MAList} object from which the printer layout may be extracted.} \item{ndups}{number of duplicate spots, i.e., number of times print-head dips into each well} \item{spacing}{character string indicating layout of duplicate spots. Choices are \code{"columns"}, \code{"rows"} or \code{"topbottom"}.} \item{npins}{actual number of pins or tips on the print-head} \item{start}{character string giving position of the spot printed first in each grid. Choices are \code{"topleft"} or \code{"topright"} and partial matches are accepted.} } \details{ In most cases the printer-head contains the \code{layout$ngrid.r} times \code{layout$ngrid.c} pins or tips and the array is printed using \code{layout$nspot.r} times \code{layout$npot.c} dips of the head. The plate holding the DNA to be printed is assumed to have 384 wells in 16 rows and 24 columns. \code{ndups} indicates the number of spots printed from each well. The replicate spots from multiple dips into the same wells are assumed to be side-by-side by columns (\code{spacing="columns"}), by rows (\code{spacing="rows"}) or in the top and bottom halves of the array (\code{spacing="topbottom"}). In some cases a smaller number of physical pins is used and the total number of grids is built up by effectively printing two or more sub-arrays on the same slide. In this case the number of grids should be a multiple of the number of pins. Printing is assumed to proceed by rows within in each grid starting either from the top-left or the top-right. } \value{ List with components \item{printorder}{numeric vector giving printorder of each spot, i.e., which dip of the print-head was used to print it} \item{plate}{numeric vector giving plate number from which each spot was printed} \item{plate.r}{numeric vector giving plate-row number of the well from which each spot was printed} \item{plate.c}{numeric vector giving plate-column number of the well from which each spot was printed} \item{plateposition}{character vector summarizing plate number and plate position of the well from which each spot was printed with letters for plate rows and number for columns. For example \code{02B13} is second row, 13th column, of the second plate.} } \seealso{ \code{\link{normalizeForPrintorder}}. An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \author{Gordon Smyth} \examples{ printorder(list(ngrid.r=2,ngrid.c=2,nspot.r=12,nspot.c=8)) } \keyword{IO} limma/man/normalizeprintorder.Rd0000755007451300017500000001131112127125247017166 0ustar charlescharles\name{normalizeForPrintorder} \alias{normalizeForPrintorder} \alias{normalizeForPrintorder.rg} \alias{plotPrintorder} \title{Print-Order Normalization} \description{ Normalize intensity values on one or more spotted microarrays to adjust for print-order effects. } \usage{ normalizeForPrintorder(object, layout, start="topleft", method = "loess", separate.channels = FALSE, span = 0.1, plate.size = 32) normalizeForPrintorder.rg(R, G, printorder, method = "loess", separate.channels = FALSE, span = 0.1, plate.size = 32, plot = FALSE) plotPrintorder(object, layout, start="topleft", slide = 1, method = "loess", separate.channels = FALSE, span = 0.1, plate.size = 32) } \arguments{ \item{object}{an \code{RGList} or \code{list} object containing components \code{R} and \code{G} which are matrices containing the red and green channel intensities for a series of arrays} \item{R}{numeric vector containing red channel intensities for a single microarray} \item{G}{numeric vector containing the green channel intensities for a single microarray} \item{layout}{list specifying the printer layout, see \code{\link{PrintLayout-class}}} \item{start}{character string specifying where printing starts in each pin group. Choices are \code{"topleft"} or \code{"topright"}.} \item{printorder}{numeric vector specifying order in which spots are printed. Can be computed from \code{printorder(layout,start=start)}.} \item{slide}{positive integer giving the column number of the array for which a plot is required} \item{method }{character string, "loess" if a smooth loess curve should be fitted through the print-order trend or "plate" if plate effects are to be estimated} \item{separate.channels}{logical, \code{TRUE} if normalization should be done separately for the red and green channel and \code{FALSE} if the normalization should be proportional for the two channels} \item{span}{numerical constant between 0 and 1 giving the smoothing span for the loess the curve. Ignored if \code{method="plate"}.} \item{plate.size}{positive integer giving the number of consecutive spots corresponding to one plate or plate pack. Ignored if \code{method="loess"}.} \item{plot}{logical. If \code{TRUE} then a scatter plot of the print order effect is sent to the current graphics device.} } \details{ Print-order is associated with the 384-well plates used in the printing of spotted microarrays. There may be variations in DNA concentration or quality between the different plates. The may be variations in ambient conditions during the time the array is printed. This function is intended to pre-process the intensities before other normalization methods are applied to adjust for variations in DNA quality or concentration and other print-order effects. Printorder means the order in which spots are printed on a microarray. Spotted arrays are printed using a print head with an array of print-tips. Spots in the various tip-groups are printed in parallel. Printing is assumed to start in the top left hand corner of each tip-groups and to proceed right and down by rows, or else to start in the top right hand and to proceed left and down by rows. See \code{\link{printorder}} for more details. (WARNING: this is not always the case.) This is true for microarrays printed at the Australian Genome Research Facility but might not be true for arrays from other sources. If \code{object} is an \code{RGList} then printorder is performed for each intensity in each array. \code{plotPrintorder} is a non-generic function which calls \code{normalizeForPrintorder} with \code{plot=TRUE}. } \value{ \code{normalizeForPrintorder} produces an \code{RGList} containing normalized intensities. The function \code{plotPrintorder} or \code{normalizeForPrintorder.rg} with \code{plot=TRUE} returns no value but produces a plot as a side-effect. \code{normalizeForPrintorder.rg} with \code{plot=FALSE} returns a list with the following components: \item{R}{numeric vector containing the normalized red channel intensities} \item{G}{numeric vector containing the normalized red channel intensites} \item{R.trend}{numeric vector containing the fitted printorder trend for the red channel} \item{G.trend}{numeric vector containing the fitted printorder trend for the green channe} } \references{ Smyth, G. K. Print-order normalization of cDNA microarrays. March 2002. \url{http://www.statsci.org/smyth/pubs/porder/porder.html} } \author{Gordon Smyth} \seealso{ \code{\link{printorder}}. An overview of LIMMA functions for normalization is given in \link{05.Normalization}. } \examples{ \dontrun{ plotPrintorder(RG,layout,slide=1,separate=TRUE) RG <- normalizeForPrintorder(mouse.data,mouse.setup) } } \keyword{models} limma/man/normexpsignal.Rd0000644007451300017500000000275512127125247015754 0ustar charlescharles\name{normexp.signal} \alias{normexp.signal} \title{Expected Signal Given Observed Foreground Under Normal+Exp Model} \description{ Adjust foreground intensities for observed background using Normal+Exp Model. This function is called by \code{backgroundCorrect} and is not normally called directly by the user. } \usage{ normexp.signal(par, x) } \arguments{ \item{par}{numeric vector containing the parameters of the Normal+Exp distribution, see \code{\link{normexp.fit}} for details.} \item{x}{numeric vector of (background corrected) intensities} } \details{ In general the vector \code{normmean} is computed conditional on background at each spot. } \value{ Numeric vector containing adjusted intensities. } \references{ Ritchie, M. E., Silver, J., Oshlack, A., Silver, J., Holmes, M., Diyagama, D., Holloway, A., and Smyth, G. K. (2007). A comparison of background correction methods for two-colour microarrays. \emph{Bioinformatics} \url{http://bioinformatics.oxfordjournals.org/cgi/content/abstract/btm412} Silver, JD, Ritchie, ME, and Smyth, GK (2009). Microarray background correction: maximum likelihood estimation for the normal-exponential convolution. \emph{Biostatistics} 10, 352-363. \url{http://biostatistics.oxfordjournals.org/cgi/content/abstract/kxn042} } \author{Gordon Smyth} \seealso{ \code{\link{normexp.fit}} An overview of background correction functions is given in \code{\link{04.Background}}. } \examples{# See normexp.fit} \keyword{models} limma/man/auROC.Rd0000755007451300017500000000241612127125247014034 0ustar charlescharles\name{auROC} \alias{auROC} \title{Area Under Receiver Operating Curve} \description{ Compute exact area under the ROC for empirical data. } \usage{ auROC(truth, stat=NULL) } \arguments{ \item{truth}{logical vector, or numeric vector of 0s and 1s, indicating whether each case is a true positive.} \item{stat}{numeric vector containing test statistics used to rank cases, from largest to smallest. If \code{NULL}, then \code{truth} is assumed to be already sorted in decreasing test statistic order.} } \details{ This function computes the exact area under an empirical ROC curve. Cases are ranked by \code{stat} from largest to smallest. The number of true and false discoveries are determined by how well the true states represented by \code{truth} match up with the observed statistics given by \code{stat}. } \value{ Numeric vector giving area under the curve, 1 being perfect and 0 being the minimum, or \code{NULL} if \code{truth} has zero length. } \seealso{ See \link{08.Tests} for other functions for testing and processing p-values. See also \code{\link[ROC]{AUC}} in the \code{ROC} package. } \examples{ auROC(c(1,1,0,0,0)) truth <- rbinom(30,size=1,prob=0.2) stat <- rchisq(30,df=2) auROC(truth,stat) } \author{Gordon Smyth} \keyword{htest} limma/man/intraspotCorrelation.Rd0000755007451300017500000000511712127125247017311 0ustar charlescharles\name{intraspotCorrelation} \alias{intraspotCorrelation} \title{Intra-Spot Correlation for Two Color Data} \description{ Estimate the within-block correlation associated with spots for spotted two color microarray data. } \usage{ intraspotCorrelation(object, design, trim=0.15) } \arguments{ \item{object}{an \code{\link[limma:malist]{MAList}} object or a list from which \code{M} and \code{A} values may be extracted} \item{design}{a numeric matrix containing the design matrix for linear model in terms of the individual channels. The number of rows should be twice the number of arrays. The number of columns will determine the number of coefficients estimated for each gene.} \item{trim}{the fraction of observations to be trimmed from each end of the atanh-correlations when computing the consensus correlation. See \code{\link{mean}}.} } \value{ A list with components \item{consensus.correlation}{robust average of the estimated inter-duplicate correlations. The average is the trimmed mean of the correlations for individual genes on the atanh-transformed scale.} \item{atanh.correlations}{a numeric vector giving the individual genewise correlations on the atanh scale} \item{df}{numeric matrix of degrees of freedom associated with the correlations. The first column gives the degrees of freedom for estimating the within-spot or M-value mean square while the second gives the degrees of freedom for estimating the between spot or A-value mean square.} } \details{ This function estimates the correlation between two channels observed on each spot. The correlation is estimated by fitting a heteroscedastic regression model to the M and A-values of each gene. The function also returns a consensus correlation, which is a robust average of the individual correlations, which can be used as input for functions \code{lmscFit}. The function may take long time to execute. } \references{ Smyth, G. K. (2005). Individual channel analysis of two-colour microarray data. \emph{Proceedings of the 55th Session of the International Statistics Institute}, 5-12 April 2005, Sydney, Australia, Paper 116. \url{http://www.statsci.org/smyth/pubs/ISI2005-116.pdf} } \seealso{ This function uses \code{\link[statmod:remlscor]{remlscore}} from the statmod package. An overview of methods for single channel analysis in limma is given by \link{07.SingleChannel}. } \examples{ # See lmscFit \dontrun{ corfit <- intraspotCorrelation(MA, design) all.correlations <- tanh(corfit$atanh.correlations) boxplot(all.correlations) } } \author{Gordon Smyth} \keyword{multivariate} limma/man/01Introduction.Rd0000644007451300017500000000431712127125247015704 0ustar charlescharles\name{01.Introduction} \docType{package} \alias{01.Introduction} \alias{limma} \alias{limma-package} \title{Introduction to the LIMMA Package} \description{ LIMMA is a library for the analysis of gene expression microarray data, especially the use of linear models for analysing designed experiments and the assessment of differential expression. LIMMA provides the ability to analyse comparisons between many RNA targets simultaneously in arbitrary complicated designed experiments. Empirical Bayesian methods are used to provide stable results even when the number of arrays is small. The normalization and data analysis functions are for two-colour spotted microarrays. The linear model and differential expression functions apply to all microarrays including Affymetrix and other multi-array oligonucleotide experiments. } \details{ There are three types of documentation available: \tabular{ll}{ (1) \tab The \emph{LIMMA User's Guide} can be reached through the "User Guides and Package Vignettes" links at the top of the LIMMA contents page. The function \code{\link{limmaUsersGuide}} gives the file location of the User's Guide.\cr (2) \tab An overview of limma functions grouped by purpose is contained in the numbered chapters at the top of the LIMMA contents page, of which this page is the first.\cr (3) \tab The LIMMA contents page gives an alphabetical index of detailed help topics.\cr } The function \code{\link{changeLog}} displays the record of changes to the package. } \author{Gordon Smyth} \references{ Smyth, G. K., Yang, Y.-H., Speed, T. P. (2003). Statistical issues in microarray data analysis. \emph{Methods in Molecular Biology} 224, 111-136. Smyth, G. K. (2004). Linear models and empirical Bayes methods for assessing differential expression in microarray experiments. \emph{Statistical Applications in Genetics and Molecular Biology}, Volume \bold{3}, Article 3. \url{http://www.bepress.com/sagmb/vol3/iss1/art3} Smyth, G. K. (2005). Limma: linear models for microarray data. In: \emph{Bioinformatics and Computational Biology Solutions using R and Bioconductor}. R. Gentleman, V. Carey, S. Dudoit, R. Irizarry, W. Huber (eds), Springer, New York, 2005. } \keyword{package} limma/man/romer.Rd0000644007451300017500000001302212127125247014177 0ustar charlescharles\name{romer} \alias{romer} \alias{romer2} \title{Rotation Gene Set Enrichment Analysis} \description{ Gene set enrichment analysis for linear models using rotation tests (ROtation testing using MEan Ranks). } \usage{ romer(index,y,design,contrast=ncol(design),array.weights=NULL,block=NULL,correlation,set.statistic="mean",nrot=9999) } \arguments{ \item{index}{list of indices specifying the rows of \code{y} in the gene sets. The list can be made using \link{symbols2indices}.} \item{y}{numeric matrix giving log-expression values.} \item{design}{design matrix} \item{contrast}{contrast for which the test is required. Can be an integer specifying a column of \code{design}, or else a contrast vector of length equal to the number of columns of \code{design}.} \item{array.weights}{optional numeric vector of array weights.} \item{block}{optional vector of blocks.} \item{correlation}{correlation between blocks.} \item{set.statistic}{statistic used to summarize the gene ranks for each set. Possible values are \code{"mean"}, \code{"floormean"} or \code{"mean50"}.} \item{nrot}{number of rotations used to estimate the p-values.} } \value{ Numeric matrix giving p-values and the number of matched genes in each gene set. Rows correspond to gene sets. There are four columns giving the number of genes in the set and p-values for the alternative hypotheses mixed, up or down. } \details{ This function implements the ROMER procedure described by Majewski et al (2010). \code{romer} tests a hypothesis similar to that of Gene Set Enrichment Analysis (GSEA) (Subramanian et al, 2005) but is designed for use with linear models. Like GSEA, it is designed for use with a database of gene sets. Like GSEA, it is a competitive test in that the different gene sets are pitted against one another. Instead of permutation, it uses rotation, a parametric resampling method suitable for linear models (Langsrud, 2005). \code{romer} can be used with any linear model with some level of replication. Curated gene sets suitable for use with \code{romer} can be downloaded from \url{http://bioinf.wehi.edu.au/software/MSigDB/}. These lists are based on the molecular signatures database from the Broad Institute, but with gene symbols converted to offical gene symbols, separately for mouse and human. In the output, p-values are given for each set for three possible alternative hypotheses. The alternative "up" means the genes in the set tend to be up-regulated, with positive t-statistics. The alternative "down" means the genes in the set tend to be down-regulated, with negative t-statistics. The alternative "mixed" test whether the genes in the set tend to be differentially expressed, without regard for direction. In this case, the test will be significant if the set contains mostly large test statistics, even if some are positive and some are negative. The first two alternatives are appropriate if you have a prior expection that all the genes in the set will react in the same direction. The "mixed" alternative is appropriate if you know only that the genes are involved in the relevant pathways, without knowing the direction of effect for each gene. Note that \code{romer} estimates p-values by simulation, specifically by random rotations of the orthogonalized residuals. This means that the p-values will vary slightly from run to run. To get more precise p-values, increase the number of rotations \code{nrot}. The strategy of random rotations is due to Langsrud (2005). The argument \code{set.statistic} controls the way that t-statistics are summarized to form a summary test statistic for each set. In all cases, genes are ranked by moderated t-statistic. If \code{set.statistic="mean"}, the mean-rank of the genes in each set is the summary statistic. If \code{set.statistic="floormean"} then negative t-statistics are put to zero before ranking for the up test, and vice versa for the down test. This improves the power for detecting genes with a subset of responding genes. If \code{set.statistics="mean50"}, the mean of the top 50\% ranks in each set is the summary statistic. This statistic performs well in practice but is slightly slower to compute. } \seealso{ \code{\link{topRomer}}, \code{\link{symbols2indices}}, \code{\link{roast}}, \code{\link{wilcoxGST}} An overview of tests in limma is given in \link{08.Tests}. } \author{Yifang Hu and Gordon Smyth} \references{ Langsrud, O, 2005. Rotation tests. \emph{Statistics and Computing} 15, 53-60 Doerum G, Snipen L, Solheim M, Saeboe S (2009). Rotation testing in gene set enrichment analysis for small direct comparison experiments. \emph{Stat Appl Genet Mol Biol}, Article 34. Majewski, IJ, Ritchie, ME, Phipson, B, Corbin, J, Pakusch, M, Ebert, A, Busslinger, M, Koseki, H, Hu, Y, Smyth, GK, Alexander, WS, Hilton, DJ, and Blewitt, ME (2010). Opposing roles of polycomb repressive complexes in hematopoietic stem and progenitor cells. \emph{Blood}, published online 5 May 2010. \url{http://www.ncbi.nlm.nih.gov/pubmed/20445021} Subramanian, A, Tamayo, P, Mootha, VK, Mukherjee, S, Ebert, BL, Gillette, MA, Paulovich, A, Pomeroy, SL, Golub, TR, Lander, ES and Mesirov JP, 2005. Gene set enrichment analysis: a knowledge-based approach for interpreting genome-wide expression profiles. \emph{Proc Natl Acad Sci U S A} 102, 15545-15550 } \examples{ y <- matrix(rnorm(100*4),100,4) design <- cbind(Intercept=1,Group=c(0,0,1,1)) index <- 1:5 y[index,3:4] <- y[index,3:4]+3 index1 <- 1:5 index2 <- 6:10 r <- romer(index=list(set1=index1,set2=index2),y=y,design=design,contrast=2,nrot=99) r topRomer(r,alt="up") topRomer(r,alt="down") } \keyword{htest} limma/man/zscore.Rd0000755007451300017500000000455112127125247014372 0ustar charlescharles\name{zscore} \alias{zscore} \alias{zscoreGamma} \alias{zscoreT} \alias{tZscore} \alias{zscoreHyper} \title{Z-score Equivalents} \description{ Compute z-score equivalents of non-normal random deviates. } \usage{ zscore(q, distribution, ...) zscoreGamma(q, shape, rate = 1, scale = 1/rate) zscoreT(x, df) tZscore(x, df) zscoreHyper(q, m, n, k) } \arguments{ \item{q, x}{numeric vector or matrix giving deviates of a random variable} \item{distribution}{character name of probabability distribution for which a cumulative distribution function exists} \item{\ldots}{other arguments specify distributional parameters and are passed to the cumulative distribution} \item{shape}{gamma shape parameter (>0)} \item{rate}{gamma rate parameter (>0)} \item{scale}{gamma scale parameter (>0)} \item{df}{degrees of freedom (>0 for \code{zscoreT} or >=1 for \code{tZscore})} \item{m}{as for \code{\link{qhyper}}} \item{n}{as for \code{\link{qhyper}}} \item{k}{as for \code{\link{qhyper}}} } \value{ Numeric vector giving equivalent deviates from the standard normal distribution. The exception is \code{tZscore} which gives deviates from the specified t-distribution. } \details{ These functions compute the standard normal deviates which have the same quantiles as the given values in the specified distribution. For example, if \code{z <- zscoreT(x,df=df)} then \code{pnorm(z)} equals \code{pt(x,df=df)}. \code{zscore} works for any distribution for which a cumulative distribution function (like \code{pnorm}) exists in R. The argument \code{distribution} is the name of the cumulative distribution function with the \code{"p"} removed. \code{zscoreGamma}, \code{zscoreT} and \code{zscoreHyper} are specific functions for the gamma, t and hypergeometric distributions respectively. \code{tZscore} is the inverse of \code{zscoreT}, and computes t-distribution equivalents for standard normal deviates. Care is taken to do the computations accurately in both tails of the distributions. } \author{Gordon Smyth} \seealso{ \code{\link{qnorm}}, \code{\link{pgamma}}, \code{\link{pt}} in the stats package. } \examples{ # First three are equivalent zscore(c(1,2.5), dist="gamma", shape=0.5, scale=2) zscore(c(1,2.5), dist="chisq", df=1) zscoreGamma(c(1,2.5), shape=0.5, scale=2) zscoreT(2, df=3) tZscore(2, df=3) } \keyword{distribution} limma/man/exprsMA.Rd0000644007451300017500000000137312127125247014440 0ustar charlescharles\name{exprs.MA} \alias{exprs.MA} \title{Extract Log-Expression Matrix from MAList} \description{ Extract the matrix of log-expression values from an \code{MAList} object. } \usage{ exprs.MA(MA) } \arguments{ \item{MA}{an \code{MAList} object.} } \details{ Converts M and A-values to log-expression values. The output matrix will have two columns for each array, in the order green, red for each array. This contrasts with \code{as.matrix.MAList} which extracts the M-values only, or \code{RG.MA} which converts to expression values in \code{RGList} form. } \value{ A numeric matrix with twice the columns of the input. } \author{Gordon Smyth} \seealso{ \link{02.Classes} gives an overview of data classes used in LIMMA. } \keyword{array} limma/man/predFCm.Rd0000644007451300017500000000464412127125247014405 0ustar charlescharles\name{predFCm} \alias{predFCm} \alias{predFCm} \title{Predictive log fold change for microarrays} \description{ Calculates the predictive log fold change for a particular coefficient from a fit object. } \usage{ predFCm(fit,coef=2,prob=TRUE,VarRel=NULL) } \arguments{ \item{fit}{an \code{MArrayLM} fitted model object produced by \code{lmFit} or \code{contrasts.fit} and followed by \code{eBayes}} \item{coef}{integer indicating which contrasts/columns in the fit object are to be used} \item{prob}{logical, whether the probability that the gene is differentially expressed should be taken into account} \item{VarRel}{string, options are "Independent" or "Increasing"} } \details{ The predictive log fold changes are calculated as the posterior log fold changes in the empirical Bayes hierarchical model. The log fold changes are shrunk towards zero depending on how variable they are. The \code{VarRel} argument specifies whether the prior belief is that the log fold changes are independent of the variability of the genes (option "Independent"), or whether the log fold changes increase with increasing variability of the genes (option "Increasing"). The \code{prob} argument is a logical argument indicating whether the probability that a particular gene is differentially expressed should be taken into account. } \value{ \code{predFCm} produces a numeric vector corresponding to the predictive or posterior log fold changes of the specified contrast } \seealso{ \code{\link{lmFit}}, \code{\link{eBayes}}, \code{\link{contrasts.fit}} } \author{Belinda Phipson and Gordon Smyth} \references{ Phipson, B. (2013). \emph{Empirical Bayes modelling of expression profiles and their associations}. PhD Thesis. University of Melbourne, Australia. } \examples{ library(limma) # Simulate gene expression data, # 6 microarrays with 1000 genes on each array set.seed(2004) y<-matrix(rnorm(6000),ncol=6) # two experimental groups and one control group with two replicates each group<-factor(c("A","A","B","B","control","control")) design<-model.matrix(~0+group) colnames(design)<-c("A","B","control") # fit a linear model fit<-lmFit(y,design) contrasts<-makeContrasts(A-control,B-control,levels=design) fit2<-contrasts.fit(fit,contrasts) fit2<-eBayes(fit2) # output predictive log fold changes for first contrast for first 5 genes pfc<-predFCm(fit2,coef=1,prob=FALSE) cbind(pfc[1:5],fit2$coeff[1:5,1]) }limma/man/plotma.Rd0000755007451300017500000001134112170636050014351 0ustar charlescharles\title{MA-Plot} \name{plotMA} \alias{plotMA} \description{ Creates an MA-plot with color coding for control spots. } \usage{ plotMA(MA, array=1, xlab="A", ylab="M", main=colnames(MA)[array], xlim=NULL, ylim=NULL, status, values, pch, col, cex, legend=TRUE, zero.weights=FALSE, ...) } \arguments{ \item{MA}{an \code{RGList}, \code{MAList} or \code{MArrayLM} object, or any list with components \code{M} containing log-ratios and \code{A} containing average intensities. Alternatively a \code{matrix} or \code{ExpressionSet} object.} \item{array}{integer giving the array to be plotted. Corresponds to columns of \code{M} and \code{A}.} \item{xlab}{character string giving label for x-axis} \item{ylab}{character string giving label for y-axis} \item{main}{character string giving title for plot} \item{xlim}{numeric vector of length 2 giving limits for x-axis, defaults to min and max of the data} \item{ylim}{numeric vector of length 2 giving limits for y-axis, defaults to min and max of the data} \item{status}{character vector giving the control status of each spot on the array, of same length as the number of rows of \code{MA$M}. If omitted, all points are plotted in the default color, symbol and size.} \item{values}{character vector giving values of \code{status} to be highlighted on the plot. Defaults to unique values of \code{status}. Ignored if there is no \code{status} vector.} \item{pch}{vector or list of plotting characters. Default is integer code 16 which gives a solid circle. Ignored is there is no \code{status} vector.} \item{col}{numeric or character vector of colors, of the same length as \code{values}. Defaults to \code{1:length(values)}. Ignored if there is no \code{status} vector.} \item{cex}{numeric vector of plot symbol expansions, of the the same length as \code{values}. Defaults to 0.3 for the most common status value and 1 for the others. Ignored if there is no \code{status} vector.} \item{legend}{logical, should a legend of plotting symbols and colors be included. Can also be a character string giving position to place legend. Ignored if there is no \code{status} vector.} \item{zero.weights}{logical, should spots with zero or negative weights be plotted?} \item{...}{any other arguments are passed to \code{plot}} } \details{ An MA-plot is a plot of log-intensity ratios (M-values) versus log-intensity averages (A-values). If \code{MA} is an \code{RGList} or \code{MAList} then this function produces an ordinary within-array MA-plot. If \code{MA} is an \code{MArrayLM} object, then the plot is an fitted model MA-plot in which the estimated coefficient is on the y-axis and the average A-value is on the x-axis. If \code{MA} is a \code{matrix} or \code{ExpressionSet} object, then this function produces a between-array MA-plot. In this case the A-values in the plot are the average log-intensities across the arrays and the M-values are the deviations of the log-intensities for the specified array from the average. If there are more than five arays, then the average is computed robustly using medians. With five or fewer arrays, it is computed by means. The \code{status} vector is intended to specify the control status of each spot, for example "gene", "ratio control", "house keeping gene", "buffer" and so on. The vector is usually computed using the function \code{\link{controlStatus}} and a spot-types file. However the function may be used to highlight any subset of spots. The \code{status} can be included as the component \code{MA$genes$Status} instead of being passed as an argument to \code{plotMA}. The arguments \code{values}, \code{pch}, \code{col} and \code{cex} can be included as attributes to \code{status} instead of being passed as arguments to \code{plotMA}. See \code{\link[graphics]{points}} for possible values for \code{pch}, \code{col} and \code{cex}. } \value{A plot is created on the current graphics device.} \references{See \url{http://www.statsci.org/micrarra/refs/maplots.html}} \author{Gordon Smyth} \examples{ MA <- new("MAList") MA$A <- runif(300,4,16) MA$M <- rt(300,df=3) status <- rep("Gene",300) status[1:3] <- "M=0" MA$M[1:3] <- 0 status[4:6] <- "M=3" MA$M[4:6] <- 3 status[7:9] <- "M=-3" MA$M[7:9] <- -3 plotMA(MA,main="MA-Plot with Simulated Data",status=status,values=c("M=0","M=3","M=-3"),col=c("blue","red","green")) # Same as above attr(status,"values") <- c("M=0","M=3","M=-3") attr(status,"col") <- c("blue","red","green") plotMA(MA,main="MA-Plot with Simulated Data",status=status) # Same as above MA$genes$Status <- status plotMA(MA,main="MA-Plot with Simulated Data") } \seealso{ An overview of diagnostic functions available in LIMMA is given in \link{09.Diagnostics}. } \keyword{hplot} limma/man/fitfdist.Rd0000755007451300017500000000603412127125247014677 0ustar charlescharles\name{fitFDist} \alias{fitFDist} \alias{fitFDistRobustly} \title{Moment Estimation of Scaled F-Distribution} \description{ Moment estimation of the parameters of a scaled F-distribution given one of the degrees of freedom. This function is called internally by \code{eBayes} and \code{squeezeVar} and is not usually called directly by a user. } \usage{ fitFDist(x, df1, covariate=NULL) fitFDistRobustly(x, df1, covariate=NULL, winsor.tail.p=c(0.05,0.1), trace=FALSE) } \arguments{ \item{x}{numeric vector or array of positive values representing a sample from a scaled F-distribution.} \item{df1}{the first degrees of freedom of the F-distribution. Can be a single value, or else a vector of the same length as \code{x}.} \item{covariate}{if non-\code{NULL}, the estimated scale value will depend on this numeric covariate.} \item{winsor.tail.p}{numeric vector of length 1 or 2, giving left and right tail proportions of \code{x} to Winsorize.} \item{trace}{logical value indicating whether a trace of the iteration progress should be printed.} } \details{ \code{fitFDist} implements an algorithm proposed by Smyth (2004). It estimates \code{scale} and \code{df2} under the assumption that \code{x} is distributed as \code{scale} times an F-distributed random variable on \code{df1} and \code{df2} degrees of freedom. The parameters are estimated using the method of moments, specifically from the mean and variance of the \code{x} values on the log-scale. \code{fitFDistRobustly} is similar to \code{fitFDist} except that it computes the moments of the Winsorized values of \code{x}, making it robust against left and right outliers. Larger values for \code{winsor.tail.p} produce more robustness but less efficiency. The robust method is described by Phipson (2013). } \value{ A list containing the components \item{scale}{scale factor for F-distribution. A vector if \code{covariate} is non-\code{NULL}, otherwise a scalar.} \item{df2}{the second degrees of freedom of the F-distribution.} } \author{Gordon Smyth and Belinda Phipson} \references{ Smyth, G. K. (2004). Linear models and empirical Bayes methods for assessing differential expression in microarray experiments. \emph{Statistical Applications in Genetics and Molecular Biology}, \bold{3}, No. 1, Article 3. \url{http://www.bepress.com/sagmb/vol3/iss1/art3} Phipson, B. (2013). \emph{Empirical Bayes modelling of expression profiles and their associations}. PhD Thesis. University of Melbourne, Australia. Phipson, B., and Smyth, G. K. (2013). \emph{Robust empirical Bayes estimation protetcts against hyper-variable genes and improves power to detect differential expression in RNA-seq data}. Bioinformatics Division, Walter and Eliza Hall Institute of Medical Research, Australia } \seealso{ This function is called by \code{\link{squeezeVar}}, and hence by \code{\link{ebayes}} and \code{\link{eBayes}}. This function calls \code{\link{trigammaInverse}}. } \examples{ x <- rf(100,df1=8,df2=16) fitFDist(x,df1=8) } \keyword{distribution} limma/man/printHead.Rd0000755007451300017500000000134612127125247015002 0ustar charlescharles\name{printHead} \alias{printHead} \title{Print Leading Rows of Large Objects} \description{ Print the leading rows of a large vector, matrix or data.frame. This function is used by \code{show} methods for data classes defined in LIMMA. } \usage{ printHead(x) } \arguments{ \item{x}{any object} } \details{ If \code{x} is a vector with more than 20 elements, then \code{printHead(x)} prints only the first 5 elements. If \code{x} is a matrix or data.frame with more than 10 rows, then \code{printHead(x)} prints only the first 5 rows. Any other type of object is printed normally. } \author{Gordon Smyth} \seealso{ An overview of classes defined in LIMMA is given in \link{02.Classes} } \keyword{hplot} limma/man/propTrueNull.Rd0000644007451300017500000000675312127125247015543 0ustar charlescharles\name{propTrueNull} \alias{convest} \alias{propTrueNull} \alias{estimate.m0} \title{Estimate Proportion of True Null Hypotheses} \description{ Estimate the proportion of true null hypotheses from a vector of p-values. } \usage{ propTrueNull(p, method="lfdr", nbins=20, \dots) convest(p, niter=100, plot=FALSE, report=FALSE, file="", tol=1e-6) } \arguments{ \item{p}{numeric vector of p-values.} \item{method}{estimation method. Choices are \code{"lfdr"}, \code{"mean"}, \code{"hist"} or \code{"convest"}.} \item{nbins}{number of histogram bins (if \code{method="hist"}).} \item{niter}{number of iterations to be used in fitting the convex, decreasing density for the p-values.} \item{plot}{logical, should updated plots of fitted convex decreasing p-value density be produced at each iteration?} \item{report}{logical, should the estimated proportion be printed at each iteration?} \item{file}{name of file to which to write the report. Defaults to standard output.} \item{tol}{accuracy of the bisectional search for finding a new convex combination of the current iterate and the mixing density} \item{\dots}{other arguments are passed to \code{convest} (if \code{method="convest"}.} } \details{ The proportion of true null hypotheses in a collection of hypothesis tests is often denoted pi0. This function estimates pi0 from a vector of p-values. \code{method="lfdr"} implements the method of Phipson (2013) based on averaging local false discovery rates across the p-values. \code{method="mean"} is a very simple method based on averaging the p-values. It gives a slightly smaller estimate than \code{2*mean(p)}. \code{method="hist"} implements the histogram method of Mosig et al (2001) and Nettleton et al (2006). \code{method="convest"} calls \code{convest}, which implements the method of Langaas et al (2005) based on a convex decreasing density estimate. } \value{ Numeric value in the interval [0,1] representing the estimated proportion of true null hypotheses. } \references{ Langaas, M, Ferkingstad, E, and Lindqvist, B (2005). Estimating the proportion of true null hypotheses, with application to DNA microarray data. \emph{Journal of the Royal Statistical Society Series} B 67, 555-572. Preprint at \url{http://www.math.ntnu.no/~mettela/pi0.imf} Mosig MO, Lipkin E, Khutoreskaya G, Tchourzyna E, Soller M, Friedmann A (2001). A whole genome scan for quantitative trait loci affecting milk protein percentage in Israeli-Holstein cattle, by means of selective milk DNA pooling in a daughter design, using an adjusted false discovery rate criterion. \emph{Genetics} 157, 1683-1698. Nettleton D, Hwang JTG, Caldo RA, Wise RP (2006). Estimating the number of true null hypotheses from a histogram of p values. \emph{Journal of Agricultural, Biological, and Environmental Statistics} 11, 337-356. Phipson, B (2013). Empirical Bayes Modelling of Expression Profiles and Their Associations. PhD Thesis, University of Melbourne, Australia. } \author{Belinda Phipson and Gordon Smyth for \code{propTrueNull}; Egil Ferkingstad, Mette Langaas and Marcus Davy for \code{convest}} \seealso{ See \link{08.Tests} for other functions for producing or interpreting p-values. } \examples{ # Test statistics z <- rnorm(200) # First 40 are have non-zero means z[1:40] <- z[1:40]+2 # True pi0 160/200 # Two-sided p-values p <- 2*pnorm(-abs(z)) # Estimate pi0 propTrueNull(p, method="lfdr") propTrueNull(p, method="hist") } \keyword{htest} limma/man/merge.Rd0000755007451300017500000000451212170636050014156 0ustar charlescharles\name{merge} \alias{merge.RGList} \alias{merge.MAList} \alias{merge.EList} \alias{merge.EListRaw} \title{Merge RGList or MAList Data Objects} \description{ Merge two microarray data sets represented by RGLists in possibly irregular order. } \usage{ \method{merge}{RGList}(x,y,\dots) } \arguments{ \item{x}{data object of class \code{\link[limma:rglist]{RGList}}, \code{\link[limma:malist]{MAList}}, \code{\link[limma:EList]{EList}} or \code{\link[limma:EList]{EListRaw}}.} \item{y}{data object of same class as \code{x}, corresponding to the same genes as for \code{x}, possibly in a different order, but with different arrays.} \item{\dots}{other arguments are accepted but not used at present} } \details{ \code{RGList}, \code{MAList}, \code{EListRaw} and \code{EList} data objects are lists containing numeric matrices all of the same dimensions. The data objects are merged by merging each of the components by row names or, if there are no row names, by IDs in the \code{genes} component. Unlike when using \code{\link{cbind}}, row names are not required to be in the same order or to be unique. In the case of repeated row names, the order of the rows with repeated names in preserved. This means that the first occurrence of each name in \code{x} is matched with the first occurrence of the same name in \code{y}, the second with the second, and so on. The final vector of row names is the same as in \code{x}. Note: if the objects contain the same number of genes in the same order then the appropriate function to combine them is \code{\link[limma:cbind]{cbind}} rather than \code{merge}. } \value{ An merged object of the same class as \code{x} and \code{y} with the same components as \code{x}. Component matrices have the same rows names as in \code{x} but columns from \code{y} as well as from \code{x}. } \author{Gordon Smyth} \seealso{ R base provides a \code{\link[base]{merge}} method for merging data.frames. An overview of limma commands for reading, subsetting and merging data is given in \link{03.ReadingData}. } \examples{ M <- A <- matrix(11:14,4,2) rownames(M) <- rownames(A) <- c("a","a","b","c") MA1 <- new("MAList",list(M=M,A=A)) M <- A <- matrix(21:24,4,2) rownames(M) <- rownames(A) <- c("b","a","a","c") MA2 <- new("MAList",list(M=M,A=A)) merge(MA1,MA2) merge(MA2,MA1) } \keyword{manip} limma/man/weightedmedian.Rd0000644007451300017500000000207012127125247016032 0ustar charlescharles\name{weighted.median} \alias{weighted.median} \title{Weighted Median} \description{ Compute a weighted median of a numeric vector. } \usage{ weighted.median(x, w, na.rm = FALSE) } \arguments{ \item{x}{a numeric vector containing the values whose mean is to be computed.} \item{w}{a vector of weights the same length as \code{x} giving the weights to use for each element of \code{x}.} \item{na.rm}{a logical value indicating whether \code{NA} values in \code{x} should be stripped before the computation proceeds.} } \details{ If \code{w} is missing then all elements of \code{x} are given the same weight. Missing values in \code{w} are not handled. The weighted median is the median of the discrete distribution with values given by \code{x} and probabilities given by \code{w/sum(w)}. } \value{numeric value giving the weighted median} \seealso{ \code{\link{median}}, \code{\link{weighted.mean}} } \examples{ ## GPA from Siegel 1994 wt <- c(5, 5, 4, 1)/15 x <- c(3.7,3.3,3.5,2.8) xm <- weighted.median(x,wt) } \keyword{univar} limma/man/normalizequantiles.Rd0000755007451300017500000000350112127125247017005 0ustar charlescharles\name{normalizeQuantiles} \alias{normalizeQuantiles} \title{Normalize Columns of a Matrix to have the same Quantiles} \description{ Normalize the columns of a matrix to have the same quantiles, allowing for missing values. Users do not normally need to call this function directly - use \code{\link{normalizeBetweenArrays}} instead. } \usage{ normalizeQuantiles(A, ties=TRUE) } \arguments{ \item{A}{numeric matrix. Missing values are allowed.} \item{ties}{logical. If \code{TRUE}, ties in each column of \code{A} are treated in careful way. tied values will be normalized to the mean of the corresponding pooled quantiles.} } \details{ This function is intended to normalize single channel or A-value microarray intensities between arrays. Each quantile of each column is set to the mean of that quantile across arrays. The intention is to make all the normalized columns have the same empirical distribution. This will be exactly true if there are no missing values and no ties within the columns: the normalized columns are then simply permutations of one another. If there are ties amongst the intensities for a particular array, then with \code{ties=FALSE} the ties are broken in an unpredictable order. If \code{ties=TRUE}, all the tied values for that array will be normalized to the same value, the average of the quantiles for the tied values. } \value{ A matrix of the same dimensions as \code{A} containing the normalized values. } \references{ 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. \emph{Bioinformatics} \bold{19}, 185-193. } \author{Gordon Smyth} \seealso{ An overview of LIMMA functions for normalization is given in \link{05.Normalization}. } \keyword{models} limma/man/uniquegenelist.Rd0000755007451300017500000000161612127125247016125 0ustar charlescharles\name{uniquegenelist} \alias{uniquegenelist} \title{Eliminate Duplicate Names from the Gene List} \description{ Eliminate duplicate names from the gene list. The new list is shorter than the full list by a factor of \code{ndups}. } \usage{ uniquegenelist(genelist,ndups=2,spacing=1) } \arguments{ \item{genelist}{vector of gene names} \item{ndups}{number of duplicate spots. The number of rows of \code{genelist} must be divisible by \code{ndups}.} \item{spacing}{the spacing between duplicate names in \code{genelist}} } \value{ A vector of length \code{length(genelist)/ndups} containing each gene name once only. } \author{Gordon Smyth} \seealso{ \code{\link{unwrapdups}} } \examples{ genelist <- c("A","A","B","B","C","C","D","D") uniquegenelist(genelist,ndups=2) genelist <- c("A","B","A","B","C","D","C","D") uniquegenelist(genelist,ndups=2,spacing=2) } \keyword{array} limma/man/printtipWeights.Rd0000755007451300017500000000763712127125247016301 0ustar charlescharles\name{printtipWeights} \alias{printtipWeights} \alias{printtipWeightsSimple} \title{Sub-array Quality Weights} \description{ Estimates relative quality weights for each sub-array in a multi-array experiment. } \usage{ printtipWeights(object, design = NULL, weights = NULL, method = "genebygene", layout, maxiter = 50, tol = 1e-10, trace=FALSE) } \arguments{ \item{object}{object of class \code{numeric}, \code{matrix}, \code{MAList}, \code{marrayNorm}, or \code{ExpressionSet} containing log-ratios or log-values of expression for a series of spotted microarrays.} \item{design}{the design matrix of the microarray experiment, with rows corresponding to arrays and columns to coefficients to be estimated. Defaults to the unit vector meaning that the arrays are treated as replicates.} \item{weights}{optional numeric matrix containing prior weights for each spot.} \item{method}{character string specifying the estimating algorithm to be used. Choices are \code{"genebygene"} and \code{"reml"}.} \item{layout}{list specifying the dimensions of the spot matrix and the grid matrix. For details see \code{\link[limma:PrintLayout]{PrintLayout-class}}.} \item{maxiter}{maximum number of iterations allowed.} \item{tol}{convergence tolerance.} \item{trace}{logical variable. If true then output diagnostic information at each iteration of '"reml"' algorithm.} } \details{ The relative reliability of each sub-array (print-tip group) is estimated by measuring how well the expression values for that sub-array follow the linear model. The method described in Ritchie et al (2006) and implemented in the \code{arrayWeights} function is adapted for this purpose. A heteroscedastic model is fitted to the expression values for each gene by calling the function \code{lm.wfit}. The dispersion model is fitted to the squared residuals from the mean fit, and is set up to have sub-array specific coefficients, which are updated in either full REML scoring iterations, or using an efficient gene-by-gene update algorithm. The final estimates of the sub-array variances are converted to weights. The data object \code{object} is interpreted as for \code{lmFit}. In particular, the arguments \code{design}, \code{weights} and \code{layout} will be extracted from the data \code{object} if available and do not normally need to be set explicitly in the call; if any of these are set in the call then they will over-ride the slots or components in the data \code{object}. } \value{ A matrix of sub-array weights which can be passed to \code{lmFit}. } \references{ Ritchie, M. E., Diyagama, D., Neilson, van Laar, R., J., Dobrovic, A., Holloway, A., and Smyth, G. K. (2006). Empirical array quality weights in the analysis of microarray data. BMC Bioinformatics 7, 261. \url{http://www.biomedcentral.com/1471-2105/7/261/abstract} } \seealso{ An overview of linear model functions in limma is given by \link{06.LinearModels}. } \examples{ \dontrun{ # This example is designed for work on a subset of the data # from ApoAI case study in Limma User's Guide RG <- backgroundCorrect(RG, method="normexp") MA <- normalizeWithinArrays(RG) targets <- data.frame(Cy3=I(rep("Pool",6)),Cy5=I(c("WT","WT","WT","KO","KO","KO"))) design <- modelMatrix(targets, ref="Pool") subarrayw <- printtipWeights(MA, design, layout=mouse.setup) fit <- lmFit(MA, design, weights=subarrayw) fit2 <- contrasts.fit(fit, contrasts=c(-1,1)) fit2 <- eBayes(fit2) # Use of sub-array weights increases the significance of the top genes topTable(fit2) # Create an image plot of sub-array weights from each array zlim <- c(min(subarrayw), max(subarrayw)) par(mfrow=c(3,2), mai=c(0.1,0.1,0.3,0.1)) for(i in 1:6) imageplot(subarrayw[,i], layout=mouse.setup, zlim=zlim, main=paste("Array", i)) } } \author{Matthew Ritchie and Gordon Smyth} \keyword{regression} \keyword{models} limma/man/normexpfitcontrol.Rd0000644007451300017500000000754112127125247016660 0ustar charlescharles\name{normexp.fit.control} \alias{normexp.fit.control} \title{Normexp Model Parameter Estimation Aided by Negative Controls} \description{The mean and log-standard-deviation of the background-normal part of the normexp+exponential convolution model is estimated as the mean and log-standard deviation of intensities from negative control probes. The log-mean of the signal-exponential part is estimated as the log of the difference between signal mean and background mean.} \usage{ normexp.fit.control(x, status=NULL, negctrl="negative", regular="regular", robust=FALSE) } \arguments{ \item{x}{object of class \code{EListRaw-class} or \code{matrix} containing raw intensities for regular and control probes for a series of microarrays} \item{status}{character vector giving probe types.} \item{negctrl}{character string identifier for negative control probes.} \item{regular}{character string identifier for regular probes.} \item{robust}{logical. Should robust estimators be used for the background mean and standard deviation?} } \details{ \code{x} has to contain raw expression intensities from both regular probes and negative control probes. The probe type information for an object of \code{\link{EListRaw-class}} is normally saved in the \code{Status} column of its \code{genes} component. However, it will be overriden by the \code{status} parameter if it is explicitly provided to this function. If \code{x} is a \code{matrix} object, the probe type information has to be provided through the \code{status} parameter of this function. Regular probes have the status \code{regular}. Negative control probes have the status indicated by \code{negctrl}, which is \code{negative} by default. This function estimates parameters of the normal+exponential convolution model with the help of negative control probes. The mean and log-standard-deviation of the background-normal part of the normexp+exponential(normexp) convolution model are estimated as the mean and log-standard deviation of intensities from negative control probes respectively. The log-mean of the signal-exponential part is estimated as the log of the difference between signal mean and background mean. The signal mean is simply the mean of intensities from regular probes. When negative control probes are not available, the \code{\link{normexp.fit.detection.p}} function can be used to estimate the normexp model parameters which infers the negative control probe intensities from regular probes by taking advantage of their detection p value information. } \value{ A matrix containing estimated parameters with rows being arrays and with columns being parameters. Column names are \code{mu}, \code{logsigma} and \code{logalpha}. } \references{ Shi W, Oshlack A and Smyth GK (2010). Optimizing the noise versus bias trade-off for Illumina Whole Genome Expression BeadChips. Nucleic Acids Research, 38(22):e204. Epub 2010 Oct 6. PMID: 20929874 } \author{Wei Shi and Gordon Smyth} \seealso{ \code{\link{nec}} calls this function to get the parameters of the normal+exponential convolution model and then calls \code{\link{normexp.signal}} to perform the background correction. \code{\link{normexp.fit.detection.p}} estimates the parameters in the normal+exponential convolution model using negative control probe intensities inferred from regular probes by using their detection p values information. \code{\link{normexp.fit}} estimates normexp parameters using a saddle-point approximation or other mothods. An overview of background correction functions is given in \code{\link{04.Background}}. } \examples{ \dontrun{ # read in BeadChip probe profile file and control profile file x <- read.ilmn(files="sample probe profile", ctrlfiles="control probe profile") # estimated normexp parameters normexp.fit.control(x) # normalization using control data y <- neqc(x) } } \keyword{models} limma/man/getlayout.Rd0000755007451300017500000000453112127125247015100 0ustar charlescharles\name{getLayout} \alias{getLayout} \alias{getLayout2} \alias{getDupSpacing} \title{Extract the Print Layout of an Array from the GAL File} \description{ From the Block, Row and Column information in a genelist, determine the number of grid rows and columns on the array and the number of spot rows and columns within each grid. } \usage{ getLayout(gal, guessdups=FALSE) getLayout2(galfile) getDupSpacing(ID) } \arguments{ \item{gal}{data.frame containing the GAL, i.e., giving the position and gene identifier of each spot} \item{galfile}{name or path of GAL file} \item{guessdups}{logical, if \code{TRUE} then try to determine number and spacing of duplicate spots, i.e., within-array replicates} \item{ID}{vector or factor of gene IDs} } \details{ A GenePix Array List (GAL) file is a list of genes and associated information produced by an Axon microarray scanner. The function \code{getLayout} determines the print layout from a data frame created from a GAL file or gene list. The data.frame must contain columns \code{Block}, \code{Column} and \code{Row}. (The number of tip columns is assumed to be either one or four.) On some arrays, each probe may be duplicated a number of times (\code{ndups}) at regular intervals (\code{spacing}) in the GAL file. \code{getDupSpacing} determines valid values for \code{ndups} and \code{spacing} from a vector of IDs. If \code{guessdups=TRUE}, then \code{getLayout} calls \code{getDupSpacing}. The function \code{getLayout2} attempts to determine the print layout from the header information of an actual GAL file. } \value{ A \code{printlayout} object, which is a list with the following components. The last two components are present only if \code{guessdups=TRUE}. \item{ngrid.r}{integer, number of grid rows on the arrays} \item{ngrid.c}{integer, number of grid columns on the arrays} \item{nspot.r}{integer, number of rows of spots in each grid} \item{nspot.c}{integer, number of columns of spots in each grid} \item{ndups}{integer, number of times each probe is printed on the array} \item{spacing}{integer, spacing between multiple printings of each probe} } \author{Gordon Smyth and James Wettenhall} \seealso{ An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \examples{ # gal <- readGAL() # layout <- getLayout(gal) } \keyword{IO} limma/man/modifyWeights.Rd0000755007451300017500000000261212127125247015703 0ustar charlescharles\title{modifyWeights} \name{modifyWeights} \alias{modifyWeights} \description{ Modify weights matrix for given gene status values. } \usage{ modifyWeights(weights=rep(1,length(status)), status, values, multipliers) } \arguments{ \item{weights}{numeric matrix of relative weights, rows corresponding to genes and columns to arrays} \item{status}{character vector giving the control status of each spot on the array, of same length as the number of rows of \code{weights}} \item{values}{character vector giving subset of the unique values of \code{status}} \item{multipliers}{numeric vector of same length as \code{values} giving factor by which weights will be modified} } \details{ The function is usually used to temporarily modify the weights matrix during normalization of data. The function can be used for example to give zero weight to spike-in ratio control spots during normalization. } \value{ Numeric matrix of same dimensions as \code{weights} with rows corresponding to \code{values} in \code{status} modified by the specified multipliers. } \author{Gordon Smyth} \examples{ w <- matrix(runif(6*3),6,3) status <- c("Gene","Gene","Ratio_Control","Ratio_Control","Gene","Gene") modifyWeights(w,status,values="Ratio_Control",multipliers=0) } \seealso{ An overview of normalization functions available in LIMMA is given in \link{05.Normalization}. } \keyword{hplot} limma/man/readImaGeneHeader.Rd0000755007451300017500000000267512127125247016344 0ustar charlescharles\name{readImaGeneHeader} \alias{readImaGeneHeader} \title{Read ImaGene Header Information} \description{ Read the header information from an ImaGene image analysis output file. This function is used internally by \code{read.maimages} and is not usually called directly by users. } \usage{ readImaGeneHeader(file) } \arguments{ \item{file}{character string giving file name or path} } \details{ The raw data files exported by the image analysis software ImaGene include a number of header lines which contain information about the printing and scanning processes. This function extracts that information and locates the line where the intensity data begins. } \value{ A list containing information read from the header of the ImaGene file. Each Begin-End environment found in the file header will become a recursive list in the output object, with components corresponding to fields in the file. See the ImaGene documentation for further information. The output object will also contain a component \code{NHeaderRecords}giving the number of lines in the file before the intensity data begins. } \references{ \url{http://www.biodiscovery.com/imagene.asp} } \author{Gordon Smyth} \seealso{\code{\link{read.imagene}} An overview of LIMMA functions to read data is given in \link{03.ReadingData}. } \examples{\dontrun{ h <- readImaGeneHeader("myImaGenefile.txt") names(h) h$NHeaderRecords h[["Field Dimensions"]] } } \keyword{file} limma/man/dim.Rd0000755007451300017500000000272412127125247013636 0ustar charlescharles\name{dim} \alias{dim.RGList} \alias{dim.MAList} \alias{dim.EListRaw} \alias{dim.EList} \alias{dim.MArrayLM} \alias{length.RGList} \alias{length.MAList} \alias{length.EListRaw} \alias{length.EList} \alias{length.MArrayLM} \title{Retrieve the Dimensions of an RGList, MAList or MArrayLM Object} \description{ Retrieve the number of rows (genes) and columns (arrays) for an RGList, MAList or MArrayLM object. } \usage{ \method{dim}{RGList}(x) \method{length}{RGList}(x) } \arguments{ \item{x}{an object of class \code{RGList}, \code{MAList} or \code{MArrayLM}} } \details{ Microarray data objects share many analogies with ordinary matrices in which the rows correspond to spots or genes and the columns to arrays. These methods allow one to extract the size of microarray data objects in the same way that one would do for ordinary matrices. A consequence is that row and column commands \code{nrow(x)}, \code{ncol(x)} and so on also work. } \value{ Numeric vector of length 2. The first element is the number of rows (genes) and the second is the number of columns (arrays). } \author{Gordon Smyth} \seealso{ \code{\link[base]{dim}} in the base package. \link{02.Classes} gives an overview of data classes used in LIMMA. } \examples{ M <- A <- matrix(11:14,4,2) rownames(M) <- rownames(A) <- c("a","b","c","d") colnames(M) <- colnames(A) <- c("A1","A2") MA <- new("MAList",list(M=M,A=A)) dim(M) ncol(M) nrow(M) length(M) } \keyword{array} limma/man/read.ilmn.targets.Rd0000644007451300017500000000205112127125247016374 0ustar charlescharles\name{read.ilmn.targets} \alias{read.ilmn.targets} \title{Read Illumina Data from a Target Dataframe} \description{Read Illumina data from a target dataframe} \usage{ read.ilmn.targets(targets, ...) } \arguments{ \item{targets}{ data frame including names of profile files.} \item{...}{ any other parameters are passed on to \code{\link{read.ilmn}}.} } \details{ \code{targets} is often created by calling the function \code{\link{readTargets}}. Rows in \code{targets} are arrays and columns contain related array or RNA sample information. At least one of the two columns called \code{files} and/or \code{ctrlfiles} should be present in \code{targets}, which includes names of summary probe profile files and names of summary control probe profile files respectively. This function calls \code{\link{read.ilmn}} to read in the data. } \value{ An \code{\link{EListRaw-class}} object. See return value of the function \code{\link{read.ilmn}} for details. } \author{Wei Shi} \seealso{ \code{\link{read.ilmn}} } \keyword{IO} limma/man/nec.Rd0000644007451300017500000001163312127125247013626 0ustar charlescharles\name{nec} \alias{nec} \alias{neqc} \title{NormExp Background Correction and Normalization Using Control Probes} \description{Perform normexp background correction using negative control probes and quantile normalization using negative and positive control probes.} \usage{ nec(x, status=NULL, negctrl="negative", regular="regular", offset=16, robust=FALSE,detection.p="Detection") neqc(x, status=NULL, negctrl="negative", regular="regular", offset=16, robust=FALSE, detection.p="Detection",...) } \arguments{ \item{x}{object of class \code{EListRaw} or \code{matrix} containing raw intensities for regular and control probes from a series of microarrays.} \item{status}{character vector giving probe types. Defaults to \code{x$genes$Status} if \code{x} is an \code{EListRaw} object.} \item{negctrl}{character string identifier for negative control probes.} \item{regular}{character string identifier for regular probes, i.e., all probes other than control probes.} \item{offset}{numeric value added to the intensities after background correction.} \item{robust}{logical. Should robust estimators be used for the background mean and standard deviation?} \item{detection.p}{a character string giving the name of the component which contains detection p value information in \code{x} or a numeric matrix giving detection p values, \code{Detection} by default} \item{...}{any other arguments are passed to \code{normalizeBetweenArrays.}} } \details{ \code{neqc} performs background correction followed by quantile normalization, using negative control probes for background correction and both negative and positive controls for normalization. \code{nec} is similar but performs background correction only. When control data are available, these function call \code{\link{normexp.fit.control}} to estimate the parameters required by normal+exponential(normexp) convolution model with the help of negative control probes, followed by \code{\link{normexp.signal}} to perform the background correction. If \code{x} contains background intensities \code{x$Eb}, then these are first subtracted from the foreground intensities, prior to normexp background correction. After background correction, an \code{offset} is added to the data. When control data are not available, these functions call \code{\link{normexp.fit.detection.p}} to estimate the normexp parameters. \code{\link{normexp.fit.detection.p}} infers negative control probe intensities from regular probes by taking advantage of their detection p value information. For more descriptions to parameters \code{x}, \code{status}, \code{negctrl}, \code{regular} and \code{detection.p}, please refer to functions \code{\link{normexp.fit.control}}, \code{\link{normexp.fit.detection.p}} and \code{\link{read.ilmn}}. Both \code{nec} and \code{neqc} perform the above steps. \code{neqc} continues on to quantile normalize the background-corrected intensities, including control probes. After normalization, the intensities are log2 transformed and the control probes are removed. } \value{ \code{nec} produces a \code{\link{EListRaw-class}} or matrix object of the same dimensions as \code{x} containing background-corrected intensities, on the raw scale. \code{neqc} produces a \code{\link{EList-class}} or matrix object containing normalized log2 intensities, with rows corresponding to control probes removed. } \references{ Shi W, Oshlack A and Smyth GK (2010). Optimizing the noise versus bias trade-off for Illumina Whole Genome Expression BeadChips. \emph{Nucleic Acids Research} 38, e204. \url{http://nar.oxfordjournals.org/content/38/22/e204} } \author{Wei Shi and Gordon Smyth} \seealso{ An overview of background correction functions is given in \link{04.Background}. An overview of LIMMA functions for normalization is given in \link{05.Normalization}. \code{\link{normexp.fit.control}} estimates the parameters in the normal+exponential convolution model using the negative control probes. \code{\link{normexp.fit.detection.p}} estimates the parameters in the normal+exponential convolution model using negative control probe intensities inferred from regular probes by using their detection p values information. \code{\link{normexp.fit}} estimates parameters in the normal+exponential convolution model using a saddle-point approximation or other methods. \code{\link{neqc}} performs normexp background correction and quantile normalization aided by control probes. } \examples{ \dontrun{ # neqc normalization for data which include control probes x <- read.ilmn(files="sample probe profile.txt",ctrlfiles="control probe profile.txt") y <- neqc(x) # Same thing but in separate steps: x.b <- nec(x) y <- normalizeBetweenArrays(x.b,method="quantile") y <- y[y$genes$Status=="regular",] # neqc normalization for data which do not include control probes xr <- read.ilmn(files="sample probe profile.txt") yr <- neqc(xr) } } \keyword{models} limma/man/03reading.Rd0000644007451300017500000001001512127125247014626 0ustar charlescharles\name{03.ReadingData} \alias{03.ReadingData} \title{Reading Microarray Data from Files} \description{ This help page gives an overview of LIMMA functions used to read data from files. } \section{Reading Target Information}{ The function \code{\link{readTargets}} is designed to help with organizing information about which RNA sample is hybridized to each channel on each array and which files store information for each array. } \section{Reading Intensity Data}{ The first step in a microarray data analysis is to read into R the intensity data for each array provided by an image analysis program. This is done using the function \code{\link{read.maimages}}. \code{\link{read.maimages}} optionally constructs quality weights for each spot using quality functions listed in \link{QualityWeights}. If the data is two-color, then \code{read.maimages} produces an \code{RGList} object. If the data is one-color (single channel) then an \code{EListRaw} object is produced. In either case, \code{read.maimages} stores only the information required from each image analysis output file. \code{\link{read.maimages}} uses utility functions \code{\link{removeExt}}, \code{\link{read.imagene}} and \code{\link{read.columns}}. There are also a series of utility functions which read the header information from image output files including \code{\link{readGPRHeader}}, \code{\link{readImaGeneHeader}} and \code{\link{readGenericHeader}}. \code{\link{read.ilmn}} reads probe or gene summary profile files from Illumina BeadChips, and produces an \code{ElistRaw} object. The function \link{as.MAList} can be used to convert a \code{marrayNorm} object to an \code{MAList} object if the data was read and normalized using the marray and marrayNorm packages. } \section{Reading the Gene List}{ Most image analysis software programs provide gene IDs as part of the intensity output files, for example GenePix, Imagene and the Stanford Microarray Database do this. In other cases the probe ID and annotation information may be in a separate file. The most common format for the probe annotation file is the GenePix Array List (GAL) file format. The function \code{\link{readGAL}} reads information from a GAL file and produces a data frame with standard column names. The function \code{\link{getLayout}} extracts from the GAL-file data frame the print layout information for a spotted array. The functions \code{\link{gridr}}, \code{\link{gridc}}, \code{\link{spotr}} and \code{\link{spotc}} use the extracted layout to compute grid positions and spot positions within each grid for each spot. The function \code{\link{printorder}} calculates the printorder, plate number and plate row and column position for each spot given information about the printing process. The utility function \code{\link{getSpacing}} converts character strings specifying spacings of duplicate spots to numeric values. The Australian Genome Research Facility in Australia often produces GAL files with composite probe IDs or names consisting of multiple strings separated by a delimiter. These can be separated into name and annotation information using \code{\link{strsplit2}}. If each probe is printed more than once of the arrays in a regular pattern, then \code{\link{uniquegenelist}} will remove duplicate names from the gal-file or gene list. } \section{Identifying Control Spots}{ The functions \code{\link{readSpotTypes}} and \code{\link{controlStatus}} assist with separating control spots from ordinary genes in the analysis and data exploration. } \section{Manipulating Data Objects}{ \code{\link[limma:cbind]{cbind}}, \code{\link[limma:cbind]{rbind}}, \code{\link[limma:merge]{merge}} allow different \code{RGList} or \code{MAList} objects to be combined. \code{cbind} combines data from different arrays assuming the layout of the arrays to be the same. \code{merge} can combine data even when the order of the probes on the arrays has changed. \code{merge} uses utility function \code{\link{makeUnique}}. } \author{Gordon Smyth} \keyword{documentation} limma/man/bwss.matrix.Rd0000755007451300017500000000172612127125247015347 0ustar charlescharles\name{bwss.matrix} \alias{bwss.matrix} \title{Between and within sums of squares for matrix} \description{Sums of squares between and within the columns of a matrix. Allows for missing values. This function is called by the \code{\link[limma:anova-method]{anova}} method for \code{MAList} objects.} \usage{bwss.matrix(x)} \arguments{ \item{x}{a numeric matrix.} } \value{ A list with components \item{bss}{sums of squares between the column means.} \item{wss}{sums of squares within the column means.} \item{bdf}{degrees of freedom corresponding to \code{bss}.} \item{wdf}{degrees of freedom corresponding to \code{wss}.} } \details{This is equivalent to a one-way analysis of variance where the columns of the matrix are the groups. If \code{x} is a matrix then \code{bwss.matrix(x)} is the same as \code{bwss(x,col(x))} except for speed of execution.} \author{Gordon Smyth} \seealso{\code{\link{bwss}}, \code{\link{anova.MAList}}} \keyword{models} limma/man/helpMethods.Rd0000755007451300017500000000105112127125247015331 0ustar charlescharles\name{helpMethods} \alias{helpMethods} \title{Prompt for Method Help Topics} \description{ For any S4 generic function, find all methods defined in currently loaded packages. Prompt the user to choose one of these to display the help document. } \usage{ helpMethods(genericFunction) } \arguments{ \item{genericFunction}{a generic function or a character string giving the name of a generic function} } \author{Gordon Smyth} \seealso{ \code{\link[methods]{showMethods}} } \examples{ \dontrun{helpMethods(show)} } \keyword{methods} limma/man/mergeScansRG.Rd0000644007451300017500000001073012127125247015376 0ustar charlescharles\name{mergeScans} \alias{mergeScans} \alias{mergeScansRG} \title{Merge two scans of two-color arrays} \description{ Merge two sets of intensities of two-color arrays that are scanned twice at two different scanner settings, one at a lower gain setting with no saturated spot intensities and the other at a higher gain setting with a higher signal-to-noise ratio and some saturated spot intensities. } \usage{ mergeScansRG(RGlow, RGhigh, AboveNoiseLowG=NULL, AboveNoiseLowR=NULL, outlierp=0.01) } \arguments{ \item{RGlow}{object of class \code{RGList} containing red and green intensities constituting two-color microarray data scanned at a lower gain setting.} \item{RGhigh}{object of class \code{RGList} containing red and green intensities constituting two-color microarray data scanned at a higher gain setting.} \item{AboveNoiseLowG}{matrix of 1 or 0 for low scan intensities of green color, 1 for spots above noise level or 0 otherwise. One column per array.} \item{AboveNoiseLowR}{matrix of 1 or 0 for low scan intensities of red color, 1 for spots above noise level or 0 otherwise. One column per array. } \item{outlierp}{p-value for outliers. 0 for no outlier detection or any value between 0 and 1. Default p-value is 0.01.} } \details{ This function merges two separate scans of each fluorescent label on a two-color array scanned at two different scanner settings by using a nonlinear regression model consisting of two linear regression lines and a quadratic function connecting the two, which looks like a hockey stick. The changing point, i.e. the saturation point, in high scan is also estimated as part of model. Signals produced for certain spots can sometimes be very low (below noise) or too high (saturated) to be accurately read by the scanner. The proportions of spots that are below noise or above saturation are affected by the settings of the laser scanner used to read the arrays, with low scans minimizing saturation effects and high scans maximizing signal-to-noise ratios. Saturated spots can cause bias in intensity ratios that cannot be corrected for using conventional normalization methods. Each fluorescent label on a two-color array can be scanned twice: for example, a high scan targeted at reaching saturation level for the brightest 1 percent of the spots on the array, and a low scan targeted at the lowest level of intensity which still allowed accurate grid placement on the arrays. By merging data from two separate laser scans of each fluorescent label on an array, we can avoid the potential bias in signal intensities due to below noise or above saturation and, thus provide better estimates of true differential expression as well as increase usable spots. The merging process is designed to retain signal intensities from the high scan except when scanner saturation causes the high scan signal to be under-measured. The saturated spots are predicted from the corresponding low scans by the fitted regression model. It also checks any inconsistency between low and high scans. } \value{ An object of class \code{\link{RGList-class}} with the following components: \item{G}{numeric matrix containing the merged green (cy3) foreground intensities. Rows correspond to spots and columns to arrays.} \item{R}{numeric matrix containing the merged red (cy5) foreground intensities. Rows correspond to spots and columns to arrays.} \item{Gb}{numeric matrix containing the green (cy3) background intensities from high scan.} \item{Rb}{numeric matrix containing the red (cy5) background intensities from high scan.} \item{other}{list numeric matrices \code{Gsaturated}, \code{Rsatured}, \code{Goutlier} and \code{Routlier}. The first two contain saturation flags (1=saturated, 0=otherwise) for the green (cy3) and red (Cy5) channels of the high scan. The second two contain outlier flags (1=outlier, 0=otherwise) for the green (cy3) and red (Cy5) channels.} } \author{Dongseok Choi \email{choid@ohsu.edu}.} \references{ Choi D, O'Malley JP, Lasarev MR, Lapidus J, Lu X, Pattee P, Nagalla SR (2006). Extending the Dynamic Range of Signal Intensities in DNA Microarrays. \emph{Online Journal of Bioinformatics}, \bold{7}, 46-56. } \examples{ \dontrun{ #RG1: An RGList from low scan #RG2: An RGList from high scan RGmerged <- mergeScansRG(RG1,RG2,AboveNoiseLowG=ANc3,AboveNoiseLowR=ANc5) #merge two scans when all spots are above noise in low scan and no outlier detection. RGmerged <- mergeScansRG(RG1,RG2,outlierp=0) } } \keyword{models} limma/man/topRomer.Rd0000644007451300017500000000201112127125247014656 0ustar charlescharles\name{topRomer} \alias{topRomer} \title{Top Gene Set Testing Results from Romer} \description{ Extract a matrix of the top gene set testing results from the \link{romer} output. } \usage{ topRomer(x,n=10,alternative="up") } \arguments{ \item{x}{matrix which is the output from \link{romer}.} \item{n}{number of top gene set testing results to be extracted.} \item{alternative}{character which can be one of the three possible alternative p values: "up", "down" or "mixed". } } \value{ matrix, which is sorted by the "up", "down" or "mixed" p values, with the rows corresponding to estimated p-values for the top number of gene sets and the columns corresponding to the number of genes for each gene set and the alternative hypotheses mixed, up, down. } \details{ This function takes the results from romer and returns a number of top gene set testing results that are sorted by the p values. } \examples{ # See romer for examples } \seealso{\code{\link{romer}}} \author{Gordon Smyth and Yifang Hu}limma/man/gridspotrc.Rd0000755007451300017500000000112412127125247015236 0ustar charlescharles\name{gridr} \alias{gridr} \alias{gridc} \alias{spotr} \alias{spotc} \title{Row and Column Positions on Microarray} \description{ Grid and spot row and column positions. } \usage{ gridr(layout) gridc(layout) spotr(layout) spotc(layout) } \arguments{ \item{layout}{list with the components \code{ngrid.r}, \code{ngrid.c}, \code{nspot.r} and \code{nspot.c}} } \value{ Vector of length \code{prod(unlist(layout))} giving the grid rows (\code{gridr}), grid columns (\code{gridc}), spot rows (\code{spotr}) or spot columns (\code{spotc}). } \author{Gordon Smyth} \keyword{IO} limma/man/trimWhiteSpace.Rd0000755007451300017500000000115112127125247016006 0ustar charlescharles\name{trimWhiteSpace} \alias{trimWhiteSpace} \title{Trim Leading and Trailing White Space} \description{Trims leading and trailing white space from character strings.} \usage{ trimWhiteSpace(x) } \arguments{ \item{x}{character vector} } \value{ A character vector of the same length as \code{x} in which leading and trailing white space has been stripped off each value. } \seealso{ An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \examples{ x <- c("a "," b ") trimWhiteSpace(x) } \author{Tim Beissbarth and Gordon Smyth} \keyword{character} limma/man/arrayWeights.Rd0000644007451300017500000000725112127125247015533 0ustar charlescharles\name{arrayWeights} \alias{arrayWeights} \alias{arrayWeightsSimple} \title{Array Quality Weights} \description{ Estimates relative quality weights for each array in a multi-array experiment. } \usage{ arrayWeights(object, design = NULL, weights = NULL, method = "genebygene", maxiter = 50, tol = 1e-10, trace=FALSE) arrayWeightsSimple(object, design = NULL, maxiter = 100, tol = 1e-6, maxratio = 100, trace=FALSE) } \arguments{ \item{object}{object of class \code{numeric}, \code{matrix}, \code{MAList}, \code{marrayNorm}, \code{ExpressionSet} or \code{PLMset} containing log-ratios or log-values of expression for a series of microarrays.} \item{design}{the design matrix of the microarray experiment, with rows corresponding to arrays and columns to coefficients to be estimated. Defaults to the unit vector meaning that the arrays are treated as replicates.} \item{weights}{optional numeric matrix containing prior weights for each spot.} \item{method}{character string specifying the estimating algorithm to be used. Choices are \code{"genebygene"} and \code{"reml"}.} \item{maxiter}{maximum number of iterations allowed.} \item{tol}{convergence tolerance.} \item{maxratio}{maximum ratio between largest and smallest weights before iteration stops} \item{trace}{logical variable. If true then output diagnostic information at each iteration of the '"reml"' algorithm, or at every 1000th iteration of the '"genebygene"' algorithm.} } \details{ The relative reliability of each array is estimated by measuring how well the expression values for that array follow the linear model. The method is described in Ritchie et al (2006). A heteroscedastic model is fitted to the expression values for each gene by calling the function \code{lm.wfit}. The dispersion model is fitted to the squared residuals from the mean fit, and is set up to have array specific coefficients, which are updated in either full REML scoring iterations, or using an efficient gene-by-gene update algorithm. The final estimates of these array variances are converted to weights. The data object \code{object} is interpreted as for \code{lmFit}. In particular, the arguments \code{design} and \code{weights} will be extracted from the data \code{object} if available and do not normally need to be set explicitly in the call; if any of these are set in the call then they will over-ride the slots or components in the data \code{object}. \code{arrayWeightsSimple} is a fast version of \code{arrayWeights} with \code{method="reml"}, no prior weights and no missing values. } \value{ A vector of array weights. } \references{ Ritchie, M. E., Diyagama, D., Neilson, van Laar, R., J., Dobrovic, A., Holloway, A., and Smyth, G. K. (2006). Empirical array quality weights in the analysis of microarray data. BMC Bioinformatics 7, 261. \url{http://www.biomedcentral.com/1471-2105/7/261/abstract} } \seealso{ An overview of linear model functions in limma is given by \link{06.LinearModels}. } \examples{ \dontrun{ # Subset of data from ApoAI case study in Limma User's Guide RG <- backgroundCorrect(RG, method="normexp") MA <- normalizeWithinArrays(RG) targets <- data.frame(Cy3=I(rep("Pool",6)),Cy5=I(c("WT","WT","WT","KO","KO","KO"))) design <- modelMatrix(targets, ref="Pool") arrayw <- arrayWeightsSimple(MA, design) fit <- lmFit(MA, design, weights=arrayw) fit2 <- contrasts.fit(fit, contrasts=c(-1,1)) fit2 <- eBayes(fit2) # Use of array weights increases the significance of the top genes topTable(fit2) } } \author{Matthew Ritchie and Gordon Smyth} \keyword{regression} \keyword{models} limma/man/qqt.Rd0000755007451300017500000000324612127125247013672 0ustar charlescharles\name{qqt} \alias{qqt} \alias{qqf} \title{Student's t Quantile-Quantile Plot} \description{Plots the quantiles of a data sample against the theoretical quantiles of a Student's t distribution.} \usage{qqt(y, df = Inf, ylim = range(y), main = "Student's t Q-Q Plot", xlab = "Theoretical Quantiles", ylab = "Sample Quantiles", plot.it = TRUE, ...) qqf(y, df1, df2, ylim=range(y), main= "F Distribution Q-Q Plot", xlab = "Theoretical Quantiles", ylab = "Sample Quantiles", plot.it = TRUE,...) } \arguments{ \item{y}{a numeric vector or array containing the data sample} \item{df}{degrees of freedom for the t-distribution. The default \code{df=Inf} represents the normal distribution.} \item{df1}{numerator degrees of freedom for the F-distribution.} \item{df2}{denominator degrees of freedom for the F-distribution.} \item{ylim}{plotting range for \code{y}} \item{main}{main title for the plot} \item{xlab}{x-axis title for the plot} \item{ylab}{y-axis title for the plot} \item{plot.it}{whether or not to produce a plot} \item{...}{other arguments to be passed to \code{plot}} } \value{A list is invisibly returned containing the values plotted in the QQ-plot: \item{x}{theoretical quantiles of the t-distribution or F-distribution} \item{y}{the data sample, same as input \code{y}} } \details{ This function is analogous to \code{qqnorm} for normal probability plots. In fact \code{qqt(y,df=Inf)} is identical to \code{qqnorm(y)} in all respects except the default title on the plot. } \author{Gordon Smyth} \seealso{\code{\link[stats]{qqnorm}}} \examples{ # See also the lmFit examples y <- rt(50,df=4) qqt(y,df=4) abline(0,1) } \keyword{distribution} limma/man/10Other.Rd0000644007451300017500000000062012127125247014275 0ustar charlescharles\name{10.Other} \alias{10.Other} \title{Other Functions} \description{ This page describes some functions not covered in the previous numbered pages, so far only \code{\link{blockDiag}} and \code{\link{poolVar}} which are not used in the package yet but are part of the development of methods to handle technical and biological replicates. } \author{Gordon Smyth} \keyword{documentation} limma/man/unwrapdups.Rd0000755007451300017500000000241612127125247015273 0ustar charlescharles\name{unwrapdups} \alias{unwrapdups} \title{Unwrap Duplicate Spot Values from Rows into Columns} \description{Reshape a matrix so that a set of consecutive rows becomes a single row in the output.} \usage{ unwrapdups(M,ndups=2,spacing=1) } \arguments{ \item{M}{a matrix.} \item{ndups}{number of duplicate spots. The number of rows of M must be divisible by \code{ndups}.} \item{spacing}{the spacing between the rows of \code{M} corresponding to duplicate spots, \code{spacing=1} for consecutive spots} } \value{A matrix containing the same values as \code{M} but with fewer rows and more columns by a factor of \code{ndups}. Each set of \code{ndups} rows in \code{M} is strung out to a single row so that duplicate values originally in consecutive rows in the same column are in consecutive columns in the output. } \details{ This function is used on matrices corresponding to a series of microarray experiments. Rows corresponding to duplicate spots are re-arranged to that all values corresponding to a single gene are on the same row. This facilitates fitting models or computing statistics for each gene. } \author{Gordon Smyth} \examples{ M <- matrix(1:12,6,2) unwrapdups(M,ndups=2) unwrapdups(M,ndups=3) unwrapdups(M,ndups=2,spacing=3) } \keyword{array} limma/man/volcanoplot.Rd0000755007451300017500000000250112127125247015416 0ustar charlescharles\title{Volcano Plot} \name{volcanoplot} \alias{volcanoplot} \description{ Creates a volcano plot of log-fold changes versus log-odds of differential expression. } \usage{ volcanoplot(fit, coef=1, highlight=0, names=fit$genes$ID, xlab="Log Fold Change", ylab="Log Odds", pch=16, cex=0.35, ...) } \arguments{ \item{fit}{an \code{MArrayLM} fitted linear model object} \item{coef}{integer giving the coefficient} \item{highlight}{number of top genes to be highlighted} \item{names}{character vector giving text labels for the probes to be used in highlighting} \item{xlab}{character string giving label for x-axis} \item{ylab}{character string giving label for y-axis} \item{pch}{vector or list of plotting characters. Default is integer code 16 which gives a solid circle.} \item{cex}{numeric vector of plot symbol expansions. Default is 0.35.} \item{...}{any other arguments are passed to \code{plot}} } \details{ A volcano plot is any plot which displays fold changes versus a measure of statistical significance of the change. } \value{A plot is created on the current graphics device.} \author{Gordon Smyth} \seealso{ An overview of presentation plots following the fitting of a linear model in LIMMA is given in \link{06.LinearModels}. } \examples{ # See lmFit examples } \keyword{hplot} limma/man/08Tests.Rd0000644007451300017500000000642512127125247014336 0ustar charlescharles\name{08.Tests} \alias{08.Tests} \title{Hypothesis Testing for Linear Models} \description{ LIMMA provides a number of functions for multiple testing across both contrasts and genes. The starting point is an \code{MArrayLM} object, called \code{fit} say, resulting from fitting a linear model and running \code{eBayes} and, optionally, \code{contrasts.fit}. See \link{06.LinearModels} or \link{07.SingleChannel} for details. } \section{Multiple testing across genes and contrasts}{ The key function is \code{\link{decideTests}}. This function writes an object of class \code{\link[limma:TestResults]{TestResults}}, which is basically a matrix of \code{-1}, \code{0} or \code{1} elements, of the same dimension as \code{fit$coefficients}, indicating whether each coefficient is significantly different from zero. A number of different multiple testing strategies are provided. The function calls other functions \code{\link{classifyTestsF}}, \code{\link{classifyTestsP}} and \code{\link{classifyTestsT}} which implement particular strategies. The function \code{\link{FStat}} provides an alternative interface to \code{classifyTestsF} to extract only the overall moderated F-statistic. \code{\link{selectModel}} chooses between linear models for each probe using AIC or BIC criteria. This is an alternative to hypothesis testing and can choose between non-nested models. A number of other functions are provided to display the results of \code{decideTests}. The functions \code{\link{heatDiagram}} (or the older version \code{\link{heatdiagram}} displays the results in a heat-map style display. This allows visual comparison of the results across many different conditions in the linear model. The functions \code{\link{vennCounts}} and \code{\link{vennDiagram}} provide Venn diagram style summaries of the results. Summary and \code{show} method exists for objects of class \code{TestResults}. The results from \code{decideTests} can also be included when the results of a linear model fit are written to a file using \code{\link{write.fit}}. } \section{Gene Set Tests}{ Competitive gene set testing for an individual gene set is provided by \code{\link{wilcoxGST}} or \code{\link{geneSetTest}}, which permute genes. The gene set can be displayed using \code{\link{barcodeplot}}. Self-contained gene set testing for an individual set is provided by \code{\link{roast}}, which uses rotation technology, analogous to permuting arrays. Gene set enrichment analysis for a large database of gene sets is provided by \code{\link{romer}}. \code{\link{topRomer}} is used to rank results from \code{romer}. The functions \code{\link{alias2Symbol}} and \code{\link{alias2SymbolTable}} are provided to help match gene sets with microarray probes by way of official gene symbols. } \section{Global Tests}{ The function \code{\link{genas}} can test for associations between two contrasts in a linear model. Given a set of p-values, the function \code{\link{convest}} can be used to estimate the proportion of true null hypotheses. When evaluating test procedures with simulated or known results, the utility function \code{\link{auROC}} can be used to compute the area under the Receiver Operating Curve for the test results for a given probe. } \author{Gordon Smyth} \keyword{documentation} limma/man/plotFB.Rd0000644007451300017500000000236412127125247014250 0ustar charlescharles\title{FB-Plot} \name{plotFB} \alias{plotFB} \description{ Creates foreground-background plots. } \usage{ plotFB(RG, array=1, lim="separate", pch=16, cex=0.2, ...) } \arguments{ \item{RG}{an \code{RGList} object.} \item{array}{integer giving the array to be plotted. Corresponds to columns of \code{R}, \code{G}, \code{Rb} and \code{Gb}.} \item{lim}{character string indicating whether the red and green plots should have \code{"separate"} or \code{"common"} x- and y- co-ordinate limits.} \item{pch}{vector or list of plotting characters. Defaults to integer code 16.} \item{cex}{numeric vector of plot symbol expansions.} \item{...}{any other arguments are passed to \code{plot}} } \details{ A foreground-background plot is a plot of log2-foreground vs log2-background for a particular channel on a particular two-color array. This function produces a pair of plots, one for green and one for red, for a specified array. See \code{\link[graphics]{points}} for possible values for \code{pch}, \code{col} and \code{cex}. } \value{A plot is created on the current graphics device.} \author{Gordon Smyth} \seealso{ An overview of diagnostic functions available in LIMMA is given in \link{09.Diagnostics}. } \keyword{hplot} limma/man/classifytests.Rd0000755007451300017500000001146012127125247015762 0ustar charlescharles\name{classifyTests} \alias{FStat} \alias{classifyTestsF} \alias{classifyTestsT} \alias{classifyTestsP} \title{Multiple Testing Genewise Across Contrasts} \description{ For each gene, classify a series of related t-statistics as up, down or not significant. } \usage{ classifyTestsF(object, cor.matrix=NULL, df=Inf, p.value=0.01, fstat.only=FALSE) classifyTestsT(object, t1=4, t2=3) classifyTestsP(object, df=Inf, p.value=0.05, method="holm") FStat(object, cor.matrix=NULL) } \arguments{ \item{object}{numeric matrix of t-statistics or an \code{MArrayLM} object from which the t-statistics may be extracted.} \item{cor.matrix}{covariance matrix of each row of t-statistics. Defaults to the identity matrix.} \item{df}{numeric vector giving the degrees of freedom for the t-statistics. May have length 1 or length equal to the number of rows of \code{tstat}.} \item{p.value}{numeric value between 0 and 1 giving the desired size of the test} \item{fstat.only}{logical, if \code{TRUE} then return the overall F-statistic as for \code{FStat} instead of classifying the test results} \item{t1}{first critical value for absolute t-statistics} \item{t2}{second critical value for absolute t-statistics} \item{method}{character string specifying p-value adjustment method. See \code{\link[stats]{p.adjust}} for possible values.} } \value{ An object of class \code{TestResults}. This is essentially a numeric matrix with elements \code{-1}, \code{0} or \code{1} depending on whether each t-statistic is classified as significantly negative, not significant or significantly positive respectively. \code{FStat} produces a numeric vector of F-statistics with attributes \code{df1} and \code{df2} giving the corresponding degrees of freedom. } \details{ Note that these functions do not adjust for multiple testing across genes. The adjustment for multiple testing is across the contrasts rather than the more usual control across genes. The functions described here are called by \code{\link{decideTests}}. Most users should use \code{decideTests} rather than using these functions directly. These functions implement multiple testing procedures for determining whether each statistic in a matrix of t-statistics should be considered significantly different from zero. Rows of \code{tstat} correspond to genes and columns to coefficients or contrasts. \code{FStat} computes the gene-wise F-statistics for testing all the contrasts equal to zero. It is equivalent to \code{classifyTestsF} with \code{fstat.only=TRUE}. \code{classifyTestsF} uses a nested F-test approach giving particular attention to correctly classifying genes which have two or more significant t-statistics, i.e., are differential expressed under two or more conditions. For each row of \code{tstat}, the overall F-statistics is constructed from the t-statistics as for \code{FStat}. At least one constrast will be classified as significant if and only if the overall F-statistic is significant. If the overall F-statistic is significant, then the function makes a best choice as to which t-statistics contributed to this result. The methodology is based on the principle that any t-statistic should be called significant if the F-test is still significant for that row when all the larger t-statistics are set to the same absolute size as the t-statistic in question. \code{classifyTestsT} and \code{classifyTestsP} implement simpler classification schemes based on threshold or critical values for the individual t-statistics in the case of \code{classifyTestsT} or p-values obtained from the t-statistics in the case of \code{classifyTestsP}. For \code{classifyTestsT}, classifies any t-statistic with absolute greater than \code{t2} as significant provided that at least one t-statistic for that gene is at least \code{t1} in absolute value. \code{classifyTestsP} applied p-value adjustment from \code{p.adjust} to the p-values for each gene. If \code{tstat} is an \code{MArrayLM} object, then all arguments except for \code{p.value} are extracted from it. \code{cor.matrix} is the same as the correlation matrix of the coefficients from which the t-statistics are calculated. If \code{cor.matrix} is not specified, then it is calculated from \code{design} and \code{contrasts} if at least \code{design} is specified or else defaults to the identity matrix. In terms of \code{design} and \code{contrasts}, \code{cor.matrix} is obtained by standardizing the matrix \code{ t(contrasts) \%*\% solve(t(design) \%*\% design) \%*\% contrasts } to a correlation matrix. } \seealso{ An overview of multiple testing functions is given in \link{08.Tests}. } \author{Gordon Smyth} \examples{ tstat <- matrix(c(0,5,0, 0,2.5,0, -2,-2,2, 1,1,1), 4, 3, byrow=TRUE) classifyTestsF(tstat) # See also the examples for contrasts.fit and vennDiagram } \keyword{htest} limma/man/avearrays.Rd0000644007451300017500000000304512127125247015054 0ustar charlescharles\name{avearrays} \alias{avearrays} \alias{avearrays.default} \alias{avearrays.MAList} \alias{avearrays.EList} \title{Average Over Replicate Arrays} \description{ Condense a microarray data object so that technical replicate arrays are replaced with (weighted) averages. } \usage{ \method{avearrays}{default}(x, ID=colnames(x), weights=NULL) \method{avearrays}{MAList}(x, ID=colnames(x), weights=x$weights) \method{avearrays}{EList}(x, ID=colnames(x), weights=x$weights) } \arguments{ \item{x}{a matrix-like object, usually a matrix, \code{MAList} or \code{EList} object.} \item{ID}{sample identifier.} \item{weights}{numeric matrix of non-negative weights} } \details{ A new data object is computed in which technical replicate arrays are replaced by their (weighted) averages. For an \code{MAList} object, the components \code{M} and \code{A} are both averaged in this way, as are \code{weights} and any matrices found in \code{object$other}. \code{EList} objects are similar, except that the \code{E} component is averaged instead of \code{M} and \code{A}. If \code{x} is of mode \code{"character"}, then the replicate values are assumed to be equal and the first is taken as the average. } \value{ A data object of the same class as \code{x} with a row for each unique value of \code{ID}. } \author{Gordon Smyth} \seealso{ \code{\link{avereps}}. \link{02.Classes} gives an overview of data classes used in LIMMA. } \examples{ x <- matrix(rnorm(8*3),8,3) colnames(x) <- c("a","a","b") avearrays(x) } \keyword{array} limma/man/dupcor.Rd0000755007451300017500000001140312175540776014366 0ustar charlescharles\name{dupcor} \alias{duplicateCorrelation} \title{Correlation Between Duplicates} \description{ Estimate the correlation between duplicate spots (regularly spaced replicate spots on the same array) or between technical replicates from a series of arrays. } \usage{ duplicateCorrelation(object, design=NULL, ndups=2, spacing=1, block=NULL, trim=0.15, weights=NULL) } \arguments{ \item{object}{a numeric matrix of expression values, or any data object from which \code{as.matrix} will extract a suitable matrix such as an \code{\link[limma:malist]{MAList}}, \code{marrayNorm} or \code{ExpressionSet} object. If \code{object} is an \code{MAList} object then the arguments \code{design}, \code{ndups}, \code{spacing} and \code{weights} will be extracted from it if available and do not have to be specified as arguments. Specifying these arguments explicitly will over-rule any components found in the data object.} \item{design}{the design matrix of the microarray experiment, with rows corresponding to arrays and columns to comparisons to be estimated. The number of rows must match the number of columns of \code{object}. Defaults to the unit vector meaning that the arrays are treated as replicates.} \item{ndups}{a positive integer giving the number of times each gene is printed on an array. \code{nrow(object)} must be divisible by \code{ndups}. Will be ignored if \code{block} is specified.} \item{spacing}{the spacing between the rows of \code{object} corresponding to duplicate spots, \code{spacing=1} for consecutive spots} \item{block}{vector or factor specifying a blocking variable} \item{trim}{the fraction of observations to be trimmed from each end of \code{tanh(all.correlations)} when computing the trimmed mean.} \item{weights}{an optional numeric matrix of the same dimension as \code{object} containing weights for each spot. If smaller than \code{object} then it will be filled out the same size.} } \value{ A list with components \item{consensus.correlation}{the average estimated inter-duplicate correlation. The average is the trimmed mean of the individual correlations on the atanh-transformed scale.} \item{cor}{same as \code{consensus.correlation}, for compatibility with earlier versions of the software} \item{atanh.correlations}{numeric vector of length \code{nrow(object)/ndups} giving the individual genewise atanh-transformed correlations.} } \details{ When \code{block=NULL}, this function estimates the correlation between duplicate spots (regularly spaced within-array replicate spots). If \code{block} is not null, this function estimates the correlation between repeated observations on the blocking variable. Typically the blocks are biological replicates and the repeated observations are technical replicates. In either case, the correlation is estimated by fitting a mixed linear model by REML individually for each gene. The function also returns a consensus correlation, which is a robust average of the individual correlations, which can be used as input for functions \code{lmFit} or \code{gls.series}. At this time it is not possible to estimate correlations between duplicate spots and between technical replicates simultaneously. If \code{block} is not null, then the function will set \code{ndups=1}, which is equivalent to ignoring duplicate spots. For this function to return statistically useful results, there must be at least two more arrays than the number of coefficients to be estimated, i.e., two more than the column rank of \code{design}. The function may take long time to execute as it fits a mixed linear model for each gene for an iterative algorithm. It is not uncommon for the function to return a small number of warning messages that correlation estimates cannot be computed for some individual genes. This is not a serious concern providing that there are only a few such warnings and the total number of genes is large. The consensus estimator computed by this function will not be materially affected by a small number of genes. } \seealso{ These functions use \code{\link[statmod:mixedmodel]{mixedModel2Fit}} from the statmod package. An overview of linear model functions in limma is given by \link{06.LinearModels}. } \author{Gordon Smyth} \references{ Smyth, G. K., Michaud, J., and Scott, H. (2005). The use of within-array replicate spots for assessing differential expression in microarray experiments. \emph{Bioinformatics} 21(9), 2067-2075. \url{http://www.statsci.org/smyth/pubs/dupcor.pdf} } \examples{ # Also see lmFit examples \dontrun{ corfit <- duplicateCorrelation(MA, ndups=2, design) all.correlations <- tanh(corfit$atanh.correlations) boxplot(all.correlations) fit <- lmFit(MA, design, ndups=2, correlation=corfit$consensus) } } \keyword{multivariate} limma/man/toptable.Rd0000755007451300017500000002021312127125247014670 0ustar charlescharles\name{toptable} \alias{toptable} \alias{topTable} \alias{topTableF} \alias{topTreat} \title{Table of Top Genes from Linear Model Fit} \description{ Extract a table of the top-ranked genes from a linear model fit. } \usage{ topTable(fit, coef=NULL, number=10, genelist=fit$genes, adjust.method="BH", sort.by="B", resort.by=NULL, p.value=1, lfc=0, confint=FALSE) toptable(fit, coef=1, number=10, genelist=NULL, A=NULL, eb=NULL, adjust.method="BH", sort.by="B", resort.by=NULL, p.value=1, lfc=0, confint=FALSE, ...) topTableF(fit, number=10, genelist=fit$genes, adjust.method="BH", sort.by="F", p.value=1, lfc=0) topTreat(fit, coef=1, number=10, genelist=fit$genes, adjust.method="BH", sort.by="p", resort.by=NULL, p.value=1) } \arguments{ \item{fit}{list containing a linear model fit produced by \code{lmFit}, \code{lm.series}, \code{gls.series} or \code{mrlm}. For \code{topTable}, \code{fit} should be an object of class \code{MArrayLM} as produced by \code{lmFit} and \code{eBayes}.} \item{coef}{column number or column name specifying which coefficient or contrast of the linear model is of interest. For \code{topTable}, can also be a vector of column subscripts, in which case the gene ranking is by F-statistic for that set of contrasts.} \item{number}{maximum number of genes to list} \item{genelist}{data frame or character vector containing gene information. For \code{topTable} only, this defaults to \code{fit$genes}.} \item{A}{matrix of A-values or vector of average A-values. For \code{topTable} only, this defaults to \code{fit$Amean}.} \item{eb}{output list from \code{ebayes(fit)}. If \code{NULL}, this will be automatically generated.} \item{adjust.method}{method used to adjust the p-values for multiple testing. Options, in increasing conservatism, include \code{"none"}, \code{"BH"}, \code{"BY"} and \code{"holm"}. See \code{\link{p.adjust}} for the complete list of options. A \code{NULL} value will result in the default adjustment method, which is \code{"BH"}.} \item{sort.by}{character string specifying statistic to rank genes by. Possibilities for \code{topTable} and \code{toptable} are \code{"logFC"}, \code{"AveExpr"}, \code{"t"}, \code{"P"}, \code{"p"}, \code{"B"} or \code{"none"}. \code{"M"} is allowed as a synonym for \code{"logFC"} for backward compatibility. Other permitted synonyms are \code{"A"} or \code{"Amean"} for \code{"AveExpr"}, \code{"T"} for \code{"t"} and \code{"p"} for \code{"P"}. Possibilities for \code{topTableF} are \code{"F"} or \code{"none"}. Possibilities for \code{topTreat} are as for \code{topTable} minus \code{"B"}.} \item{resort.by}{character string specifying statistic to sort the selected genes by in the output data.frame. Possibilities are the same as for \code{sort.by}.} \item{p.value}{cutoff value for adjusted p-values. Only genes with lower p-values are listed.} \item{lfc}{minimum absolute log2-fold-change required. \code{topTable} and \code{topTableF} include only genes with (at least one) absolute log-fold-changes greater than \code{lfc}. \code{topTreat} does not remove genes but ranks genes by evidence that their log-fold-change exceeds \code{lfc}.} \item{confint}{logical, should 95\% confidence intervals be output for \code{logFC}?} \item{...}{any other arguments are passed to \code{ebayes} if \code{eb} is \code{NULL}} } \value{ Produces a dataframe with a row for the \code{number} top genes and the following columns: \item{genelist}{one or more columns of probe annotation, if genelist was included as input} \item{logFC}{estimate of the log2-fold-change corresponding to the effect or contrast (for \code{topTableF} there may be several columns of log-fold-changes)} \item{CI.025}{left limit of confidence interval for \code{logFC} (if \code{confint=TRUE})} \item{CI.975}{right limit of confidence interval for \code{logFC} (if \code{confint=TRUE})} \item{AveExpr}{average log2-expression for the probe over all arrays and channels, same as \code{Amean} in the \code{MarrayLM} object} \item{t}{moderated t-statistic (omitted for \code{topTableF})} \item{F}{moderated F-statistic (omitted for \code{topTable} unless more than one coef is specified)} \item{P.Value}{raw p-value} \item{adj.P.Value}{adjusted p-value or q-value} \item{B}{log-odds that the gene is differentially expressed (omitted for \code{topTreat})} } \details{ \code{toptable} is an earlier interface and is retained only for backward compatibility. This function summarizes a linear model fit object produced by \code{lmFit}, \code{lm.series}, \code{gls.series} or \code{mrlm} by selecting the top-ranked genes for any given contrast. \code{topTable} and \code{topTableF} assume that the linear model fit has already been processed by \code{\link{eBayes}}. \code{topTreat} assumes that the fit has been processed by \code{\link{treat}}. The p-values for the coefficient/contrast of interest are adjusted for multiple testing by a call to \code{\link[stats]{p.adjust}}. The \code{"BH"} method, which controls the expected false discovery rate (FDR) below the specified value, is the default adjustment method because it is the most likely to be appropriate for microarray studies. Note that the adjusted p-values from this method are bounds on the FDR rather than p-values in the usual sense. Because they relate to FDRs rather than rejection probabilities, they are sometimes called q-values. See \code{help("p.adjust")} for more information. Note, if there is no good evidence for differential expression in the experiment, that it is quite possible for all the adjusted p-values to be large, even for all of them to be equal to one. It is quite possible for all the adjusted p-values to be equal to one if the smallest p-value is no smaller than \code{1/ngenes} where \code{ngenes} is the number of genes with non-missing p-values. The \code{sort.by} argument specifies the criterion used to select the top genes. The choices are: \code{"logFC"} to sort by the (absolute) coefficient representing the log-fold-change; \code{"A"} to sort by average expression level (over all arrays) in descending order; \code{"T"} or \code{"t"} for absolute t-statistic; \code{"P"} or \code{"p"} for p-values; or \code{"B"} for the \code{lods} or B-statistic. Normally the genes appear in order of selection in the output table. If a different order is wanted, then the \code{resort.by} argument may be useful. For example, \code{topTable(fit, sort.by="B", resort.by="logFC")} selects the top genes according to log-odds of differential expression and then orders the selected genes by log-ratio in decreasing order. Or \code{topTable(fit, sort.by="logFC", resort.by="logFC")} would select the genes by absolute log-fold-change and then sort them from most positive to most negative. \code{topTableF} ranks genes on the basis of moderated F-statistics for one or more coefficients. If \code{topTable} is called and \code{coef} has two or more elements, then the specified columns will be extracted from \code{fit} and \code{topTableF} called on the result. \code{topTable} with \code{coef=NULL} is the same as \code{topTableF}, unless the fitted model \code{fit} has only one column. Toptable output for all probes in original (unsorted) order can be obtained by \code{topTable(fit,sort="none",n=Inf)}. However \code{\link{write.fit}} or \code{\link{write}} may be preferable if the intention is to write the results to a file. A related method is \code{as.data.frame(fit)} which coerces an \code{MArrayLM} object to a data.frame. By default \code{number} probes are listed. Alternatively, by specifying \code{p.value} and \code{number=Inf}, all genes with adjusted p-values below a specified value can be listed. The argument \code{lfc} gives the ability to filter genes by log-fold change. This argument is not available for \code{topTreat} because \code{treat} already handles fold-change thresholding in a more sophisticated way. } \seealso{ An overview of linear model and testing functions is given in \link{06.LinearModels}. See also \code{\link[stats]{p.adjust}} in the \code{stats} package. } \author{Gordon Smyth} \examples{ # See lmFit examples } \keyword{htest} limma/man/09Diagnostics.Rd0000644007451300017500000000475412127125247015507 0ustar charlescharles\name{09.Diagnostics} \alias{09.Diagnostics} \title{Diagnostics and Quality Assessment} \description{ This page gives an overview of the LIMMA functions available for microarray quality assessment and diagnostic plots. This package provides an \code{\link[limma:anova-method]{anova}} method which is designed for assessing the quality of an array series or of a normalization method. It is not designed to assess differential expression of individual genes. \code{\link[limma:anova-method]{anova}} uses utility functions \code{\link{bwss}} and \code{\link{bwss.matrix}}. The function \code{\link{arrayWeights}} estimates the empirical reliability of each array following a linear model fit. Diagnostic plots can be produced by \describe{ \item{ \code{\link{imageplot}} }{ Produces a spatial picture of any spot-specific measure from an array image. If the log-ratios are plotted, then this produces an in-silico representation of the well known false-color TIFF image of an array. \code{\link{imageplot3by2}} will write imageplots to files, six plots to a page.} \item{ \code{\link{plotFB}} }{ Plots foreground versus background log-intensies for a two-color array.} \item{ \code{\link{plotMA}} }{ MA-plots. One of the most useful plots of a two-color array. \code{\link{plotMA3by2}} will write MA-plots to files, six plots to a page. \code{\link{mdplot}} can also be useful for comparing two one-channel microarrays.} \item{ \code{\link{plotPrintTipLoess}} }{ Produces a grid of MA-plots, one for each print-tip group on an array, together with the corresponding lowess curve. Intended to help visualize print-tip loess normalization.} \item{ \code{\link{plotPrintorder}} }{ For an array, produces a scatter plot of log-ratios or log-intensities by print order.} \item{ \code{\link{plotDensities}} }{ Individual channel densities for one or more arrays. An essential plot to accompany between array normalization, especially quantile normalization.} \item{ \code{\link{plotMDS}} }{ Multidimensional scaling plot for a set of arrays. Useful for visualizing the relationship between the set of samples.} \item{ \code{\link{plotSA}} }{ Sigma vs A plot. After a linear model is fitted, this checks constancy of the variance with respect to intensity level.} } \code{plotPrintTipLoess} uses utility functions \code{\link{gridr}} and \code{\link{gridc}}. \code{\link{plotDensities}} uses utility function \code{\link{RG.MA}}. } \author{Gordon Smyth} \keyword{documentation} limma/man/06linearmodels.Rd0000644007451300017500000001364112127125247015706 0ustar charlescharles\name{06.LinearModels} \alias{06.LinearModels} \title{Linear Models for Microarrays} \description{ This page gives an overview of the LIMMA functions available to fit linear models and to interpret the results. This page covers models for two color arrays in terms of log-ratios or for single-channel arrays in terms of log-intensities. If you wish to fit models to the individual channel log-intensities from two colour arrays, see \link{07.SingleChannel}. The core of this package is the fitting of gene-wise linear models to microarray data. The basic idea is to estimate log-ratios between two or more target RNA samples simultaneously. See the LIMMA User's Guide for several case studies. } \section{Fitting Models}{ The main function for model fitting is \code{\link{lmFit}}. This is recommended interface for most users. \code{lmFit} produces a fitted model object of class \code{\link[limma:marraylm]{MArrayLM}} containing coefficients, standard errors and residual standard errors for each gene. \code{lmFit} calls one of the following three functions to do the actual computations: \describe{ \item{ \code{\link{lm.series}} }{ Straightforward least squares fitting of a linear model for each gene.} \item{ \code{\link{mrlm}} }{ An alternative to \code{lm.series} using robust regression as implemented by the \code{rlm} function in the MASS package.} \item{ \code{\link{gls.series}} }{ Generalized least squares taking into account correlations between duplicate spots (i.e., replicate spots on the same array) or related arrays. The function \code{\link{duplicateCorrelation}} is used to estimate the inter-duplicate or inter-block correlation before using \code{gls.series}.} } All the functions which fit linear models use \code{link{getEAW}} to extract data from microarray data objects, and \code{\link{unwrapdups}} which provides an unified method for handling duplicate spots. } \section{Forming the Design Matrix}{ \code{lmFit} has two main arguments, the expression data and the design matrix. The design matrix is essentially an indicator matrix which specifies which target RNA samples were applied to each channel on each array. There is considerable freedom in choosing the design matrix - there is always more than one choice which is correct provided it is interpreted correctly. Design matrices for Affymetrix or single-color arrays can be created using the function \code{\link[stats]{model.matrix}} which is part of the R base package. The function \code{\link{modelMatrix}} is provided to assist with creation of an appropriate design matrix for two-color microarray experiments. For direct two-color designs, without a common reference, the design matrix often needs to be created by hand. } \section{Making Comparisons of Interest}{ Once a linear model has been fit using an appropriate design matrix, the command \code{\link{makeContrasts}} may be used to form a contrast matrix to make comparisons of interest. The fit and the contrast matrix are used by \code{\link{contrasts.fit}} to compute fold changes and t-statistics for the contrasts of interest. This is a way to compute all possible pairwise comparisons between treatments for example in an experiment which compares many treatments to a common reference. } \section{Assessing Differential Expression}{ After fitting a linear model, the standard errors are moderated using a simple empirical Bayes model using \code{\link{eBayes}} or \code{\link{treat}}. \code{\link{ebayes}} is an older version of \code{eBayes}. A moderated t-statistic and a log-odds of differential expression is computed for each contrast for each gene. \code{treat} tests whether log-fold-changes are greater than a threshold rather than merely different to zero. \code{\link{eBayes}} and \code{\link{eBayes}} use internal functions \code{\link{squeezeVar}}, \code{\link{fitFDist}}, \code{\link{tmixture.matrix}} and \code{\link{tmixture.vector}}. The function \code{\link{zscoreT}} is sometimes used for computing z-score equivalents for t-statistics so as to place t-statistics with different degrees of freedom on the same scale. \code{\link{zscoreGamma}} is used the same way with standard deviations instead of t-statistics. These functions are for research purposes rather than for routine use. } \section{Summarizing Model Fits}{ After the above steps the results may be displayed or further processed using: \describe{ \item{ \code{\link{toptable}} or \code{\link{topTable}} }{ Presents a list of the genes most likely to be differentially expressed for a given contrast.} \item{ \code{\link{topTableF}} }{ Presents a list of the genes most likely to be differentially expressed for a given set of contrasts.} \item{ \code{\link{volcanoplot}}}{ Volcano plot of fold change versus the B-statistic for any fitted coefficient.} \item{ \code{\link{plotlines}}}{ Plots fitted coefficients or log-intensity values for time-course data.} \item{ \code{\link{write.fit}} }{ Writes an \code{MarrayLM} object to a file. Note that if \code{fit} is an \code{MArrayLM} object, either \code{write.fit} or \code{write.table} can be used to write the results to a delimited text file.} } For multiple testing functions which operate on linear model fits, see \link{08.Tests}. } \section{Model Selection}{ \code{\link{selectModel}} provides a means to choose between alternative linear models using AIC or BIC information criteria. } \author{Gordon Smyth} \references{ Smyth, G. K. (2004). Linear models and empirical Bayes methods for assessing differential expression in microarray experiments. \emph{Statistical Applications in Genetics and Molecular Biology}, \bold{3}, No. 1, Article 3. \url{http://www.bepress.com/sagmb/vol3/iss1/art3} Smyth, G. K., Michaud, J., and Scott, H. (2005). The use of within-array replicate spots for assessing differential expression in microarray experiments. Bioinformatics 21(9), 2067-2075. } \keyword{documentation} limma/man/voom.Rd0000644007451300017500000000776512145542372014056 0ustar charlescharles\name{voom} \alias{voom} \title{Transform RNA-Seq Data Ready for Linear Modelling} \description{ Transform count data to log2-counts per million (logCPM), estimate the mean-variance relationship and use this to compute appropriate observational-level weights. The data are then ready for linear modelling. } \usage{ voom(counts, design = NULL, lib.size = NULL, normalize.method = "none", plot = FALSE, span=0.5, ...) } \arguments{ \item{counts}{a numeric \code{matrix} containing raw counts, or an \code{ExpressionSet} containing raw counts, or a \code{DGEList} object.} \item{design}{design matrix with rows corresponding to samples and columns to coefficients to be estimated. Defaults to the unit vector meaning that samples are treated as replicates.} \item{lib.size}{numeric vector containing total library sizes for each sample. If \code{NULL} and \code{counts} is a \code{DGEList} then, then normalized library sizes are taken from \code{counts}. Otherwise library sizes are calculated from the columnwise counts totals.} \item{normalize.method}{normalization method to be applied to the logCPM values. Choices are as for the \code{method} argument of \code{normalizeBetweenArrays} when the data is single-channel.} \item{plot}{\code{logical}, should a plot of the mean-variance trend be displayed?} \item{span}{width of the lowess smoothing window as a proportion.} \item{...}{other arguments are passed to \code{lmFit}.} } \details{ This function is intended to process RNA-Seq or ChIP-Seq data prior to linear modelling in limma. \code{voom} is an acronym for mean-variance modelling at the observational level. The key concern is to estimate the mean-variance relationship in the data, then use this to compute appropriate weights for each observation. Count data almost show non-trivial mean-variance relationships. Raw counts show increasing variance with increasing count size, while log-counts typically show a decreasing mean-variance trend. This function estimates the mean-variance trend for log-counts, then assigns a weight to each observation based on its predicted variance. The weights are then used in the linear modelling process to adjust for heteroscedasticity. In an experiment, a count value is observed for each tag in each sample. A tag-wise mean-variance trend is computed using \code{\link{lowess}}. The tag-wise mean is the mean log2 count with an offset of 0.5, across samples for a given tag. The tag-wise variance is the quarter-root-variance of normalized log2 counts per million values with an offset of 0.5, across samples for a given tag. Tags with zero counts across all samples are not included in the lowess fit. Optional normalization is performed using \code{\link{normalizeBetweenArrays}}. Using fitted values of log2 counts from a linear model fit by \code{\link{lmFit}}, variances from the mean-variance trend were interpolated for each observation. This was carried out by \code{\link{approxfun}}. Inverse variance weights can be used to correct for mean-variance trend in the count data. } \value{ An \code{\link[limma:EList]{EList}} object with the following components: \item{E}{numeric matrix of normalized expression values on the log2 scale} \item{weights}{numeric matrix of inverse variance weights} \item{design}{design matrix} \item{lib.size}{numeric vector of total normalized library sizes} \item{genes}{dataframe of gene annotation extracted from \code{counts}} } \author{Charity Law and Gordon Smyth} \references{ Law, CW (2013). \emph{Precision weights for gene expression analysis}. PhD Thesis. University of Melbourne, Australia. Law, CW, Chen, Y, Shi, W, Smyth, GK (2013). Voom! Precision weights unlock linear model analysis tools for RNA-seq read counts. Technical Report 1 May 2013, Bioinformatics Division, Walter and Eliza Hall Institute of Medical Reseach, Melbourne, Australia. \url{http://www.statsci.org/smyth/pubs/VoomPreprint.pdf} } \seealso{ A \code{voom} case study is given in the User's Guide. \code{\link{vooma}} is a similar function but for microarrays instead of RNA-seq. } limma/man/asmalist.Rd0000755007451300017500000000100212127125247014666 0ustar charlescharles\name{as.MAList} \alias{as.MAList} \title{Convert marrayNorm Object to an MAList Object} \description{ Convert marrayNorm Object to an MAList Object } \usage{ as.MAList(object) } \arguments{ \item{object}{an \code{\link[marray:marrayNorm-class]{marrayNorm}} object} } \value{ Object of class \code{\link[=MAList-class]{MAList}} } \author{Gordon Smyth} \seealso{ \link{02.Classes} gives an overview of all the classes defined by this package. } \keyword{classes} \keyword{data} limma/man/arrayWeightsQuick.Rd0000644007451300017500000000235412127125247016527 0ustar charlescharles\name{arrayWeightsQuick} \alias{arrayWeightsQuick} \title{Array Quality Weights} \description{ Estimates relative quality weights for each array in a multi-array experiment with replication. } \usage{ arrayWeightsQuick(y, fit) } \arguments{ \item{y}{the data object used to estimate \code{fit}. Can be of any class which can be coerced to matrix, including \code{matrix}, \code{MAList}, \code{marrayNorm} or \code{ExpressionSet}.} \item{fit}{\code{MArrayLM} fitted model object} } \details{ Estimates the relative reliability of each array by measuring how well the expression values for that array follow the linear model. This is a quick and dirty version of \code{\link{arrayWeights}}. } \value{ Numeric vector of weights of length \code{ncol(fit)}. } \references{ Ritchie, M. E., Diyagama, D., Neilson, van Laar, R., J., Dobrovic, A., Holloway, A., and Smyth, G. K. (2006). Empirical array quality weights for microarray data. BMC Bioinformatics. (Accepted 11 April 2006) } \author{Gordon Smyth} \seealso{ See \link{arrayWeights}. An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \examples{ \dontrun{ fit <- lmFit(y, design) arrayWeightsQuick(y, fit) } } \keyword{regression} limma/man/squeezeVar.Rd0000755007451300017500000000577312127125247015226 0ustar charlescharles\name{squeezeVar} \alias{squeezeVar} \title{Squeeze Sample Variances} \description{ Squeeze a set of sample variances together by computing empirical Bayes posterior means. } \usage{ squeezeVar(var, df, covariate=NULL, robust=FALSE, winsor.tail.p=c(0.05,0.1)) } \arguments{ \item{var}{numeric vector of independent sample variances.} \item{df}{numeric vector of degrees of freedom for the sample variances.} \item{covariate}{if non-\code{NULL}, \code{var.prior} will depend on this numeric covariate. Otherwise, \code{var.prior} is constant.} \item{robust}{logical, should the estimation of \code{df.prior} and \code{var.prior} be robustified against outlier sample variances?} \item{winsor.tail.p}{numeric vector of length 1 or 2, giving left and right tail proportions of \code{x} to Winsorize. Used only when \code{robust=TRUE}.} } \details{ This function implements an empirical Bayes algorithm proposed by Smyth (2004). A conjugate Bayesian hierarchical model is assumed for a set of sample variances. The hyperparameters are estimated by fitting a scaled F-distribution to the sample variances. The function returns the posterior variances and the estimated hyperparameters. Specifically, the sample variances \code{var} are assumed to follow scaled chi-squared distributions, conditional on the true variances, and an scaled inverse chi-squared prior is assumed for the true variances. The scale and degrees of freedom of this prior distribution are estimated from the values of \code{var}. The effect of this function is to squeeze the variances towards a common value. The squeezed variances have a smaller expected mean square error to the true variances than do the sample variances themselves. } \note{ This function is called by \code{eBayes}, but beware a possible confusion with the output from that function. The values \code{var.prior} and \code{var.post} output by \code{squeezeVar} correspond to the quantities \code{s2.prior} and \code{s2.post} output by \code{eBayes}, whereas \code{var.prior} output by \code{eBayes} relates to a different parameter. } \value{ A list with components \item{var.post}{numeric vector of posterior variances.} \item{var.prior}{location of prior distribution. A vector if \code{covariate} is non-\code{NULL}, otherwise a scalar.} \item{df.prior}{degrees of freedom of prior distribution. A vector if \code{robust=TRUE}, otherwise a scalar.} } \author{Gordon Smyth} \references{ Smyth, G. K. (2004). Linear models and empirical Bayes methods for assessing differential expression in microarray experiments. \emph{Statistical Applications in Genetics and Molecular Biology}, \bold{3}, No. 1, Article 3. \url{http://www.bepress.com/sagmb/vol3/iss1/art3} } \seealso{ This function is called by \code{\link{ebayes}}. This function calls \code{\link{fitFDist}}. An overview of linear model functions in limma is given by \link{06.LinearModels}. } \examples{ s2 <- rchisq(20,df=5)/5 squeezeVar(s2, df=5) } \keyword{htest} limma/man/dimnames.Rd0000755007451300017500000000244212127125247014657 0ustar charlescharles\name{dimnames} \alias{dimnames.RGList} \alias{dimnames.MAList} \alias{dimnames.EListRaw} \alias{dimnames.EList} \alias{dimnames.MArrayLM} \alias{dimnames<-.RGList} \alias{dimnames<-.MAList} \alias{dimnames<-.EList} \alias{dimnames<-.EListRaw} \title{Retrieve the Dimension Names of an RGList, MAList, EList, EListRaw or MArrayLM Object} \description{ Retrieve the dimension names of a microarray data object. } \usage{ \method{dimnames}{RGList}(x) \method{dimnames}{RGList}(x) <- value } \arguments{ \item{x}{an object of class \code{RGList}, \code{MAList}, \code{EList}, \code{EListRaw} or (not for assignment) \code{MArrayLM}} \item{value}{a possible value for \code{dimnames(x)}: see \code{\link{dimnames}}} } \details{ The dimension names of a microarray object are the same as those of the most important matrix component of that object. A consequence is that \code{rownames} and \code{colnames} will work as expected. } \value{ Either \code{NULL} or a list of length 2. If a list, its components are either \code{NULL} or a character vector the length of the appropriate dimension of \code{x}. } \author{Gordon Smyth} \seealso{ \code{\link[base]{dimnames}} in the base package. \link{02.Classes} gives an overview of data classes used in LIMMA. } \keyword{array} limma/man/geneSetTest.Rd0000755007451300017500000001673512127125247015326 0ustar charlescharles\name{geneSetTest} \alias{geneSetTest} \alias{wilcoxGST} \title{Mean-rank Gene Set Test} \description{ Test whether a set of genes is highly ranked relative to other genes in terms of a given statistic. Genes are assumed to be independent. } \usage{ geneSetTest(index, statistics, alternative="mixed", type="auto", ranks.only=TRUE, nsim=9999) wilcoxGST(index, statistics, ...) } \arguments{ \item{index}{index vector for the gene set. This can be a vector of indices, or a logical vector of the same length as \code{statistics} or, in general, any vector such that \code{statistic[index]} gives the statistic values for the gene set to be tested.} \item{statistics}{vector, any genewise statistic by which genes can be ranked.} \item{alternative}{character string specifying the alternative hypothesis, must be one of \code{"mixed"}, \code{"either"}, \code{"up"} or \code{"down"}. \code{"two.sided"}, \code{"greater"} and \code{"less"} are also permitted as synonyms for \code{"either"}, \code{"up"} and \code{"down"} respectively.} \item{type}{character string specifying whether the statistics are signed (t-like, \code{"t"}) or unsigned (F-like, \code{"f"}) or whether the function should make an educated guess (\code{"auto"}). If the statistic is unsigned, then it assume that larger statistics are more significant.} \item{ranks.only}{logical, if \code{TRUE} only the ranks of the \code{statistics} are used.} \item{nsim}{number of random samples to take in computing the p-value. Not used if \code{ranks.only=TRUE}.} \item{\ldots}{other arguments are passed to \code{geneSetTest}.} } \value{ numeric value giving the estimated p-value. } \details{ These functions compute a p-value to test the hypothesis that the indexed test set of genes tends to be more highly ranked in terms of some test statistic compared to randomly chosen genes. The statistic might be any statistic of interest, for example a t-statistic or F-statistic for differential expression. Like all gene set tests, these functions can be used to detect differential expression for a group of genes, even when the effects are too small or there is too little data to detect the genes individually. \code{wilcoxGST} is a synonym for \code{geneSetTest} with \code{ranks.only=TRUE}. This version of the test procedure was developed by Michaud et al (2008), who called it \emph{mean-rank gene-set enrichment}. \code{geneSetTest} performs a \emph{competitive} test in the sense that genes in the test set are compared to other genes (Goeman and Buhlmann, 2007). If the \code{statistic} is a genewise test statistic for differential expression, then \code{geneSetTest} tests whether genes in the set are more differentially expressed than genes not in the set. By contrast, a \emph{self-contained} gene set test such as \code{\link{roast}} tests whether genes in the test set are differentially expressed, in an absolute sense, without regard to any other genes on the array. Because it is based on permuting genes, \code{geneSetTest} assumes that the different genes (or probes) are statistically independent. (Strictly speaking, it assumes that the genes in the set are no more correlated on average than randomly chosen genes.) If inter-gene correlations are present, then a statistically significant result from \code{geneSetTest} indicates either that the set is highly ranked or that the genes in the set are positively correlated on average (Wu and Smyth, 2012). Unless gene sets with positive correlations are particularly of interest, it may be advisable to use \code{\link{camera}} instead to adjust the test for inter-gene correlations. Inter-gene correlations are likely to be present in differential expression experiments with biologically heterogeneous experimental units. On the other hand, the assumption of independence between genes should hold when the replicates are purely technical, i.e., when there is no biological variability between the replicate arrays in each experimental condition. The \code{statistics} are usually a set of probe-wise statistics arising for some comparison from a microarray experiment. They may be t-statistics, meaning that the genewise null hypotheses would be rejected for large positive or negative values, or they may be F-statistics, meaning that only large values are significant. Any set of signed statistics, such as log-ratios, M-values or moderated t-statistics, are treated as t-like. Any set of unsigned statistics, such as F-statistics, posterior probabilities or chi-square tests are treated as F-like. If \code{type="auto"} then the statistics will be taken to be t-like if they take both positive and negative values and will be taken to be F-like if they are all of the same sign. There are four possible alternatives to test for. \code{alternative=="up"} means the genes in the set tend to be up-regulated, with positive t-statistics. \code{alternative=="down"} means the genes in the set tend to be down-regulated, with negative t-statistics. \code{alternative=="either"} means the set is either up or down-regulated as a whole. \code{alternative=="mixed"} test whether the genes in the set tend to be differentially expressed, without regard for direction. In this case, the test will be significant if the set contains mostly large test statistics, even if some are positive and some are negative. The latter three alternatives are appropriate if you have a prior expection that all the genes in the set will react in the same direction. The \code{"mixed"} alternative is appropriate if you know only that the genes are involved in the relevant pathways, possibly in different directions. The \code{"mixed"} is the only meaningful alternative with F-like statistics. The test statistic used for the gene-set-test is the mean of the statistics in the set. If \code{ranks.only} is \code{TRUE} the only the ranks of the statistics are used. In this case the p-value is obtained from a Wilcoxon test. If \code{ranks.only} is \code{FALSE}, then the p-value is obtained by simulation using \code{nsim} random sets of genes. } \note{ This function does not does correct for inter-gene correlation, so it is more likely to assign small p-values to sets containing positive correlated genes. For this reason, the alternative \code{camera} is now recommended over \code{geneSetTest} in those contexts for which \code{camera} is applicable. } \seealso{ \code{\link{camera}}, \code{\link{roast}}, \code{\link{romer}}, \code{\link{wilcox.test}}, \code{\link{barcodeplot}} An overview of tests in limma is given in \link{08.Tests}. } \author{Gordon Smyth and Di Wu} \references{ Wu, D, and Smyth, GK (2012). Camera: a competitive gene set test accounting for inter-gene correlation. \emph{Nucleic Acids Research}, doi: 10.1093/nar/gks461. \url{http://nar.oxfordjournals.org/content/early/2012/05/24/nar.gks461.abstract} Goeman, JJ, and Buhlmann P (2007). Analyzing gene expression data in terms of gene sets: methodological issues. \emph{Bioinformatics} 23, 980-987. Michaud, J, Simpson, KM, Escher, R, Buchet-Poyau, K, Beissbarth, T, Carmichael, C, Ritchie, ME, Schutz, F, Cannon, P, Liu, M, Shen, X, Ito, Y, Raskind, WH, Horwitz, MS, Osato, M, Turner, DR, Speed, TP, Kavallaris, M, Smyth, GK, and Scott, HS (2008). Integrative analysis of RUNX1 downstream pathways and target genes. \emph{BMC Genomics} 9, 363. \url{http://www.biomedcentral.com/1471-2164/9/363} } \examples{ stat <- rnorm(100) sel <- 1:10; stat[sel] <- stat[sel]+1 wilcoxGST(sel,stat) } \keyword{htest} limma/man/normalizeWithinArrays.Rd0000755007451300017500000001407412127125247017433 0ustar charlescharles\name{normalizeWithinArrays} \alias{normalizeWithinArrays} \alias{MA.RG} \alias{RG.MA} \title{Normalize Within Arrays} \description{ Normalize the expression log-ratios for one or more two-colour spotted microarray experiments so that the log-ratios average to zero within each array or sub-array. } \usage{ normalizeWithinArrays(object, layout, method="printtiploess", weights=object$weights, span=0.3, iterations=4, controlspots=NULL, df=5, robust="M", bc.method="subtract", offset=0) MA.RG(object, bc.method="subtract", offset=0) RG.MA(object) } \arguments{ \item{object}{object of class \code{list}, \code{RGList} or \code{MAList} containing red and green intensities constituting two-color microarray data.} \item{layout}{list specifying the dimensions of the spot matrix and the grid matrix. For details see \code{\link[limma:PrintLayout]{PrintLayout-class}}.} \item{method}{character string specifying the normalization method. Choices are \code{"none"}, \code{"median"}, \code{"loess"}, \code{"printtiploess"}, \code{"composite"}, \code{"control"} and \code{"robustspline"}. A partial string sufficient to uniquely identify the choice is permitted.} \item{weights}{numeric matrix or vector of the same size and shape as the components of \code{object} containing spot quality weights.} \item{span}{numeric scalar giving the smoothing parameter for the \code{loess} fit} \item{iterations}{number of iterations used in loess fitting. More iterations give a more robust fit.} \item{controlspots}{numeric or logical vector specifying the subset of spots which are non-differentially-expressed control spots, for use with \code{method="composite"} or \code{method="control"}.} \item{df}{degrees of freedom for spline if \code{method="robustspline"}.} \item{robust}{robust regression method if \code{method="robustspline"}. Choices are \code{"M"} or \code{"MM"}.} \item{bc.method}{character string specifying background correct method, see \code{\link{backgroundCorrect}} for options.} \item{offset}{numeric value, intensity offset used when computing log-ratios, see \code{\link{backgroundCorrect}}.} } \details{ Normalization is intended to remove from the expression measures any systematic trends which arise from the microarray technology rather than from differences between the probes or between the target RNA samples hybridized to the arrays. This function normalizes M-values (log-ratios) for dye-bias within each array. Apart from \code{method="none"} and \code{method="median"}, all the normalization methods make use of the relationship between dye-bias and intensity. Method \code{"none"} computes M-values and A-values but does no normalization. Method \code{"median"} subtracts the weighted median from the M-values for each array. The loess normalization methods (\code{"loess"}, \code{"printtiploess"} and \code{"composite"}) were proposed by Yang et al (2001, 2002). Smyth and Speed (2003) review these methods and describe how the methods are implemented in the limma package, including choices of tuning parameters. More information on the loess control parameters \code{span} and \code{iterations} can be found under \code{\link{loessFit}}. The default values used here are equivalent to those for the older function \code{stat.ma} in the sma package. Oshlack et al (2004) consider the special issues that arise when a large proportion of probes are differentially expressed. They propose an improved version of composite loess normalization, which is implemented in the \code{"control"} method. This fits a global loess curve through a set of control spots, such as a whole-library titration series, and applies that curve to all the other spots. The \code{"robustspline"} method calls \code{\link{normalizeRobustSpline}}. See that function for more documentation. \code{MA.RG} converts an unlogged \code{RGList} object into an \code{MAList} object. \code{MA.RG(object)} is equivalent to \code{normalizeWithinArrays(object,method="none")}. \code{RG.MA(object)} converts back from an \code{MAList} object to a \code{RGList} object with unlogged intensities. \code{weights} is normally a matrix giving a quality weight for every spot on every array. If \code{weights} is instead a vector or a matrix with only one column, then the weights will be assumed to be the same for every array, i.e., the weights will be probe-specific rather than spot-specific. } \value{ An object of class \code{\link[limma:malist]{MAList}}. Any components found in \code{object} will preserved except for \code{R}, \code{G}, \code{Rb}, \code{Gb} and \code{other}. } \author{Gordon Smyth} \references{ Oshlack, A., Emslie, D., Corcoran, L., and Smyth, G. K. (2007). Normalization of boutique two-color microarrays with a high proportion of differentially expressed probes. \emph{Genome Biology} \bold{8}, R2. Smyth, G. K., and Speed, T. P. (2003). Normalization of cDNA microarray data. \emph{Methods} \bold{31}, 265-273. Yang, Y. H., Dudoit, S., Luu, P., and Speed, T. P. (2001). Normalization for cDNA microarray data. In \emph{Microarrays: Optical Technologies and Informatics}, M. L. Bittner, Y. Chen, A. N. Dorsel, and E. R. Dougherty (eds), Proceedings of SPIE, Vol. 4266, pp. 141-152. Yang, Y. H., Dudoit, S., Luu, P., Lin, D. M., Peng, V., Ngai, J., and Speed, T. P. (2002). Normalization for cDNA microarray data: a robust composite method addressing single and multiple slide systematic variation. \emph{Nucleic Acids Research} \bold{30}(4):e15. } \seealso{ An overview of limma functions for normalization is given in \link{05.Normalization}. In particular, see \code{\link{normalizeBetweenArrays}} for between-array normalization. The original loess normalization function was the \code{statma} funtion in the sma package. \code{normalizeWithinArrays} is a direct generalization of that function, with more options and with support for quantitative spot quality weights. A different implementation of loess normalization methods, with potentially different behavior, is provided by the \code{\link[marray:maNorm]{maNorm}} in the marray package. } \keyword{models} limma/man/imageplot.Rd0000755007451300017500000000753112127125247015047 0ustar charlescharles\title{Image Plot of Microarray Statistics} \name{imageplot} \alias{imageplot} \description{ Creates an image of colors or shades of gray that represent the values of a statistic for each spot on a spotted microarray. This function can be used to explore any spatial effects across the microarray. } \usage{ imageplot(z, layout, low = NULL, high = NULL, ncolors = 123, zerocenter = NULL, zlim = NULL, mar=c(2,1,1,1), legend=TRUE, ...) } \arguments{ \item{z}{numeric vector or array. This vector can contain any spot statistics, such as log intensity ratios, spot sizes or shapes, or t-statistics. Missing values are allowed and will result in blank spots on the image. Infinite values are not allowed.} \item{layout}{a list specifying the dimensions of the spot matrix and the grid matrix.} \item{low}{color associated with low values of \code{z}. May be specified as a character string such as \code{"green"}, \code{"white"} etc, or as a rgb vector in which \code{c(1,0,0)} is red, \code{c(0,1,0)} is green and \code{c(0,0,1)} is blue. The default value is \code{"green"} if \code{zerocenter=T} or \code{"white"} if \code{zerocenter=F}.} \item{high}{color associated with high values of \code{z}. The default value is \code{"red"} if \code{zerocenter=T} or \code{"blue"} if \code{zerocenter=F}.} \item{ncolors}{number of color shades used in the image including low and high.} \item{zerocenter}{should zero values of \code{z} correspond to a shade exactly halfway between the colors low and high? The default is TRUE if \code{z} takes positive and negative values, otherwise FALSE.} \item{zlim}{numerical vector of length 2 giving the extreme values of \code{z} to associate with colors \code{low} and \code{high}. By default \code{zlim} is the range of \code{z}. Any values of \code{z} outside the interval \code{zlim} will be truncated to the relevant limit.} \item{mar}{numeric vector of length 4 specifying the width of the margin around the plot. This argument is passed to \code{\link[graphics]{par}}.} \item{legend}{logical, if \code{TRUE} the range of \code{z} and \code{zlim} is shown in the bottom margin} \item{...}{any other arguments will be passed to the function image} } \details{ This function may be used to plot the values of any spot-specific statistic, such as the log intensity ratio, background intensity or a quality measure such as spot size or shape. The image follows the layout of an actual microarray slide with the bottom left corner representing the spot (1,1,1,1). The color range is used to represent the range of values for the statistic. When this function is used to plot the red/green log-ratios, it is intended to be an in silico version of the classic false-colored red-yellow-green image of a scanned two-color microarray. This function is related to the earlier \code{plot.spatial} function in the \code{sma} package and to the later \code{maImage} function in the \code{marray} package. It differs from \code{plot.spatial} most noticeably in that all the spots are plotted and the image is plotted from bottom left rather than from top left. It is intended to display spatial patterns and artefacts rather than to highlight only the extreme values as does \code{plot.spatial}. It differs from \code{maImage} in that any statistic may be plotted and in its use of a red-yellow-green color scheme for log-ratios, similar to the classic false-colored jpeg image, rather than the red-black-green color scheme associated with heat maps. } \value{An plot is created on the current graphics device.} \author{Gordon Smyth} \seealso{ \code{\link[marray]{maImage}}, \code{\link[graphics]{image}}. An overview of diagnostic functions available in LIMMA is given in \link{09.Diagnostics}. } \examples{ M <- rnorm(8*4*16*16) imageplot(M,layout=list(ngrid.r=8,ngrid.c=4,nspot.r=16,nspot.c=16)) } \keyword{hplot} limma/man/removeext.Rd0000755007451300017500000000114112127125247015073 0ustar charlescharles\name{removeExt} \alias{removeExt} \title{Remove Common Extension from File Names} \description{Finds and removes any common extension from a vector of file names.} \usage{ removeExt(x) } \arguments{ \item{x}{character vector} } \value{ A character vector of the same length as \code{x} in which any common extension has been stripped off. } \seealso{ An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \examples{ x <- c("slide1.spot","slide2.spot","slide3.spot") removeExt(x) } \author{Gordon Smyth} \keyword{character} \keyword{file} limma/man/loessfit.Rd0000755007451300017500000000775112150771760014725 0ustar charlescharles\name{loessFit} \alias{loessFit} \title{Fast Simple Loess} \description{ Locally weighted linear regression when there is only one x-variable and only the fitted values and residuals are required. } \usage{ loessFit(y, x, weights=NULL, span=0.3, bin=NULL, iterations=4, min.weight=1e-5, max.weight=1e5, equal.weights.as.null=TRUE) } \arguments{ \item{y}{numeric vector of response values. Missing values are allowed.} \item{x}{numeric vector of predictor values Missing values are allowed.} \item{weights}{numeric vector of non-negative weights. Missing values are treated as zero.} \item{span}{positive numeric value between 0 and 1 specifying proportion of data to be used in the local regression moving window. Larger numbers give smoother fits.} \item{bin}{numeric value between 0 and 1 giving the proportion of the data that can be grouped in a single bin when doing local regression fit. \code{bin=0} forces an exact local regression fit with no interpolation. Default is 0.005 with weights and 0.01 without weights.} \item{iterations}{number of iterations of loess fit. Values greater than 1 produce robust fits.} \item{min.weight}{minimum weight. Any lower weights will be reset.} \item{max.weight}{maxium weight. Any higher weights will be reset.} \item{equal.weights.as.null}{should equal weights be treated as if weights were \code{NULL}, so that \code{lowess} is used instead of \code{loess}? Applies even all weights are all zero.} } \details{ This function calls the \code{lowess} function when \code{weights=NULL} and \code{stats:::simpleLoess} otherwise. Its purpose is to give a unified and streamlined interface to \code{lowess} and \code{loess} for use in \code{\link{normalizeWithinArrays}}. When \code{weights} is null, this function call \code{lowess} in the stats package with appropropriate choice of tuning parameters. When \code{weights} is non-null, it is in effect a call to \code{loess} with \code{degree=1}. See the help pages for those functions for references and credits. Note that \code{lowess} is faster, needs less memory and has a more accurate interpolation scheme than \code{loess}, so it is desirable to use \code{lowess} whenever \code{loess} is not needed to handle quantitative weights. The arguments \code{span}, \code{cell} and \code{iterations} here have the same meaning as in \code{loess}. \code{span} is equivalent to the argument \code{f} of \code{lowess} and \code{iterations} is equivalent to \code{iter+1}. The parameter \code{bin} is intended to give a uniform interface to the \code{delta} argument of \code{lowess} and the \code{cell} argument of \code{loess}. \code{bin} translates to \code{delta=bin*diff(range(x))} in a call to \code{lowess} or to \code{cell=bin/span} in a call to \code{loess}. This is an attempt to put the \code{delta} and \code{cell} arguments on comparable scales. Unlike \code{lowess}, \code{loessFit} returns values in original rather than sorted order. Also unlike \code{lowess}, \code{loessFit} allows missing values, the treatment being analogous to \code{na.exclude}. Unlike \code{loess}, \code{loessFit} returns a linear regression fit if there are insufficient observations to estimate the loess curve. } \value{ A list with components \item{fitted}{numeric vector of same length as \code{y} giving the loess fit} \item{residuals}{numeric vector of same length as \code{x} giving residuals from the fit} } \author{Gordon Smyth} \seealso{ \code{\link[stats]{lowess}} and \code{\link[stats]{loess}} in the stats package. See \link{05.Normalization} for an outline of the limma package normalization functions. } \examples{ y <- rnorm(1000) x <- rnorm(1000) w <- rep(1,1000) # The following are equivalent apart from execution time # and interpolation inaccuracies fit1 <- loessFit(y,x)$fitted fit2 <- loessFit(y,x,w)$fitted fit3 <- fitted(loess(y~x,weights=w,span=0.3,family="symmetric",iterations=4)) # The same but with sorted x-values fit4 <- lowess(x,y,f=0.3)$y } \keyword{models} limma/man/plotSA.Rd0000755007451300017500000000236112127125247014264 0ustar charlescharles\title{Sigma vs A plot for microarray linear model} \name{plotSA} \alias{plotSA} \description{ Plot log residual standard deviation versus average log expression for a fitted microarray linear model. } \usage{ plotSA(fit, xlab="Average log-expression", ylab="log2(sigma)", zero.weights=FALSE, pch=16, cex=0.2, ...) } \arguments{ \item{fit}{an \code{MArrayLM} object.} \item{xlab}{character string giving label for x-axis} \item{ylab}{character string giving label for y-axis} \item{pch}{vector or list of plotting characters. Default is integer code 16 which gives a solid circle.} \item{cex}{numeric expansion factor for plotting character. Defaults to 0.2.} \item{zero.weights}{logical, should spots with zero or negative weights be plotted?} \item{...}{any other arguments are passed to \code{plot}} } \details{ This plot is used to check the mean-variance relationship of the expression data, after fitting a linear model. See \code{\link[graphics]{points}} for possible values for \code{pch} and \code{cex}. } \value{A plot is created on the current graphics device.} \author{Gordon Smyth} \seealso{ An overview of diagnostic functions available in LIMMA is given in \link{09.Diagnostics}. } \keyword{hplot} limma/man/normexpfitdetectionp.Rd0000644007451300017500000001025512170636050017327 0ustar charlescharles\name{normexp.fit.detection.p} \alias{normexp.fit.detection.p} \title{Estimate Normexp Model Parameter Using Negative Controls Inferred from Regular Probes} \description{Detection p values from Illumina BeadChip microarray data can be used to infer negative control probe intensities from regular probe intensities by using detection p value information when negative control data are not available. The inferred negative control intensities can then be used in the background correction in the same way as those control data outputted from BeadChip used in the \code{\link{normexp.fit.control}} function. } \usage{ normexp.fit.detection.p(x, detection.p="Detection") } \arguments{ \item{x}{object of class \code{EListRaw-class} or \code{matrix} containing raw intensities of regular probes for a series of microarrays} \item{detection.p}{a character string giving the name of the component which contains detection p value information in \code{x} or a numeric matrix giving detection p values, \code{Detection} by default} } \details{ This function estimates the normexp parameters in the same way as \code{\link{normexp.fit.control}} does, except that negative control probe intensities are inferred from regular probes by taking advantage of detection p value information rather than from the control probe profile outputted by BeadStudio. Calculation of detection p values in Illumina BeadChip data is based on the rank of probe intensities in the list of negative control probe intensities. Therefore, the detection p values can be used to find regular probes which have expression intensities falling into the range of negative control probe intensities. These probes give a good approximation to the real negative control data and thus can be used to estimate the mean and standard deviation of background intensities when negative control data is not available. If \code{x} is an \code{EListRaw-class} object, this function will try to look for the component which includes detection p value matrix in \code{x} when \code{detection.p} is a character string. This function assumes that this component is located within the \code{other} component in \code{x}. The component name specified by \code{detection.p} should be exactly the same as the name of the detection p value component in \code{x}. If \code{detection.p} is a matrix, then this matrix will be used as the detection p value data used in this function. If \code{x} is an \code{matrix} object, then \code{detection.p} has to be a data matrix which includes detection p values. When \code{detection.p} is a \code{matrix}, it has to have the same dimension as that of \code{x}. This function will replace the detection p values with 1 subtracted by these values if high intensity probes have detection p values less than those from low intensity probes. Note that when control data are available, the \code{\link{normexp.fit.control}} function should be used instead. } \value{ A matrix containing estimated parameters with rows being arrays and with columns being parameters. Column names are \code{mu}, \code{logsigma} and \code{logalpha}. } \references{ Shi W, Oshlack A and Smyth GK (2010). Optimizing the noise versus bias trade-off for Illumina Whole Genome Expression BeadChips. \emph{Nucleic Acids Research} 38, e204. \url{http://nar.oxfordjournals.org/content/38/22/e204} } \author{Wei Shi and Gordon Smyth} \seealso{ \code{\link{nec}} calls this function to get the parameters of the normal+exponential convolution model when control probe profile file is not available and then calls \code{\link{normexp.signal}} to perform the background correction. \code{\link{normexp.fit.control}} estimates normexp parameters using control data outputted by BeadStudio. \code{\link{normexp.fit}} estimates normexp parameters using a saddle-point approximation or other mothods. An overview of background correction functions is given in \code{\link{04.Background}}. } \examples{ \dontrun{ # read in BeadChip data which do not have control data available x <- read.ilmn(files="sample probe profile") # estimated normexp parameters normexp.fit.detection.p(x) # normalization using inferred negative controls y <- neqc(x) } } \keyword{models} limma/man/modelMatrix.Rd0000755007451300017500000000526612127125247015356 0ustar charlescharles\name{modelMatrix} \alias{modelMatrix} \alias{uniqueTargets} \title{Construct Design Matrix} \description{ Construct design matrix from RNA target information for a two colour microarray experiment. } \usage{ modelMatrix(targets, parameters, ref, verbose=TRUE) uniqueTargets(targets) } \arguments{ \item{targets}{matrix or data.frame with columns \code{Cy3} and \code{Cy5} specifying which RNA was hybridized to each array} \item{parameters}{matrix specifying contrasts between RNA samples which should correspond to regression coefficients. Row names should correspond to unique RNA sample names found in \code{targets}.} \item{ref}{character string giving name of one of the RNA sources to be treated as reference. Exactly one argument of \code{parameters} or \code{ref} should be specified.} \item{verbose}{logical, if \code{TRUE} then unique names found in \code{targets} will be printed to standard output} } \details{ This function computes a design matrix for input to \code{lmFit} when analysing two-color microarray experiments in terms of log-ratios. If the argument \code{ref} is used, then the experiment is treated as a one-way layout and the coefficients measure expression changes relative to the RNA source specified by \code{ref}. The RNA source \code{ref} is often a common reference which appears on every array or is a control sample to which all the others are compared. There is no restriction however. One can choose \code{ref} to be any of the RNA sources appearing the \code{Cy3} or \code{Cy5} columns of \code{targets}. If the \code{parameters} argument is set, then the columns of this matrix specify the comparisons between the RNA sources which are of interest. This matrix must be of size n by (n-1), where n is the number of unique RNA sources found in \code{Cy3} and \code{Cy5}, and must have row names which correspond to the RNA sources. } \value{ \code{modelMatrix} produces a numeric design matrix with row names as in \code{targets} and column names as in \code{parameters}. \code{uniqueTargets} produces a character vector of unique target names from the columns \code{Cy3} and \code{Cy5} of \code{targets}. } \seealso{ \code{\link[stats]{model.matrix}} in the stats package. An overview of linear model functions in limma is given by \link{06.LinearModels}. } \author{Gordon Smyth} \examples{ targets <- cbind(Cy3=c("Ref","Control","Ref","Treatment"),Cy5=c("Control","Ref","Treatment","Ref")) rownames(targets) <- paste("Array",1:4) parameters <- cbind(C=c(-1,1,0),T=c(-1,0,1)) rownames(parameters) <- c("Ref","Control","Treatment") modelMatrix(targets, parameters) modelMatrix(targets, ref="Ref") } \keyword{regression} limma/man/cbind.Rd0000755007451300017500000000406412127125247014143 0ustar charlescharles\name{cbind} \alias{cbind} \alias{cbind.RGList} \alias{cbind.MAList} \alias{cbind.EList} \alias{cbind.EListRaw} \alias{rbind.RGList} \alias{rbind.MAList} \alias{rbind.EList} \alias{rbind.EListRaw} \title{Combine RGList, MAList, EList or EListRaw Objects} \description{ Combine a set of \code{RGList}, \code{MAList}, \code{EList} or \code{EListRaw} objects. } \usage{ \method{cbind}{RGList}(\dots, deparse.level=1) \method{rbind}{RGList}(\dots, deparse.level=1) } \arguments{ \item{\dots}{\code{RGList}, \code{MAList}, \code{EList} or \code{EListRaw} objects.} \item{deparse.level}{not currently used, see \code{\link[base]{cbind}} in the base package} } \details{ \code{cbind} combines data objects assuming the same probes in the same order but different arrays. \code{rbind} combines data objects assuming equivalent arrays, i.e., the same RNA targets, but different probes. For \code{cbind}, the matrices of expression data from the individual objects are cbinded. The data.frames of target information, if they exist, are rbinded. The combined data object will preserve any additional components or attributes found in the first object to be combined. For \code{rbind}, the matrices of expression data are rbinded while the target information, in any, is unchanged. } \value{ An \code{\link[limma:rglist]{RGList}}, \code{\link[limma:malist]{MAList}}, \code{\link[limma:EList]{EList}} or \code{\link[limma:EList]{EListRaw}} object holding data from all the arrays and all genes from the individual objects. } \author{Gordon Smyth} \seealso{ \code{\link[base]{cbind}} in the base package. \link{03.ReadingData} gives an overview of data input and manipulation functions in LIMMA. } \examples{ M <- A <- matrix(11:14,4,2) rownames(M) <- rownames(A) <- c("a","b","c","d") colnames(M) <- colnames(A) <- c("A1","A2") MA1 <- new("MAList",list(M=M,A=A)) M <- A <- matrix(21:24,4,2) rownames(M) <- rownames(A) <- c("a","b","c","d") colnames(M) <- colnames(A) <- c("B1","B2") MA2 <- new("MAList",list(M=M,A=A)) cbind(MA1,MA2) } \keyword{manip} limma/man/getEAWP.Rd0000644007451300017500000000275412127125247014321 0ustar charlescharles\name{getEAWP} \alias{getEAWP} \title{Extract Basic Data from Microarray Data Objects} \description{ Given a microarray data object of any known class, get the expression values, weights, probe annotation and A-values, which are needed for linear modelling. This function is called by the linear modelling functions in LIMMA. } \usage{ getEAWP(object) } \arguments{ \item{object}{a microarray data object. An object of class \code{list}, \code{MAList}, \code{EList}, \code{marrayNorm}, \code{PLMset}, \code{vsn}, or any class inheriting from \code{ExpressionSet}, or any object that can be coerced to a numeric matrix.} } \details{ In the case of two-color objects, the \code{Amean} is computed from the matrix of A-values. For single-channel objects, \code{Amean} is computed from the matrix of expression vales. \code{PLMset}, \code{vsn} and \code{ExpressionSet} are assumed to be single-channel for this purpose. If \code{object} is a matrix, it is assumed to contain log-intensities if the values are all positive and log-ratios otherwise. \code{Amean} is computed in the former case but not the latter. } \value{ A list with components \item{exprs}{numeric matrix of log-ratios or log-intensities} \item{weights}{numeric matrix of weights} \item{probes}{data.frame of probe-annotation} \item{Amean}{numeric vector of average log-expression for each probe} } \author{Gordon Smyth} \seealso{ \link{02.Classes} gives an overview of data classes used in LIMMA. } \keyword{array} limma/man/fitGammaIntercept.Rd0000644007451300017500000000235512127125247016465 0ustar charlescharles\name{fitGammaIntercept} \alias{fitGammaIntercept} \title{Fit Intercept to Vector of Gamma Distributed Variates} \description{ Fit Intercept to Vector of Gamma Distributed Variates} \usage{ fitGammaIntercept(y,offset=0,maxit=1000) } \arguments{ \item{y}{numeric vector of positive response values.} \item{offset}{numeric vector giving known part of the expected value of \code{y}. Can be a single value, or else a vector of the same length as \code{y}.} \item{maxit}{maximum number of Newton iterations to be done.} } \details{ The values \code{y} are assumed to follow a gamma distribution with common shape parameter and with expected values given by \code{x+offset}. The function implements a globally convergent Newton iteration to estimate \code{x}. } \value{ Numeric value giving intercept. } \author{Gordon Smyth and Belinda Phipson} \references{ Phipson, B. (2013). \emph{Empirical Bayes modelling of expression profiles and their associations}. PhD Thesis. University of Melbourne, Australia. } \seealso{ This function is called by \code{\link{genas}}. } \examples{ offset <- runif(10) x <- 9 mu <- x+offset y <- rgamma(10,shape=20,scale=mu/20) fitGammaIntercept(y,offset=offset) } \keyword{distribution} limma/man/plotma3by2.Rd0000755007451300017500000000344612127125247015063 0ustar charlescharles\title{Write MA-Plots to Files} \name{plotMA3by2} \alias{plotMA3by2} \description{ Write MA-plots to files in PNG format, six plots to a file in a 3 by 2 grid arrangement. } \usage{ plotMA3by2(MA, prefix="MA", path=NULL, main=colnames(MA), zero.weights=FALSE, common.lim=TRUE, device="png", ...) } \arguments{ \item{MA}{an \code{MAList} or \code{RGList} object, or any list with components \code{M} containing log-ratios and \code{A} containing average intensities} \item{prefix}{character string giving prefix to attach to file names} \item{path}{character string specifying directory for output files} \item{main}{character vector giving titles for plots} \item{zero.weights}{logical, should points with non-positive weights be plotted} \item{common.lim}{logical, should all plots on a page use the same axis limits} \item{device}{device driver for the plot. Choices are \code{"png"}, \code{"jpeg"}, \code{"pdf"}, \code{"postscript"}.} \item{...}{any other arguments are passed to \code{plotMA}} } \details{ This function writes a series of graphic files to disk. Each file contains six MA-plots in three rows and two columns. The layout is optimized for A4-sized paper. The graph format can be \code{"png"} or \code{"jpeg"}, which are screen-resolution formats, or \code{"pdf"} or \code{"postscript"}, which are loss-less formats. \code{"png"} is not available on every R platform. Note that \code{"pdf"} or \code{"postscript"} may produce very large files. } \value{ No value is returned, but one or more files are written to the working directory. The number of files is determined by the number of columns of \code{MA}. } \author{Gordon Smyth} \seealso{ An overview of diagnostic functions available in LIMMA is given in \link{09.Diagnostics}. } \keyword{hplot} limma/man/asdataframe.Rd0000644007451300017500000000227212127125247015330 0ustar charlescharles\name{as.data.frame} \alias{as.data.frame.MAList} \alias{as.data.frame.EList} \alias{as.data.frame.EListRaw} \alias{as.data.frame.MArrayLM} \title{Turn a Microarray Linear Model Object into a Dataframe} \description{ Turn a \code{MArrayLM} object into a \code{data.frame}. } \usage{ \method{as.data.frame}{MArrayLM}(x, row.names = NULL, optional = FALSE, ...) } \arguments{ \item{x}{an object of class \code{MArrayLM}} \item{row.names}{\code{NULL} or a character vector giving the row names for the data frame. Missing values are not allowed.} \item{optional}{logical. If \code{TRUE}, setting row names and converting column names (to syntactic names) is optional.} \item{\dots}{additional arguments to be passed to or from methods.} } \details{ This method combines all the components of \code{x} which have a row for each probe on the array into a \code{data.frame}. } \value{ A data.frame. } \author{Gordon Smyth} \seealso{ \code{\link[base]{as.data.frame}} in the base package. \link{02.Classes} gives an overview of data classes used in LIMMA. \link{06.LinearModels} gives an overview of linear model functions in LIMMA. } \keyword{array} limma/man/barcodeplot.Rd0000644007451300017500000000622412127125247015357 0ustar charlescharles\name{barcodeplot} \alias{barcodeplot} \title{Barcode Plot} \description{ Plot positions of one or two gene sets in a ranked list of statistics. } \usage{ barcodeplot(statistics,index,index2=NULL,labels=c("Group 1 (highest statistic)","Group 2 (lowest statistic)"), quantiles=c(-1,1),col.bars=NULL,offset.bars=!is.null(index2), ...) } \arguments{ \item{index}{index vector for the gene set. This can be a vector of indices, or a logical vector of the same length as \code{statistics} or, in general, any vector such that \code{statistic[index]} gives the statistic values for the gene set to be tested.} \item{index2}{index vector for a second gene set. Usually used to specify down-regulated genes when \code{index} is used for up-regulated genes.vector specifying the elements of \code{statistic} in the test group.} \item{statistics}{numeric vector giving the values of statistics to rank genes by.} \item{labels}{character vector of labels for the two groups of RNA samples that are being compared by the statistics. First labe is associated with high statistics and is displayed at the left end of the plot. Second label is associated with low or negative statistics and is displayed at the right end of the plot.} \item{quantiles}{numeric vector of length 2, giving cutoff values for \code{statistics} considered small or large respectively. Used to color the rectangle of the barcodeplot.} \item{col.bars}{character vector giving colors for the bars on the barcodeplot. Defaults to \code{"black"} for one set or \code{c("red","blue")} for two sets.} \item{offset.bars}{logical. When there are two sets, bars for the first set are normally offset up and and bars for the second set are offset down from the rectangle of the barcodeplot.} \item{\ldots}{other arguments are passed to \code{plot}.} } \value{ No value is returned but a plot is produced as a side effect. } \details{ Rank statistics left to right from largest to smallest, and show positions of one or two specified subsets. This plot is typically used in conjunction with gene set tests. It first appeared in the literature in Lim et al (2009). It was inspired by the set location plot of Subramanian et al (2005). } \seealso{ \code{\link{camera}}, \code{\link{wilcox.test}} } \author{Gordon Smyth and Di Wu} \references{ Lim E, Vaillant F, Wu D, Forrest NC, Pal B, Hart AH, Asselin-Labat ML, Gyorki DE, Ward T, Partanen A, Feleppa F, Huschtscha LI, Thorne HJ; kConFab; Fox SB, Yan M, French JD, Brown MA, Smyth GK, Visvader JE, Lindeman GJ (2009). Aberrant luminal progenitors as the candidate target population for basal tumor development in BRCA1 mutation carriers. \emph{Nat Med}, 15, 907-913.. Subramanian A, Tamayo P, Mootha VK, Mukherjee S, Ebert BL, Gillette MA, Paulovich A, Pomeroy SL, Golub TR, Lander ES, Mesirov JP (2005). Gene set enrichment analysis: a knowledge-based approach for interpreting genome-wide expression profiles. \emph{Proc Natl Acad Sci USA}, 102, 15545-15550. } \examples{ stat <- rnorm(100) sel <- 1:10 stat[sel] <- stat[sel]+1 barcodeplot(stat,sel) sel2 <- 11:20 stat[sel2] <- stat[sel2]-1 barcodeplot(stat,sel,sel2) } limma/man/poolvar.Rd0000755007451300017500000000447212127125247014551 0ustar charlescharles\name{poolVar} \alias{poolVar} \title{Pool Sample Variances with Unequal Variances} \description{ Compute the Satterthwaite (1946) approximation to the distribution of a weighted sum of sample variances. } \usage{ poolVar(var, df=n-1, multiplier=1/n, n) } \arguments{ \item{var}{numeric vector of independent sample variances} \item{df}{numeric vector of degrees of freedom for the sample variances} \item{multiplier}{numeric vector giving multipliers for the sample variances} \item{n}{numeric vector of sample sizes} } \details{ The sample variances \code{var} are assumed to follow scaled chi-square distributions. A scaled chi-square approximation is found for the distribution of \code{sum(multiplier * var)} by equating first and second moments. On output the sum to be approximated is equal to \code{multiplier * var} which follows approximately a scaled chisquare distribution on \code{df} degrees of freedom. The approximation was proposed by Satterthwaite (1946). If there are only two groups and the degrees of freedom are one less than the sample sizes then this gives the denominator of Welch's t-test for unequal variances. } \value{ A list with components \item{var}{effective pooled sample variance} \item{df}{effective pooled degrees of freedom} \item{multiplier}{pooled multiplier} } \author{Gordon Smyth} \references{ Welch, B. L. (1938). The significance of the difference between two means when the population variances are unequal. \emph{Biometrika} \bold{29}, 350-362. Satterthwaite, F. E. (1946). An approximate distribution of estimates of variance components. \emph{Biometrics Bulletin} \bold{2}, 110-114. Welch, B. L. (1947). The generalization of 'Student's' problem when several different population variances are involved. \emph{Biometrika} \bold{34}, 28-35. Welch, B. L. (1949). Further note on Mrs. Aspin's tables and on certain approximations to the tabled function. \emph{Biometrika} \bold{36}, 293-296. } \seealso{ \link{10.Other} } \examples{ # Welch's t-test with unequal variances x <- rnorm(10,mean=1,sd=2) y <- rnorm(20,mean=2,sd=1) s2 <- c(var(x),var(y)) n <- c(10,20) out <- poolVar(var=s2,n=n) tstat <- (mean(x)-mean(y)) / sqrt(out$var*out$multiplier) pvalue <- 2*pt(-abs(tstat),df=out$df) # Equivalent to t.test(x,y) } \keyword{htest} limma/man/protectMetachar.Rd0000755007451300017500000000147612127125247016215 0ustar charlescharles\name{protectMetachar} \alias{protectMetachar} \title{Protect Metacharacters} \description{Add backslashes before any metacharacters found in a string.} \usage{ protectMetachar(x) } \arguments{ \item{x}{character vector} } \details{ This function is used to protect strings containing metacharacters so that the metacharacters can be treated as ordinary characters in string matching functions operations. } \value{ A character vector of the same length as \code{x} in which two backslashes have been inserted before any metacharacter. } \seealso{ An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \examples{ # without protectMetachar, this would be no match grep(protectMetachar("Ch1 (mean)"),"Ch1 (mean)") } \author{Gordon Smyth} \keyword{character} limma/man/changelog.Rd0000755007451300017500000000070112127125247015005 0ustar charlescharles\name{changeLog} \alias{changeLog} \title{Limma Change Log} \description{Write as text the most recent changes from the limma package changelog.} \usage{ changeLog(n=20) } \arguments{ \item{n}{integer, number of lines to write of changelog.} } \value{No value is produced, but a number of lines of text are written to standard output.} \author{Gordon Smyth} \seealso{ \link{01.Introduction} } \keyword{documentation} limma/man/rglist.Rd0000755007451300017500000000632512150771760014375 0ustar charlescharles\name{RGList-class} \docType{class} \alias{RGList-class} \alias{coerce,RGList,exprSet2-method} \title{Red, Green Intensity List - class} \description{ A list-based S4 class for storing red and green channel foreground and background intensities for a batch of spotted microarrays. \code{RGList} objects are normally created by \code{\link{read.maimages}}. } \section{Slots/List Components}{ \code{RGList} objects can be created by \code{new("RGList",RG)} where \code{RG} is a list. Objects of this class contains no slots (other than \code{.Data}), but objects should contain the following list components: \tabular{ll}{ \code{R}\tab numeric matrix containing the red (cy5) foreground intensities. Rows correspond to spots and columns to arrays.\cr \code{G}\tab numeric matrix containing the green (cy3) foreground intensities. Rows correspond to spots and columns to arrays. } Optional components include \tabular{ll}{ \code{Rb}\tab numeric matrix containing the red (cy5) background intensities\cr \code{Gb}\tab numeric matrix containing the green (cy3) background intensities\cr \code{weights}\tab numeric matrix of same dimension as \code{R} containing relative spot quality weights. Elements should be non-negative.\cr \code{other}\tab list containing other matrices, all of the same dimensions as \code{R} and \code{G}.\cr \code{genes}\tab data.frame containing probe information. Should have one row for each spot. May have any number of columns.\cr \code{targets}\tab data.frame containing information on the target RNA samples. Rows correspond to arrays. May have any number of columns. Usually includes columns \code{Cy3} and \code{Cy5} specifying which RNA was hybridized to each array.\cr \code{printer}\tab list containing information on the process used to print the spots on the arrays. See \link[limma:PrintLayout]{PrintLayout}. } Valid \code{RGList} objects may contain other optional components, but all probe or array information should be contained in the above components. } \section{Methods}{ This class inherits directly from class \code{list} so any operation appropriate for lists will work on objects of this class. In addition, \code{RGList} objects can be \link[limma:subsetting]{subsetted}, \link[limma:cbind]{combined} and \link[limma:merge]{merged}. \code{RGList} objects will return dimensions and hence functions such as \code{\link[limma:dim]{dim}}, \code{\link[base:nrow]{nrow}} and \code{\link[base:nrow]{ncol}} are defined. \code{RGLists} also inherit a \code{\link[methods]{show}} method from the virtual class \code{\link[limma:LargeDataObject]{LargeDataObject}}, which means that \code{RGLists} will print in a compact way. \code{RGList} objects can be converted to \code{exprSet2} objects by \code{as(RG,"exprSet2")}. Other functions in LIMMA which operate on \code{RGList} objects include \code{\link{normalizeBetweenArrays}}, \code{\link{normalizeForPrintorder}}, \code{\link{normalizeWithinArrays}}. } \author{Gordon Smyth} \seealso{ \link{02.Classes} gives an overview of all the classes defined by this package. \code{\link[marray:marrayRaw-class]{marrayRaw}} is the corresponding class in the marray package. } \keyword{classes} \keyword{data} limma/man/getSpacing.Rd0000755007451300017500000000275712127125247015157 0ustar charlescharles\name{getSpacing} \alias{getSpacing} \title{Get Numerical Spacing} \description{ Convert character to numerical spacing measure for within-array replicate spots. } \usage{ getSpacing(spacing, layout) } \arguments{ \item{spacing}{character string or integer. Acceptable character strings are \code{"columns"}, \code{"rows"}, \code{"subarrays"} or \code{"topbottom"}. Integer values are simply passed through.} \item{layout}{list containing printer layout information} } \details{ \code{"rows"} means that duplicate spots are printed side-by-side by rows. These will be recorded in consecutive rows in the data object. \code{"columns"} means that duplicate spots are printed side-by-sidy by columns. These will be separated in the data object by \code{layout$nspot.r} rows. \code{"subarrays"} means that a number of sub-arrays, with identical probes in the same arrangement, are printed on each array. The spacing therefore will be the size of a sub-array. \code{"topbottom"} is the same as \code{"subarrays"} when there are two sub-arrays. } \value{ Integer giving spacing between replicate spots in the gene list. } \author{Gordon Smyth} \seealso{ An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \examples{ getSpacing("columns",list(ngrid.r=2,ngrid.c=2,nspot.r=20,nspot.c=19)) getSpacing("rows",list(ngrid.r=2,ngrid.c=2,nspot.r=20,nspot.c=19)) getSpacing("topbottom",list(ngrid.r=2,ngrid.c=2,nspot.r=20,nspot.c=19)) } \keyword{IO} limma/man/subsetting.Rd0000755007451300017500000000242512127125247015252 0ustar charlescharles\name{subsetting} \alias{subsetting} \alias{[.RGList} \alias{[.MAList} \alias{[.EListRaw} \alias{[.EList} \alias{[.MArrayLM} \title{Subset RGList, MAList, EList or MArrayLM Objects} \description{ Extract a subset of an \code{RGList}, \code{MAList}, \code{EList} or \code{MArrayLM} object. } \usage{ \method{[}{RGList}(object, i, j, \ldots) } \arguments{ \item{object}{object of class \code{RGList}, \code{MAList}, \code{EList} or \code{MArrayLM}} \item{i,j}{elements to extract. \code{i} subsets the probes or spots while \code{j} subsets the arrays} \item{\ldots}{not used} } \details{ \code{i,j} may take any values acceptable for the matrix components of \code{object}. See the \link[base]{Extract} help entry for more details on subsetting matrices. } \value{ An object of the same class as \code{object} holding data from the specified subset of genes and arrays. } \author{Gordon Smyth} \seealso{ \code{\link[base]{Extract}} in the base package. \link{03.ReadingData} gives an overview of data input and manipulation functions in LIMMA. } \examples{ M <- A <- matrix(11:14,4,2) rownames(M) <- rownames(A) <- c("a","b","c","d") colnames(M) <- colnames(A) <- c("A","B") MA <- new("MAList",list(M=M,A=A)) MA[1:2,] MA[1:2,2] MA[,2] } \keyword{manip} limma/man/isfullrank.Rd0000755007451300017500000000200712127125247015231 0ustar charlescharles\name{is.fullrank} \alias{is.fullrank} \alias{nonEstimable} \title{Check for Full Column Rank} \description{ Test whether a numeric matrix has full column rank. } \usage{ is.fullrank(x) nonEstimable(x) } \arguments{ \item{x}{a numeric matrix or vector} } \value{ \code{is.fullrank} returns \code{TRUE} or \code{FALSE}. \code{nonEstimable} returns a character vector of names for the columns of \code{x} which are linearly dependent on previous columns. If \code{x} has full column rank, then the value is \code{NULL}. } \details{ \code{is.fullrank} is used to check the integrity of design matrices in limma, for example after \link[limma:subsetting]{subsetting} operations. \code{nonEstimable} is used by \code{\link{lmFit}} to report which coefficients in a linear model cannot be estimated. } \author{Gordon Smyth} \examples{ # TRUE is.fullrank(1) is.fullrank(cbind(1,0:1)) # FALSE is.fullrank(0) is.fullrank(matrix(1,2,2)) nonEstimable(matrix(1,2,2)) } \keyword{algebra} limma/man/read.columns.Rd0000644007451300017500000000450512127125247015453 0ustar charlescharles\name{read.columns} \alias{read.columns} \title{Read specified columns from a file} \description{ Reads specified columns from a file in table format and creates a data frame from it, with cases corresponding to lines and variables to fields in the file. } \usage{ read.columns(file,required.col=NULL,text.to.search="",sep="\t",quote="\"",skip=0,fill=TRUE,blank.lines.skip=TRUE,comment.char="",allowEscapes=FALSE,...) } \arguments{ \item{file}{the name of the file which the data are to be read from.} \item{required.col}{character vector of names of the required columns} \item{text.to.search}{character string. If any column names can be found in this string, those columns will also be read.} \item{sep}{the field separator character} \item{quote}{character string of characters to be treated as quote marks} \item{skip}{the number of lines of the data file to skip before beginning to read data.} \item{fill}{logical: if \code{TRUE} then in case the rows have unequal length, blank fields are implicitly added.} \item{blank.lines.skip}{logical: if \code{TRUE} blank lines in the input are ignored.} \item{comment.char}{character: a character vector of length one containing a single character or an empty string.} \item{allowEscapes}{logical. Should C-style escapes such as \samp{\\n} be processed or read verbatim (the default)?} \item{\dots}{other arguments are passed to \code{read.table}, excluding the following which are reserved and cannot be set by the user: \code{header}, \code{col.names}, \code{check.names} and \code{colClasses}.} } \details{ This function is an interface to \code{read.table} in the base package. It uses \code{required.col} and \code{text.to.search} to set up the \code{colClasses} argument of \code{read.table}. Note the following arguments of \code{read.table} are used by \code{read.columns} and therefore cannot be set by the user: \code{header}, \code{col.names}, \code{check.names} and \code{colClasses}. This function is used by \code{\link{read.maimages}}. } \value{ A data frame (data.frame) containing a representation of the data in the file. } \author{Gordon Smyth} \seealso{ \code{\link{read.maimages}}, \code{\link[utils]{read.table}}. An overview of LIMMA functions for reading data is given in \link{03.ReadingData}. } \keyword{file} limma/man/ma3x3.Rd0000755007451300017500000000254112127125247014015 0ustar charlescharles\name{ma3x3} \alias{ma3x3.matrix} \alias{ma3x3.spottedarray} \title{Two dimensional Moving Averages with 3x3 Window} \description{ Apply a specified function to each to each value of a matrix and its immediate neighbors. } \usage{ ma3x3.matrix(x,FUN=mean,na.rm=TRUE,...) ma3x3.spottedarray(x,printer,FUN=mean,na.rm=TRUE,...) } \arguments{ \item{x}{numeric matrix} \item{FUN}{function to apply to each window of values} \item{na.rm}{logical value, should missing values be removed when applying \code{FUN}} \item{...}{other arguments are passed to \code{FUN}} \item{printer}{list giving the printer layout, see \code{\link{PrintLayout-class}}} } \details{ For \code{ma3x3.matrix}, \code{x} is an arbitrary function. for \code{ma3x3.spotted}, each column of \code{x} is assumed to contain the expression values of a spotted array in standard order. The printer layout information is used to re-arrange the values of each column as a spatial matrix before applying \code{ma3x3.matrix}. } \value{ Numeric matrix of same dimension as \code{x} containing smoothed values } \seealso{ An overview of functions for background correction are given in \code{\link{04.Background}}. } \examples{ x <- matrix(c(2,5,3,1,6,3,10,12,4,6,4,8,2,1,9,0),4,4) ma3x3.matrix(x,FUN="mean") ma3x3.matrix(x,FUN="min") } \author{Gordon Smyth} \keyword{smooth} limma/man/heatdiagram.Rd0000755007451300017500000000767312127125247015343 0ustar charlescharles\title{Stemmed Heat Diagram} \name{heatdiagram} \alias{heatdiagram} \alias{heatDiagram} \description{ Creates a heat diagram showing the co-regulation of genes under one condition with a range of other conditions. } \usage{ heatDiagram(results,coef,primary=1,names=NULL,treatments=colnames(coef),limit=NULL,orientation="landscape",low="green",high="red",cex=1,mar=NULL,ncolors=123,...) heatdiagram(stat,coef,primary=1,names=NULL,treatments=colnames(stat),critical.primary=4,critical.other=3,limit=NULL,orientation="landscape",low="green",high="red",cex=1,mar=NULL,ncolors=123,...) } \arguments{ \item{results}{\code{TestResults} matrix, containing elements -1, 0 or 1, from \code{\link{decideTests}}} \item{stat}{numeric matrix of test statistics. Rows correspond to genes and columns to treatments or contrasts between treatments.} \item{coef}{numeric matrix of the same size as \code{stat}. Holds the coefficients to be displayed in the plot.} \item{primary}{number or name of the column to be compared to the others. Genes are included in the diagram according to this column of \code{stat} and are sorted according to this column of \code{coef}. If \code{primary} is a name, then \code{stat} and \code{coef} must have the same column names.} \item{names}{optional character vector of gene names} \item{treatments}{optional character vector of treatment names} \item{critical.primary}{critical value above which the test statistics for the primary column are considered significant and included in the plot} \item{critical.other}{critical value above which the other test statistics are considered significant. Should usually be no larger than \code{critical.primary} although larger values are permitted.} \item{limit}{optional value for \code{coef} above which values will be plotted in extreme color. Defaults to \code{max(abs(coef))}.} \item{orientation}{\code{"portrait"} for upright plot or \code{"landscape"} for plot orientated to be wider than high. \code{"portrait"} is likely to be appropriate for inclusion in printed document while \code{"landscape"} may be appropriate for a presentation on a computer screen.} \item{low}{color associated with repressed gene regulation} \item{high}{color associated with induced gene regulation} \item{ncolors}{number of distinct colors used for each of up and down regulation} \item{cex}{factor to increase or decrease size of column and row text} \item{mar}{numeric vector of length four giving the size of the margin widths. Default is \code{cex*c(5,6,1,1)} for landscape and \code{cex*c(1,1,4,3)} for portrait.} \item{...}{any other arguments will be passed to the \code{image} function} } \details{ Users are encouraged to use \code{heatDiagram} rather than \code{heatdiagram} as the later function may be removed in future versions of limma. This function plots an image of gene expression profiles in which rows (or columns for portrait orientation) correspond to treatment conditions and columns (or rows) correspond to genes. Only genes which are significantly differentially expressed in the primary condition are included. Genes are sorted by differential expression under the primary condition. Note: the plot produced by this function is unique to the limma package. It should not be confused with "heatmaps" often used to display results from cluster analyses. } \value{An image is created on the current graphics device. A matrix with named rows containing the coefficients used in the plot is also invisibly returned.} \author{Gordon Smyth} \seealso{\code{\link[graphics]{image}}.} \examples{ \dontrun{ MA <- normalizeWithinArrays(RG) design <- cbind(c(1,1,1,0,0,0),c(0,0,0,1,1,1)) fit <- lmFit(MA,design=design) contrasts.mouse <- cbind(Control=c(1,0),Mutant=c(0,1),Difference=c(-1,1)) fit <- eBayes(contrasts.fit(fit,contrasts=contrasts.mouse)) results <- decideTests(fit,method="global",p=0.1) heatDiagram(results,fit$coef,primary="Difference") } } \keyword{hplot} limma/man/camera.Rd0000644007451300017500000001066212127125247014312 0ustar charlescharles\name{camera} \alias{camera} \alias{camera.EList} \alias{camera.MAList} \alias{camera.default} \alias{interGeneCorrelation} \title{Competitive Gene Set Test Accounting for Inter-gene Correlation} \description{ Test whether a set of genes is highly ranked relative to other genes in terms of differential expression, accounting for inter-gene correlation. } \usage{ \method{camera}{EList}(y, index, design, contrast=ncol(design), weights=NULL, use.ranks=FALSE, allow.neg.cor=TRUE, trend.var=FALSE, sort=TRUE) interGeneCorrelation(y, design) } \arguments{ \item{y}{numeric matrix giving log-expression or log-ratio values for a series of microarrays, or any data object that can coerced to a matrix including \code{ExpressionSet}, \code{MAList}, \code{EList} or \code{PLMSet} objects. Rows correspond to probes and columns to samples.} \item{index}{an index vector or a list of index vectors. Can be any vector such that \code{y[index,]} selects the rows corresponding to the test set.} \item{design}{design matrix.} \item{contrast}{contrast of the linear model coefficients for which the test is required. Can be an integer specifying a column of \code{design}, or else a numeric vector of same length as the number of columns of \code{design}.} \item{weights}{can be a numeric matrix of individual weights, of same size as \code{y}, or a numeric vector of array weights with length equal to \code{ncol(y)}.} \item{use.ranks}{do a rank-based test (\code{TRUE}) or a parametric test (\code{FALSE}?} \item{allow.neg.cor}{should reduced variance inflation factors be allowed for negative correlations?} \item{trend.var}{logical, should an empirical Bayes trend be estimated? See \code{\link{eBayes}} for details.} \item{sort}{logical, should the results be sorted by p-value?} } \details{ \code{camera} and \code{interGeneCorrelation} implement methods proposed by Wu and Smyth (2012). \code{camera} performs a \emph{competitive} test in the sense defined by Goeman and Buhlmann (2007). It tests whether the genes in the set are highly ranked in terms of differential expression relative to genes not in the set. It has similar aims to \code{geneSetTest} but accounts for inter-gene correlation. See \code{\link{roast}} for an analogous \emph{self-contained} gene set test. The function can be used for any microarray experiment which can be represented by a linear model. The design matrix for the experiment is specified as for the \code{\link{lmFit}} function, and the contrast of interest is specified as for the \code{\link{contrasts.fit}} function. This allows users to focus on differential expression for any coefficient or contrast in a linear model by giving the vector of test statistic values. \code{camera} estimates p-values after adjusting the variance of test statistics by an estimated variance inflation factor. The inflation factor depends on estimated genewise correlation and the number of genes in the gene set. \code{interGeneCorrelation} estimates the mean pair-wise correlation between a set of genes. } \value{ \code{camera} returns a data.frame with a row for each set and the following columns: \item{NGenes}{number of genes in set} \item{Correlation}{inter-gene correlation} \item{Direction}{direction of change (\code{"Up"} or \code{"Down"})} \item{PValue}{two-tailed p-value} \item{FDR}{Benjamini and Hochberg FDR adjusted p-value} \code{interGeneCorrelation} returns a list with components: \item{vif}{variance inflation factor} \item{correlation}{inter-gene correlation} } \author{Di Wu and Gordon Smyth} \references{ Wu, D, and Smyth, GK (2012). Camera: a competitive gene set test accounting for inter-gene correlation. \emph{Nucleic Acids Research} 40, e133. \url{http://nar.oxfordjournals.org/content/40/17/e133} Goeman, JJ, and Buhlmann, P (2007). Analyzing gene expression data in terms of gene sets: methodological issues. \emph{Bioinformatics} 23, 980-987. } \seealso{ \code{\link{rankSumTestWithCorrelation}}, \code{\link{geneSetTest}}, \code{\link{roast}}, \code{\link{romer}}. } \examples{ y <- matrix(rnorm(1000*6),1000,6) design <- cbind(Intercept=1,Group=c(0,0,0,1,1,1)) # First set of 20 genes are genuinely differentially expressed index1 <- 1:20 y[index1,4:6] <- y[index1,4:6]+1 # Second set of 20 genes are not DE index2 <- 21:40 camera(y, index1, design) camera(y, index2, design) camera(y, list(set1=index1,set2=index2), design) } \keyword{htest} limma/man/contrasts.fit.Rd0000755007451300017500000000763312150771760015675 0ustar charlescharles\name{contrasts.fit} \alias{contrasts.fit} \title{Compute Contrasts from Linear Model Fit} \description{ Given a linear model fit to microarray data, compute estimated coefficients and standard errors for a given set of contrasts. } \usage{ contrasts.fit(fit, contrasts=NULL, coefficients=NULL) } \arguments{ \item{fit}{an \code{\link[limma:marraylm]{MArrayLM}} object or a list object produced by the function \code{lm.series} or equivalent. Must contain components \code{coefficients} and \code{stdev.unscaled}.} \item{contrasts}{numeric matrix with row corresponding to coefficients in \code{fit} and columns containing contrasts. May be a vector if there is only one contrast.} \item{coefficients}{vector indicating which coefficients are to be kept in the revised fit object. An alternative way to specify the \code{contrasts}.} } \value{ An list object of the same class as \code{fit}, usually \code{\link[limma:marraylm]{MArrayLM}}. This is a list with components \item{coefficients}{numeric matrix containing the estimated coefficients for each contrast for each probe.} \item{stdev.unscaled}{numeric matrix conformal with \code{coef} containing the unscaled standard deviations for the coefficient estimators.} \item{\code{cov.coefficients}}{numeric \code{matrix} giving the unscaled covariance matrix of the estimable coefficients.} \item{\dots}{any other components found in \code{fit} are passed through unchanged.} } \details{ This function accepts input from any of the functions \code{\link{lmFit}}, \code{lm.series}, \code{mrlm}, \code{gls.series} or \code{lmscFit}. The function re-orientates the fitted model object from the coefficients of the original design matrix to any set of contrasts of the original coefficients. The coefficients, unscaled standard deviations and correlation matrix are re-calculated in terms of the contrasts. The idea of this function is to fit a full-rank model using \code{lmFit} or equivalent, then use \code{contrasts.fit} to obtain coefficients and standard errors for any number of contrasts of the coefficients of the original model. Unlike the design matrix input to \code{lmFit}, which normally has one column for each treatment in the experiment, the matrix \code{contrasts} may have any number of columns and these are not required to be linearly independent. Methods of assessing differential expression, such as \code{eBayes} or \code{classifyTestsF}, can then be applied to fitted model object. The \code{coefficients} argument provides a simpler way to specify the \code{contrasts} matrix when the desired contrasts are just a subset of the original coefficients. Warning. For efficiency reasons, this function does not re-factorize the design matrix for each probe. A consequence is that, if the design matrix is non-orthogonal and the original fit included quality weights or missing values, then the unscaled standard deviations produced by this function are approximate rather than exact. The approximation is usually acceptable. The results are always exact if the original fit was a oneway model. } \seealso{ An overview of linear model functions in limma is given by \link{06.LinearModels}. } \author{Gordon Smyth} \examples{ # Simulate gene expression data: 6 microarrays and 100 genes # with one gene differentially expressed in first 3 arrays M <- matrix(rnorm(100*6,sd=0.3),100,6) M[1,1:3] <- M[1,1:3] + 2 # Design matrix corresponds to oneway layout, columns are orthogonal design <- cbind(First3Arrays=c(1,1,1,0,0,0),Last3Arrays=c(0,0,0,1,1,1)) fit <- lmFit(M,design=design) # Would like to consider original two estimates plus difference between first 3 and last 3 arrays contrast.matrix <- cbind(First3=c(1,0),Last3=c(0,1),"Last3-First3"=c(-1,1)) fit2 <- contrasts.fit(fit,contrast.matrix) fit2 <- eBayes(fit2) # Large values of eb$t indicate differential expression results <- classifyTestsF(fit2) vennCounts(results) } \keyword{htest} limma/man/plotlines.Rd0000644007451300017500000000151612127125247015071 0ustar charlescharles\title{plotlines} \name{plotlines} \alias{plotlines} \description{ Time course style plot of expression data. } \usage{ plotlines(x,first.column.origin=FALSE,xlab="Column",ylab="x",col="black",lwd=1,...) } \arguments{ \item{x}{numeric matrix or object containing expression data.} \item{first.column.origin}{logical, should the lines be started from zero?} \item{xlab}{x-axis label} \item{ylab}{y-axis label} \item{col}{vector of colors for lines} \item{lwd}{line width multiplier} \item{...}{any other arguments are passed to \code{plot}} } \details{ Plots a line for each probe. } \value{A plot is created on the current graphics device.} \author{Gordon Smyth} \seealso{ An overview of modeling functions and associated plots available in LIMMA is given in \link{06.LinearModels}. } \keyword{hplot} limma/man/avereps.Rd0000644007451300017500000000326112127125247014524 0ustar charlescharles\name{avereps} \alias{avereps} \alias{avereps.default} \alias{avereps.MAList} \alias{avereps.EList} \title{Average Over Irregular Replicate Probes} \description{ Condense a microarray data object so that values for within-array replicate probes are replaced with their average. } \usage{ \method{avereps}{default}(x, ID=rownames(x)) \method{avereps}{MAList}(x, ID=NULL) \method{avereps}{EList}(x, ID=NULL) } \arguments{ \item{x}{a matrix-like object, usually a matrix, \code{MAList} or \code{EList} object.} \item{ID}{probe identifier.} } \details{ A new data object is computed in which each probe ID is represented by the average of its replicate spots or features. For an \code{MAList} object, the components \code{M} and \code{A} are both averaged in this way, as are \code{weights} and any matrices found in \code{object$other}. For an \code{MAList} object, \code{ID} defaults to \code{MA$genes$ID} is that exists, otherwise to \code{rownames(MA$M)}. \code{EList} objects are similar, except that the \code{E} component is averaged instead of \code{M} and \code{A}. If \code{x} is of mode \code{"character"}, then the replicate values are assumed to be equal and the first is taken as the average. } \value{ A data object of the same class as \code{x} with a row for each unique value of \code{ID}. } \author{Gordon Smyth} \seealso{ \code{\link{avedups}}, \code{\link{avearrays}}. Also \code{\link[base]{rowsum}} in the base package. \link{02.Classes} gives an overview of data classes used in LIMMA. } \examples{ x <- matrix(rnorm(8*3),8,3) colnames(x) <- c("S1","S2","S3") rownames(x) <- c("b","a","a","c","c","b","b","b") avereps(x) } \keyword{array} limma/man/fitted.MArrayLM.Rd0000644007451300017500000000120412127125247015754 0ustar charlescharles\name{fitted.MArrayLM} \alias{fitted.MArrayLM} \concept{regression} \title{Fitted Values Method for MArrayLM Fits} \usage{ \S3method{fitted}{MArrayLM}(object, design = object$design, \dots) } \arguments{ \item{object}{a fitted object of class inheriting from \code{"MArrayLM"}.} \item{design}{numeric design matrix.} \item{\dots}{further arguments passed to or from other methods.} } \description{ Obtains fitted values from a fitted microarray linear model object. } \value{ A numeric matrix of fitted values. } \seealso{ \code{\link{fitted}} } \author{Gordon Smyth} \keyword{models} \keyword{regression} limma/man/alias2Symbol.Rd0000644007451300017500000000363412127125247015424 0ustar charlescharles\name{alias2Symbol} \alias{alias2Symbol} \alias{alias2SymbolTable} \title{Convert Gene Alias to Official Gene Symbols} \description{ Maps gene alias names to official gene symbols. } \usage{ alias2Symbol(alias, species = "Hs", expand.symbols = FALSE) alias2SymbolTable(alias, species = "Hs") } \arguments{ \item{alias}{character vector of gene aliases} \item{species}{character string specifying the species. Possible values are \code{"Dm"}, \code{"Hs"}, \code{"Mm"} or \code{"Rn"}.} \item{expand.symbols}{logical, should those elements of \code{alias} which are already official symbols be expanded if they are aliases for other symbols.} } \details{ Aliases are mapped via NCBI Entrez Gene identity numbers using Bioconductor organism packages. Species are \code{"Dm"} for fly, \code{"Hs"} for human, \code{"Mm"} for mouse and \code{"Rn"} for rat. The user needs to have the appropriate Bioconductor organism package installed. \code{alias2Symbol} maps a set of aliases to a set of symbols, without necessarily preserving order. The output vector may be longer or shorter than the original vector, because some aliases might not be found and some aliases may map to more than one symbol. \code{alias2SymbolTable} maps each alias to a gene symbol and returns a table with one row for each alias. If an alias maps to more than one symbol, then the first one found will be returned. } \value{ Character vector of gene symbols. \code{alias2SymbolTable} returns a vector of the same length and order as \code{alias}, including \code{NA} values where no gene symbol was found. \code{alias2Symbol} returns an unordered vector which may be longer or shorter than \code{alias}. } \author{Gordon Smyth and Yifang Hu} \seealso{ This function is often used to assist gene set testing, see \link{08.Tests}. } \examples{ if(require("org.Hs.eg.db")) alias2Symbol(c("PUMA","NOXA","BIM")) } \keyword{character} limma/man/plotRLDF.Rd0000644007451300017500000000575512127125247014517 0ustar charlescharles\title{Plot of regularized linear discriminant functions for microarray data} \name{plotRLDF} \alias{plotRLDF} \description{ Plot of regularized linear discriminant functions for microarray data. } \usage{ plotRLDF(y,design=NULL,z=NULL,labels.y=NULL,labels.z=NULL,col.y=1,col.z=1, df.prior=5,show.dimensions=c(1,2),main=NULL,nprobes=500,...)} \arguments{ \item{y}{any data object which can be coerced to a matrix, such as \code{ExpressionSet} or \code{EList}. The training dataset.} \item{z}{any data object which can be coerced to a matrix, such as \code{ExpressionSet} or \code{EList}. The dataset to be classified.} \item{design}{the design matrix ofthe microarray experiment for \code{y}, with rows corresponding to arrays and columns to coefficients to be estimated. Defaults to the unit vector meaning that the arrays are treated as replicates.} \item{labels.y}{character vector of sample names or labels in \code{y}. Default is integers starting from 1.} \item{labels.z}{character vector of sample names or labels in \code{z}. Default is \code{letters}.} \item{col.y}{numeric or character vector of colors for the plotting characters of \code{y}. Default is black.} \item{col.z}{numeric or character vector of colors for the plotting characters of \code{z}. Default is black.} \item{df.prior}{prior degrees of freedom for residual variances. Used in gene selection.} \item{show.dimensions}{which two dimensions should be plotted, numeric vector of length two.} \item{main}{title of the plot.} \item{nprobes}{number of probes to be used for the calculations. Selected by moderated F tests.} \item{...}{any other arguments are passed to \code{plot}.} } \details{ This function is a variation on the plot of usual linear discriminant fuction, in that the within-group covariance matrix is regularized to ensure that it is invertible, with eigenvalues bounded away from zero. A diagonal regulation using \code{df.prior} and the median within-group variance is used. The calculations are based on a filtered list of probes. The \code{nprobes} probes with largest moderated F statistics are used to discriminate. See \code{\link[graphics]{text}} for possible values for \code{col} and \code{cex}. } \value{A list containing metagene information is (invisibly) returned. A plot is created on the current graphics device.} \author{Di Wu and Gordon Smyth} \seealso{ \code{lda} in package \code{MASS} } \examples{ # Simulate gene expression data for 1000 probes and 6 microarrays. # Samples are in two groups # First 50 probes are differentially expressed in second group sd <- 0.3*sqrt(4/rchisq(1000,df=4)) y <- matrix(rnorm(1000*6,sd=sd),1000,6) rownames(y) <- paste("Gene",1:1000) y[1:50,4:6] <- y[1:50,4:6] + 2 z <- matrix(rnorm(1000*6,sd=sd),1000,6) rownames(z) <- paste("Gene",1:1000) z[1:50,4:6] <- z[1:50,4:6] + 1.8 z[1:50,1:3] <- z[1:50,1:3] - 0.2 design <- cbind(Grp1=1,Grp2vs1=c(0,0,0,1,1,1)) options(digit=3) plotRLDF(y,z, design=design) } \keyword{hplot} limma/man/asmatrix.Rd0000644007451300017500000000260612127125247014711 0ustar charlescharles\name{as.matrix} \alias{as.matrix.RGList} \alias{as.matrix.MAList} \alias{as.matrix.EListRaw} \alias{as.matrix.EList} \alias{as.matrix.MArrayLM} \alias{as.matrix.marrayNorm} \alias{as.matrix.PLMset} \alias{as.matrix.ExpressionSet} \alias{as.matrix.LumiBatch} \alias{as.matrix.vsn} \title{Turn a Microarray Data Object into a Matrix} \description{ Turn a microarray data object into a numeric matrix by extracting the expression values. } \usage{ \method{as.matrix}{MAList}(x,\dots) } \arguments{ \item{x}{an object of class \code{RGList}, \code{MAList}, \code{EList}, \code{MArrayLM}, \code{marrayNorm}, \code{PLMset}, \code{ExpressionSet}, \code{LumiBatch} or \code{vsn}.} \item{\dots}{additional arguments, not used for these methods.} } \details{ These methods extract the matrix of log-ratios, for \code{MAList} or \code{marrayNorm} objects, or the matrix of expression values for other expression objects such as \code{EList} or \code{ExressionSet}. For \code{MArrayLM} objects, the matrix of fitted coefficients is extracted. These methods involve loss of information, so the original data object is not recoverable. } \value{ A numeric matrix. } \author{Gordon Smyth} \seealso{ \code{\link{as.matrix}} in the base package or \code{\link[Biobase]{exprs}} in the Biobase package. \link{02.Classes} gives an overview of data classes used in LIMMA. } \keyword{array} limma/NAMESPACE0000644007451300017500000000405712170636051013236 0ustar charlescharles# All functions exported other than those starting with "." exportPattern("^[^\\.]") exportClasses("RGList","MAList","EListRaw","EList","MArrayLM","TestResults","LargeDataObject","Roast","MDS") exportMethods("show") S3method("[",MAList) S3method("[",MArrayLM) S3method("[",RGList) S3method("[",EList) S3method("[",EListRaw) S3method(anova,MAList) S3method(as.data.frame,MArrayLM) S3method(as.matrix,MAList) S3method(as.matrix,EList) S3method(as.matrix,EListRaw) S3method(as.matrix,MArrayLM) S3method(as.matrix,marrayNorm) S3method(as.matrix,PLMset) S3method(as.matrix,RGList) S3method(as.matrix,ExpressionSet) S3method(as.matrix,LumiBatch) S3method(as.matrix,vsn) S3method(avedups,MAList) S3method(avedups,EList) S3method(avereps,MAList) S3method(avereps,EList) S3method(avearrays,MAList) S3method(avearrays,EList) S3method(cbind,MAList) S3method(cbind,RGList) S3method(cbind,EList) S3method(cbind,EListRaw) S3method(dim,MAList) S3method(dim,MArrayLM) S3method(dim,RGList) S3method(dim,EList) S3method(dim,EListRaw) S3method(dimnames,MAList) S3method(dimnames,MArrayLM) S3method(dimnames,RGList) S3method(dimnames,EList) S3method(dimnames,EListRaw) S3method("dimnames<-",MAList) S3method("dimnames<-",RGList) S3method("dimnames<-",EList) S3method("dimnames<-",EListRaw) S3method(fitted,MArrayLM) S3method(length,MAList) S3method(length,MArrayLM) S3method(length,RGList) S3method(length,EList) S3method(length,EListRaw) S3method(merge,MAList) S3method(merge,RGList) S3method(merge,EList) S3method(merge,EListRaw) S3method(rbind,MAList) S3method(rbind,RGList) S3method(rbind,EList) S3method(rbind,EListRaw) S3method(residuals,MArrayLM) S3method(summary,MAList) S3method(summary,MArrayLM) S3method(summary,RGList) S3method(summary,EList) S3method(summary,EListRaw) S3method(summary,TestResults) S3method(normalizeVSN,RGList) S3method(normalizeVSN,EListRaw) S3method(plotMDS,MDS) S3method(roast,MAList) S3method(roast,EList) S3method(mroast,MAList) S3method(mroast,EList) S3method(camera,MAList) S3method(camera,EList) limma/tests/0000755007451300017500000000000012127125241013147 5ustar charlescharleslimma/tests/limma-Tests.Rout.save0000755007451300017500000016670712127125241017202 0ustar charlescharles R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i386-w64-mingw32/i386 (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(limma) > > set.seed(0); u <- runif(100) > > ### strsplit2 > > x <- c("ab;cd;efg","abc;def","z","") > strsplit2(x,split=";") [,1] [,2] [,3] [1,] "ab" "cd" "efg" [2,] "abc" "def" "" [3,] "z" "" "" [4,] "" "" "" > > ### removeext > > removeExt(c("slide1.spot","slide.2.spot")) [1] "slide1" "slide.2" > removeExt(c("slide1.spot","slide")) [1] "slide1.spot" "slide" > > ### printorder > > printorder(list(ngrid.r=4,ngrid.c=4,nspot.r=8,nspot.c=6),ndups=2,start="topright",npins=4) $printorder [1] 6 5 4 3 2 1 12 11 10 9 8 7 18 17 16 15 14 13 [19] 24 23 22 21 20 19 30 29 28 27 26 25 36 35 34 33 32 31 [37] 42 41 40 39 38 37 48 47 46 45 44 43 6 5 4 3 2 1 [55] 12 11 10 9 8 7 18 17 16 15 14 13 24 23 22 21 20 19 [73] 30 29 28 27 26 25 36 35 34 33 32 31 42 41 40 39 38 37 [91] 48 47 46 45 44 43 6 5 4 3 2 1 12 11 10 9 8 7 [109] 18 17 16 15 14 13 24 23 22 21 20 19 30 29 28 27 26 25 [127] 36 35 34 33 32 31 42 41 40 39 38 37 48 47 46 45 44 43 [145] 6 5 4 3 2 1 12 11 10 9 8 7 18 17 16 15 14 13 [163] 24 23 22 21 20 19 30 29 28 27 26 25 36 35 34 33 32 31 [181] 42 41 40 39 38 37 48 47 46 45 44 43 54 53 52 51 50 49 [199] 60 59 58 57 56 55 66 65 64 63 62 61 72 71 70 69 68 67 [217] 78 77 76 75 74 73 84 83 82 81 80 79 90 89 88 87 86 85 [235] 96 95 94 93 92 91 54 53 52 51 50 49 60 59 58 57 56 55 [253] 66 65 64 63 62 61 72 71 70 69 68 67 78 77 76 75 74 73 [271] 84 83 82 81 80 79 90 89 88 87 86 85 96 95 94 93 92 91 [289] 54 53 52 51 50 49 60 59 58 57 56 55 66 65 64 63 62 61 [307] 72 71 70 69 68 67 78 77 76 75 74 73 84 83 82 81 80 79 [325] 90 89 88 87 86 85 96 95 94 93 92 91 54 53 52 51 50 49 [343] 60 59 58 57 56 55 66 65 64 63 62 61 72 71 70 69 68 67 [361] 78 77 76 75 74 73 84 83 82 81 80 79 90 89 88 87 86 85 [379] 96 95 94 93 92 91 102 101 100 99 98 97 108 107 106 105 104 103 [397] 114 113 112 111 110 109 120 119 118 117 116 115 126 125 124 123 122 121 [415] 132 131 130 129 128 127 138 137 136 135 134 133 144 143 142 141 140 139 [433] 102 101 100 99 98 97 108 107 106 105 104 103 114 113 112 111 110 109 [451] 120 119 118 117 116 115 126 125 124 123 122 121 132 131 130 129 128 127 [469] 138 137 136 135 134 133 144 143 142 141 140 139 102 101 100 99 98 97 [487] 108 107 106 105 104 103 114 113 112 111 110 109 120 119 118 117 116 115 [505] 126 125 124 123 122 121 132 131 130 129 128 127 138 137 136 135 134 133 [523] 144 143 142 141 140 139 102 101 100 99 98 97 108 107 106 105 104 103 [541] 114 113 112 111 110 109 120 119 118 117 116 115 126 125 124 123 122 121 [559] 132 131 130 129 128 127 138 137 136 135 134 133 144 143 142 141 140 139 [577] 150 149 148 147 146 145 156 155 154 153 152 151 162 161 160 159 158 157 [595] 168 167 166 165 164 163 174 173 172 171 170 169 180 179 178 177 176 175 [613] 186 185 184 183 182 181 192 191 190 189 188 187 150 149 148 147 146 145 [631] 156 155 154 153 152 151 162 161 160 159 158 157 168 167 166 165 164 163 [649] 174 173 172 171 170 169 180 179 178 177 176 175 186 185 184 183 182 181 [667] 192 191 190 189 188 187 150 149 148 147 146 145 156 155 154 153 152 151 [685] 162 161 160 159 158 157 168 167 166 165 164 163 174 173 172 171 170 169 [703] 180 179 178 177 176 175 186 185 184 183 182 181 192 191 190 189 188 187 [721] 150 149 148 147 146 145 156 155 154 153 152 151 162 161 160 159 158 157 [739] 168 167 166 165 164 163 174 173 172 171 170 169 180 179 178 177 176 175 [757] 186 185 184 183 182 181 192 191 190 189 188 187 $plate [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [112] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [149] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [186] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [223] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [260] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [297] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [334] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [371] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [408] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [445] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [482] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [519] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [556] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [593] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [630] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [667] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [704] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [741] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 $plate.r [1] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 [26] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 [51] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 [76] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 [101] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [126] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 [151] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [176] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 8 8 8 8 8 8 8 [201] 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 [226] 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 7 7 7 7 7 7 7 7 7 [251] 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 [276] 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 6 [301] 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 [326] 6 6 6 6 6 6 6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 5 5 5 5 [351] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 [376] 5 5 5 5 5 5 5 5 5 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 [401] 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 [426] 12 12 12 12 12 12 12 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 [451] 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 [476] 11 11 11 11 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 [501] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 [526] 10 10 10 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 [551] 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 [576] 9 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 [601] 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 15 [626] 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 [651] 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 14 14 14 [676] 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 [701] 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 13 13 13 13 13 [726] 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 [751] 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 $plate.c [1] 3 3 2 2 1 1 6 6 5 5 4 4 9 9 8 8 7 7 12 12 11 11 10 10 15 [26] 15 14 14 13 13 18 18 17 17 16 16 21 21 20 20 19 19 24 24 23 23 22 22 3 3 [51] 2 2 1 1 6 6 5 5 4 4 9 9 8 8 7 7 12 12 11 11 10 10 15 15 14 [76] 14 13 13 18 18 17 17 16 16 21 21 20 20 19 19 24 24 23 23 22 22 3 3 2 2 [101] 1 1 6 6 5 5 4 4 9 9 8 8 7 7 12 12 11 11 10 10 15 15 14 14 13 [126] 13 18 18 17 17 16 16 21 21 20 20 19 19 24 24 23 23 22 22 3 3 2 2 1 1 [151] 6 6 5 5 4 4 9 9 8 8 7 7 12 12 11 11 10 10 15 15 14 14 13 13 18 [176] 18 17 17 16 16 21 21 20 20 19 19 24 24 23 23 22 22 3 3 2 2 1 1 6 6 [201] 5 5 4 4 9 9 8 8 7 7 12 12 11 11 10 10 15 15 14 14 13 13 18 18 17 [226] 17 16 16 21 21 20 20 19 19 24 24 23 23 22 22 3 3 2 2 1 1 6 6 5 5 [251] 4 4 9 9 8 8 7 7 12 12 11 11 10 10 15 15 14 14 13 13 18 18 17 17 16 [276] 16 21 21 20 20 19 19 24 24 23 23 22 22 3 3 2 2 1 1 6 6 5 5 4 4 [301] 9 9 8 8 7 7 12 12 11 11 10 10 15 15 14 14 13 13 18 18 17 17 16 16 21 [326] 21 20 20 19 19 24 24 23 23 22 22 3 3 2 2 1 1 6 6 5 5 4 4 9 9 [351] 8 8 7 7 12 12 11 11 10 10 15 15 14 14 13 13 18 18 17 17 16 16 21 21 20 [376] 20 19 19 24 24 23 23 22 22 3 3 2 2 1 1 6 6 5 5 4 4 9 9 8 8 [401] 7 7 12 12 11 11 10 10 15 15 14 14 13 13 18 18 17 17 16 16 21 21 20 20 19 [426] 19 24 24 23 23 22 22 3 3 2 2 1 1 6 6 5 5 4 4 9 9 8 8 7 7 [451] 12 12 11 11 10 10 15 15 14 14 13 13 18 18 17 17 16 16 21 21 20 20 19 19 24 [476] 24 23 23 22 22 3 3 2 2 1 1 6 6 5 5 4 4 9 9 8 8 7 7 12 12 [501] 11 11 10 10 15 15 14 14 13 13 18 18 17 17 16 16 21 21 20 20 19 19 24 24 23 [526] 23 22 22 3 3 2 2 1 1 6 6 5 5 4 4 9 9 8 8 7 7 12 12 11 11 [551] 10 10 15 15 14 14 13 13 18 18 17 17 16 16 21 21 20 20 19 19 24 24 23 23 22 [576] 22 3 3 2 2 1 1 6 6 5 5 4 4 9 9 8 8 7 7 12 12 11 11 10 10 [601] 15 15 14 14 13 13 18 18 17 17 16 16 21 21 20 20 19 19 24 24 23 23 22 22 3 [626] 3 2 2 1 1 6 6 5 5 4 4 9 9 8 8 7 7 12 12 11 11 10 10 15 15 [651] 14 14 13 13 18 18 17 17 16 16 21 21 20 20 19 19 24 24 23 23 22 22 3 3 2 [676] 2 1 1 6 6 5 5 4 4 9 9 8 8 7 7 12 12 11 11 10 10 15 15 14 14 [701] 13 13 18 18 17 17 16 16 21 21 20 20 19 19 24 24 23 23 22 22 3 3 2 2 1 [726] 1 6 6 5 5 4 4 9 9 8 8 7 7 12 12 11 11 10 10 15 15 14 14 13 13 [751] 18 18 17 17 16 16 21 21 20 20 19 19 24 24 23 23 22 22 $plateposition [1] "p1D03" "p1D03" "p1D02" "p1D02" "p1D01" "p1D01" "p1D06" "p1D06" "p1D05" [10] "p1D05" "p1D04" "p1D04" "p1D09" "p1D09" "p1D08" "p1D08" "p1D07" "p1D07" [19] "p1D12" "p1D12" "p1D11" "p1D11" "p1D10" "p1D10" "p1D15" "p1D15" "p1D14" [28] "p1D14" "p1D13" "p1D13" "p1D18" "p1D18" "p1D17" "p1D17" "p1D16" "p1D16" [37] "p1D21" "p1D21" "p1D20" "p1D20" "p1D19" "p1D19" "p1D24" "p1D24" "p1D23" [46] "p1D23" "p1D22" "p1D22" "p1C03" "p1C03" "p1C02" "p1C02" "p1C01" "p1C01" [55] "p1C06" "p1C06" "p1C05" "p1C05" "p1C04" "p1C04" "p1C09" "p1C09" "p1C08" [64] "p1C08" "p1C07" "p1C07" "p1C12" "p1C12" "p1C11" "p1C11" "p1C10" "p1C10" [73] "p1C15" "p1C15" "p1C14" "p1C14" "p1C13" "p1C13" "p1C18" "p1C18" "p1C17" [82] "p1C17" "p1C16" "p1C16" "p1C21" "p1C21" "p1C20" "p1C20" "p1C19" "p1C19" [91] "p1C24" "p1C24" "p1C23" "p1C23" "p1C22" "p1C22" "p1B03" "p1B03" "p1B02" [100] "p1B02" "p1B01" "p1B01" "p1B06" "p1B06" "p1B05" "p1B05" "p1B04" "p1B04" [109] "p1B09" "p1B09" "p1B08" "p1B08" "p1B07" "p1B07" "p1B12" "p1B12" "p1B11" [118] "p1B11" "p1B10" "p1B10" "p1B15" "p1B15" "p1B14" "p1B14" "p1B13" "p1B13" [127] "p1B18" "p1B18" "p1B17" "p1B17" "p1B16" "p1B16" "p1B21" "p1B21" "p1B20" [136] "p1B20" "p1B19" "p1B19" "p1B24" "p1B24" "p1B23" "p1B23" "p1B22" "p1B22" [145] "p1A03" "p1A03" "p1A02" "p1A02" "p1A01" "p1A01" "p1A06" "p1A06" "p1A05" [154] "p1A05" "p1A04" "p1A04" "p1A09" "p1A09" "p1A08" "p1A08" "p1A07" "p1A07" [163] "p1A12" "p1A12" "p1A11" "p1A11" "p1A10" "p1A10" "p1A15" "p1A15" "p1A14" [172] "p1A14" "p1A13" "p1A13" "p1A18" "p1A18" "p1A17" "p1A17" "p1A16" "p1A16" [181] "p1A21" "p1A21" "p1A20" "p1A20" "p1A19" "p1A19" "p1A24" "p1A24" "p1A23" [190] "p1A23" "p1A22" "p1A22" "p1H03" "p1H03" "p1H02" "p1H02" "p1H01" "p1H01" [199] "p1H06" "p1H06" "p1H05" "p1H05" "p1H04" "p1H04" "p1H09" "p1H09" "p1H08" [208] "p1H08" "p1H07" "p1H07" "p1H12" "p1H12" "p1H11" "p1H11" "p1H10" "p1H10" [217] "p1H15" "p1H15" "p1H14" "p1H14" "p1H13" "p1H13" "p1H18" "p1H18" "p1H17" [226] "p1H17" "p1H16" "p1H16" "p1H21" "p1H21" "p1H20" "p1H20" "p1H19" "p1H19" [235] "p1H24" "p1H24" "p1H23" "p1H23" "p1H22" "p1H22" "p1G03" "p1G03" "p1G02" [244] "p1G02" "p1G01" "p1G01" "p1G06" "p1G06" "p1G05" "p1G05" "p1G04" "p1G04" [253] "p1G09" "p1G09" "p1G08" "p1G08" "p1G07" "p1G07" "p1G12" "p1G12" "p1G11" [262] "p1G11" "p1G10" "p1G10" "p1G15" "p1G15" "p1G14" "p1G14" "p1G13" "p1G13" [271] "p1G18" "p1G18" "p1G17" "p1G17" "p1G16" "p1G16" "p1G21" "p1G21" "p1G20" [280] "p1G20" "p1G19" "p1G19" "p1G24" "p1G24" "p1G23" "p1G23" "p1G22" "p1G22" [289] "p1F03" "p1F03" "p1F02" "p1F02" "p1F01" "p1F01" "p1F06" "p1F06" "p1F05" [298] "p1F05" "p1F04" "p1F04" "p1F09" "p1F09" "p1F08" "p1F08" "p1F07" "p1F07" [307] "p1F12" "p1F12" "p1F11" "p1F11" "p1F10" "p1F10" "p1F15" "p1F15" "p1F14" [316] "p1F14" "p1F13" "p1F13" "p1F18" "p1F18" "p1F17" "p1F17" "p1F16" "p1F16" [325] "p1F21" "p1F21" "p1F20" "p1F20" "p1F19" "p1F19" "p1F24" "p1F24" "p1F23" [334] "p1F23" "p1F22" "p1F22" "p1E03" "p1E03" "p1E02" "p1E02" "p1E01" "p1E01" [343] "p1E06" "p1E06" "p1E05" "p1E05" "p1E04" "p1E04" "p1E09" "p1E09" "p1E08" [352] "p1E08" "p1E07" "p1E07" "p1E12" "p1E12" "p1E11" "p1E11" "p1E10" "p1E10" [361] "p1E15" "p1E15" "p1E14" "p1E14" "p1E13" "p1E13" "p1E18" "p1E18" "p1E17" [370] "p1E17" "p1E16" "p1E16" "p1E21" "p1E21" "p1E20" "p1E20" "p1E19" "p1E19" [379] "p1E24" "p1E24" "p1E23" "p1E23" "p1E22" "p1E22" "p1L03" "p1L03" "p1L02" [388] "p1L02" "p1L01" "p1L01" "p1L06" "p1L06" "p1L05" "p1L05" "p1L04" "p1L04" [397] "p1L09" "p1L09" "p1L08" "p1L08" "p1L07" "p1L07" "p1L12" "p1L12" "p1L11" [406] "p1L11" "p1L10" "p1L10" "p1L15" "p1L15" "p1L14" "p1L14" "p1L13" "p1L13" [415] "p1L18" "p1L18" "p1L17" "p1L17" "p1L16" "p1L16" "p1L21" "p1L21" "p1L20" [424] "p1L20" "p1L19" "p1L19" "p1L24" "p1L24" "p1L23" "p1L23" "p1L22" "p1L22" [433] "p1K03" "p1K03" "p1K02" "p1K02" "p1K01" "p1K01" "p1K06" "p1K06" "p1K05" [442] "p1K05" "p1K04" "p1K04" "p1K09" "p1K09" "p1K08" "p1K08" "p1K07" "p1K07" [451] "p1K12" "p1K12" "p1K11" "p1K11" "p1K10" "p1K10" "p1K15" "p1K15" "p1K14" [460] "p1K14" "p1K13" "p1K13" "p1K18" "p1K18" "p1K17" "p1K17" "p1K16" "p1K16" [469] "p1K21" "p1K21" "p1K20" "p1K20" "p1K19" "p1K19" "p1K24" "p1K24" "p1K23" [478] "p1K23" "p1K22" "p1K22" "p1J03" "p1J03" "p1J02" "p1J02" "p1J01" "p1J01" [487] "p1J06" "p1J06" "p1J05" "p1J05" "p1J04" "p1J04" "p1J09" "p1J09" "p1J08" [496] "p1J08" "p1J07" "p1J07" "p1J12" "p1J12" "p1J11" "p1J11" "p1J10" "p1J10" [505] "p1J15" "p1J15" "p1J14" "p1J14" "p1J13" "p1J13" "p1J18" "p1J18" "p1J17" [514] "p1J17" "p1J16" "p1J16" "p1J21" "p1J21" "p1J20" "p1J20" "p1J19" "p1J19" [523] "p1J24" "p1J24" "p1J23" "p1J23" "p1J22" "p1J22" "p1I03" "p1I03" "p1I02" [532] "p1I02" "p1I01" "p1I01" "p1I06" "p1I06" "p1I05" "p1I05" "p1I04" "p1I04" [541] "p1I09" "p1I09" "p1I08" "p1I08" "p1I07" "p1I07" "p1I12" "p1I12" "p1I11" [550] "p1I11" "p1I10" "p1I10" "p1I15" "p1I15" "p1I14" "p1I14" "p1I13" "p1I13" [559] "p1I18" "p1I18" "p1I17" "p1I17" "p1I16" "p1I16" "p1I21" "p1I21" "p1I20" [568] "p1I20" "p1I19" "p1I19" "p1I24" "p1I24" "p1I23" "p1I23" "p1I22" "p1I22" [577] "p1P03" "p1P03" "p1P02" "p1P02" "p1P01" "p1P01" "p1P06" "p1P06" "p1P05" [586] "p1P05" "p1P04" "p1P04" "p1P09" "p1P09" "p1P08" "p1P08" "p1P07" "p1P07" [595] "p1P12" "p1P12" "p1P11" "p1P11" "p1P10" "p1P10" "p1P15" "p1P15" "p1P14" [604] "p1P14" "p1P13" "p1P13" "p1P18" "p1P18" "p1P17" "p1P17" "p1P16" "p1P16" [613] "p1P21" "p1P21" "p1P20" "p1P20" "p1P19" "p1P19" "p1P24" "p1P24" "p1P23" [622] "p1P23" "p1P22" "p1P22" "p1O03" "p1O03" "p1O02" "p1O02" "p1O01" "p1O01" [631] "p1O06" "p1O06" "p1O05" "p1O05" "p1O04" "p1O04" "p1O09" "p1O09" "p1O08" [640] "p1O08" "p1O07" "p1O07" "p1O12" "p1O12" "p1O11" "p1O11" "p1O10" "p1O10" [649] "p1O15" "p1O15" "p1O14" "p1O14" "p1O13" "p1O13" "p1O18" "p1O18" "p1O17" [658] "p1O17" "p1O16" "p1O16" "p1O21" "p1O21" "p1O20" "p1O20" "p1O19" "p1O19" [667] "p1O24" "p1O24" "p1O23" "p1O23" "p1O22" "p1O22" "p1N03" "p1N03" "p1N02" [676] "p1N02" "p1N01" "p1N01" "p1N06" "p1N06" "p1N05" "p1N05" "p1N04" "p1N04" [685] "p1N09" "p1N09" "p1N08" "p1N08" "p1N07" "p1N07" "p1N12" "p1N12" "p1N11" [694] "p1N11" "p1N10" "p1N10" "p1N15" "p1N15" "p1N14" "p1N14" "p1N13" "p1N13" [703] "p1N18" "p1N18" "p1N17" "p1N17" "p1N16" "p1N16" "p1N21" "p1N21" "p1N20" [712] "p1N20" "p1N19" "p1N19" "p1N24" "p1N24" "p1N23" "p1N23" "p1N22" "p1N22" [721] "p1M03" "p1M03" "p1M02" "p1M02" "p1M01" "p1M01" "p1M06" "p1M06" "p1M05" [730] "p1M05" "p1M04" "p1M04" "p1M09" "p1M09" "p1M08" "p1M08" "p1M07" "p1M07" [739] "p1M12" "p1M12" "p1M11" "p1M11" "p1M10" "p1M10" "p1M15" "p1M15" "p1M14" [748] "p1M14" "p1M13" "p1M13" "p1M18" "p1M18" "p1M17" "p1M17" "p1M16" "p1M16" [757] "p1M21" "p1M21" "p1M20" "p1M20" "p1M19" "p1M19" "p1M24" "p1M24" "p1M23" [766] "p1M23" "p1M22" "p1M22" > printorder(list(ngrid.r=4,ngrid.c=4,nspot.r=8,nspot.c=6)) $printorder [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1 2 [51] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [76] 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1 2 3 4 [101] 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 [126] 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1 2 3 4 5 6 [151] 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [176] 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1 2 3 4 5 6 7 8 [201] 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 [226] 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1 2 3 4 5 6 7 8 9 10 [251] 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 [276] 36 37 38 39 40 41 42 43 44 45 46 47 48 1 2 3 4 5 6 7 8 9 10 11 12 [301] 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 [326] 38 39 40 41 42 43 44 45 46 47 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [351] 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 [376] 40 41 42 43 44 45 46 47 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [401] 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 [426] 42 43 44 45 46 47 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [451] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 [476] 44 45 46 47 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [501] 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 [526] 46 47 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [551] 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 [576] 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 [601] 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1 [626] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [651] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1 2 3 [676] 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 [701] 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1 2 3 4 5 [726] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 [751] 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 $plate [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 [38] 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 [75] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [112] 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 [149] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [186] 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 [223] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [260] 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 [297] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [334] 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 [371] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [408] 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 [445] 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 [482] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [519] 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [556] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [593] 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 [630] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [667] 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 [704] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [741] 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 $plate.r [1] 4 4 4 4 4 4 8 8 8 8 8 8 12 12 12 12 12 12 16 16 16 16 16 16 4 [26] 4 4 4 4 4 8 8 8 8 8 8 12 12 12 12 12 12 16 16 16 16 16 16 3 3 [51] 3 3 3 3 7 7 7 7 7 7 11 11 11 11 11 11 15 15 15 15 15 15 3 3 3 [76] 3 3 3 7 7 7 7 7 7 11 11 11 11 11 11 15 15 15 15 15 15 2 2 2 2 [101] 2 2 6 6 6 6 6 6 10 10 10 10 10 10 14 14 14 14 14 14 2 2 2 2 2 [126] 2 6 6 6 6 6 6 10 10 10 10 10 10 14 14 14 14 14 14 1 1 1 1 1 1 [151] 5 5 5 5 5 5 9 9 9 9 9 9 13 13 13 13 13 13 1 1 1 1 1 1 5 [176] 5 5 5 5 5 9 9 9 9 9 9 13 13 13 13 13 13 4 4 4 4 4 4 8 8 [201] 8 8 8 8 12 12 12 12 12 12 16 16 16 16 16 16 4 4 4 4 4 4 8 8 8 [226] 8 8 8 12 12 12 12 12 12 16 16 16 16 16 16 3 3 3 3 3 3 7 7 7 7 [251] 7 7 11 11 11 11 11 11 15 15 15 15 15 15 3 3 3 3 3 3 7 7 7 7 7 [276] 7 11 11 11 11 11 11 15 15 15 15 15 15 2 2 2 2 2 2 6 6 6 6 6 6 [301] 10 10 10 10 10 10 14 14 14 14 14 14 2 2 2 2 2 2 6 6 6 6 6 6 10 [326] 10 10 10 10 10 14 14 14 14 14 14 1 1 1 1 1 1 5 5 5 5 5 5 9 9 [351] 9 9 9 9 13 13 13 13 13 13 1 1 1 1 1 1 5 5 5 5 5 5 9 9 9 [376] 9 9 9 13 13 13 13 13 13 4 4 4 4 4 4 8 8 8 8 8 8 12 12 12 12 [401] 12 12 16 16 16 16 16 16 4 4 4 4 4 4 8 8 8 8 8 8 12 12 12 12 12 [426] 12 16 16 16 16 16 16 3 3 3 3 3 3 7 7 7 7 7 7 11 11 11 11 11 11 [451] 15 15 15 15 15 15 3 3 3 3 3 3 7 7 7 7 7 7 11 11 11 11 11 11 15 [476] 15 15 15 15 15 2 2 2 2 2 2 6 6 6 6 6 6 10 10 10 10 10 10 14 14 [501] 14 14 14 14 2 2 2 2 2 2 6 6 6 6 6 6 10 10 10 10 10 10 14 14 14 [526] 14 14 14 1 1 1 1 1 1 5 5 5 5 5 5 9 9 9 9 9 9 13 13 13 13 [551] 13 13 1 1 1 1 1 1 5 5 5 5 5 5 9 9 9 9 9 9 13 13 13 13 13 [576] 13 4 4 4 4 4 4 8 8 8 8 8 8 12 12 12 12 12 12 16 16 16 16 16 16 [601] 4 4 4 4 4 4 8 8 8 8 8 8 12 12 12 12 12 12 16 16 16 16 16 16 3 [626] 3 3 3 3 3 7 7 7 7 7 7 11 11 11 11 11 11 15 15 15 15 15 15 3 3 [651] 3 3 3 3 7 7 7 7 7 7 11 11 11 11 11 11 15 15 15 15 15 15 2 2 2 [676] 2 2 2 6 6 6 6 6 6 10 10 10 10 10 10 14 14 14 14 14 14 2 2 2 2 [701] 2 2 6 6 6 6 6 6 10 10 10 10 10 10 14 14 14 14 14 14 1 1 1 1 1 [726] 1 5 5 5 5 5 5 9 9 9 9 9 9 13 13 13 13 13 13 1 1 1 1 1 1 [751] 5 5 5 5 5 5 9 9 9 9 9 9 13 13 13 13 13 13 $plate.c [1] 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 [26] 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 [51] 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 [76] 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 [101] 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 [126] 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 [151] 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 1 [176] 5 9 13 17 21 1 5 9 13 17 21 1 5 9 13 17 21 2 6 10 14 18 22 2 6 [201] 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 [226] 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 [251] 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 [276] 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 [301] 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 [326] 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 [351] 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 14 18 22 2 6 10 [376] 14 18 22 2 6 10 14 18 22 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 [401] 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 [426] 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 [451] 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 [476] 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 [501] 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 [526] 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 [551] 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 23 3 7 11 15 19 [576] 23 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 [601] 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 [626] 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 [651] 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 [676] 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 [701] 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 [726] 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 [751] 4 8 12 16 20 24 4 8 12 16 20 24 4 8 12 16 20 24 $plateposition [1] "p1D01" "p1D05" "p1D09" "p1D13" "p1D17" "p1D21" "p1H01" "p1H05" "p1H09" [10] "p1H13" "p1H17" "p1H21" "p1L01" "p1L05" "p1L09" "p1L13" "p1L17" "p1L21" [19] "p1P01" "p1P05" "p1P09" "p1P13" "p1P17" "p1P21" "p2D01" "p2D05" "p2D09" [28] "p2D13" "p2D17" "p2D21" "p2H01" "p2H05" "p2H09" "p2H13" "p2H17" "p2H21" [37] "p2L01" "p2L05" "p2L09" "p2L13" "p2L17" "p2L21" "p2P01" "p2P05" "p2P09" [46] "p2P13" "p2P17" "p2P21" "p1C01" "p1C05" "p1C09" "p1C13" "p1C17" "p1C21" [55] "p1G01" "p1G05" "p1G09" "p1G13" "p1G17" "p1G21" "p1K01" "p1K05" "p1K09" [64] "p1K13" "p1K17" "p1K21" "p1O01" "p1O05" "p1O09" "p1O13" "p1O17" "p1O21" [73] "p2C01" "p2C05" "p2C09" "p2C13" "p2C17" "p2C21" "p2G01" "p2G05" "p2G09" [82] "p2G13" "p2G17" "p2G21" "p2K01" "p2K05" "p2K09" "p2K13" "p2K17" "p2K21" [91] "p2O01" "p2O05" "p2O09" "p2O13" "p2O17" "p2O21" "p1B01" "p1B05" "p1B09" [100] "p1B13" "p1B17" "p1B21" "p1F01" "p1F05" "p1F09" "p1F13" "p1F17" "p1F21" [109] "p1J01" "p1J05" "p1J09" "p1J13" "p1J17" "p1J21" "p1N01" "p1N05" "p1N09" [118] "p1N13" "p1N17" "p1N21" "p2B01" "p2B05" "p2B09" "p2B13" "p2B17" "p2B21" [127] "p2F01" "p2F05" "p2F09" "p2F13" "p2F17" "p2F21" "p2J01" "p2J05" "p2J09" [136] "p2J13" "p2J17" "p2J21" "p2N01" "p2N05" "p2N09" "p2N13" "p2N17" "p2N21" [145] "p1A01" "p1A05" "p1A09" "p1A13" "p1A17" "p1A21" "p1E01" "p1E05" "p1E09" [154] "p1E13" "p1E17" "p1E21" "p1I01" "p1I05" "p1I09" "p1I13" "p1I17" "p1I21" [163] "p1M01" "p1M05" "p1M09" "p1M13" "p1M17" "p1M21" "p2A01" "p2A05" "p2A09" [172] "p2A13" "p2A17" "p2A21" "p2E01" "p2E05" "p2E09" "p2E13" "p2E17" "p2E21" [181] "p2I01" "p2I05" "p2I09" "p2I13" "p2I17" "p2I21" "p2M01" "p2M05" "p2M09" [190] "p2M13" "p2M17" "p2M21" "p1D02" "p1D06" "p1D10" "p1D14" "p1D18" "p1D22" [199] "p1H02" "p1H06" "p1H10" "p1H14" "p1H18" "p1H22" "p1L02" "p1L06" "p1L10" [208] "p1L14" "p1L18" "p1L22" "p1P02" "p1P06" "p1P10" "p1P14" "p1P18" "p1P22" [217] "p2D02" "p2D06" "p2D10" "p2D14" "p2D18" "p2D22" "p2H02" "p2H06" "p2H10" [226] "p2H14" "p2H18" "p2H22" "p2L02" "p2L06" "p2L10" "p2L14" "p2L18" "p2L22" [235] "p2P02" "p2P06" "p2P10" "p2P14" "p2P18" "p2P22" "p1C02" "p1C06" "p1C10" [244] "p1C14" "p1C18" "p1C22" "p1G02" "p1G06" "p1G10" "p1G14" "p1G18" "p1G22" [253] "p1K02" "p1K06" "p1K10" "p1K14" "p1K18" "p1K22" "p1O02" "p1O06" "p1O10" [262] "p1O14" "p1O18" "p1O22" "p2C02" "p2C06" "p2C10" "p2C14" "p2C18" "p2C22" [271] "p2G02" "p2G06" "p2G10" "p2G14" "p2G18" "p2G22" "p2K02" "p2K06" "p2K10" [280] "p2K14" "p2K18" "p2K22" "p2O02" "p2O06" "p2O10" "p2O14" "p2O18" "p2O22" [289] "p1B02" "p1B06" "p1B10" "p1B14" "p1B18" "p1B22" "p1F02" "p1F06" "p1F10" [298] "p1F14" "p1F18" "p1F22" "p1J02" "p1J06" "p1J10" "p1J14" "p1J18" "p1J22" [307] "p1N02" "p1N06" "p1N10" "p1N14" "p1N18" "p1N22" "p2B02" "p2B06" "p2B10" [316] "p2B14" "p2B18" "p2B22" "p2F02" "p2F06" "p2F10" "p2F14" "p2F18" "p2F22" [325] "p2J02" "p2J06" "p2J10" "p2J14" "p2J18" "p2J22" "p2N02" "p2N06" "p2N10" [334] "p2N14" "p2N18" "p2N22" "p1A02" "p1A06" "p1A10" "p1A14" "p1A18" "p1A22" [343] "p1E02" "p1E06" "p1E10" "p1E14" "p1E18" "p1E22" "p1I02" "p1I06" "p1I10" [352] "p1I14" "p1I18" "p1I22" "p1M02" "p1M06" "p1M10" "p1M14" "p1M18" "p1M22" [361] "p2A02" "p2A06" "p2A10" "p2A14" "p2A18" "p2A22" "p2E02" "p2E06" "p2E10" [370] "p2E14" "p2E18" "p2E22" "p2I02" "p2I06" "p2I10" "p2I14" "p2I18" "p2I22" [379] "p2M02" "p2M06" "p2M10" "p2M14" "p2M18" "p2M22" "p1D03" "p1D07" "p1D11" [388] "p1D15" "p1D19" "p1D23" "p1H03" "p1H07" "p1H11" "p1H15" "p1H19" "p1H23" [397] "p1L03" "p1L07" "p1L11" "p1L15" "p1L19" "p1L23" "p1P03" "p1P07" "p1P11" [406] "p1P15" "p1P19" "p1P23" "p2D03" "p2D07" "p2D11" "p2D15" "p2D19" "p2D23" [415] "p2H03" "p2H07" "p2H11" "p2H15" "p2H19" "p2H23" "p2L03" "p2L07" "p2L11" [424] "p2L15" "p2L19" "p2L23" "p2P03" "p2P07" "p2P11" "p2P15" "p2P19" "p2P23" [433] "p1C03" "p1C07" "p1C11" "p1C15" "p1C19" "p1C23" "p1G03" "p1G07" "p1G11" [442] "p1G15" "p1G19" "p1G23" "p1K03" "p1K07" "p1K11" "p1K15" "p1K19" "p1K23" [451] "p1O03" "p1O07" "p1O11" "p1O15" "p1O19" "p1O23" "p2C03" "p2C07" "p2C11" [460] "p2C15" "p2C19" "p2C23" "p2G03" "p2G07" "p2G11" "p2G15" "p2G19" "p2G23" [469] "p2K03" "p2K07" "p2K11" "p2K15" "p2K19" "p2K23" "p2O03" "p2O07" "p2O11" [478] "p2O15" "p2O19" "p2O23" "p1B03" "p1B07" "p1B11" "p1B15" "p1B19" "p1B23" [487] "p1F03" "p1F07" "p1F11" "p1F15" "p1F19" "p1F23" "p1J03" "p1J07" "p1J11" [496] "p1J15" "p1J19" "p1J23" "p1N03" "p1N07" "p1N11" "p1N15" "p1N19" "p1N23" [505] "p2B03" "p2B07" "p2B11" "p2B15" "p2B19" "p2B23" "p2F03" "p2F07" "p2F11" [514] "p2F15" "p2F19" "p2F23" "p2J03" "p2J07" "p2J11" "p2J15" "p2J19" "p2J23" [523] "p2N03" "p2N07" "p2N11" "p2N15" "p2N19" "p2N23" "p1A03" "p1A07" "p1A11" [532] "p1A15" "p1A19" "p1A23" "p1E03" "p1E07" "p1E11" "p1E15" "p1E19" "p1E23" [541] "p1I03" "p1I07" "p1I11" "p1I15" "p1I19" "p1I23" "p1M03" "p1M07" "p1M11" [550] "p1M15" "p1M19" "p1M23" "p2A03" "p2A07" "p2A11" "p2A15" "p2A19" "p2A23" [559] "p2E03" "p2E07" "p2E11" "p2E15" "p2E19" "p2E23" "p2I03" "p2I07" "p2I11" [568] "p2I15" "p2I19" "p2I23" "p2M03" "p2M07" "p2M11" "p2M15" "p2M19" "p2M23" [577] "p1D04" "p1D08" "p1D12" "p1D16" "p1D20" "p1D24" "p1H04" "p1H08" "p1H12" [586] "p1H16" "p1H20" "p1H24" "p1L04" "p1L08" "p1L12" "p1L16" "p1L20" "p1L24" [595] "p1P04" "p1P08" "p1P12" "p1P16" "p1P20" "p1P24" "p2D04" "p2D08" "p2D12" [604] "p2D16" "p2D20" "p2D24" "p2H04" "p2H08" "p2H12" "p2H16" "p2H20" "p2H24" [613] "p2L04" "p2L08" "p2L12" "p2L16" "p2L20" "p2L24" "p2P04" "p2P08" "p2P12" [622] "p2P16" "p2P20" "p2P24" "p1C04" "p1C08" "p1C12" "p1C16" "p1C20" "p1C24" [631] "p1G04" "p1G08" "p1G12" "p1G16" "p1G20" "p1G24" "p1K04" "p1K08" "p1K12" [640] "p1K16" "p1K20" "p1K24" "p1O04" "p1O08" "p1O12" "p1O16" "p1O20" "p1O24" [649] "p2C04" "p2C08" "p2C12" "p2C16" "p2C20" "p2C24" "p2G04" "p2G08" "p2G12" [658] "p2G16" "p2G20" "p2G24" "p2K04" "p2K08" "p2K12" "p2K16" "p2K20" "p2K24" [667] "p2O04" "p2O08" "p2O12" "p2O16" "p2O20" "p2O24" "p1B04" "p1B08" "p1B12" [676] "p1B16" "p1B20" "p1B24" "p1F04" "p1F08" "p1F12" "p1F16" "p1F20" "p1F24" [685] "p1J04" "p1J08" "p1J12" "p1J16" "p1J20" "p1J24" "p1N04" "p1N08" "p1N12" [694] "p1N16" "p1N20" "p1N24" "p2B04" "p2B08" "p2B12" "p2B16" "p2B20" "p2B24" [703] "p2F04" "p2F08" "p2F12" "p2F16" "p2F20" "p2F24" "p2J04" "p2J08" "p2J12" [712] "p2J16" "p2J20" "p2J24" "p2N04" "p2N08" "p2N12" "p2N16" "p2N20" "p2N24" [721] "p1A04" "p1A08" "p1A12" "p1A16" "p1A20" "p1A24" "p1E04" "p1E08" "p1E12" [730] "p1E16" "p1E20" "p1E24" "p1I04" "p1I08" "p1I12" "p1I16" "p1I20" "p1I24" [739] "p1M04" "p1M08" "p1M12" "p1M16" "p1M20" "p1M24" "p2A04" "p2A08" "p2A12" [748] "p2A16" "p2A20" "p2A24" "p2E04" "p2E08" "p2E12" "p2E16" "p2E20" "p2E24" [757] "p2I04" "p2I08" "p2I12" "p2I16" "p2I20" "p2I24" "p2M04" "p2M08" "p2M12" [766] "p2M16" "p2M20" "p2M24" > > ### merge.rglist > > R <- G <- matrix(11:14,4,2) > rownames(R) <- rownames(G) <- c("a","a","b","c") > RG1 <- new("RGList",list(R=R,G=G)) > R <- G <- matrix(21:24,4,2) > rownames(R) <- rownames(G) <- c("b","a","a","c") > RG2 <- new("RGList",list(R=R,G=G)) > merge(RG1,RG2) An object of class "RGList" $R [,1] [,2] [,3] [,4] a 11 11 22 22 a 12 12 23 23 b 13 13 21 21 c 14 14 24 24 $G [,1] [,2] [,3] [,4] a 11 11 22 22 a 12 12 23 23 b 13 13 21 21 c 14 14 24 24 > merge(RG2,RG1) An object of class "RGList" $R [,1] [,2] [,3] [,4] b 21 21 13 13 a 22 22 11 11 a 23 23 12 12 c 24 24 14 14 $G [,1] [,2] [,3] [,4] b 21 21 13 13 a 22 22 11 11 a 23 23 12 12 c 24 24 14 14 > > ### background correction > > RG <- new("RGList", list(R=c(1,2,3,4),G=c(1,2,3,4),Rb=c(2,2,2,2),Gb=c(2,2,2,2))) > backgroundCorrect(RG) An object of class "RGList" $R [,1] [1,] -1 [2,] 0 [3,] 1 [4,] 2 $G [,1] [1,] -1 [2,] 0 [3,] 1 [4,] 2 > backgroundCorrect(RG, method="half") An object of class "RGList" $R [,1] [1,] 0.5 [2,] 0.5 [3,] 1.0 [4,] 2.0 $G [,1] [1,] 0.5 [2,] 0.5 [3,] 1.0 [4,] 2.0 > backgroundCorrect(RG, method="minimum") An object of class "RGList" $R [,1] [1,] 0.5 [2,] 0.5 [3,] 1.0 [4,] 2.0 $G [,1] [1,] 0.5 [2,] 0.5 [3,] 1.0 [4,] 2.0 > backgroundCorrect(RG, offset=5) An object of class "RGList" $R [,1] [1,] 4 [2,] 5 [3,] 6 [4,] 7 $G [,1] [1,] 4 [2,] 5 [3,] 6 [4,] 7 > > ### loessFit > > x <- 1:100 > y <- rnorm(100) > out <- loessFit(y,x) > f1 <- quantile(out$fitted) > r1 <- quantile(out$residual) > w <- rep(1,100) > w[1:50] <- 0.5 > out <- loessFit(y,x,weights=w) > f2 <- quantile(out$fitted) > r2 <- quantile(out$residual) > w[1:80] <- 0 > out <- loessFit(y,x,weights=w) > f3 <- quantile(out$fitted) > r3 <- quantile(out$residual) > data.frame(f1,f2,f3,r1,r2,r3) f1 f2 f3 r1 r2 r3 0% -0.78835384 -0.78097895 -0.78367166 -2.04434053 -2.04315267 -11.5610680 25% -0.18340154 -0.18907787 -0.15525721 -0.59321065 -0.59309327 -0.8249477 50% -0.11492924 -0.12136183 -0.03316003 0.05874864 0.08898459 -0.2466309 75% 0.01507921 -0.01000344 0.13229151 0.56010750 0.56606786 0.4502908 100% 0.21653837 0.21604173 11.69912073 2.57936026 2.56259812 2.5149556 > > ### normalizeWithinArrays > > RG <- new("RGList",list()) > RG$R <- matrix(rexp(100*2),100,2) > RG$G <- matrix(rexp(100*2),100,2) > RG$Rb <- matrix(rnorm(100*2,sd=0.02),100,2) > RG$Gb <- matrix(rnorm(100*2,sd=0.02),100,2) > RGb <- backgroundCorrect(RG,method="normexp",normexp.method="saddle") Array 1 corrected Array 2 corrected Array 1 corrected Array 2 corrected > summary(cbind(RGb$R,RGb$G)) V1 V2 V3 V4 Min. :0.01626 Min. :0.01213 Min. :0.0000 Min. :0.0000 1st Qu.:0.35497 1st Qu.:0.29133 1st Qu.:0.2745 1st Qu.:0.3953 Median :0.71793 Median :0.70294 Median :0.6339 Median :0.8223 Mean :0.90184 Mean :1.00122 Mean :0.9454 Mean :1.1324 3rd Qu.:1.16891 3rd Qu.:1.33139 3rd Qu.:1.4059 3rd Qu.:1.4221 Max. :4.56267 Max. :6.37947 Max. :5.0486 Max. :6.6295 > RGb <- backgroundCorrect(RG,method="normexp",normexp.method="mle") Array 1 corrected Array 2 corrected Array 1 corrected Array 2 corrected > summary(cbind(RGb$R,RGb$G)) V1 V2 V3 V4 Min. :0.01701 Min. :0.01255 Min. :0.0000 Min. :0.0000 1st Qu.:0.35423 1st Qu.:0.29118 1st Qu.:0.2745 1st Qu.:0.3953 Median :0.71719 Median :0.70280 Median :0.6339 Median :0.8223 Mean :0.90118 Mean :1.00110 Mean :0.9454 Mean :1.1324 3rd Qu.:1.16817 3rd Qu.:1.33124 3rd Qu.:1.4059 3rd Qu.:1.4221 Max. :4.56193 Max. :6.37932 Max. :5.0486 Max. :6.6295 > MA <- normalizeWithinArrays(RGb,method="loess") > summary(MA$M) V1 V2 Min. :-5.85163 Min. :-5.69877 1st Qu.:-1.18482 1st Qu.:-1.55421 Median :-0.21631 Median : 0.06267 Mean : 0.03613 Mean :-0.05369 3rd Qu.: 1.49673 3rd Qu.: 1.41900 Max. : 7.07528 Max. : 6.28902 > #MA <- normalizeWithinArrays(RG[,1:2], mouse.setup, method="robustspline") > #MA$M[1:5,] > #MA <- normalizeWithinArrays(mouse.data, mouse.setup) > #MA$M[1:5,] > > ### normalizeBetweenArrays > > MA2 <- normalizeBetweenArrays(MA,method="scale") > MA$M[1:5,] [,1] [,2] [1,] -1.1623390 4.5343276 [2,] 0.8971391 0.3495635 [3,] 2.8247455 1.4459533 [4,] -1.8533288 0.4894799 [5,] 1.9158416 -5.5363732 > MA$A[1:5,] [,1] [,2] [1,] -2.48465011 -2.4041550 [2,] -0.79230447 -0.9002250 [3,] -0.76237200 0.2071043 [4,] 0.09281027 -1.3880965 [5,] 0.22385828 -3.0855818 > MA2 <- normalizeBetweenArrays(MA,method="quantile") > MA$M[1:5,] [,1] [,2] [1,] -1.1623390 4.5343276 [2,] 0.8971391 0.3495635 [3,] 2.8247455 1.4459533 [4,] -1.8533288 0.4894799 [5,] 1.9158416 -5.5363732 > MA$A[1:5,] [,1] [,2] [1,] -2.48465011 -2.4041550 [2,] -0.79230447 -0.9002250 [3,] -0.76237200 0.2071043 [4,] 0.09281027 -1.3880965 [5,] 0.22385828 -3.0855818 > > ### unwrapdups > > M <- matrix(1:12,6,2) > unwrapdups(M,ndups=1) [,1] [,2] [1,] 1 7 [2,] 2 8 [3,] 3 9 [4,] 4 10 [5,] 5 11 [6,] 6 12 > unwrapdups(M,ndups=2) [,1] [,2] [,3] [,4] [1,] 1 2 7 8 [2,] 3 4 9 10 [3,] 5 6 11 12 > unwrapdups(M,ndups=3) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 2 3 7 8 9 [2,] 4 5 6 10 11 12 > unwrapdups(M,ndups=2,spacing=3) [,1] [,2] [,3] [,4] [1,] 1 4 7 10 [2,] 2 5 8 11 [3,] 3 6 9 12 > > ### trigammaInverse > > trigammaInverse(c(1e-6,NA,5,1e6)) [1] 1.000000e+06 NA 4.961687e-01 1.000001e-03 > > ### lm.series, contrasts.fit, ebayes > > M <- matrix(rnorm(10*6,sd=0.3),10,6) > M[1,1:3] <- M[1,1:3] + 2 > design <- cbind(First3Arrays=c(1,1,1,0,0,0),Last3Arrays=c(0,0,0,1,1,1)) > fit <- lm.series(M,design=design) > contrast.matrix <- cbind(First3=c(1,0),Last3=c(0,1),"Last3-First3"=c(-1,1)) > fit2 <- contrasts.fit(fit,contrasts=contrast.matrix) > eb <- ebayes(fit2) > > eb$t First3 Last3 Last3-First3 [1,] 9.23328899 0.3132376 -6.3074289 [2,] -0.62297130 0.7033694 0.9378645 [3,] -0.63617368 0.7848179 1.0047928 [4,] -0.28354965 2.0342050 1.6389001 [5,] 0.09867104 0.5424981 0.3138331 [6,] -0.84479508 -1.7161311 -0.6161276 [7,] 1.60397813 -0.3573420 -1.3868627 [8,] -0.88080565 1.0698285 1.3793067 [9,] -0.24543647 0.2077673 0.3204634 [10,] 1.11347326 0.3678166 -0.5272589 > eb$s2.prior [1] 0.1109952 > eb$s2.post [1] 0.1109952 0.1109952 0.1109952 0.1109952 0.1109952 0.1109952 0.1109952 [8] 0.1109952 0.1109952 0.1109952 > eb$df.prior [1] Inf > eb$lods First3 Last3 Last3-First3 [1,] 35.192546 -4.704301 12.838652 [2,] -7.009617 -4.662107 -6.386845 [3,] -7.001350 -4.649212 -6.322593 [4,] -7.162627 -4.274513 -5.494162 [5,] -7.197767 -4.683429 -6.772846 [6,] -6.847709 -4.401419 -6.633922 [7,] -5.923227 -4.701154 -5.871024 [8,] -6.816808 -4.592976 -5.881353 [9,] -7.172653 -4.710147 -6.770768 [10,] -6.586066 -4.700346 -6.684136 > eb$p.value First3 Last3 Last3-First3 [1,] 1.829781e-11 0.75572772 1.747263e-07 [2,] 5.368393e-01 0.48589978 3.539428e-01 [3,] 5.282869e-01 0.43718400 3.210366e-01 [4,] 7.782180e-01 0.04859899 1.090771e-01 [5,] 9.218923e-01 0.59048539 7.552787e-01 [6,] 4.032500e-01 0.09387463 5.413009e-01 [7,] 1.165868e-01 0.72271436 1.731642e-01 [8,] 3.836849e-01 0.29110994 1.754637e-01 [9,] 8.073734e-01 0.83646492 7.502852e-01 [10,] 2.721518e-01 0.71494923 6.009262e-01 > eb$var.prior [1] 61.00259109 0.09009399 56.57780753 > > ### toptable > > toptable(fit) logFC t P.Value adj.P.Val B 1 1.77602021 9.23328899 1.829781e-11 1.829781e-10 35.192546 7 0.30852468 1.60397813 1.165868e-01 5.829340e-01 -5.923227 10 0.21417623 1.11347326 2.721518e-01 7.669133e-01 -6.586066 8 -0.16942269 -0.88080565 3.836849e-01 7.669133e-01 -6.816808 6 -0.16249607 -0.84479508 4.032500e-01 7.669133e-01 -6.847709 3 -0.12236781 -0.63617368 5.282869e-01 7.669133e-01 -7.001350 2 -0.11982833 -0.62297130 5.368393e-01 7.669133e-01 -7.009617 4 -0.05454069 -0.28354965 7.782180e-01 8.970816e-01 -7.162627 9 -0.04720963 -0.24543647 8.073734e-01 8.970816e-01 -7.172653 5 0.01897934 0.09867104 9.218923e-01 9.218923e-01 -7.197767 > > ### topTable > > fit <- lmFit(M,design) > fit2 <- eBayes(contrasts.fit(fit,contrasts=contrast.matrix)) > topTable(fit2) First3 Last3 Last3.First3 F P.Value adj.P.Val 1 1.77602021 0.06025114 -1.71576906 42.67587166 2.924856e-19 2.924856e-18 4 -0.05454069 0.39127869 0.44581938 2.10919528 1.213356e-01 5.350369e-01 6 -0.16249607 -0.33009728 -0.16760121 1.82939237 1.605111e-01 5.350369e-01 7 0.30852468 -0.06873462 -0.37725930 1.35021957 2.591833e-01 6.479584e-01 8 -0.16942269 0.20578118 0.37520387 0.96017584 3.828256e-01 7.656511e-01 10 0.21417623 0.07074940 -0.14342683 0.68755586 5.028035e-01 8.039105e-01 3 -0.12236781 0.15095948 0.27332729 0.51032807 6.002986e-01 8.039105e-01 2 -0.11982833 0.13529287 0.25512120 0.44141085 6.431284e-01 8.039105e-01 5 0.01897934 0.10434934 0.08536999 0.15202008 8.589710e-01 9.496107e-01 9 -0.04720963 0.03996397 0.08717360 0.05170315 9.496107e-01 9.496107e-01 > topTable(fit2,coef=3,resort.by="logFC") logFC t P.Value adj.P.Val B 4 0.44581938 1.6389001 1.090771e-01 4.386591e-01 -5.494162 8 0.37520387 1.3793067 1.754637e-01 4.386591e-01 -5.881353 3 0.27332729 1.0047928 3.210366e-01 5.899046e-01 -6.322593 2 0.25512120 0.9378645 3.539428e-01 5.899046e-01 -6.386845 9 0.08717360 0.3204634 7.502852e-01 7.552787e-01 -6.770768 5 0.08536999 0.3138331 7.552787e-01 7.552787e-01 -6.772846 10 -0.14342683 -0.5272589 6.009262e-01 7.511577e-01 -6.684136 6 -0.16760121 -0.6161276 5.413009e-01 7.511577e-01 -6.633922 7 -0.37725930 -1.3868627 1.731642e-01 4.386591e-01 -5.871024 1 -1.71576906 -6.3074289 1.747263e-07 1.747263e-06 12.838652 > topTable(fit2,coef=3,resort.by="p") logFC t P.Value adj.P.Val B 1 -1.71576906 -6.3074289 1.747263e-07 1.747263e-06 12.838652 4 0.44581938 1.6389001 1.090771e-01 4.386591e-01 -5.494162 7 -0.37725930 -1.3868627 1.731642e-01 4.386591e-01 -5.871024 8 0.37520387 1.3793067 1.754637e-01 4.386591e-01 -5.881353 3 0.27332729 1.0047928 3.210366e-01 5.899046e-01 -6.322593 2 0.25512120 0.9378645 3.539428e-01 5.899046e-01 -6.386845 6 -0.16760121 -0.6161276 5.413009e-01 7.511577e-01 -6.633922 10 -0.14342683 -0.5272589 6.009262e-01 7.511577e-01 -6.684136 9 0.08717360 0.3204634 7.502852e-01 7.552787e-01 -6.770768 5 0.08536999 0.3138331 7.552787e-01 7.552787e-01 -6.772846 > topTable(fit2,coef=3,sort="logFC",resort.by="t") logFC t P.Value adj.P.Val B 4 0.44581938 1.6389001 1.090771e-01 4.386591e-01 -5.494162 8 0.37520387 1.3793067 1.754637e-01 4.386591e-01 -5.881353 3 0.27332729 1.0047928 3.210366e-01 5.899046e-01 -6.322593 2 0.25512120 0.9378645 3.539428e-01 5.899046e-01 -6.386845 9 0.08717360 0.3204634 7.502852e-01 7.552787e-01 -6.770768 5 0.08536999 0.3138331 7.552787e-01 7.552787e-01 -6.772846 10 -0.14342683 -0.5272589 6.009262e-01 7.511577e-01 -6.684136 6 -0.16760121 -0.6161276 5.413009e-01 7.511577e-01 -6.633922 7 -0.37725930 -1.3868627 1.731642e-01 4.386591e-01 -5.871024 1 -1.71576906 -6.3074289 1.747263e-07 1.747263e-06 12.838652 > topTable(fit2,coef=3,resort.by="B") logFC t P.Value adj.P.Val B 1 -1.71576906 -6.3074289 1.747263e-07 1.747263e-06 12.838652 4 0.44581938 1.6389001 1.090771e-01 4.386591e-01 -5.494162 7 -0.37725930 -1.3868627 1.731642e-01 4.386591e-01 -5.871024 8 0.37520387 1.3793067 1.754637e-01 4.386591e-01 -5.881353 3 0.27332729 1.0047928 3.210366e-01 5.899046e-01 -6.322593 2 0.25512120 0.9378645 3.539428e-01 5.899046e-01 -6.386845 6 -0.16760121 -0.6161276 5.413009e-01 7.511577e-01 -6.633922 10 -0.14342683 -0.5272589 6.009262e-01 7.511577e-01 -6.684136 9 0.08717360 0.3204634 7.502852e-01 7.552787e-01 -6.770768 5 0.08536999 0.3138331 7.552787e-01 7.552787e-01 -6.772846 > topTable(fit2,coef=3,lfc=1) logFC t P.Value adj.P.Val B 1 -1.715769 -6.307429 1.747263e-07 1.747263e-06 12.83865 > topTable(fit2,coef=3,p=0.2) logFC t P.Value adj.P.Val B 1 -1.715769 -6.307429 1.747263e-07 1.747263e-06 12.83865 > topTable(fit2,coef=3,p=0.2,lfc=0.5) logFC t P.Value adj.P.Val B 1 -1.715769 -6.307429 1.747263e-07 1.747263e-06 12.83865 > topTable(fit2,coef=3,p=0.2,lfc=0.5,sort="none") logFC t P.Value adj.P.Val B 1 -1.715769 -6.307429 1.747263e-07 1.747263e-06 12.83865 > > designlist <- list(Null=matrix(1,6,1),Two=design,Three=cbind(1,c(0,0,1,1,0,0),c(0,0,0,0,1,1))) > out <- selectModel(M,designlist) > table(out$pref) Null Two Three 5 3 2 > > ### marray object > > #suppressMessages(suppressWarnings(gotmarray <- require(marray,quietly=TRUE))) > #if(gotmarray) { > # data(swirl) > # snorm = maNorm(swirl) > # fit <- lmFit(snorm, design = c(1,-1,-1,1)) > # fit <- eBayes(fit) > # topTable(fit,resort.by="AveExpr") > #} > > ### duplicateCorrelation > > cor.out <- duplicateCorrelation(M) Loading required package: statmod > cor.out$consensus.correlation [1] -0.09290714 > cor.out$atanh.correlations [1] -0.4419130 0.4088967 -0.1964978 -0.6093769 0.3730118 > > ### gls.series > > fit <- gls.series(M,design,correlation=cor.out$cor) > fit$coefficients First3Arrays Last3Arrays [1,] 0.82809594 0.09777201 [2,] -0.08845425 0.27111909 [3,] -0.07175836 -0.11287397 [4,] 0.06955100 0.06852328 [5,] 0.08348330 0.05535668 > fit$stdev.unscaled First3Arrays Last3Arrays [1,] 0.3888215 0.3888215 [2,] 0.3888215 0.3888215 [3,] 0.3888215 0.3888215 [4,] 0.3888215 0.3888215 [5,] 0.3888215 0.3888215 > fit$sigma [1] 0.7630059 0.2152728 0.3350370 0.3227781 0.3405473 > fit$df.residual [1] 10 10 10 10 10 > > ### mrlm > > fit <- mrlm(M,design) Loading required package: MASS Warning message: In rlm.default(x = X, y = y, weights = w, ...) : 'rlm' failed to converge in 20 steps > fit$coef First3Arrays Last3Arrays [1,] 1.75138894 0.06025114 [2,] -0.11982833 0.10322039 [3,] -0.09302502 0.15095948 [4,] -0.05454069 0.33700045 [5,] 0.07927938 0.10434934 [6,] -0.16249607 -0.34010852 [7,] 0.30852468 -0.06873462 [8,] -0.16942269 0.24392984 [9,] -0.04720963 0.03996397 [10,] 0.21417623 -0.05679272 > fit$stdev.unscaled First3Arrays Last3Arrays [1,] 0.5933418 0.5773503 [2,] 0.5773503 0.6096497 [3,] 0.6017444 0.5773503 [4,] 0.5773503 0.6266021 [5,] 0.6307703 0.5773503 [6,] 0.5773503 0.5846707 [7,] 0.5773503 0.5773503 [8,] 0.5773503 0.6544564 [9,] 0.5773503 0.5773503 [10,] 0.5773503 0.6689776 > fit$sigma [1] 0.2894294 0.2679396 0.2090236 0.1461395 0.2309018 0.2827476 0.2285945 [8] 0.2267556 0.3537469 0.2172409 > fit$df.residual [1] 4 4 4 4 4 4 4 4 4 4 > > # Similar to Mette Langaas 19 May 2004 > set.seed(123) > narrays <- 9 > ngenes <- 5 > mu <- 0 > alpha <- 2 > beta <- -2 > epsilon <- matrix(rnorm(narrays*ngenes,0,1),ncol=narrays) > X <- cbind(rep(1,9),c(0,0,0,1,1,1,0,0,0),c(0,0,0,0,0,0,1,1,1)) > dimnames(X) <- list(1:9,c("mu","alpha","beta")) > yvec <- mu*X[,1]+alpha*X[,2]+beta*X[,3] > ymat <- matrix(rep(yvec,ngenes),ncol=narrays,byrow=T)+epsilon > ymat[5,1:2] <- NA > fit <- lmFit(ymat,design=X) > test.contr <- cbind(c(0,1,-1),c(1,1,0),c(1,0,1)) > dimnames(test.contr) <- list(c("mu","alpha","beta"),c("alpha-beta","mu+alpha","mu+beta")) > fit2 <- contrasts.fit(fit,contrasts=test.contr) > eBayes(fit2) An object of class "MArrayLM" $coefficients alpha-beta mu+alpha mu+beta [1,] 3.537333 1.677465 -1.859868 [2,] 4.355578 2.372554 -1.983024 [3,] 3.197645 1.053584 -2.144061 [4,] 2.697734 1.611443 -1.086291 [5,] 3.502304 2.051995 -1.450309 $stdev.unscaled alpha-beta mu+alpha mu+beta [1,] 0.8164966 0.5773503 0.5773503 [2,] 0.8164966 0.5773503 0.5773503 [3,] 0.8164966 0.5773503 0.5773503 [4,] 0.8164966 0.5773503 0.5773503 [5,] 1.1547005 0.8368633 0.8368633 $sigma [1] 1.3425032 0.4647155 1.1993444 0.9428569 0.9421509 $df.residual [1] 6 6 6 6 4 $cov.coefficients alpha-beta mu+alpha mu+beta alpha-beta 0.6666667 3.333333e-01 -3.333333e-01 mu+alpha 0.3333333 3.333333e-01 9.280771e-17 mu+beta -0.3333333 9.280771e-17 3.333333e-01 $method [1] "ls" $design mu alpha beta 1 1 0 0 2 1 0 0 3 1 0 0 4 1 1 0 5 1 1 0 6 1 1 0 7 1 0 1 8 1 0 1 9 1 0 1 $contrasts alpha-beta mu+alpha mu+beta mu 0 1 1 alpha 1 1 0 beta -1 0 1 $df.prior [1] 9.306153 $s2.prior [1] 0.923179 $var.prior [1] 17.33142 17.33142 12.26855 $proportion [1] 0.01 $s2.post [1] 1.2677996 0.6459499 1.1251558 0.9097727 0.9124980 $t alpha-beta mu+alpha mu+beta [1,] 3.847656 2.580411 -2.860996 [2,] 6.637308 5.113018 -4.273553 [3,] 3.692066 1.720376 -3.500994 [4,] 3.464003 2.926234 -1.972606 [5,] 3.175181 2.566881 -1.814221 $df.total [1] 15.30615 15.30615 15.30615 15.30615 13.30615 $p.value alpha-beta mu+alpha mu+beta [1,] 1.529450e-03 0.0206493481 0.0117123495 [2,] 7.144893e-06 0.0001195844 0.0006385076 [3,] 2.109270e-03 0.1055117477 0.0031325769 [4,] 3.381970e-03 0.0102514264 0.0668844448 [5,] 7.124839e-03 0.0230888584 0.0922478630 $lods alpha-beta mu+alpha mu+beta [1,] -1.013417 -3.702133 -3.0332393 [2,] 3.981496 1.283349 -0.2615911 [3,] -1.315036 -5.168621 -1.7864101 [4,] -1.757103 -3.043209 -4.6191869 [5,] -2.257358 -3.478267 -4.5683738 $F [1] 7.421911 22.203107 7.608327 6.227010 5.060579 $F.p.value [1] 5.581800e-03 2.988923e-05 5.080726e-03 1.050148e-02 2.320274e-02 > > ### uniquegenelist > > uniquegenelist(letters[1:8],ndups=2) [1] "a" "c" "e" "g" > uniquegenelist(letters[1:8],ndups=2,spacing=2) [1] "a" "b" "e" "f" > > ### classifyTests > > tstat <- matrix(c(0,5,0, 0,2.5,0, -2,-2,2, 1,1,1), 4, 3, byrow=TRUE) > classifyTestsF(tstat) TestResults matrix [,1] [,2] [,3] [1,] 0 1 0 [2,] 0 0 0 [3,] -1 -1 1 [4,] 0 0 0 > FStat(tstat) [1] 8.333333 2.083333 4.000000 1.000000 attr(,"df1") [1] 3 attr(,"df2") [1] Inf > classifyTestsT(tstat) TestResults matrix [,1] [,2] [,3] [1,] 0 1 0 [2,] 0 0 0 [3,] 0 0 0 [4,] 0 0 0 > classifyTestsP(tstat) TestResults matrix [,1] [,2] [,3] [1,] 0 1 0 [2,] 0 1 0 [3,] 0 0 0 [4,] 0 0 0 > > ### avereps > > x <- matrix(rnorm(8*3),8,3) > colnames(x) <- c("S1","S2","S3") > rownames(x) <- c("b","a","a","c","c","b","b","b") > avereps(x) S1 S2 S3 b -0.2353018 0.5220094 0.2302895 a -0.4347701 0.6453498 -0.6758914 c 0.3482980 -0.4820695 -0.3841313 > > ### roast > > y <- matrix(rnorm(100*4),100,4) > sigma <- sqrt(2/rchisq(100,df=7)) > y <- y*sigma > design <- cbind(Intercept=1,Group=c(0,0,1,1)) > iset1 <- 1:5 > y[iset1,3:4] <- y[iset1,3:4]+3 > iset2 <- 6:10 > roast(y=y,iset1,design,contrast=2) Active.Prop P.Value Down 0 0.996 Up 1 0.005 Mixed 1 0.008 > roast(y=y,iset1,design,contrast=2,array.weights=c(0.5,1,0.5,1)) Active.Prop P.Value Down 0 0.999 Up 1 0.002 Mixed 1 0.003 > mroast(y=y,list(set1=iset1,set2=iset2),design,contrast=2) NGenes PropDown PropUp Direction PValue FDR PValue.Mixed FDR.Mixed set1 5 0 1 Up 0.006 0.010 0.003 0.0050 set2 5 0 0 Up 0.566 0.565 0.547 0.5465 > mroast(y=y,list(set1=iset1,set2=iset2),design,contrast=2,gene.weights=runif(100)) NGenes PropDown PropUp Direction PValue FDR PValue.Mixed FDR.Mixed set1 5 0 1 Up 0.004 0.006 0.009 0.0170 set2 5 0 0 Up 0.364 0.363 0.205 0.2045 > > ### camera > > camera(y=y,iset1,design,contrast=2,weights=c(0.5,1,0.5,1)) NGenes Correlation Direction PValue set1 5 -0.2481655 Up 0.001050253 > camera(y=y,list(set1=iset1,set2=iset2),design,contrast=2) NGenes Correlation Direction PValue FDR set1 5 -0.2481655 Up 0.0009047749 0.00180955 set2 5 0.1719094 Down 0.9068364381 0.90683644 > > ### with EList arg > > y <- new("EList",list(E=y)) > roast(y=y,iset1,design,contrast=2) Active.Prop P.Value Down 0 0.999 Up 1 0.002 Mixed 1 0.002 > camera(y=y,iset1,design,contrast=2) NGenes Correlation Direction PValue set1 5 -0.2481655 Up 0.0009047749 > > ### eBayes with trend > > fit <- lmFit(y,design) > fit <- eBayes(fit,trend=TRUE) Loading required package: splines > topTable(fit,coef=2) logFC AveExpr t P.Value adj.P.Val B 3 3.488703 1.03931081 4.860410 0.0002436118 0.01647958 0.6722078 2 3.729512 1.73488969 4.700998 0.0003295917 0.01647958 0.3777787 4 2.696676 1.74060725 3.280613 0.0053915597 0.17971866 -2.3313104 1 2.391846 1.72305203 3.009776 0.0092611288 0.23152822 -2.8478458 5 2.387967 1.63066783 2.786529 0.0144249169 0.26573834 -3.2671364 33 -1.492317 -0.07525287 -2.735781 0.0159443006 0.26573834 -3.3613142 80 -1.839760 -0.32802306 -2.594532 0.0210374835 0.30053548 -3.6207072 95 -1.907074 1.26297763 -2.462009 0.0272186263 0.33449167 -3.8598265 39 1.366141 -0.27360750 2.409767 0.0301042507 0.33449167 -3.9527943 70 -1.789476 0.21771869 -2.184062 0.0462410739 0.46241074 -4.3445901 > fit$df.prior [1] 12.17481 > fit$s2.prior [1] 0.7108745 0.7186517 0.3976222 0.7224388 0.6531157 0.3014062 0.3169880 [8] 0.3149772 0.3074632 0.2917431 0.3329334 0.3378027 0.2900500 0.3031741 [15] 0.3221763 0.2981580 0.2897078 0.2925188 0.2924234 0.3042822 0.2923686 [22] 0.2897022 0.3251669 0.2929813 0.4922090 0.2902725 0.3018205 0.3029119 [29] 0.3030051 0.3331358 0.3259651 0.2939051 0.3077824 0.3553515 0.3139985 [36] 0.3181689 0.3197601 0.4687993 0.3316536 0.2897621 0.2910744 0.2907116 [43] 0.2907966 0.3265722 0.3240487 0.3241126 0.3003970 0.3064187 0.3645035 [50] 0.2994391 0.3295512 0.2901076 0.2898658 0.3086659 0.2897209 0.2982976 [57] 0.3043910 0.2900320 0.3006936 0.2935101 0.3646949 0.3596385 0.3064203 [64] 0.3027439 0.3076483 0.3363356 0.3504336 0.3496698 0.2897618 0.2898810 [71] 0.3182290 0.3121707 0.2945001 0.2897549 0.3579410 0.3434376 0.3037970 [78] 0.3201893 0.3048412 0.3394079 0.3516034 0.3034589 0.3120384 0.3007827 [85] 0.3013925 0.2902524 0.3527793 0.2969359 0.3033756 0.3170187 0.2978833 [92] 0.2908437 0.3139422 0.3050183 0.4727609 0.2897104 0.2931671 0.2904177 [99] 0.3231607 0.2941699 > summary(fit$s2.post) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.2518 0.2746 0.3080 0.3425 0.3583 0.7344 > > y$E[1,1] <- NA > y$E[1,3] <- NA > fit <- lmFit(y,design) > fit <- eBayes(fit,trend=TRUE) > topTable(fit,coef=2) logFC AveExpr t P.Value adj.P.Val B 3 3.488703 1.03931081 4.697008 0.0003209946 0.03209946 0.4203254 2 3.729512 1.73488969 3.999120 0.0012579276 0.06289638 -0.9004934 4 2.696676 1.74060725 2.813904 0.0135288060 0.39858921 -3.1693877 33 -1.492317 -0.07525287 -2.731110 0.0159435682 0.39858921 -3.3232081 80 -1.839760 -0.32802306 -2.589351 0.0210816889 0.42163378 -3.5833549 5 2.387967 1.63066783 2.485152 0.0258403123 0.43067187 -3.7715574 39 1.366141 -0.27360750 2.394886 0.0307776648 0.43968093 -3.9322196 1 2.638272 1.47993643 2.191607 0.0482424084 0.48242408 -4.0353253 95 -1.907074 1.26297763 -2.323190 0.0353245811 0.44155726 -4.0580889 70 -1.789476 0.21771869 -2.198418 0.0447803591 0.48242408 -4.2730579 > fit$df.residual[1] [1] 0 > fit$df.prior [1] 12.35976 > fit$s2.prior [1] 0.7245758 0.9965185 0.4417532 1.0037410 0.8738246 0.3006625 0.3199347 [8] 0.3175766 0.3084128 0.2878407 0.3375034 0.3425540 0.2857778 0.3029544 [15] 0.3258534 0.2963955 0.2852604 0.2892364 0.2887441 0.3043789 0.2886711 [22] 0.2852486 0.3291690 0.2898777 0.4748285 0.2859269 0.3021138 0.3036285 [29] 0.3027364 0.3377157 0.3300432 0.2907249 0.3088128 0.3598916 0.3164146 [36] 0.3213019 0.3231250 0.4563979 0.3361549 0.2852951 0.2872259 0.2864913 [43] 0.2868366 0.3307052 0.3279369 0.3280075 0.2993443 0.3070975 0.3685088 [50] 0.2980866 0.3339193 0.2858607 0.2854174 0.3099154 0.2852511 0.2965803 [57] 0.3045183 0.2857518 0.2997325 0.2906102 0.3686865 0.3847458 0.3070996 [64] 0.3023988 0.3086449 0.3410451 0.3551517 0.3544080 0.2852948 0.2854358 [71] 0.3213712 0.3142182 0.2915214 0.2852871 0.3623552 0.3482564 0.3037564 [78] 0.3236131 0.3050938 0.3441932 0.3562867 0.3043882 0.3140578 0.2998489 [85] 0.3006447 0.2860677 0.3574227 0.2953492 0.3032142 0.3199704 0.2960316 [92] 0.2866624 0.3163475 0.3053198 0.5604622 0.2852416 0.2901352 0.2863025 [99] 0.3269520 0.2910794 > summary(fit$s2.post) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.2495 0.2749 0.3091 0.3512 0.3649 0.9233 > > proc.time() user system elapsed 1.02 0.07 1.09 limma/tests/limma-Tests.R0000755007451300017500000001400212127125241015471 0ustar charlescharleslibrary(limma) set.seed(0); u <- runif(100) ### strsplit2 x <- c("ab;cd;efg","abc;def","z","") strsplit2(x,split=";") ### removeext removeExt(c("slide1.spot","slide.2.spot")) removeExt(c("slide1.spot","slide")) ### printorder printorder(list(ngrid.r=4,ngrid.c=4,nspot.r=8,nspot.c=6),ndups=2,start="topright",npins=4) printorder(list(ngrid.r=4,ngrid.c=4,nspot.r=8,nspot.c=6)) ### merge.rglist R <- G <- matrix(11:14,4,2) rownames(R) <- rownames(G) <- c("a","a","b","c") RG1 <- new("RGList",list(R=R,G=G)) R <- G <- matrix(21:24,4,2) rownames(R) <- rownames(G) <- c("b","a","a","c") RG2 <- new("RGList",list(R=R,G=G)) merge(RG1,RG2) merge(RG2,RG1) ### background correction RG <- new("RGList", list(R=c(1,2,3,4),G=c(1,2,3,4),Rb=c(2,2,2,2),Gb=c(2,2,2,2))) backgroundCorrect(RG) backgroundCorrect(RG, method="half") backgroundCorrect(RG, method="minimum") backgroundCorrect(RG, offset=5) ### loessFit x <- 1:100 y <- rnorm(100) out <- loessFit(y,x) f1 <- quantile(out$fitted) r1 <- quantile(out$residual) w <- rep(1,100) w[1:50] <- 0.5 out <- loessFit(y,x,weights=w) f2 <- quantile(out$fitted) r2 <- quantile(out$residual) w[1:80] <- 0 out <- loessFit(y,x,weights=w) f3 <- quantile(out$fitted) r3 <- quantile(out$residual) data.frame(f1,f2,f3,r1,r2,r3) ### normalizeWithinArrays RG <- new("RGList",list()) RG$R <- matrix(rexp(100*2),100,2) RG$G <- matrix(rexp(100*2),100,2) RG$Rb <- matrix(rnorm(100*2,sd=0.02),100,2) RG$Gb <- matrix(rnorm(100*2,sd=0.02),100,2) RGb <- backgroundCorrect(RG,method="normexp",normexp.method="saddle") summary(cbind(RGb$R,RGb$G)) RGb <- backgroundCorrect(RG,method="normexp",normexp.method="mle") summary(cbind(RGb$R,RGb$G)) MA <- normalizeWithinArrays(RGb,method="loess") summary(MA$M) #MA <- normalizeWithinArrays(RG[,1:2], mouse.setup, method="robustspline") #MA$M[1:5,] #MA <- normalizeWithinArrays(mouse.data, mouse.setup) #MA$M[1:5,] ### normalizeBetweenArrays MA2 <- normalizeBetweenArrays(MA,method="scale") MA$M[1:5,] MA$A[1:5,] MA2 <- normalizeBetweenArrays(MA,method="quantile") MA$M[1:5,] MA$A[1:5,] ### unwrapdups M <- matrix(1:12,6,2) unwrapdups(M,ndups=1) unwrapdups(M,ndups=2) unwrapdups(M,ndups=3) unwrapdups(M,ndups=2,spacing=3) ### trigammaInverse trigammaInverse(c(1e-6,NA,5,1e6)) ### lm.series, contrasts.fit, ebayes M <- matrix(rnorm(10*6,sd=0.3),10,6) M[1,1:3] <- M[1,1:3] + 2 design <- cbind(First3Arrays=c(1,1,1,0,0,0),Last3Arrays=c(0,0,0,1,1,1)) fit <- lm.series(M,design=design) contrast.matrix <- cbind(First3=c(1,0),Last3=c(0,1),"Last3-First3"=c(-1,1)) fit2 <- contrasts.fit(fit,contrasts=contrast.matrix) eb <- ebayes(fit2) eb$t eb$s2.prior eb$s2.post eb$df.prior eb$lods eb$p.value eb$var.prior ### toptable toptable(fit) ### topTable fit <- lmFit(M,design) fit2 <- eBayes(contrasts.fit(fit,contrasts=contrast.matrix)) topTable(fit2) topTable(fit2,coef=3,resort.by="logFC") topTable(fit2,coef=3,resort.by="p") topTable(fit2,coef=3,sort="logFC",resort.by="t") topTable(fit2,coef=3,resort.by="B") topTable(fit2,coef=3,lfc=1) topTable(fit2,coef=3,p=0.2) topTable(fit2,coef=3,p=0.2,lfc=0.5) topTable(fit2,coef=3,p=0.2,lfc=0.5,sort="none") designlist <- list(Null=matrix(1,6,1),Two=design,Three=cbind(1,c(0,0,1,1,0,0),c(0,0,0,0,1,1))) out <- selectModel(M,designlist) table(out$pref) ### marray object #suppressMessages(suppressWarnings(gotmarray <- require(marray,quietly=TRUE))) #if(gotmarray) { # data(swirl) # snorm = maNorm(swirl) # fit <- lmFit(snorm, design = c(1,-1,-1,1)) # fit <- eBayes(fit) # topTable(fit,resort.by="AveExpr") #} ### duplicateCorrelation cor.out <- duplicateCorrelation(M) cor.out$consensus.correlation cor.out$atanh.correlations ### gls.series fit <- gls.series(M,design,correlation=cor.out$cor) fit$coefficients fit$stdev.unscaled fit$sigma fit$df.residual ### mrlm fit <- mrlm(M,design) fit$coef fit$stdev.unscaled fit$sigma fit$df.residual # Similar to Mette Langaas 19 May 2004 set.seed(123) narrays <- 9 ngenes <- 5 mu <- 0 alpha <- 2 beta <- -2 epsilon <- matrix(rnorm(narrays*ngenes,0,1),ncol=narrays) X <- cbind(rep(1,9),c(0,0,0,1,1,1,0,0,0),c(0,0,0,0,0,0,1,1,1)) dimnames(X) <- list(1:9,c("mu","alpha","beta")) yvec <- mu*X[,1]+alpha*X[,2]+beta*X[,3] ymat <- matrix(rep(yvec,ngenes),ncol=narrays,byrow=T)+epsilon ymat[5,1:2] <- NA fit <- lmFit(ymat,design=X) test.contr <- cbind(c(0,1,-1),c(1,1,0),c(1,0,1)) dimnames(test.contr) <- list(c("mu","alpha","beta"),c("alpha-beta","mu+alpha","mu+beta")) fit2 <- contrasts.fit(fit,contrasts=test.contr) eBayes(fit2) ### uniquegenelist uniquegenelist(letters[1:8],ndups=2) uniquegenelist(letters[1:8],ndups=2,spacing=2) ### classifyTests tstat <- matrix(c(0,5,0, 0,2.5,0, -2,-2,2, 1,1,1), 4, 3, byrow=TRUE) classifyTestsF(tstat) FStat(tstat) classifyTestsT(tstat) classifyTestsP(tstat) ### avereps x <- matrix(rnorm(8*3),8,3) colnames(x) <- c("S1","S2","S3") rownames(x) <- c("b","a","a","c","c","b","b","b") avereps(x) ### roast y <- matrix(rnorm(100*4),100,4) sigma <- sqrt(2/rchisq(100,df=7)) y <- y*sigma design <- cbind(Intercept=1,Group=c(0,0,1,1)) iset1 <- 1:5 y[iset1,3:4] <- y[iset1,3:4]+3 iset2 <- 6:10 roast(y=y,iset1,design,contrast=2) roast(y=y,iset1,design,contrast=2,array.weights=c(0.5,1,0.5,1)) mroast(y=y,list(set1=iset1,set2=iset2),design,contrast=2) mroast(y=y,list(set1=iset1,set2=iset2),design,contrast=2,gene.weights=runif(100)) ### camera camera(y=y,iset1,design,contrast=2,weights=c(0.5,1,0.5,1)) camera(y=y,list(set1=iset1,set2=iset2),design,contrast=2) ### with EList arg y <- new("EList",list(E=y)) roast(y=y,iset1,design,contrast=2) camera(y=y,iset1,design,contrast=2) ### eBayes with trend fit <- lmFit(y,design) fit <- eBayes(fit,trend=TRUE) topTable(fit,coef=2) fit$df.prior fit$s2.prior summary(fit$s2.post) y$E[1,1] <- NA y$E[1,3] <- NA fit <- lmFit(y,design) fit <- eBayes(fit,trend=TRUE) topTable(fit,coef=2) fit$df.residual[1] fit$df.prior fit$s2.prior summary(fit$s2.post) limma/DESCRIPTION0000755007451300017500000000163012175636024013527 0ustar charlescharlesPackage: limma Version: 3.16.7 Date: 2013/07/29 Title: Linear Models for Microarray Data Author: Gordon Smyth with contributions from Matthew Ritchie, Jeremy Silver, James Wettenhall, Natalie Thorne, Mette Langaas, Egil Ferkingstad, Marcus Davy, Francois Pepin, Dongseok Choi, Davis McCarthy, Di Wu, Alicia Oshlack, Carolyn de Graaf, Yifang Hu, Wei Shi and Belinda Phipson. Maintainer: Gordon Smyth Depends: R (>= 2.3.0), methods Suggests: affy, MASS, org.Hs.eg.db, splines, statmod (>= 1.2.2), vsn, ellipse LazyLoad: yes Description: Data analysis, linear models and differential expression for microarray data. License: GPL (>=2) URL: http://bioinf.wehi.edu.au/limma biocViews: Microarray, OneChannel, TwoChannel, DataImport, QualityControl, Preprocessing, Bioinformatics, DifferentialExpression, MultipleComparisons, TimeCourse Packaged: 2013-07-30 04:07:48 UTC; biocbuild limma/inst/0000755007451300017500000000000012127125250012762 5ustar charlescharleslimma/inst/CITATION0000755007451300017500000000170312127125250014123 0ustar charlescharlescitHeader("Please cite the paper below for the limma software itself. Please also try to cite the appropriate methodology articles that describe the statistical methods implemented in limma, depending on which limma functions you are using. The methodology articles are listed in Section 2.1 of the limma User's Guide.") citEntry(entry="incollection", title = "Limma: linear models for microarray data", author = "Gordon K Smyth", booktitle="Bioinformatics and Computational Biology Solutions Using {R} and Bioconductor", editor="R. Gentleman and V. Carey and S. Dudoit and R. Irizarry, W. Huber", publisher="Springer", address="New York", year = 2005, pages = "397--420", textVersion = "Smyth, GK (2005). Limma: linear models for microarray data. In: 'Bioinformatics and Computational Biology Solutions using R and Bioconductor'. R. Gentleman, V. Carey, S. Dudoit, R. Irizarry, W. Huber (eds), Springer, New York, pages 397-420." ) limma/inst/NEWS.Rd0000644007451300017500000002571612127125250014040 0ustar charlescharles\name{limmanews} \title{limma News} \encoding{UTF-8} \section{Version 3.16.0}{\itemize{ \item New section in User's Guide on time course experiments with many time points. The RNA-seq case study in User's Guide has also been revised. \item Improvements to various help pages including read.maimages.Rd, squeezeVar.Rd, fitFDist.Rd, trigammaInverse.Rd, normalizeRobustSpline.Rd, genas.Rd and roast.Rd. Previously the meaning of source="agilent" was mis-stated in read.maimages.Rd. \item New robust method for estimating the empirical Bayes prior, called by specifying robust=TRUE in the call to eBayes(). When this is TRUE the output df.prior is now a vector instead of a scalar. \item New function fitFDistRobustly() estimates the parameters of a scaled F-distribution robustly using Winsorized values. Outlier observations receive smaller values for df.prior than non-outliers. This permits robust methods for squeezeVar(), ebayes() and eBayes(), all of which now have a new argument wins.tail.p to specify the tail proportions for Winsorizing. \item fitFDist() now permits infinite values for the covariate. It also gracefully handles cases where the covariate takes only a small number of distinct values. Similarly for eBayes() and squeezeVar() that call fitFDist(). \item All the functions that perform gene set tests have been revised to make the input and output formats more consistent. roast(), mroast() and camera() are now S3 generic functions, with methods for EList and MAList objects. The order of arguments has been changed for roast(), mroast() and camera() so that the first argument is now y. All functions that perform gene sets now use the argument 'index' to specify which genes are included in the test set. Previously this argument was called 'iset' for roast() and romer() and 'indices' for camera(). camera() and mroast() now produce a data.frames. Instead of separate up and down p-value columns, there is now a two-sided p-value and a column indicating direction of change. There are new columns giving FDR values and the number of genes in each set. There is a new argument 'sort' to indicate whether output results should be sorted by p-value. mroast() has a new argument 'weights' for observational weights, to bring it into line with roast(), \item vennDiagram() can now plot up to five sets (previously limited to three). \item genas() now optionally draws a plot in which ellipses are used to represent the technical and biological components of correlation. It also now has the ability to automatically select which probes are used for the correlation analysis, and a new argument controls the method used for this selection. \item New options for the method argument of propTrueNull(). \item New functions vooma() and voomaByGroup() for computing precision weights based on a mean-variance trend. vooma() is similar to voom() but for microarray data instead of RNA-Seq. voomaByGroup() allows different groups to have systematically different variances. \item New function predFCm() to compute predictive (shrunk) log fold changes. \item New function fitGammaIntercept() for estimating the intercept of a gamma glm with an offset. Used by genas(). \item New function zscoreHyper() for computing z-score equivalents of deviates from a hypergeometric distribution. \item New function qqf() for qq-plots relative to an F-distribution. \item normalizeWithinArrays() with method="robustspline" now longer requires the layout argument to be set. The layout argument for normalizeRobustSpline() now defaults to a single print-tip group. \item fitFDist() now coerces degrees of freedom df1 below 1e-15 to zero. \item Due to changes in R, loessFit() no longer makes direct calls to foreign language code in the stats package, and instead calls R functions. Unfortunately, this makes loessFit() about 25-30\% slower than previously when weights are used. \item Bug fix to read.maimages(), which was not accepting source="agilent.mean". \item Bug fix for contrasts.fit() when the covariance matrix of the coefficients (cov.coefficients) is not found in the fitted model object. This situation doesn't arise using any of the standard limma analysis pipelines. \item Bug fix to lmscFit() when the residual df = 1. \item Bug fix to readTargets() to avoid warning message when targets$Label is used to set row names but targets$Label contains duplicated entries. }} \section{Version 3.14.0}{\itemize{ \item limma license upgraded to GPL (>=2) instead of LGPL to match R itself. \item Many updates to the User's Guide. Sections have been added on reading single channel Agilent and Illumina data. The chapter on experimental designs has been split into three chapters on single-channel, common reference and two-color designs respectively. The material on the fixed effect approach to technical replication has been deleted. There are new sections on nested interactions for factorial designs and on multi-level designs. \item The links to the Apoa1, Weaver and Bob1 datasets in the User's Guide have been updated to help users download the data themselves if they wish to repeat the case study analyses. \item The help page for camera() now cites published paper Wu and Smyth (NAR, 2012). In view of the results of this paper, the claim is no longer made on help page for geneSetTest() that genes might be treated as independent when the experimental units are genetically identical mice. \item Minor edits to CITATION file. \item New function propTrueNull() for fast estimation of the proportion of true null hypotheses from a vector of p-values. \item New function zscore() to compute z-score equivalents for deviates from any continuous distribution. Includes the functionality of the older functions zscoreGamma() and zscoreT() as special cases. \item roast() now accepts observation level weights, through a new argument 'weights'. \item loessFit() now applies minimum and maximum bounds by default to avoid zero or infinite weights. Equal weights are now treated as if the weights were NULL, even all zero weights, so that the lowess code is called instead of the loess code. \item When there are no weights, loessFit() now extracts residuals directly from the C code output instead of computing in R. \item fitFDist() now permits missing values for x or zero values for df1 even when there is a covariate. This means that squeezeVar() and eBayes() now work with trends even when not all the data values are informative. \item New argument 'file' for convest(), implementing edits contributed by Marcus Davy. Arguments doplot and dereport renamed to 'plot' and 'report'. \item Two improvements for plotMDS(). It now coerces labels to be character, and now makes extra room on the plot when the text labels are wide. \item plotMDS() no longer gives an error when the requested number of top genes is greater than the total number of rows of data. \item Code speed-up for alias2SymbolTable() \item any(duplicated()) replaced by anyDuplicated() in several functions. \item Fix to voom() so that it computes weights correctly even when the design matrix is not of full rank. \item Bug fix for roast() when the fitted model has only one coefficient. }} \section{Version 3.12.0}{\itemize{ \item read.maimages() with source="agilent" now reads median foreground estimates instead of mean foreground. New option source= "agilent.mean" preserves earlier meaning of source="agilent". \item Agilent single-channel case study added to User's Guide. \item removeBatchEffect() now corrects for continuous covariates as well as qualitative factors. \item new function camera() performs competitive gene set tests while adjusting for inter-gene correlation. \item new function interGeneCorrelation() estimates the average intergene correlation for a set of genes. \item columns in output from roast() have been re-ordered. \item arguments 'selected' and 'selected2' renamed to 'index' and 'index2' in functions barcodeplot(), geneSetTest() and wilcoxGST(). \item default labels for barcodeplot() are now somewhat more explicit. \item new function rankSumTestWithCorrelation extends the Wilcoxon-Mann-Whitney test to allow for correlation between cases in one of the groups. geneSetTest() now calls this function instead of wilcox.test, with a consequence improvement in speed. \item The lfc (log-fold-change) cutoff argument of topTable() is now applied to the minimum absolute logFC when ranking by F-statistic. Previously lfc was only used when ranking by t-statistic. \item new methods "fast" and "affy" for normalizeCyclicLoess(), with "fast" becoming the default method. New argument 'cyclic.method' for normalizeBetweenArrays() gives access to the different cyclic loess methods. \item There were problems with using the argument gene.weights in mroast(). This argument is now permitted to be of the same length as the number of probes in the data set. It is then automatically subsetted for each gene set. \item mroast() now uses mid-p-values by default when adjusting for multiple testing. \item neqc(), nec() and normexp.fit.control() now give user-friendly error messages when no negative control probes or no regular probes are found. }} \section{Version 3.10.0}{\itemize{ \item New function voom() allows RNA-Seq experiments to be analysed using the standard limma pipeline. An RNA-Seq case study is added to User's Guide. \item treat(), roast() and mroast() can now estimate and work with a trend on the prior variance, bringing them into line with eBayes(). \item barcodeplot() and barcodeplot2() merged into one function. \item removeBatchEffect() can now correct for two batch factors. \item plotMDS is now an S3 generic function. This allows MDS plots to be redrawn with new labels without needing to repeat the distance or scaling calculations. New S4 class "MDS" to hold the multidimensional scaling information output from plotMDS. \item getEAWP() now gets probe annotation from the expression rownames of an EList object, if no other probe annotation is available. \item topRomer() now ranks gene sets by secondary columns as well the primary criterion specified, to give a more meaningful ranking when the p-values are tied. \item wilcoxGST() now accepts signed or unsigned test statistics. Change to p-value calculation in geneSetTest() when rank.only=FALSE to avoid zero p-values and follow recommendation of Phipson and Smyth (SAGMB, 2010). \item plotMA() now recognizes ElistRaw and EList objects appropriately. \item Default span for normalizeCyclicLoess increased from 0.4 to 0.7. Speed improved when weights=NULL. \item Weaver case study (Section 11.5) in User's Guide is updated and rewritten. Data classes ElistRaw and Elist now described in the quick start section of the User's Guide. Other minor updates to User's Guide. \item Bug fix for normalizeBetweenArrays() when object is an EListRaw and method="cyclicloess". Previously this function was applying cyclicloess to the raw intensities, then logging. Now it logs first, then applies cyclicloess. \item Bug fix to avereps() for EList objects x when x$other is not empty. }} limma/inst/doc/0000755007451300017500000000000012175636024013540 5ustar charlescharleslimma/inst/doc/index.html0000755007451300017500000000124112127125250015525 0ustar charlescharles LIMMA User's Guides

Linear Models for Microarray Data


User Guides and Package Vignettes


limma/inst/doc/limma.pdf0000644007451300017500000013103512175636024015335 0ustar charlescharles%PDF-1.4 %ÐÔÅØ 3 0 obj << /Length 1532 /Filter /FlateDecode >> stream xÚ•XKÛ6¾ï¯0r© DªD‰z\ $@ºhQ´E꤇¦Ù–½FlkaÉI6¿¾ó¤(Y>ô 5Eg>~ó¢öíêáÇŸM¾0q”çÆ.V;Ú¨°É"ÏLTTÙbµ]üü¶L‚<§S½ Ó8 þ\š"¨7ø÷óÒš †Å=< /Dáý™&’ ï›å¿«_ÁR¼H²(Írƒ–låq²Seeņ[¿À³…§=ƒ6cƒ¿ÐòÒ”Á *ƒç Õ-Bc¡)¢Ê¼ßÀjŠ»òànPº]/CxoH3-¡TŒO6àJ@‰%\abm”€,Ë`rJ<@„±Mu8´ÄÁ™gßóÏ3Ê)I,°oxiÇ¥qÿÄÌá¸>“î$8ƒçí< ¸gÇC"û<ìk¾Áí]ðœíj@'A¿AnÛZH¾-€÷ÂR[±¬Õ¯‘µ2h:RL n8HŽHŠÈÚ ~³(Ëræ‹ýÄ‘ÛàŠ¨hœë1pú(¸è$µxæO\K˜1×ñþ.Š`-›e§qÏ2¤‚Ù«©-¯ âoÏCx–†L³ný`RÍȾÉáêŽN×u'+ÛiÑ6' co±0f™±]s™ÈÓ,S¬ì5òŠçä$ˆ–!dÑ\˜âfÝ×¢ò/"ü°€Æ ŽÑèZdÔA=ç˲sT”èwá*:6­x–S\8Ž)«™V’Ì$å_1fO²ó̦}Æ$ÆÞÃêïo@ÚJÌÊ)÷TuІƒÎ1j®r¤^7ˆ“‚“O–+‰Ú­*׎x×Iß´zPekƒ`z 4¹‚°"‰K<\<çy!®µ± Þ©•ƒ˜'K!3ä¼­™7SŠe©OY\² â!Ï:^­/ Y\iÞRäãZßò¯PÅ8 x_§þX -2ÏÁëÜ F‡/„T~Õ“w/áPø¬¾$§®•=mw,3SäÐØ SRaÓ ~N“ Üç¦ Vš{¯½¸ü¼þj§WyÓ*悾屫¯µ·6WìÑÌî*‘²Ñb ©NÆP`iGÁñP8R2µj‚ᎮôbL\§ç˜âö o™Å”Ž)S”“ê~áI-í\›#Ï*M8Ö2ù)NR™)‹²kèzVšêxqÀå±c¸¡#Ï^î¾ð¾¾P.ò™&Zß­OT¨ÿ?‰]爽è¢ú \<¤G)IÛI+±7ÂÉ‹vš^ Á7¾+ù ^[—8žè…’—áñ£ ùà,N¡Ý^pï™WÉ;…Ù´ý8÷¤²©W ŽÌ“Ôÿˆ˜]¤º$+ »N¸OËd¶¯Ø‡Ž¢ãÉ ˜y¼NÁœfU™57@¼<˜^• µ({öšJÏSÚÎA— À•³G×y˜ßº€ß\oŠ{=L,8± VËçî^¯.za’ðKÕdù„˜¹!æ¨Cp$%„œº“hlYNOå*»óÎá㌳`ZÙônÄt¥kƒ_v7€üº°¥1 ­Ò>\Æ1“÷ÌÃÖ"%N1â2ˆ^µRkbÂÜß·_nY_»×*Ö«“ëòüÍ‘þ7‡Ià#¨(2A%×£«Æ§Øâ'ËÑñZS…´ÉÜ'LG|¸ˆ¶Z¢·ˆGŽ‚×÷x/­¸‚ú¶žç{¯ ãûf¸ß…)|0Vi2æZ?= JÒì6 ’à/礼žÀ@šà¥|q׎ƒ°ÂÜ3o’ £7Má>äbBŠ@ø8º|õRššîÕ2§`óÊcA0|×û°¦e¼ç׫”5?`z>f¢’M]¹àn¸ ÓøNØT¾ŸA—]qɺ~‚‹¢I]ú­]Öë*ELì•)ß!LS„­þ–røF,àøQhÊŒ³z/\'Çh‡/õÚ»(R1;ëÍúÀ…¡Äf%¢÷Ø©Fçxò>(Ÿ©à2î~Tëÿ/æIßݵ†ì{>Þðê÷ŠÏR¤EªÕ˜Ýà×Ué·“Â&ÿiÀÕÛó¢‰#'LÊ"*ôß/tÒ‡w«‡ÿ‘?7ç endstream endobj 2 0 obj << /Type /Page /Contents 3 0 R /Resources 1 0 R /MediaBox [0 0 612 792] /Parent 8 0 R >> endobj 1 0 obj << /Font << /F26 4 0 R /F20 5 0 R /F37 6 0 R /F39 7 0 R >> /ProcSet [ /PDF /Text ] >> endobj 9 0 obj [525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525] endobj 10 0 obj [514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6 514.6] endobj 11 0 obj [571.2 544 544 816 816 272 299.2 489.6 489.6 489.6 489.6 489.6 734 435.2 489.6 707.2 761.6 489.6 883.8 992.6 761.6 272 272 489.6 816 489.6 816 761.6 272 380.8 380.8 489.6 761.6 272 326.4 272 489.6 489.6 489.6 489.6 489.6 489.6 489.6 489.6 489.6 489.6 489.6 272 272 272 761.6 462.4 462.4 761.6 734 693.4 707.2 747.8 666.2 639 768.3 734 353.2 503 761.2 611.8 897.2 734 761.6 666.2 761.6 720.6 544 707.2 734 734 1006 734 734 598.4 272 489.6 272 489.6 272 272 489.6 544 435.2 544 435.2 299.2 489.6 544 272 299.2 516.8 272 816 544 489.6 544 516.8 380.8 386.2 380.8 544 516.8 707.2 516.8 516.8 435.2] endobj 12 0 obj [576 850 693.3 719.8 628.2 719.8 680.5 510.9 667.6 693.3 693.3 954.5 693.3 693.3 563.1 249.6 458.6 249.6 458.6 249.6 249.6 458.6 510.9 406.4 510.9 406.4 275.8 458.6 510.9 249.6 275.8 484.7 249.6 772.1 510.9 458.6 510.9 484.7 354.1 359.4 354.1] endobj 13 0 obj << /Length1 2152 /Length2 14903 /Length3 0 /Length 16182 /Filter /FlateDecode >> stream xÚ·tœk6§±ÑpbÛ¶Ù¨q£‰3±mÛ¶m7f“Ævã46šöËÁ{zÞ÷ÿ×ú¾5kÍ<×öµï½ïg ‰²*ƒˆ‰­PÒäÄÀÂÈÌ SPaa03³123³ÂSP¨Y8YÿÃSh-lA¼ÿ2s:½ÉÄ ÞìlAYgk €…“—…‹—™ÀÊÌÌóC[^€¸¡‹… @ k :ÂSˆÙÚ¹;X˜™;½¥ùÏ#€Ú˜ÀÂÃÃEÿ§;@Äè`al(:™mÞ2ZTm-€Nîÿ‚šßÜÉÉŽ—‰ÉÕÕ•ÑÐÆ‘ÑÖÁL†àjádP:\€&€? m€1c„§¨™[8þ%Wµ5ur5tÞÖÆ@㛇3ÈèxKP•‘(ÙAËÿe@ø»7F–ÂýíýG ÐŸÎ†ÆÆ¶6v† w ÀÔÂP’”gtrs¢‚Lþ04´v´}ó7t1´°64z3ø³rC€¤È€áÁ¿é9;XØ992:ZXÿA‘é0o]–™ˆÙÚØANŽðÔ'ná4~k»;Ó_'k²uyþ L-@&¦0q¶cRYØ;eÄÿ6yÁÿ–™ÌÌÌ\<ì =èflÎôGx5w;àŸJ–?Äo ¼=ílí¦o$€Þ¦À·xOGC ÀÉÁèíùoÅ#x€‰…±Àhf‚ÿýM 4ý ¿¾ƒ…@‡ùmöXÌ|þyÒ{/[µûoó?Ï—I^[EõãGº¿ÿ£µux2°±X9X<ÜÜ.f€÷Gù‡ÿ¸ÿ)U6´ø»6æße@¦¶ž¿(¼õî?4\þž ê¿7†ðßmßF þ=ùºÌÌÆo_,ÿÏóÿ§Ëÿߨÿåÿ6ùÿ[¤³µõŸjê?õÿµ¡…µûßo“ììô¶ ¶o»ú_ÓÀ¿6Yhbáló¿Z'÷í™YÿÓF GI 7 ‰²…“±ù_#ôŸSx om*Û:Züq×X˜™ÿG÷¶oÆVo÷‰ãÛYý©¾­Ó§”Ûšü±w¬œCCwxæ·ñbåàx²¼-¨ ÐíÏÉ01‚lÞ\oô¼¦¶ðœ('€IäÑ_ˆÀ$úñ˜$þA\,&©ßˆ À$ó½ùÉÿFÜ&Åßè-ŠÒ?ˆ›À¤ò½EQýØLj¿Ñ[eê¿Ñ[߈ ÀôñÄó† £·ìF¿Ñ[vãû[†·«Êæ·õ=g2ù|c ü|+×ô7|Sšþ†(mþeþÆÇì_ð-ùïäo„ÌÝíÌß.Ùßo2‹Á7&Vÿ‚oT¬ÿ߸Øü«˜·Êÿêâl'{³}{ýKýV¬Ýoõ[;íÞ¶Ïö7už7{g[' ‰‘µ5ÐÔéÅÛuòâ¯mþGÃó·æ¿Å,,oÿê ËIÇÁ·Ü¿ß®&'sàïRßFÉÉÕö_o]qþ|ëŠË¿à[®¿!ë›·Û¿à[x÷Á7’¿»ðÉèðWªÿZ+cg‡·×ÍŸßÛÎýÿùnÝ€Æð+‹¶Æ|A– A]u"ø® û_æ(ö?¦Ñ0x®8t;?#Ã&ÓÔfl9Ü‹$õ£®ïJPß ¯¿z~oo‚ íHüÐùâõãS¼ÊÌ~'üò4öðTÑw‘Æ!B85á¯W{/ +ÈvðYŠ<{gndåŒG×A)·Æ¡Šµ‰Åýµœr?*f¢Õ£týKç)ò²pIaœßÑ¢_º¡ÌßÝÏ¡çNý"–§ƒ÷>f+öÔÞfyZðبRcuì}Oþ^—ò}b†ÒSô(Egɳ¬xËa"u»{rÇ&‰ÅúˆÚc_QåÑáøZŸ’bŠ—ú=.$¦LdÔV‡t‚M)I {öåºì–›Ì5W»‘#½R‚Å/%k®Fžý¾çÜF#Xj¬MÚPs¬äFbÐG(!xn#%rXá¾ÙÈhœMÝãñ Ìæ6d Âön¿ofY ®þÇj$cën£2óW²³a.Ç»´Ö˜—·Æ™¶Ã=“Ž&6ïõÁ“)š›Žê:’sÅèð#±³ ïyÚñ¡ñ¢É’³2òÚÙš•F>é5ìG É¬=êr… :ÙŬP¯ø%R[Ç…V' óÔ º3éŒ-5½Ã+¾‰º#ó“:¤àæcuÿÍäç› ½Bf~Æ 3UQDEë$ í¥8ù‹¹ü|}ž¦ÌŸ¼¥r´Ð^ç’ðA¿<«¡~‹ô[ïs^ì» p»-™õSݾ§4|úI¥9p|æ{ÞeñqŒï½»ö˜òSÔn¶à¯úåu»C"U:pïØÞ’ÞÍ ÃfóÁ%O__~˜V׳‰Ü”ç¬`3ŽaÈ€”Ñ 0ø§@|©s¿(Ÿ©³›y~6Õ\¤`“žJÙ°Ey"{ÚÈ» üà]~W*–u¡å­r8e6²ÏãS;}ìtl­þŒåAR¡Gê ô"DkJ¼õè·p?C] q+Õ7Ü# ݉ˆ²Êôñ8ž­F *Ý lîÊæD5ŠäÒä|M« Õ„ƒé¬ÂÌ Tx…v¿ˆÆå¸Ã²KºlSÉUh»Æ aîê(È  JaØÎ,oàÆHžq’ù%âF;QH¾C²nF¬‰+í§ FPɧҧv¦¾íw*Db]­°R5Ãj†¡t´Æˆ¬6È•ˆûÜâ:•èK#ÔY,ön+/EÓKÿ›UfNù,_•1¼boí ÒJ´AoIÑöŠWfÂüQ˜zÑ/ãÉš­‚#ä±2ëyßDÎYó Nh8Ö•­æéÜ8"bímõÛŒoÖ]Ê^4#mÈ6—K•Ù„èè”]†ð‡UØ·²1ŽiAŸ 'Ò¡Ýc|Wð¼pÞºJ±™úýäëB0)†i[··…›Äkg}ELTß¹¹sîåü–&¶I7¤¥vG¥r5‚g9 –k»ÈB¨Pò–ÿKv™È«ô³™iÂàA8ðp.w.f kŒ½-¦©R9H1rb”¼RËp¡N N$Þ׌[æCÒûþM>˜Ô/þ3NØy©•=a§h{Í(Á±X;œjŠ:j"Í[—äñ.o–&pëJ‘Z¹Õ?pbÎb´w))z‰}¨tÏÛõÖñ·Ÿ8±n¨RÞŸf[7°¢UCl¡®)×Ë@áäPYfÐ飖¨>‘%asä…ÒŠœ¬N Bkÿ¬•plRœ‰²i2ž®¸bd\{D í›»ÎüÐJÙŽŸ2âV³ÿ}¢Ý”†Üb%VVgjÿ‘a%ù5Ó>Ü–6ÍŽŽñÞÌÒZ;ÏÈÜ ?ö«/k±ÓÊÕŠ;%¾d:‰+ÿ½=ñòY]§$£Â²'nù_†3èÙ(¡FÈeCKñ+lêðn-Æ'eùiæK?‚;ú ™ÊÃT$/ðÖ²ŽQm/ì.÷ˆ²-”{>×£~([Ê6Œ§wbžT§úÉOµÃ-ÔK›D峫„á’iýìùX«…ͯ¬hvv|&£Å_§Txé÷rkýlûÝhW×Çõþ•JæS²"#é]‚ú¥è<.¹sqî´ø°T26Nms5¼&Šd©…Iòsø†*ny$Á?LHºUÀ“2}Ã2ši¯ò`ü{öxòpTk†ÄM0¬–ðŒÈëž5®FB*ôRؽÍ9€ñ›ÒŠaƒÒÕ2ÅôJ­°œTÛÅïw¦Ð¬ ‰C2áƒ~…(*à®’¹‚Á+©å¼ÓØgè¤n%‘mnÕþ쮹×]F¢Wë±´.¼ÄØâWþ„…Èq6Å›(.ßÄñÉaEzÿ¸ÚÞ, ´–‰Èá°4õÈl²V™"1Ò PerÒ“Òë–7/òjü}(m¼c*¿à‡–Éu-oΣm´‰AXAˆÂ³²QPT¨(>ô¸Ö *A¬¹8|ØÚŒrlX–Zr”bÄa‚1C«$LJT¯®fþü~ÃÚ¥‡§ÿ øÓüû r;±ÌŒátÔm 1p ]«Ê/‘ Jvùã#NÆb yߘ3cüj¸9ª´D¨‡¨ŽÂXd3hñj1’æÆABv11;†öhºµO'T4_>±¯~ö–Óʯ¥k6YÔ7ÞÔˆäFg–Ðv¢}ÅÄxOSeq ô(7VÏår€ÐJð-¸E9~Ò ¥ºmƒº…‰û$^ Ä• väÉ1eîÖNõÛ@+½†Z‚XùVdÛ5®B}v;M¿&^wœš³± ×zI>±ºæM<‹˜ &ìÒ'Î _ëÑ-·ÄwGˆ­¡x´ßÐ<¡Ž™UNÕkz䮢è)üWñ‰ëtñ†«ãÖ÷¦ XäEë*§ÐÉd÷À›/{o~\µÚáà0cM0Á¾jË¢£ÅËqiË‹“&ßšȰ”Í[: Pqó2QGÉäHåç®Â€7sFŒ@½MCâ¤Ëo(w¸ýBª@Þ,mfJMÿh ï´Ï’¸Ì‘ëÏ݈τر£Ñ±[[z»RÚ>píJ«/éGL&„¨ŒÓæÇóãÂ'ÏfÀÇò2)+ᤠÆ0€8\îr™V—J«à~8æV; "#š0ÞjߣÒgÓYšì˜šyJ‘«à‚²Å$ƒC„`Æw”Ȭ`Šç¹œð"ÉF—¨ê* ²ó¯g>ƒ}þ~ë~·ghZèW–%Â&$q肚+Š ¾½ïŸ m<¥î¥t]F×®NHÞä0#°WƒŠ{m:ä0˜H.¤ßÞaš¿ÔwàãÂã_¾Dü¥¸$¥mXµõo–b'à2÷ e4y^zRúK“óÇî¹b¯Lµ‰¦] …ÝZSÚ­Â Î~,Ø ãÚU}þÔ,ŽI×Ú}”娰§›–‚D‹P¡½‚YQÓà¼÷Ùß UJ `-<÷¤ÉšØÍ¨ƒÁóð͆|ºà¹?3,Æ,wOb ?R{Ÿfâþ?ÀVË‚QCPHÍ R®®0¸°›Ë7ðˆòüI•™æ†~E—‘ÿ‡ÿœßi)G1c¥obËZFš0oÃ1{@àˆR7ñm çÞ·ˆEökE9môR]O¹¼Nzë`´#­±Ù𲕩K™÷ÆøFPš¶p¬>ZàÄ0diPž—]k%kKrÀùÊF®†"»^¤VláC½¾_æB«:6ÁvBd§n…©ÌôP®B¶×™­ëïd¾9+ŠJ£P‚7^Æà i|¬ÀŠ"ÑäœfhvÞ0ùz;>ºOfgœQ¯yó°„Ÿu3÷î9®¤… Â<8C‡ÜâÖ9ŽJ!¹‡éáˆ]Ë‚åÑøSnõÚ(„SàCíæMôÀfèB‰ôôMO\sÙ‰UåÊ—¢Ëж3ßÝ£Ýeªø<Úüâä Œ©†sQþFƒ!Uûcw_—¥ÁT"VÉÉß7¶}×Ú´KÄ ö[>ºàØbnðN3±w‹pا©Ö†Ý_Ðå71)Ëh Éž¾.ùÕeD-¾ÐåãűX|J/Íöpº0 Ð;Ñ3¦;òóŸ‰êj‚¦ j®ÙWÀgnï yÈ_Òý c;L¼vscÓ¡_N_¬¦ÓuS¸²htA5ä³úy¥õ«]ã±Ó§æYz*¿’~ešÕ›éÒÚ9´öÁvKäyêž„ Q-e3¢áø7€Ü¨<ûÕ¼ôxC¥ /ûÝp“4èüͯlÇxsä;'L7^³ *Ï­ QøÛµˆå|œ Ï^C¹f>×~Zç zëkjÛ®•_0óþfxéÖ(§®‰­m}‹At~Q¾v·&«šÖ˜±âšÎĘ9RíDF¬ Àj¤ýpZàÒÒã–…Êš¦w»ÈQªH=YW+&Ï=UbnÅ?³2½?ßrê‡ î…rb©CmËÊ­žš×àŒ3sºÇöG…ÕCº¸DÈ>ø^à¬UæSæÏÁèwÀùhú£èÁ…Gb‘ÂEÉìe«&&#ݻݣ™‡ƒ1ˆVÈüè›è7Ùàâõó'7/VŽ)æ‚-Áñ¹†ÑåÊuÔ>–Ê5!m£c‚(ðÍR­“åýg„ Ò³C÷š/ŸJî¡6âË)û"ÌïÀ(»‰DÀCÈQ£¢ç)žcxŒu•I¥¨I7‡¾U<½Þ5‡ìœBõöa&Ï¢‚yCDå¦Ò‘&îùá·a®¶Vh|“ŽHO¸[}ßÍ"µšû íñM ¥ëX­ar¶r Ü1ŽaÀN5 ¦²O¬±!Ïž>’‡Ç h £§2çé!VÚ!ä®Ô¡ºÈx@·­FfðÀtà7lŸeÅ*’)¸OI¨ß°qô^ÅcFÀ-ü8…æÑÌRd#‘Ê-ÔHTÙ„¿v·X6†~Že ßeaßfA–$¾ž–¿¦žIµb´B@a‚Ç[“PgM…mçY„•N1Ðä;é70IN8‰» F”ü¯sÚŠŠâø„»ý‡Äæ¸XQ…^Äè—r‡‚³‘ŒÔr;ÏXs‚t°!tìî ÂeX›ÐÙ1Ó¢ ç:ZÄm]IwpU„ ?Т’Óâ¯&ãIŠK¼ÊïT48áLÈÑ,£*]k€x¹ÕÑgÔŒŒ÷×HN½‰ð¸W£¾a9G÷M± –}s Ècf ¨’½íGz²ÙÃÜTªƒø¹‚ëÚïªäL«8òˆlæf‘þK£p¾§Jºßž»Žu¬h íªàëõõ’ïBæmA £¿j Ý(Ž0%JwD¼îàŒ^o¶ÑÇ­|’ÅÍb»,ÃsæÓØ.ëØ P缄x4b“쑘ïUÝ !ÚþüéT(Â=°ø#ÌoÙ›ñ!±¹=‰âmÄÔ—[ùZ?8ýÄßÍÖ©‰ÐÞª@G³ÎhòÒ‚üÀNDZÝÛv 0˜o- ‹Ä¼ä]°%¦`¡©§`¹F›þîI¾é"·B‹øÅ™.ä6VÕn0‚††•Ô]~Ó6·Œ†I¨\ 3ϩѮJ”~ç<ó« ±ÑŒÓ–9í"ˆíJn!õ,QS,U»l/"ë.ˆÅÈ>h¼³ÎV+ëö"$® Ù1MíZãí¯tX‹áã ~7SÝå9¡, LØÀ:ʬ$ÌAl®ýiÜív.Ųsë×ÒïðÕÔÜpåcñ÷ŸR˜r£ÄÊ5ÆÌºO–o"ÕÏf9Hýdøð’ ïfC¥D>4ÑÊ -OtR£ß>î<Ü&Tbó~Fu»|òZ®îÖ†Ö€LxÎm)€ £°^$CË™¡Ê&:ˆä…³ÝÛñ¸7ï×ׯMÍ6p˜}û”¸ÖÖ35—XùåëçU¦2@© %Æ„ðTÊ… ô}ÆG¨*vsYÊWü¢ºh7ÀÑHŽ“ŠʱgLz~èÞ‚kÓÄG¶ F)q>ü™˜HÙú`9ɨä».qÆDœ#>T“|eS|Ø3Œ&1𥸾•cv’U=!Fñ e¤Ôi•ð°žÁNµåã<‡/Ë>9BÄk=t^†…õÛ& 8ºƒ½dù&Õ¡V¿ÖË.6{ùã3ÒôqÍ\®;•Ò\(ýWžC#ÈÇl @+ÐfQAÊ¿¼vÏ÷ ›Wvy ^5‚”ÁÕªiþ¤³É_ǢfzˆïÈ9iù}­`'ÆLbgaÊÄ·RêD¨Ó…p/ÁXE¤€åúû˜wd]Õ·Ò–Õn Á¤v^ù8^à…†»½Ék jv ŽË`¹ Ktš–ÈîmO£ò#­}|(Y›Ùô–þ»À8 $Â.·¦'Š¥ø\¡h‹òßñ/Éë}6ÏJž$ wlêá*ÎaµLz²QBaøy­0òúÛd $”ÅeCx~µIû+µoµ¡õØ™Šo#,‚òа«ß•±3‘—³<™â æË=œM¼V}&¦,çlP׆øZR£ÔmgDgðÙ[Î)c'ø›fÚÃw]ž‰•Bnh7®ÖK %Ð\ìjùgò¬ã'+Wp~ÙzågçνóÅõ/µüó¹Aþï0eïB€øGºzλÐ+O6Ì?Ö—TûB*qN'›%4Ƨ÷ ©DúÑOV¹Ç>ß`gr#¤2Ò|ë ¶¦ü¼ÙŽÚQÆÄïÛÄ+’½®¸®ƒDtElz„.ZÉ”(y©.$aײGjÑ5ÙEUÓwYƒÁà‚ÅC¥3 1{­\ö꡹¶¾TbÔ¶à†·2Ⲇ¬\§"í1(;? ¢Ru¨ý¤Æ&ȳëw|%é6' h]pñu»†¨Ëb|–t 0‡ k=þ:ø¤ýuý4[€µ…§kLxñô{•Û˜Bü,®g¸é½ÆøUÚ,Ÿ§êÎ2ž:7" œí†v5" E‚7+ƼÛ "ªÐ*ªIª‘u˜vRïÓiæ*ĵiTs Ÿ6°œ‚¬wŠ6¼šÃ«dƒï‹í‰ˆDÕô¾…&Y½ÞÖíXG=§¯ó5ëhËÿü6àM1)Ûƒ"Á™Ž\þÉ0*J8æë3Ôk&jðþP¹©ËŠËÕûe¦U)¥º¨w#›`γIØ_Ú¤Xq¨n2îÄ¿ҦŬdŠâJjì/“hÁP:z Fziâ’‡OÉ3PpÈd¶té ‘/ÙÈ»l¢]¡ä×ý>ohÞgB`âd2R8¶!qßÜŽ+bH.ìoŒKjS2Þ>¼tÆ.(Î`DY3iKW´Ø·Ž×Ô„2Úf³³Ë6E ý*=K·ØŽã€I§œÜà0¨(÷ó¬S™$ä°q÷ºMbÃÕŸÖÑ'r3¡8˜Ç?òº„SÜ®ê˜@¹Q›©²&$øEœÐSÖþ[Ý䉶âÛ9ð,Á™[у¦Ã¯wÄP—RËÒ:5 4 ¶4sÚáR?¢w “ìê4X…™K<İqѯÁ¿¸*^¸0!}¸óÚÇ&RÁyYš(UÑ6ÖÅðØW—`~}Gäà<¹·k°¢/BI°4Õ.Â]ȘÂ͆9mM ¸J"¬«DCO®¶O•ö#·LëÔy"4ëJZƒï£Ü:”µ?:¥íw>5É{zí3C”|H?ùUwCMµþWÄ8Õ‰š»qÐ]Ná¬ÄaeĬ `G4ÈQþørÒ(œF1ÆÇšH‹èàÕ’»ÚÛøá*`£HˆØç¡þÜetÖ€ þì™.s3¾9¬yô%ž·„.× œ½ýܘ!ÌO¾Ê<"±NÙ…Ú˜ïï£+ž{ŸŸ9ŠUÿ-J‰à‹?*ö•`ýÙOÀVdÇKµ^2™¬Ï ×6ZŽçœ=ÔÅ•5NØc4(XaÿÈ}ŠDLÉ-#Þ÷sNΔ횞D²¦Ô×?wàK€jÄ ôkÕXŽCò^ˈñÉ‚³8"&LfñŶ*ÑE÷]Øñ BꟘËNº2æ/R…Ž…‰¿È»ú™à²{™ÒûÅåÇÞ·àæ¸©ø…¼ÃÆëóP%9/C¿Ü^{—\»2 Ñ2«è)"ËSw^£E Šq'¨Ñ’·»¿–±pNüB”Tɾ³ÉM‘¥‘MT E‹ïRÚ‰bž) HoÇé*¸Jâ>b4MK®·«)æ¯WX¿7fµì‘•ìü™º¹•QpEÕfÎ÷ä0aöŒI_{‡È0X3b±¿p^p}~¡Ò8ËÙ~Ž›­IòÝR59BYYC K*ŠíC‡t")FbOüö2Õ±Å2¡õÃãëT¥]·çR˲g„ÙƒG=ÜÓåqÀ… M²â 1æÃ>ñ¥Ú‘¬sgŽ4nDmì$þØ^Uè ½ g±Ò&A/»×Æ_Iý©µpév`ÇÜù~èGÇÁ¥ŒXö:Þ`Zé‘*çÜ­>¿bÂ˲¥›H1BÇ½Ž¡7ù`i7q¯ÄöÙú›Qï‰å÷T_Rpïµà/¶’ 4îhÛ‘Cß@DÛ·ÌD. £sÖ±äŽÍÜqE-ø’§È¸Ç'…’ß”•Ÿ Å,ÿ¸Ÿ†);dw›‡ÎöݰËei¥ý|ÍW N¾9‘ý}nA¿-*¬/>lôtZ‰%Qnïœ@$uÖ´í9k–âå…zÔq‹1­Ä&èKcçzb2q´¼$Êã¢LTÃ!DggAŠg %K„°UóxO¯ZL"ÊcÁj§JŽ&ò žç…ÆX¾šû²¢úPA­ë=3´çu6ÿÂz̥ض­hÝkX_µrT˜Œlõ§¦ð¦ÎeëHÝg¢>f×rWIÌó/† UÌʽ_ûøQ)ùP}î*ÝŠ³35f¶î×ëð]&½°’!é,¬Éç’ۨߕ&h&<Î_éºôBÍÄ&ÂJeÔœg„š€Jä³™—ÂUN,g‰MÁÆøÄàò 8tÚå‹Ó¯(Nçâ6P)?¤Vr¨¡…žXâ.±«ßù=—­vƾ&Ò†ðW¥õc£¸Ž&.-®>`Ç+æn}‰¯â*\eÑ1®ny0_+lOªÀ^îL]m(ÐÜFèבÖ(¶vG±•ö›Ð’:èñDT J5¥a3|z¨vbÇzY©¦“Ü̲OñP¦¸çªEØ–NÂú„t—°c”díÆ‘tbž-¿Ì˜döÇò˜L‡&ø;2Avu“rCŽÓ”˜ïs7%®ÀŒ…úxþÊG$­Ø>´}g|̇u&¼€Ç£a áôQB^¬ óâbî>¨°ŸºHZºœ?p Ì»9‚äZq9UVäÎ,s?[Ëx†hHP¢ææ6pnî?Æšê¦ÒçYLÜ%?Ä)‘µÌQT¼ubí–Û¢ãW;ô¤IªµÖcç uj’W³Ìh°¶ãÐ'oÓz^uØ<ªuQ;Ó#jZè$à_{ðR}×äÙœÚÍ)]¥º¬1¹ªü>¾ž—5i¡«™ÌøÚ¶ezïz³¦ª²º•šN­É2ùάa #¿{©GJÑ'ÊúLÐ+µÜ0`—m›å\ˆlQÆ =ï§ÖU/K¡ü°`Ä=’õ'Áï\ö¼ž¬Êß~’Aq¢G226]ÓI8ß/éô^dÐû)±9mjMBwc¬ ‹Ezâ ‰€R»ŠîfnÄWe/X~Z©.ùu4ÆŠè5¦tùµ@¢çŽbU ÊE§§ïçMïà ŻÈ¨ª c‚7'¬àC ŒÄ$`Ö1½ÇhŠ¢¦‘å÷kõ¶A¸;Ÿ'ìò©vDW#ˆ|Õ»”³Ò8ŒÏŠ´Ÿ›ñ–M»ûä›g¬Ué: Œð»;ÂQ[–‘QË]Ä0ÒÝpƒfÄ/ ªÄ>¬cË5@kdK’Gß0 èÛ±<ÏJa…Ú¿¿ÄÉ‘oXüLU¿øÏä{Rk”n„õ芬œ|~¿f^÷ÈþnÍŸ”€ÉÑ [ %–Âd7µªú—}]5üP¢QØ5™ß·R&ô8/"ñ} þX¦júo 5¾Á¼šÓ©,{¨¾Ùïµ3õêñGSß WVÛ´×ÔrC!9©kÏøŠ"(Öºv1åâvŠÙŸ2OUW1,$xRçæ Í¶<§Ø:oÀЈJ§<’µ”G¹Ì3Mì·ˆ±àÖjDòd2†CnGU–C9`@ñcŒ…׌»O’Ë4¡› .Î–á–žŽ„ÏΪûÈÆ¹/B½¼LfØbõìkï »UæâeMYm7`ëÙý“Øiˆ—i2fgŒª̹ýÂGQýÚu¾˜×™v½3ˆØ óæ% ¡…Œm×0Ç.3r}r*&푤:ÎîòõKâ¹ðÕø–ƒé]?°è¹ø Þw  r’N»{R>û¿e¡^*/j[Ÿ˜fôªÒê„1Ñmzj"÷?AŠ·Õì¼_]ì¦èœLö9|÷·æ\(2òí[vÉou,¤€5 Bx¸“Ÿ–vÄqŠ;\£=†®Ù‹hâ83áÎzË9•HÊÑÔ]~ˆJbâ*éJHÂ:·v.~öx}O£Þø+^Óvsšü¾z—øKXªQôxãnT+ îŠåç§ÝÕõ-ý"L¯’BÖO÷:fÂ8Y«ô Êœx]Òt³10ƒ›kŠ~GB‘47[ǃ;.m­k¹Š¯(±ìE[ŒRñ¥‡¦!J))‰‹ÎøÆ_Æ–ûyÙ#‡î$.iw¶SêçÌ%§&p6Bé{Ú¿O¾”©øcè‡MÕVÕùä¯ >®Ã×ï­‚¾1ãÉf#è÷|v3‘…[Q¥ùI5ÐD¥†Œeaø ú#Œ†FÊÅ®§¹[¾;ëp@}ú;ùáM°º3XÚ9ß°j¸öÙã±[·ŠB¿=.QÜ¢ŸƒE¶QÛgjš¼~›ÜHLþGF:¨ž²UبŠãÿYÜž°µw`/€Aó¹eêÁ[ûx˜ÙqùƒÞ`ç3ºÐ|IR’ÇÙq:ÙÛðÔËЭ¯Å!ɰÚÕÁ£ü ú\ýlµFs¾¸a? yyÝpDË„½J´»µ¶·>ê,¸ÄRg<^p¢ 댇4U!ß—ý:1ÜíÑœš1 €ø2œ/!f¥–Ìö?€/h0àÇËJ×îëÞnÚ·ãëœ|$ö©Ú÷'- ‹P’ø†Ã×ç3h'Æl_._ BZ"#]ݱRO7/ç”´5°ôýS-rlæ^ØK¿f»ÄϼðÒLÑøsÔÉš™ä“š }oo/{ïéS!jÒý8-Ø<¬‰{Ál”$÷uÍÒ2+qAUÇ‚ÃmövZ¤GÞÐð™½O»L—eöŠºR«Þȵ{KÒæb4:v†; Éû é»|DvBzè ù­b¿vªsí!ñ]¹Žy_• ®¡{_ÄŠÂPk¬Wy„Gnã7(õ;&èµæ>i+ L©Äyc1œ~Ñô£ýúŠ‹Óhxƒ ¼ågJ…·‚+L¾$ûc'¶ÀGÇò¨®šk»Š/–3%S$çfPµ>?z©j—Zõe ª@úHF ½(ñ©MDo¦a©Æ„ÿ±nÿ½ ºÉŠ ‡ÏckȲ8¢Ó^ôôr-–lPr±ã%.ì»DŒÝt’p …UΟÓ>Ÿµr`±ÇóqRÖ«]iæþò”¶ÑYý`1wz‘Žá›X7\¹Tcñ@dê«üêsúˆ_j»ðÑ”’‘÷4Íét*2EY*ëc–}¿×'±ÅWj<æñÑ»Žþ¹y Òàz:œªiQªªÍq›3ê°êGoŒuŸ æÓY~Ó”’…”#fGÄZÜ—ÎÚc‹ Ý•]q͸út; È ê„õa‘»“Ûûú.:{Ûi8*@/£€ä±$…Ðζ#’¸èfrªŽx‡ú|^i²‰¸Ë~ÔègµP ŠU BzþÊÇ™²)û¹'dëŒÌpT;ÈÏ1ó:íæë±õö£–¥ñyƒ3'¦BS± ‚² âÕi3ÓW™?kü Çé " ¿°¤ÍI·fÇåF3ØV8Ý.½)¿ŽlÖžýXÒ„“Œë¶xád»îs}Õ7s3(ÕÞ÷Rá9·V–M¾Ú',/’Ù@<ŠÄs~‘fØzCŠD¿}:$ lø"ìzš¶ö´3:œ-á³0×^½÷zçu¥X £«ÊÏÛ%ÂÑ‚†£¥~š«/Á^î…n#Ð1u­Œÿm]G FM£"õø¤Qºöæã ŒÖ="öåê(8ÑáËì6zœo8÷{‡z{1qPgj°L×!ù$¶pžÏñÜ9:Kpm‚O¼w¹ÛüNÁË“’­¦¬3VÒ ê¤¾Ë Ì;ÂïkÑ'H«ÂeÒXš/ØIÕWüzc5T~t0-è¯A™çÞ‡>‹lÜ{Go蛥za_M: œÐT^ø¢ IO›}ÙV+@ìjï[˜ ç¹ÆÂ ,Øûr•Ò3s'bÞÍ•_j&ÛW`F³o&´ ¨~Ê^Æ€„Jß3M?³Ég ûÞ$kÿÐËFÌÄù@¢·£Ù6Fà@^4̦ˆÈ-î˜\hN°ò_ÎÊsMk4Z÷ÐL^£\Ø ¼›½:J-Q×¢¼çËt©vøvö-²I\! R¬+^û’ë#o÷·ç¹jCh‰Ua­ªSƒ§- fr¯™{F¦]âï#ÁžÙ…¦ðUË®„HCŸ«È/}PAfmQáٚ܃É/ ¤¤kü¼¨ÏeásÛä̪\ÇA7Ò±[FWpÆ´òËŸÂ÷Ì rôÐQMrS'ƒ—™qŸ¨³Ról¸°{ŽVä¢b…ò?y’5¤OtM¤ɹáxn‹RìLžù$½ùÅÄÙùîx^n0kkÍ?!p¦ó]È_ ­'|O·£ñEé¿ê^¬2køñ…ê!£×0Ÿ=|ÎìÚ¯Aa)É.J`‘c¿5aCÆ öð8s”­(“%»™5(÷Ï·D†’vdgùrñtÆ/_ªB0U!ÈKÛŠD˜;Aà ÖÌ<²ñŽü‹ZSWöQŽ$çjQz+}…å–’Wmì=ú#_ö«WÜ0>³íû‘óüoM¼! g®êYVu°f…ñT¬ø~ñ¾ ÛêªLÒ KŽß¾øhúi7/[³Æ¿®è]D2|Ô)츌õ"Ïß&m7ñš‚RDL’ªwãJΠ9Ò•:kg¹÷¨J¯N¶‘…Þý,8û<cÎ:jÄqŸfÇFç5vS ¯X_çl¦W%8ë]*:;Š»L~Sáçàßù ~9\a„¸•'ÑN9~cæÏ1´Ñ$vêž{YWa`@p§EÁ˜ß~°ü5ÀA•t“ã½>ܑحþ¯§áµcÿ] ú| æ¤Xä~>„ÑŠÊHV“úþðÒ˜ ÕüøÎž—¬Ô.âwV$õ«læ¤ b?îŒJÐbE0N:&{Íýbíx¨d¾` Å7”r@ù;Á=bbf]„‹â’ȯRwš^Êö| fF9N^ßià úP@P³¼hzÊ@½~á¤9už”U îÕŽñF‚è!_Wþð`©Ð„ÓÅ80äÈØªfncT »ˆ*ÄÿŒä2Z)!Y"³¸´ß8Ù_Ù³Á~å©OdGîYÌ|/¿Tƒ3€ ¸šwgÍS&sVÞ ¬«ÃõÎŽ"XÞáã" 6…LñÚe%Õb¬4[>3Ï ¹÷ÉA\’w‹±úùø5 Îs¥¥Æ±ël:2I'‚é#ämÐ^¬5’aÈS¿§'U·¯dͲp$–¦õŽ×®;ÿ.²t/©‡›Ànø÷ g˜QÕ¨)—m.æ {Õ°iýç9dK]ºõW8$Tz\©5¡–= /³ERö½²CqújÎÃQ½®œ4¹¯@k:µðŽÛv¿ØÓË=nz°vÆ2±5½çÍ oN&i£˜ÒN¦¢KâÁw4¼áA÷64t{¹^_y†Ó"…eSju“ü¸ë¶²--ã)In[/¹!µ£8ÞoM‡9S.¡½D|žŠ°yæ0%C²É\ðólÞ†rAÝ9øÐ;¹sÜä*Kúå&×».Þ í4¹,CŽØÂ lòæ ˜æÅõ’júPsù ‚Jéþ€ ó†{`£A}…·¹T\W÷eÿ£âZXd„‡ùå>úÅ^£‹lç:¨ø[œq¯‚“ª’{ì‚ÄÆ¦áIâAü/Qk¨ª°ÑÝâ LïˆpÙ~*SŸõ¹ÌÂ"ÈjZqj—RNk_[<¥B^kÄwjŽ€L·½®E$‚C"±g§|K‘Ø5ÂѱS)!ý6Fâ;œ¯6È‚ukyJçÚÛsÊèì¥Cù‹)};욻IJë`¯ïˆ»í_GŠOä<­œFb–áÀl_ ©ÀÄ3^dì"ïú•QÙ…Çw‡éÉìQ³ë¼qhŽÆÎÍ/íK&Mh`=¿Üx½oÐBÈØGÍ7*’8!y(3Ôr;—iµÇ¼Î¶1aŠ a»÷g3)ƒQµ%è»8äývJ…Ú„tǹVCÞw+õ³93xöûéTç€Õ'xÌ ëñm©‰ýÜN$ï³²ðÍØ>tu£ZMݧŸJW}1¡eßäi›V¸“J¢÷ëB}{g3pl€}ÙÂOÖÞp—ÔlSÏ‚eXüR¯ÔdÄDg»´c–mWWeξd*··$xjˆ«)EûbBîšzh)ÿl)?JeòëËu¤õ†Dùé rÜ?P0](§™ÛÒ ÷šG¡rdÆßÅ´g 5Ê„ëutCÿæG`½F­²¨Ó¬ïlÚîSt©{—vÞO^’µ°‚H×@wßKÓ„L代Fµnd (J勎F§N¦Ÿ<dÉ7ñ¾÷Gª…|ﬖ»E#§ºM28ô×U:*«+·þ­Ù®LjÀU,ëֆɟ:ðÂVŸSéékj§†ò°ntéÀsHiÓ¡óMÐ QÐϽ "÷r Ð3‡%Ç_ˆÇ‡g†G‘ïV#².ét…\·7m¾cÍÆÜ½3%Ý’ödx*ÞóÅâìúxJŸY-(lû|H›/–m!™Ãï|½.:™‚çãÝVpšMNˆbÎÝc0¼_ÿ.q-dΫe1Î'$¢ê†”Ee §MvÔ'Õ¡›¦µÒ†RŸ±> endobj 15 0 obj << /Length1 1545 /Length2 8130 /Length3 0 /Length 9143 /Filter /FlateDecode >> stream xÚ¶TTß. ÒÒ1”4 %ÝC7Ò 0Ä ÝÝ¥„(%Ò-Ý ÝÝ¡H#- ýõÿûÖºwµæœç­ý>{?ï^Ã@£®Å.i³ËÁ nì\@!€4H“‹òpÜè Ú7ðŸft]°‹+úW€´ ØÜíÑ&cîö‚AJî.×s!.~! À  þsȘ{@¬ € vEg†9y»@llÝ—ùëÀdÉ àägût»@,Í¡¹›-ØñqEKs€ÌvóþO &[77'!NNOOOsGW˜‹3Àâf л‚]<ÀV€_„ªæŽà?˜q 3´m!®ص`Önžæ.`À£Áb †º>f¸C­À.€ÇÅZŠ*5'0ô`•?Øî €‹ƒëïrfÿ*þN6·´„9:™C½!P€5Ä P“Sápórc˜C­~š;¸ÂóÍ=Ì!æ¿;7ÈIjÌ þIÏÕÒâäæÊá qøE‘óW™Ç]–…ZIÃÁP7Wô_ýÉ@\À–ÛîÍùÇÉÚCažPß?5jeý‹„•»§âìV”ù3äÑ„þÍìàü‚|°3ìeiËù«¼¶·ø·“ë—ù‘¿¯Ì `ýHì±?¾Ð}]Í=À7w°¿ï¿ÿEè\\+ˆ¥Àl¢ÿSýÑ ¶þ?¾ Ä `|ÔøëùûËøQ^V0¨ƒ÷?á¿Ï—¤ªj §Éúã¿}RR0/€/;€›äåðó üÿ[åoþqÿmU7‡üÙ🂊Pk@ð {÷ ?UÁôçÄ0þ»‚*ìQÊ`Ó?ÊäZ>þpý?ëÿwÊÿŸìUù¿)ÿ’swpøífúíÿÿ¸Í!Þ<*ÙÝíq*@°ÇÙ€þo¨øI­ îŽÿëUt3œI¨ÃßÛq•ƒx­Ô!n–¶Hè¯Sx,ï‚Õa®_w € üßã¼YÚ?Þ'®gõÛ~§ÿ.) µ„Yýš;n¾çssotࣼ¸ùø¾\jöú­l'æö˜x¤ç°†¹ ÿ:QþçN•_¦ßHàTÿ=útÿF‚üNó €ÓòoÄõ¨WNð¿ €Óæ_À ù|¬dÿ/øXÊñÈõØô_ð± ·ßð?¼-Ý]\ïƒßÊ|Ü”¿ðïË ö[¢/ÌÂ,…ÃìªÃZ®+%É=ÙwFE§vôR™Ù}\ZÝ`£¼a®x²ær)ùæsîò–,Ó…Ä"õ½ïþ§Z”Ȧ×Í·~w¦‰š;ÍèóãD}cû’5½”hìÚ_üîýtƒí>Á·+1ä8» `«ç\{öÈ{Õô–, GÌîh|©x®ŒqW2ÉþR'îEpá4C®Eæ -²;%* þ‰ÎôÅå~öصR"+ºÿÁKž÷¾†ëܯnf|VJµ¹];HéI I(.ð‡'žùJí¾U"žó-ú‹ÛÈ1Äw¯”i|>¯DÃd²Ôík7ªÜ‰"sp¹óÌ Ñ:ôå*ÈõÄG®Eº5ö‹^¸¼W§h“£,ù3‡å\ÃËv¿ë÷C¥‰Ât"ˆEÖ0°mõSÌ«§.)„èLBº†Y% þlî^Zóm'6y²½Ñ.ÝuRxØ{kêSâoäórp‘–ÔÓøÛpV2:¿¤ˆ™Åš¢~oi&Å)Œí"r7+§ Ú¼Ó}_Rx²A·=7ám(ßšlyG£]©¿‘råocï,˜©€O|€E”xá[vÏ)éu-v¡~xCø¶ëÙ–ÞÌÞoðî%‹×¦ídËod¥¢ç['¬Á$‘,Ù]â]ôþ‰ò{E*Ž»ð;ØøJ”Nµ1H®»žínm¯¿I¯-.ô”M»f†Ú¢Õl•cPÛ™üù<&«Šš‚p"Ì%³wù?ÙÂ(:´â^_Õ²fÛ˜.jѾ9q”Êd¤˜Ú¨Á!+í2•„C!èõª…P¾àµ9ø>Y{ô5c0ZÝõ«0‚£MUEË»¾£E/Y­ø´äóÿÎIJŒ²ô.œtNª{9¶eUºPí=݈ãÔÔ&}Êߪ&ÅéNˆéy­Ï| 7¨[h 5¹²•ì}¯íl¿£Ö.2ÚÍçj£šÙ’TlS~O ÁuZy‹¸bѬ{04 ÑÜ8®ëû?4¼'ø@ÇHŽü¢°¡8 {Ãit¯4Q‰ïc%²B°¼BYÔ˜4Sð«…©ÛÅÚpö\‘uRÔRœhf¥ÕC‹ùš@ùi/bµgÍG!áŸ{ ú¶D×ñúîæ$÷°¼Q)ÀKº&rŽËÑ¢ùGaÔÁ?~\#ǦÛs\ßîÈ|`‘¬ðJè‹MðX~o~X¨ªÝAµ§íº¶‘›Íi¶$$ðôieo|xó‚!Ÿ%qN—N³}“ç6çÂñ›;âKm¼Þ½ˆePÍ;+t‹á´ÖNÁ*øF÷×Ñ®Úw¶ŠùëTŽáÆV+]"嘼„øeã%ñ±¢?ó?]f¹ÒÕ„M›¢|]Í,×½™!{oFOÀ)æSoÁ¿uÏh÷U‘™-š²Û彨êjãXœæ.`–Ð+ËgTÕù¸Î <s¶˜Î •e.aaVOY0Ê·u¨e™ÕZ;»é÷lygD”ä ¡7íÍrfdÀqCn¹2TÌNU”n_´Â¤í”mWÒšÞM&¬;; ÊͨŸ›©ö%,TJ"–ã±pIæcßcHöy„ÂqöŽRi$Æ&œDZ=êü»³BtX²Îâ¼õŒåöAAÝ>e+§Èu«WýŽþƒtzv#è(R_e‹¶C¬8u%S2&<™{Û]äÞqk±C ú®Q¨5{xX{Ê0z¬T%=ݽò]Ñ_¥#>Z˨­ì‡­rúÚîë"^&•ʣ佲Ø‚lŽÂRZb~`¶CŠîXTÓd5Xñ–Ík°S•?°{I7ÕëÎJcrBølð€ËŠ*N•ÌQ2ª¾©.z þyLäFèo´ÂŸ1•KX±ñâS­'¸°çÍ™'Ï„vΆÎ·<âTàЀâWj5ç ƒÐ7 eËfá×ÂØédïÒøß?7å‰ê?S¤÷ŸcdoY(9ƒ{§YsÀC;ÐØ9!±n7´s 6‰Teµ‘iì£Ï»Î£4E»ÇùJŒ>é8po]yÄqÞ$é§ÄD|KSôÐx†ÏžgR÷•£ƒ¹åµè õw¥É §ÞÌu¸Ähõ,˜QâFm6í 㯗bi£¿0cF—Ê|TRG…n] -[e‘wRD{½Ñýà ÔHYס·Y¤Áyé¦tYbîþ©ˆ‚Ë‚¶Å‚©øYwø7TÄ*2ƒ1~f'í®5³¼â?<»AœúçZZ,ñ•]RàX‡´ñÀCÊ W‡zÀN¤’³åÉf6Y¢úûApdª˜”ÄcI'R]?äp™8åæ'†7ÇNçÜik2Ýü2äÆu®Bt„༆ ªl½D§(|_ ºÕ ½D:í+!–^µxà7%ðbÑ놮NÕL rûõ{úÙ¨AM—Þâ™ëEC m ’;BRö­E“ EðûIvr„à†qñZ]Ì—åh3G¤…é;s‹Kܘê4&ßã£'MòÕG¬j<ë°»iôdÿyMfÆöEÑ<ßá`øEs¦ñ³ҷɺa¥£“Vˤª É AhX©bLce:„ ¹ø¬É;]F½íC±2 ì;P.ùúlŒÓ˜±b¹å{Uñ½þÏŒ–┦õF3X7–žÚÂ#>v#úQõy"ê£Ð§ »ÐØ&ä(HSËIª}™N­„aC05b?>$·‰»)éðU…SsCƒSÝriÚ´YF"ÕBÙ¾(â„òÖF£þYRYÔ3õ%ýè½ÚlÏs“ ¢ð®~e‘·à Ý;ø‰]ÇhdòêRYe°iuaŽt) ;›½‚ .Qjyõ,Óðå[wºY~×;7åî|V„”›>f¹Cf!$ªÛ·Y 1¸^•aoR?÷zÚP~­ÆyZ¼†Ÿ\™l‰X^V|Ž€*Y+Ö3“‚®ù4/4=`@°5>BZ«ÔQÕtñU0l{ II0…p`B„L^M‡×Ϊ¬¥ÆJà³ ÅÎ õ HgÃGžM¡õú”Õ\þ”«'Ü6KzË4«ùªœß’5Q÷\ć‰ÏLÏMo<ñ…MnPmþDú´ìù m>5|Ü}¯‹ÆÉT<«ÓÒC?ˆ m$À.²šCý¾_äCÔ,1åñ©Ž_Ú¹˜TY(î¡–l¨çZˆè½ÝêÎ#Ðûgж Rw®ÃKd;³\cJ"l}/ízôáæ+‡»NDøC1È%Ñ “ª(Ó¼ç;_¸8®©sóBÝÕ!¥|{oTèý:oxn7ßz‹®´ÆçÎÜy¾–UC@nŠþl³¯Hò Ç:îÛ™þ÷f9§³`½}ízõ˜œÉʳŠE\Ã2â£Lc9ãÙf'¦V1ð\õ]Ѳ´xݧuÕÌ`&YÊØ:+9‘>PâÆî…_ ¿¶û µ…^QŒ•åVáCopLááRÌ–z#GòàôUÅŠ¼tN‘C~2¿Æ'6 H7ò=Z}ˆŠ—i®î>õ¡ëÍ '<æfG¨†ÊÙ0’ÕœÌ'@–xé u¤å$¯¥'„:¨¡Hu<°ÚW 8̸Ì}&À©Ÿ®$m"Ú¾"üÝùLŒŠæ:ç‡ÂHt»DŽ•ºã°³NÝñ^k›^µ^:zâŒÚm= d›Áµ­«ƒ%÷ˆy7Ô^CTðØÖqë‹1qFìC%A]hUóÁ½ˆwöxᘂ*)Ÿï¾H¾ÊnºTò¸`ÜÉtÔLÒ›Îx}z¥åÃÙ·MïÙ›"û²$†Ð`ÛA®oÿ:/-%`Óö%mìפêvÝråP£á‹õç\h[ŸòcH=¾®6ð&£P·9Ѻ+3¡@m}ƒÁ¸éŠyfǹҴbAy[×Ùb™oñÉ·F´.ÏJø‹ˆFOÒ]µÔ™éºé<ËÐÔ)ûÊ‘ST³s;×G£¶Ûä *jn ¨¤š—©KкZDŠÌ‚uw duÞšÉ º|†€Mºo½±¨OöÕNCò¥Š» Éš^¥›ôŸwa˜­A¨¤/aÇ[ü1¡TÚTE}Ikñôβ˜}“È·lYÌÂæSŒ¤$qÕmÐ!ÇXÂØ¦–Ïß¶öèÐWI©.–m‘,îÒÚíµö92¶}á8Eß6›˜»øÔ˜a¿¥ºžóñy"Å4Tú¸g­ƒÈ´+¹•¢FôJ³îÅ‘¸%{·ú,‰+f\VjQ:åŸ m–‹ˆWt½ÿ"vè^Z€WA°éͪK­¨z¬e8¸yÃK ‘¨ÂÇKØ;¤@ ^à)ûG}Ï?c 󺪸‚¢7ù¼ðÏÚŠÏS3Ú®ý.78;óI¹‹·^D<(žtw¥Wa40Dš¤SÌfÉ ÜŽbÍî•yÚ½vNš›ðt½"í»H0däóŽ—ŒY­³†§u‘ÓÛV¹’¥Æ›:&¥—Œþã]¢GRT4fw§Ì‡ùmÖÁjœ0ÇÑg8vѵÕP¡qð·¬÷SŽ‹GeõOLy¦¢ƒ¥3*F±½wbÅ©û´è°'Ђ´ „âò û vcº/{©r™ª¿ÿÈs‹¤fíÒµºaçOoLîÌ6ÈìÂ)ui&\•Ñpmæ¸Qä!Jnî”¶}Ù_(‹Q©V“%4åHÑëÆ&ì!Ñ¡ƒ,´Â$®båH8®WâžqYŠGÐeÓÄ,K‰"WÿìÛ\0&¾Ÿ‹D’€þ¨•qNÞÜG¾å”Lk(YàŽ¦—›hgLÕavÛY¯Ð_¶2r©ÐŒáò2’%KªÙ/§¢G²2'¿R†xåÞ+´‘±!•u‘Ä0Ô3íeiè+µK:ÖrÖ˜ßrOË$9™=€ÅYŽ;÷ü×tGKiþô¤Ð<\Ðôj¤ñ‚Bý'‡>g™Ê­dŒ¾,iBpÆFËs“ç#ù/eHnd¨œ” ˆSÊYÀѵ:M0Ê'rE(Ãj(‡ÇãFüO~ØÚÀo¦ÞTkaù7'oŒà› ÔKžS«H¤ã ;@5ßkÊ{gISߎ˜{,™cHñH$ÊL¥r:»KÑÞ#h)8“|wLÖ«L}'A71ŸøÓ0ÜGP²1"{§Ï¸¾ Ø%ÖÑrwÅFØ£}ð­Þ?b×Ëa¥k”ÅA¾r4š£zi‚>35Ép!¢i\hM£ qèª4Ö>"ÝsÙN݆Èû~éçk÷ÜÙi÷ Å ªùÙŧÔÊ?Ñ#G“>bD4 …u@ø°’ÎU†Ý–&9ÕˆÆk ðáÒ¿p{é𢮠3œ{¹„~ÿ­|CƒXIdüÅ ŒS`„.ëòUÎü~·§²TáÙžœÌ| Æú[³*UêM8ŽøéŽÔ'Ë—†hboL”ÑÎ×{´²”ÓðEPÀ(¥‹W¡Å6Uç(»@=bz±Ž¸-…Sz?èBCòä¡#øCvšŽÇÓ¶Ï>ɽ€~£1ÍÔ«…“QsŒÀ †qÒÑÿÖõø!¦‘:n9ÀíØp}j7õ5.¦©cÍ{wëV¶•…è^\.…ДïÒ›£ÆÄD¡ËýgUz[-Íacïºò~ñ\/eʼŒâ"úè³ÓZžO% kºJ§Çñ¨àõ¢ldeËù¥| Ö¨ @Ž1,l?HŒ¯¦ý§9ýó“òÂpæÌÛîð?BÆ#¿\{Û_÷–­\2}종ÇÛóJ u¬ñb`EÔ¤JgĹ"XŽ|h1_UôúÆžÒ¯õE/µµÐçZí|ª1ëEéĬïëaÉm4ж!bR½ä©Z:8µ!ÔK&òL|ØÓ®Pù˜ S9þmûº†(gñF8RãÒs0n̹nõiÇz2›tǽ§P:¢?_Ÿ¼+á5SðҲΠqù«Õ1ô‡+%ÉOóeöÞÞ\Ëì°^¾ÿ»!ò]o€üî ÊÁ0)*÷3k4&ÊP¬…m ú¦;­ã–„ÜT…àŠ‘ î̘mߘ$V¬˜ªR«äô׋G,ÄûUÞDÀ¨/¼Üöô=ÎenÍâálnU“~ ¶*Â)gA¼ëûh'hkþ2ä>sm,¼¡v+OüÖ4­ðR—3ßÌLª(Û3ŠëpPyT÷$*Š òÇÊHOâR\f_V‡Ê9½ÅqÄŒuýIiÆ$$†0•/­•ÒžÓô Tðe·jV[H¶`ј ûâÛh‹²(¤éEØ»AaþƒÔóWøoAûуӉ'Ï>ºœ¼©0,ªE^Ì*E¢¿ÅÉ¡mxìÍ\ —Ü#Y¸/C<Œ§zy{›4,“ Ÿâ¦#¼1lòýÖU©XãhÙ‡¶fuí–ÿVµÔí瘇°‘Фƒ9Ju ºa >?fƒý|¥ ½0¶{M iëœ-‚Îù¦¾\=xþY“>÷z ôÀôuì‚ ÎœÉ²ÁE·­©ÅÎ×@ÖyóÑõu"€R)Žßâ°}vdãÎC%:ˆZ#‚ƒ5†QÅᣱ‘·t,®?<y³³Òûk’.‘UÞ@¹”=œŸsŒ "¾Ÿˆ,áqÞºª:R8éNsyÈéù8–G÷$KSù¾÷&óË !9!žÓÃÏ©´?‚Š"Ž.¦;xÈÓªo] ]18;‡Íù”é>1q2†`1ÞlL悎†ÁºÍÊÜÄ¥  ßfŽYÆ\Ù³ÕÛæ#üüðF5Qšnª/Î-—>¾°6EÏ*ä¥ËDÔb{ÏÒZèæH&àÚÑ0Âjì\BR¾òäpDz1œjóR¿tOé8I;yõ}oŽYT( îÙ^ U‚"Íý3œ‰ûtÊ•dJe¡™wû;ôLÆVÊ2TøŒ=Ü[®ñ¨aîGÏ’¼wçáÕ|Ê'K&FB>cøt…•dµÄ’Ú*¨Uć4ïÙàê 磅1˜Ýñ7á’1bPÔnþ`m_Ùì[iޝ3êÎÓ?Ÿ\X»½ô?4H¡~Ø›ÀGpŽŒÃYî´s޵»QgéiÑéîã#è³éc‹g0˜OßV£gS¬¹ž3 …L¬¿+ûy›ÞÝõtÛ#œùô†¤ãˆ Â2D—N„7¾'©Ü»fX‹†¬V«MNƒ1[ϱ°öçÛÚqTͰðè3\çî Øcó"Záêð¹°6iø€»Låù®v¯üXd"ŒšÙdþx—ÉŠ@=I‹…eR¼ ®(rÜ Ç¾¿Æxo žÀÎÞ½ïÛø¤Ì”‚â$\ôâþõ“…f­©½~»ôÛu*So’L‡DØ÷KÒãíÁ¼ÒhæQ²ø`02‘T¢ìîÔáMQ“²4¢¦>_I°¨šÈUÄ„2TátÇ‚C笔fqÀë…HýS^0¤ïiß––âÉLˤ¤"ZÚ?_‹bÚj™ð ¡øì)÷Çfº¬ ŽšNç™=©±²ó€ö÷Rµ^&·Ê»Ûêçc”Q^_8ŸJŽ¨ÄšW~·5‘€Ä°È@_•»ÒH¥ du'Õ•"iiÑ>ÜôËhì®d6k«ÚW>ëà˜·e%µvà ôW—¿.ÀÆbddaž¼Ü°üà´æ/š!+½„ŠWÔ¤“tß®Á$M BÙ4ÀláweÁa‹é#¦ýrl9•jÂÏëáÒw4Óá8Ê^â5þ¼P,tðSÞCûËÀîâ8×DÞA¬€–Î9ý»Á¶ºòÀ|™ð­Éxsó¥äñ9q¬Xt$)9gaÞiCšÏSתïe™;XO9•‹2©Èì3ý××<óYR»_}DîŸâ «‚T\ É©+Zøy-isi—\ÐÇ9ö'”&ù¤‘ Ý{Vá#¾ä—èâ˜X/[›èÛX€Q»j>|¹¬ô¡I¨?½¾'yÂ-©e,i±zKFäéK>-CR…”,'#§Yëß}ìûf-[ùŽƒn31õ{™Qþ•]ÊT¾.ê¥ol¦è)Š/!ÌëzZUZþQD‚‚î.õÎ÷c_$ì àh¢UņŸ">Üsû†á’ÞÓœÅ0Ù$É€F(Ô\i fÜZ·­´R¥ù8¾0bÁ/='ˆŠO@Œ ÏH§ ¯Åiu¯Ëâ9‡*—H›¿™nŸ;z>m¾õ÷Om†e+þùC-î¼Hò4Á(ùîÆ¾¯¸Ô«Ã²¬§ç[´•‘LªÓ9m£Î2O­‹•?İ}f× ì° ÑêdÖZF'u)çÄØ6 nU¦èEb]äæ§öY6•LnëJááè Zò|³l'T´ÊºxÕš‘7œ×"/ËÂ7ÑaÌ&‡Bba¢R/°²“ÿ°Œ,¤»Íü‘€Ç’¸ä]¹NΦÔ?vÁÂ5FxÔHî 2îßòdêPž<|–RÆR£ù*0œbr–R n“[öG~“ƒw'F”3U gѽìCšÀpgò­VˆîÑŠàg¶Ôó²ëåŽà¹[¥fWÚ´üðûöPd/œ0Î0Y™R±Z½…œÚ`¨WSþúÕ¥.“‚-Ìå\]ÜóŒ«ôÎüX¯+ðöTô íI@€óJaqŸ+Ï8´ˆœÕSæwon1‹<&º¹óƒ^&cR¾eÝ¿j㫆Äë^^oÌý ;:z?8'ÚÕBבÒY\¥{‘xW*. ¦(ç­[éôÁ4€"‚]—‘¢uNnin !ð,,ü$ðSÐh5®v-Ç£çðC|¹Š1#öΛÈ>‡bÄKÃbÏ„m!)óÅ•x`Y*í¥rRáa2«`Eãs"ÿªézÉIy,„«3EƒÏ¡·Cã+È‘yKÓ ˆL2­Oj}dBÞr öëoGÅ£\3,l[[å²{ù¶ú]ß°ˆ–jÌ%Lãüµˆµ4SyšÚ>îeêýè“£ï endstream endobj 16 0 obj << /Type /FontDescriptor /FontName /MNNYWR+CMR17 /Flags 4 /FontBBox [-33 -250 945 749] /Ascent 694 /CapHeight 683 /Descent -195 /ItalicAngle 0 /StemV 53 /XHeight 430 /CharSet (/L/P/V/a/c/e/g/i/k/m/n/t) /FontFile 15 0 R >> endobj 17 0 obj << /Length1 1717 /Length2 8975 /Length3 0 /Length 10073 /Filter /FlateDecode >> stream xÚvuTTo´6% Ò Ý0C‡tH‡€ !5 1ÌÐÝ!Ý 4HII‰€ÒÝ‚tƒ””ÔE}¿ï»f­3çÙûÙõî½ßu˜è4µ¹¤Ápsˆ†äqE²jÚª:: äãyq˜˜t H;È?¦ç'ýGÖ b†¼“É™!ï¨jp@ÙÙâ€EAB¢@ €ù‹wÈ™¹@Á5n€2Aà0ÉÂÜ VÖÈ»H½X-Ø !Îßæi{ˆÔ P3CZCìï"Z˜Ù´áPÒý?.XŸX#‘¢<<®®®Üfön¸“•'ÀŠ´<ƒ N.0àWÙu3{ÈßÅqã0t¬¡ˆ?TÚpK¤«™p'°ƒZ@`ˆ;#g⸋ÐVRh8@`Uÿ pþ<ˆô·»?­9‚Â~›YXÀíÌ`îP˜Àjh(¨r#Ýœ3øÑÌ¿³7s1ƒÚ™™ß~'oPÖ˜ÝÕøg… '¨Á€Úýª’ç—›»ƒ–‡eáööó+?9¨ÄâîäÝyþn±- î óü[Ba`Ë_¥€xtaPGgˆ’ÜŸ¬;Î?2+ …ï q@Ü,¬y~Ñqw€üV‚~‰ïêðöt€;,ïJxC-!w8ž3éä ñöü·â¿€¡H€9Ä ÃùÇûbù¾›'¨Àx7„ ð×ïï7ã»9ÃavîÿÐ7šGY[ÿ¹:ÇßEÿ­–‘»<¹x.^>>€ H ("ðþ¯£¿à¯òK5Í ¦÷/‡J0K8@ä*îŽï¯J\þÖ?·‡ ðßê𻱆XÿÙ# Ðâîú?ïÂo“ÿß üòòØ‚ÿ“‚³Ýoë_”ÿ‡afµsÿ“s7ØÎÈ»%Qƒß­ ìSõ ì¶ u¶ÿßZ%¤ÙݲHìîžK„›_ð1¡uƒ€5¡H ëßÃóW;î"ØAaM8úëpþjÊߺ» ´°½»dwMû­‚Ü-Ø£ÊÃ,àà_›È+ 0sr2sÇÞ¯€Àt·²`ˆÛï)ðpÃàÈ;À]…ÞK¸Î¯Ö žGóópL™ RÞF‡O@Ý «]îÐíìíãu)¢z7´£Ü–H÷³º7cH¼ÃµH)Ãá\¿Åea¶˜6$6¢Ï_‡o覛õ)‹g„§Qi3®Ž ;Ü ¤^,q{_Qó*Ð÷s‡H˰à×r“ÝÃZ}ôÀ}[Ç‹®²ÌÍ(åó{Ú–@.ö|ºZª¯a^ï×DÚññ{4Eq(†;Ã]˜}‘‚Ä~È(ËR»âôYè–ȺÇÁ†'ÉÍ%5¨ütfˆöWÖ•r«gÇd\½E^õâ,÷EkØ×|©o¾÷üG¦&þÅ;%ãm¸xÅGÝã±ñnnr&2mnð¸â‹*cjkk:?>ðf_ˆŽ¦´-ì¤ „‹hmÑÃê‘3ŸÀ~3½?…ƒX¼n<¥S‡ŸÅiõ±ïZÊ;ÌBOt²ûïêw¯Pxžv%‰°èüÔ2–UãÅ퉙™’¡‘‘)äÍ-Aôa³~ÀÇ´m¦ aSãÆ7>o¯yöâå³Í‚Û;¢3ãäËquÙ3—•æiCDagÀTG=€på¥óý¸¼ù[d IªÎŽ_’`Gà’´1"èÁ-8§X®B ×#kq©¦&ÈšìZh@ž—žæ¾ÉÏx=ÙTö.íà”0…ß(€;õ÷Ñ`z\U@@_ îÉÊ´…FÖh}iM䆯â¦iûï¯×Ùìß«·46SeJÖÝ”´ `„E"RÄyrQ,[ìû­_á;Œç§`WûÃW×¼×F‰p²ïÓR*kš9ìû‰§Ìæa“¡!˜ô91-·üvNµ‚ŽFNQ (àõm܇¶KÏ(²±{2/~¬VG¼W×z˜ÈCGXv}¼ V=ŒÞŒ´r5@7™Ñ”Öj4Æ•N“xÎgÙ²•Vþ%á\A(ªpÁL‰QRWÖ]<ôa{Æ‘A"¾ˆÅSUÞú—y…ä˜X§ †m£‡’#!4¬­ßZwfõ»ÈEnÎ?¿_JÕ˜kJ+t#OËdäz3ËφÝ7òâl‡ÛCšb‚-Í7öóÏi ý͘ M¢çºÑCÜ4.:†×÷K¢•4óXßDiZÑJÎ^-Ï[++ðïV¿Žáè·“¢uB˜¥.S/š1uéF3BssY»æÁy}&¢&“çø’HâIæâ@Ÿ‡lòõ‡ñ)¿@–›°!Ë^ŧÒo§¾—U@Þñ§ï^v­Tañdîê_“}ÚÓ=“Z\äðoú,lhÙyúª/æÒ°® XŒü7_ÖŲ‚ˆ˜Ì ®Lä’«¶eé]¤´ˆNÒÝ»M NçRYz•è€pSÑu¬CæZ¬g„Zî²eŠk®I ô#|.\㨀·Û •ًã•Û…¿üqßP{yÎG’å¼ÿ²pàÛ‰ÙÚN§C-ãuýZÌ\Ôia²TÚ.öìÖ̬èc úÄE9ñw¼m›æ"ºœÓòþtK5J1Ÿ¾¤™ÛŒTß<ÁÖ]à{D‡øðôµ—!páŠ#™'!^>³-¿T÷0—@Ÿ°È¯&/Ár>¼-3b‹a:[2RO0ƒoìeQTîžZ'„3°6E†ÏiL¦MO¾_BІ9$ÁÍ÷ží˜òæÒÃ})¯Æ}BÓ…^±:SŠz‰±4ðá¡}Ð\ïk£˜ÝëÖ»o…KWN¸¦ÊèôZ·eÊ.z)õáîÓŸÃú…$kÒÊ–Å&æx5>*çwá\_6É¿®k#9Á­Ó±s.+²±ôÝ.ÊVV½?¬½³õV”³·¨ßŠiñ]tÔ±bÕûãC½ÇÊŒdVI‚Æb6< La«CL`·#^/Ntš§»ílËHg%ÜŠ7tq?òs×z0šBE®i%í¸Ipîz>~”¥8Ñ–ô ÿw¿-j×g˜+ëÇÞ×>ðÃê6>G¼¢ ÿ@i ú—jNëi2Ê>7y3ÒÛW†Ö/MŒYÌKß¶%7*$þ˜§Œ]íâ%TÆzJ÷`Ö©xµT3ͼøïI€ØNVi{CÇ}~Úì™Üˆ‰yCBP™ÍY©&ì!Ǜ埣ÓZújHÜ”×è’qV”¼B|B8z|qh©@«µÞÂÝçGáà1qy“Ò4þðıAAƒ.Šå k”¤Žcµáµâ×]OqåêÈõÎæSÜßžÒ4½ÛdÓåZ@?nåI®7h#Tg£±«l§óèDüÞÇ›GaÆÌÜþ=7æ§…HêÆ\¼Îê@³`•o±¢%¤ Û»sTñ¨«"6þRš‘OŒ^™§³aÖ.„Œ$f&=o§0ÉvGCu¢QáK2 ø9¹uV’ÀlŒ¤o A¡²cǶ0­4î>ïG«Âݧ›«HKÉóWü"×TªHš°CñŠ8i…3H¬Èù…ga΃ð{BÑ…þ¾*žC.«Ã W@‹O³oìëàf¡ÃE¾Žû€÷õnAŸVåB}PÜ6ˆß,a ˜awÏ˧9B¼çQÒä] ’#G y‰m‹ö˜½.LãŸfP«¿9±h|¿!Õ¢m1£¾QʼÜÚô\kûpE™Š5ÊFEôFË\žS ƒ;„ÏË!““ER§ìgHM_ÿÎ-eOä4ºç¼.õÉ;'•OÝnëÜ$·ë„=Â}‰Cü) w•{‰öž¥ùgf 3¹“¸F Õj¾"jL£L'Wýà1ú¯Oô÷ye’ÖîÖ¢´†›(œÐíWà‡«ýø8Ð5 C¨Ùyµj[²7Øÿ5³ÒÊܪÒÂkÏ]¦1ޝ8[YèÂñ7 H¨ð¸ëZ.<3÷ž‘ t äɪÐ[ÔyZºä)&4<Ø6!|¬´¼%;¹"x.ºky;}Óþ²í(AÕú\_¿þ^¶‡g?dõrçMa¹6FFÿàÀ^äs«ÛC‰û*aˆ|nÆu&À=áëÎÕËÖØ58¹„aêì0d«û°zP5:|î<—¶~ü2]ŸPÉ’TÙø¹ôŽÑ¦ UâEC1á©õÐ!ž8êåÛ[[Š{’¾‚5³Ó JCSóþÚ=ŒcIôLë´Éš‡‰e”©×G¨ÓRoìðÁ­–}y)‡Å¼ÝÏ[½¿k¸OGi‹ú:­Y/J*Þ‡r=Ç  ‹Få»$µYI1»Æxa··öæ-@Æ”æõsg…iËÉwÉ<áàßÞª%ÎÓv«^>Y¾Ï²]›ÉRI&½iŸUœ¨ >«›_„íPDAï79 Ì׿‰?f®‡8w†ÎmVÔ ñe,´”NF¼ø^‡ºÏÇ¡º×ÙBSOµhm˜?@r¿ƒWp¾á[â êä!Ú ‹‹Hî¥\F¼à¥Ã±åB×ÔE6~Lç¸Ù@®+rÃg&7uB$n“ÙÇÕ†âŽ/³—!˜ ‰É¹2%_7±1®øõhn½¿7͉׌»7a1èð]F{Ÿèܼ~<þÞîfP¶xS6ø#½ÀàRÞ·€)}|Þ™/>ÍÃ72_óLϦ·F>ë|ýP6Âù…~g…vvç ëb‰|‘%ÞÔ‚X…õBÒ ÈV~tóâšÏ³èä)ÔF­ÝÃ=¸Ð”ýqóW´¨Iü1küBºÿ³Ç›)J”u‚•מFìú‡"ŽÇ¡š]$®Û ŽÒSÔF™Óî$ö·ì“ôƹ;íÏydîq@>HP ˜y°«ÈÕ3J`“ £¼'wº­©ÉµtœÐØ "‘5ºç.¨AŒhß]œéõ4r<Œw’å2¨rÉÞÄ?Là T;EsQ‰:·—<–¶sN+Yˆ/¥©ªrrdUÓjEéÞ¬Šg‹b,#G§î‡²s)E«¿(‰O³Å(ó3ÅXc˜79úÒÑx[ÁNF51˜Ê%7=²0¦ñ´_‰ÔÁ@êÉo¯üsÌ·°Ç|WËœï[êöÔs•1F§éJv¶)`•#£òk“ç¨$[ÕÒ-;” ̹˜Ã†ä„osˆxì9ì E³–#õcAK {ü/ïá|¹ Á!W8Ù´¤Ç·U”K'ÎCbå·”—üô*~ "¥hleéeŸ¶f7=Âd•+¶(ŽôÈá,˜§ätq¹ *^}Jï$gÄ\C2‡6•žK>ÃF†Né”B ¤_ê#õç­Á·í÷"ÛK2g99Å^»ŠBÜÌ‚l´¥´ìŽ›éé±·iS‡ÝyŸ–ìÏ¿îëõz&Y¹ •¦uz¬ =…+ù+T ¾dŠçÆåŸÁ™ì~þm=ü¡®N’,ëx œ”L±z­r«Ýã[—p6(9<-…&Tµü¦È.FÈÉÙ¬ÈTÿú=‚†+î-Gù§¶ùýכּǫ–v}á ÑOŒ¸¾Çubðì/W |YyÊ! T1]«ß±Î'7g™ÓÄõÑ\ûbµßâ–hç¤ÙÖ‰ u>Q‹Å¡?wÅ-®À¤ãÓï0Š×çñomOZŸ-ñVxíý³k.f^ˆ  ð²'Üå³ÿ²ª©£nöÝ×ei Öú€x•ëªßÂ;®¶GdáX­HS¡Z7a¶kæ]AüÐÇ`RÉFz“RjzW’EiNôÓ ¥ª³ÏW©€4¶#èÔX V)çOƒµÔdpá­×–k’Ì÷ ’Î/ÄTŸú–ƒ4iMö?°±g:²½ßˆg™á›©RWR©%ny˜)¯’çhªÀm}0QæFHØÅÏ’ûÀ$ÈË”¬ÿØ i€O ™ïktÂHjèV÷JCä¦Fa4bs( f»Òº1é&‹ÜÒr2y3@f7ñ¬Ì‰úÖиW ÓR¾žî6`1šp`Â^ZfµdaòÒªiiºÍ÷]÷Æòb¾´g?» `!Ý +ûÊñ­xà OPûzöˆµMÿÓÑÅ9 °V¡VÚ×x Òåå˜y}Î?ÐÎòéÖfÅ`®‹úÀëy×$U4V.°Ö)/gVÌøJ(Jf+'…Qb·F¾†·­ÿ#P"K².ŦÐÃrÎcèú*aùæ'©%C4‚ z!qé«ékkýkôæv»däÆahº»øZó—1Ö]—U‘ø ìÈWUE*‚W ÊÌÏJGãæ§x&GÑÜK¢%~t×8XG–Øo‰îã|‘öèÉÿxÿê¡ÄÄüƒcíUáøp´}¾­xþr+ó*O´˜RíÉCNiÄçáŸÏïã]Ëž•Í ££«_|•[í6Óýr¦0G¥>ûîÊaÛ^ð]bÆ€îÏ}ãïáÝ Í‘±ü;¢öÃbŒÑ>ΨͫxoáÃÕƒ;­ R±¢gRÐæ§<ºÎU‚»VŸ‚†õ”´B¡7¦%ÌÎÞåMF7J]&î*Iæœ~i}þeó÷­¡ú4(ì‘Ý¢“ ¦Ø9lu ©6ñ™r®ŒA7JL§×˜l¸.ô]]Ó5ë2Âz‘Tø~è€Á¬Ga;ØE@ñòWß¾‡}ˈe¢}µ„÷G¿êR¯OAŽ\§ L»Ù´Ûx,äN´L•¼ûÌMÀê_nö9Ÿ8„Ð8§Þo#È´‰ÜÛôäžA—•@õ±r)[¯¾,*ƒ–·Yïˆ?æ¯+†Ú«ÂñlýÞ »0<Äriñi)Bñ[©¹zÜ*¥!RUy¸s©0UkÌR[7Q6Åï}ãLDU#UþÝ{ݶc¾ˆÕ÷¹¤±˜‰ªG¹­äÑ~¶vlDéT}7#ßfë4<±UL00 sÓö¨ ½*jQÇZJ°O?o,VË@è艉“Œ¼¯«íIA»VÏΔ®yŸ™UjJÈ‹ýB|Ó™èç£.‡6>1q"hEïÜExuö1Žd·‹^>Ã*ˆRVn%8\®xÅØûœCHAq¬7ä9tœ™F´ƒÚµÓõt…ßKß­›×zç}!¸íM”Éø-Ì%©\%.øþ©d=ŽAÉýdÏB«1~ cy\ ):ÒÊtz€Ü›&J¿qéžS›{DÄÚh/s[Éž¿ÊúrÈ!™ø–ˆ³\Nó¦ÆÊýnk?-ô$‡á€í“8þdë×µÂÃ{ ‡¹áD_ý,B0e°¸Ý–ÉjÓ£:1TÛu C™·O¼ÐÔæš>ž ;w!쎿#ç5*ÆçëØoÿän÷EÍQ§ùA8þ ]R AõêtMkЦŒc›èºªßîò„‘J wCµ±•ã³õž¶dü¯ß{žWÛöæzXêÈÚ°öÁÙ~+Ïœ2¼Í¨nÔÐZú¬ÄÔ™%Ø9‘ÕÌð…­˜!óZ“üÓ%¿¤ü·môHéø#þ¬XCH]zÛrRn Ãkå©+†vOä ®Ü¡×T¨É£>ºzyGÈÄKæ¡ðH&¬«½džã¶yÂÁW~MAÍè%C€~ÏJa·Ïçô'‚Í‹ì:# aßÙå[ÔšÖ?åü^%>(Ú\¦bŸyu½Ö? 0Í»ñˆÆÿÙz_¸rLQtdl¤ÑÃ!¯’ÓåW‰`ɺ¸Ì{ÖôhJŠåúK ‹—Å‹õÓ kãõ«o'âÐPHe2¤I{çl6âmÛiE¼"R8Ö4Ï%é^µ×ä:8‰x$0º®[ºœ‹¦ÛYaÎŰ1Z¬º —ÛÊéÊ] Žv<þ”x»’Fºtë°t²*©Î bögÍOµdÂïÎîÅ/mÜeQÂD) lάýb¶t9e`‹VgåzÝò)·…ÙÙÅÏmžïL ~AE»*%¢ˆˆÝ(«ÕëzU`d Ù2˜¬$ þ˜¢‘ë”n­|4dhÙ¼$u²hኒü°sɳÈ=#²iMXÃØ§?«ôÉ¥°f××T­„ÜÔÚÜû½Y=‹AØ:ée¼‚ÌÔÓâ >׿: ÁN¿ðꉕ4qÇ ¼_a‹},.:šùÖ²öŠBÙþDåX¦Ç—µ˜ÂTw'Ó0Ð÷¯Ñ'Ñ$܆D®¬m¥å{â©øâ,õqß>Uœ'_Ò©­5$HYÝ|ž½à`j›ªW(Ïcåg‰[ šµÆD·pŠÞÓû¨Ö"Ù ­Ï ʉájÓ’0r+Â'W¾Ø[Üqbø®<•,&­Hn0íqÛIH4¥¥˜̱0p¥ª|rИŒ.ÞAêúVS¶“{e ³¶Ã þRË©¾ó”Îù»xÿSíWª!õ­xŸ–˜c'û®#ñÂYð€M™ÛDAQû=3w.嶺:éÒ—w%h_ŸÚ‰” ‡ìªD2OäkŠ}Å+¾ÿƽ•)éÇ÷ôÍY†•Ù°„…|Ú2½B1?#Ýœ]cd©!ãc{oÝÌ2='·@ø·žŸÜèq1©¦mÚÝiõ(¾¤…ýMEM½7ð<g í£Ãzï1ýºÏ=ÞæKmKõî8׋DèQoo©QïºÆ¢fœà Ž o¬­X”ÒÛÑ3¾¼bN¬›Ê"K^ÚÖrêB{Û¾}>kyæpØô®kR"ǸWcësdÎÎ÷SŽJ‹ò5"¸jß?Ý ç:4é»wNJ¾Q”!xÑê}à]”!êì X$Žâ%RZß´?ܽ@zãÇÖ×….í€æLñë|—®ìyÆ}\Î.Bž™p\ &UÜ @¶_Þg‘¼XÄJ\q†b¸«¿&Bc!­K¨Ä‘¿PÔÛŒR‰¾‡½Ð$ÃO:ü\ºô‘’zÏ©KìS ‰2G‹žÕÆ}¶zÏdùm™#à_7¦Ç : ËH_~º•.b_ •)Ñx+âKvîCg9f†Ú“}¨ùp«X“¼œÄ[äé{‹ížM­ ýâÙáfñ¸£wJFÝõèdóD½‚)ƒ<¹Lœ™{·.R·o2âÃÙïÍ©ŒNZ®=¼x¶ƒG¸7¢ØÊñLu€ŒÖdž1e(×Ñžó26ÁNÎQ˜_£däZ<{èï:Kjaa÷d"%ùÇT{°ÜÞ”lÿžQ"ç¼T/ûÆW1mÁÓÄcgÈ>WÑh°DáYxõY=ý!Ë+_~Ò1\Ü9LŽxb — BÛ%KÕ—×’S%Í¡§,›”È–Ó¸¼¤ýøµîsH+å°œ‹]ÛD<¯uì[—ˆy®p(’ëatðÃK)š4CX †t<¡ÜJüX{bFÈî~ã $1nó%*‘Í\Ì•àh—Mg)¶¨–p ™J›Ê·#OjºzXñlöxr†CY ߤÉç©|8½øØsãˆhæ¡R­b”e¯ “ˆ2lòÞÖdl”J:i˜RO¦­¯—yL*Åî-*Vm[ èçL•$ST£h[0Þ )ííáp¶a¯Ž‰ñàwOS5Õ¬o1•׈v=9*]m³\ŸÇp¦%Œ¿?Rú‘Ý] b~¹Mÿnh¹ÆNXó]gµÅ¶Cù}5¸ägõ\·O¾ÆÌüá™Ëü{¬XÀx ‰æíWí˜é™‰ú§é-[}Q~^m„áì7T“A(猔m|µ uÕø$br)ÖOY)Q¾Ÿâæúóì-b?Š™]ô¢ -ͦ’¡‹“ÓÒª«Ž=KV©>ÅÒØëÇUÀ—_Œ m÷z~á+ggC©-=™Ö €Ë§n?cúA?k|ܸQ‰Ìõ TaýæQwTòÓÅJƒbôµå£VlI(˜PîñsLŠ cå¯.R°è9jÄ«éÇ ÊI%tµé?>¨ §cÏZØ–„Ñ>—tMö3!¾;']˜çM¬:Ærþý1L­íA–¬ò*pëKåÛäØÏ›öm1'&MKß(®üSé?ßhbNv ©fD…m¬¤l<Á¥Î²tu¾Õ1%àÌa²„(d}ˆ%h*„ªŒ¹ÓÆzA¸Àé‹ìؘ3iµ>8žŠÛã¯Á`ËÁ)¿¼×†?õ†r®2Ã*ûlN§QMŸL°Tø¯…ÓøFù%·ÂàÁÅ·ž±ðÊNb÷D·ÙÓÿ±¶Dñ œ‡¥a˜qUš:ãÉ m &”®d=úvx*ån/Wöö³ÅøÚ}¢¤\Å®­Úm¬3©îZhéøŽW ÓïÓ²ÓíŒà1H×ùå^v¼•+ÅšŠ[ž½WCP,/)#­dJõI³ÔvÒ¿®sÈl+r-Q”ey0ÑØˆ.8‡iª.Ä|¯^‘¹Ì³d…¸%¡bž/Þ&ýúiƒ("k{È?ÓPñn"µêOýÏ•>lЇåÂmÄ®Þ}ʤúrö}ù‘Ô(u¾‰Y©hk äç^ƒ† ³MG  Õ?xT(B³„j\\¶lfŽS¬§+Ev=YÖÒ¹¬{¨”ëGõÝ5n›å{à4Cú^ΗÐ+cë'e•[·—#¾'FFë]8FŸïgòt­òS߯e||‹à(Í¢M¼ÑÄëHoœëJ¶}màøž~-嘞´p ÀS2u,]K]´¿¿q‰ÈÜ}’u~jÛ`O D"F§Ž%Ø|G©»—©žbKŒ—¬Vÿùu L;eT® W¯»!þ›ÿqùŒP`ÿ©}‘úȧ³ "µùèï¢Ó|q;*±G†“?m+¿@ŠzL"l™üß÷3îònÐxÇ%àúGA¬rÖ­Ô-r™v3D¢­ÿ}?›œ endstream endobj 18 0 obj << /Type /FontDescriptor /FontName /JSXVZN+CMSLTT10 /Flags 4 /FontBBox [-20 -233 617 696] /Ascent 611 /CapHeight 611 /Descent -222 /ItalicAngle -9 /StemV 69 /XHeight 431 /CharSet (/G/U/a/b/d/e/greater/h/i/l/m/p/parenleft/parenright/period/r/s/t/u/y) /FontFile 17 0 R >> endobj 19 0 obj << /Length1 1524 /Length2 2502 /Length3 0 /Length 3468 /Filter /FlateDecode >> stream xÚTTSiÓв€XÖõ¢„Iˆ „"5ôb©!¹!WÂMHB—&Ьb¡IYÄ¢RtAi²0 "E0«R\¿KQ×ýþsþÿäœ$3óÌÌû¼óÌ‹–±wP5¤2}@"æªâÔ°ÀØÆÑ§`±x5,V…F;B\øÕBÙˆ þ0fƒd.â3!s  ,à4 ¸},PÇbµ¿™l`B‚¨€`É„A mÌd…²!_:éóõ/ @QpÚÚûT–ÓC QÈ0`CæÒA¤#…̘ä†þPBA—Îå²Lpp°ÙŸ£Ædûê+ªÁ—@È©ÀeÀ–ì®RSC¡G:ÄY 80iÜ`2¢€0I „© @ºÖ€ „WÀÖ+`õrœî[¹Õì¥B¼œL¦P˜þ,2 Á¾ b€€ÑZÂUÈ0u Hfp˜H>9ˆ 1È>`ùèd€hx # Wùq(lˆÅå¨q ÆGÌRäšMaª1Óß„¹ÔÒùL 6HAî=³:\?˜ ‡µhL¥-Ñ ²0N0Z˜¬bê»ÏäX,V À ¡Ð1K CYàr·äF8D†³˜,€†Ð#!ˆü Â9ä à²ÁÈð~´P8@…(\Àô…`Ô÷ꈤ­ØÈüÙPàŽE䇰KŸoÿ! £2aFèwøòˆ1fÎDCIy•ò· ‘3WÅªêø½€†ú^@S[ˆü±Ê7þ_¹/{íÉÐêÙ°ßëYÀ4& ½B¹»¯4‚Vu¡°º4ŠÀl™ˆšA@á»ø=°X ò…û¯ÀrÊÿ¦ü¥*ÿ§øÿ}"b ƒ±WXüWœì1BWˆš¹ÈfØ0‘ý€ÿ uWÖÙ¤BþÿŽZpÉȆ¾Œo qˆPHµ‡¸ú²b¾Ž©Î€`ОɖÞ@‡Åþ+†¬ÅyS8Ȱ–C ²Q?v4…)LêÒê©khd6›ŠÂ"úR×ÐÂqÈŽRÁei5˜ÉER„]$@c²QK#ÕÞ`ÈK®K Àø|³pX ýÃD¢Œ˜ÚÆÿ›¹ `XÈ3@÷»·ê]ÑÁ·\Ü^Ãþnª#°Ðeór”@6’Ê]ÖÂü«½üÈ€`HA=ëfRtâ—ÄU}*6”ViUß+Ò0{‚¿Þ™gº#èõcݹ÷ø¼Ä^ÃÚ?Gç7¿U¿ò¥ÌÏeÖÏóeÄùD¶gwªÖÑ|^©D´oÖ›˱Tµª©qóÆÃTßmÓ夯`¾A§âv•€™‘®¬7fºrå7?Þ O Ë—N¨ml=™(,©¥…ß$Wm˜U}Óè–açŸ÷-d9³­“çvß̯oV×nx~UE:/=>.²âgë§=Д²òn:Ѽ¦’ §bøUqÑ >œ'ö§ó÷JÑgËÞæÚ펋f—O–ðÌÛ®]Wõt?ß‘4±/NÉ×ý̈šèsk£õ7ï ³ÕKן¶W¨ÒuU5=Þ~ÄÈ÷fˇüý{\9-Â]jfäiíîqjWPÄGâ¢%4ü&I]”]Ç¡¼³3ü©ÜâuǚÄ2ȶ4»]úªIô=²a³Íî©mº¸ðBáiÈð:×t,mzW’ËÇÜÜþK7¥â‰ß]îxtÎÕ?"IlýyBŽš’Ý`ÂÞ­”n¬÷›—î‰"ÒÜÍß?4JI? [þ~@iù¾SÄìªDBmFvðÞ3}3]‘×øìf¯òxÏëèò"aý)|¡ÛÜڦı ð©ލèÕÖ”áרmz.u«Ârœ/vÿø´Œµxé|öpq¦K‘ô±6ɾ ÇRéan‡ó%r| aKn] Ö®Ùiœ¿öÚ£ S?h ‰ šØ[¤ïYQ>”äYvÙ ÓÞº­'úד~þѼL²ë>Ð>a§¢J±ÉÚ™aŒ…³¡p°eKåšÇQ.G,Ðg‡³{ѧ¿h޽zp¢ÝËéO¯53»m57: ßZ;Ms›Žuæyåu”ÀJ­“3‘ª¿R×aSÅŠ›_ê;Yê¶n=Ï÷é3ðÝ.S²XQHvˆ~€»%¶ïh±òÐ"XyÜEgôbÜàÆ6#U©Ü®òõ) Ê¡Vວcä›ý.« £Ì,$å6)kêøY›©½ì)¯Vfl÷7Ùoë‹ÍQþÒcs¡ìz¾¯EãD|v}AûX/…:âY’1•iWÐo`~ˆm+«IÛê…‚Iï‹~ªþ©#Eˆì¬5Z]Ü«¯®ã:ŠÜ<"ZÕáWÏ ¸1ø¨Ú¶õ‹AwEyFäp†KÆîQØþJË/FO;Y®’gæRõ ¼£Â§.8 `1'|,Õ§"„¤**¸K¨×¼¸®T%³?:ð×uíÂ®×ør6 ˜è¿„õ­ëÔ‰þýi›ó¢ÜYºÊ/‡ð• ùsï~ý$ÉLôm|Úö[K{ÃöƒáŒ®ŸB³¶×'\¡Viã½~‹My2÷j‡¾P³”yãÜØt×À‚ãÕˆÜ Ò¶/ †Ó‡Ç$óÅvV^˜îò{7ÇÆ™F³ütM²#0×^èy»™ )H_õyb<÷FT"^mP¤t>¡«-ínÚÛ¶ÝŽâ;h­[™_ÝÝx0Ù§pCÕÝFºÐ}Ö…ú·ø&§Bì„‹¸t®Ó¬7¡9úð“{qn‹¡Žï>µdËŦîíµBÃ×)š~¢l:pF_õc¶õI: ôáÁøä)Ã…éêC#[ ó× IÂÞé§Eî\² ÒЋ ›µ/¶j^ ý³oÂUÁ½Ç3ÏÓZ¬ã]üî­îw5Âãcªçµ:\.¸—¶&Ïä?7Þ>gZ1Uc&ø2ÁRä*ãY`×½»RO CïRŸó¼lª^ˆkÇÇÒv8;LœŒ0²'Ð#tÝQGÒJ‹Š²INî-ïIOb³ôÉS–¦ã…ϯ3SÈ–0O¦²lo8]+\_WÀ«‘éÛW¢Â'FÄ aÓ ­g2Dm„´þÍh¿™ß<Ï”¶øX4ŸónÑ¿²¥ðм´•ÕíÇ›òyn&‰™km¨»Ä:^ ÎÆË›_Ь‘É$ø~,òÅÏ´ˆYPln3B&þ¾^¨É3ùÞ×ïý@ܘo Xx·‹F)mŠhÞ•—c(4(ªÀAvíÚW»p/ä=²Óóh×Ú_Ó¹Ù*~HÉ+Pýhêž“|Ú¢¿ë:ÐöÔM,"›«Å5Rº«%™²Ø{#ì…°ëcÏÍ÷CzÿgsÅÑ«Òå.‹™ƒ­›«—œøÐ&ôüäód/’x\ÌçÓ…ÁÛšO:û”xÌ'é&•þ1iv4ävÁå0ûÚ–Í4q½Þë·Ó²¸7÷hxèÔèÁd ½Py@ÐôÝî÷Æ×u‚ûò?0çw(ÕâÞÃ$´u£6ç’†QIÊÄ…~»©jÏ:Ñ&„Ëùñ—Cr½¦º4DÊ,òö¸Š–:(Ÿ&p–gÞº)8h$ÙV6ÉùnÑçOn0h§T£?.D©¸FŠŽ“Šï ZVxl|K•(‰hþ™‘…§õûñ5‹cB\ êÑØXé>ž‹\¸GŒ^Âö¤ Á²XãÌÚ¢ôõÿIã endstream endobj 20 0 obj << /Type /FontDescriptor /FontName /GWFARR+CMTT12 /Flags 4 /FontBBox [-1 -234 524 695] /Ascent 611 /CapHeight 611 /Descent -222 /ItalicAngle 0 /StemV 65 /XHeight 431 /CharSet (/a/b/i/l/m/parenleft/parenright/r/y) /FontFile 19 0 R >> endobj 5 0 obj << /Type /Font /Subtype /Type1 /BaseFont /LZRSWW+CMR12 /FontDescriptor 14 0 R /FirstChar 11 /LastChar 122 /Widths 11 0 R >> endobj 4 0 obj << /Type /Font /Subtype /Type1 /BaseFont /MNNYWR+CMR17 /FontDescriptor 16 0 R /FirstChar 76 /LastChar 116 /Widths 12 0 R >> endobj 7 0 obj << /Type /Font /Subtype /Type1 /BaseFont /JSXVZN+CMSLTT10 /FontDescriptor 18 0 R /FirstChar 40 /LastChar 121 /Widths 9 0 R >> endobj 6 0 obj << /Type /Font /Subtype /Type1 /BaseFont /GWFARR+CMTT12 /FontDescriptor 20 0 R /FirstChar 40 /LastChar 121 /Widths 10 0 R >> endobj 8 0 obj << /Type /Pages /Count 1 /Kids [2 0 R] >> endobj 21 0 obj << /Type /Catalog /Pages 8 0 R >> endobj 22 0 obj << /Producer (pdfTeX-1.40.10) /Creator (TeX) /CreationDate (D:20130729210748-07'00') /ModDate (D:20130729210748-07'00') /Trapped /False /PTEX.Fullbanner (This is pdfTeX, Version 3.1415926-1.40.10-2.2 (TeX Live 2009/Debian) kpathsea version 5.0.0) >> endobj xref 0 23 0000000000 65535 f 0000001730 00000 n 0000001626 00000 n 0000000015 00000 n 0000044187 00000 n 0000044048 00000 n 0000044467 00000 n 0000044326 00000 n 0000044607 00000 n 0000001831 00000 n 0000002176 00000 n 0000002686 00000 n 0000003297 00000 n 0000003557 00000 n 0000019859 00000 n 0000020234 00000 n 0000029496 00000 n 0000029734 00000 n 0000039926 00000 n 0000040212 00000 n 0000043799 00000 n 0000044664 00000 n 0000044714 00000 n trailer << /Size 23 /Root 21 0 R /Info 22 0 R /ID [<054532D041EFE539F9E5D2903DDDC0B7> <054532D041EFE539F9E5D2903DDDC0B7>] >> startxref 44980 %%EOF limma/inst/doc/limma.R0000644007451300017500000000005512175636024014762 0ustar charlescharles### R code from vignette source 'limma.Rnw' limma/inst/doc/changelog.txt0000755007451300017500000031353012175540776016250 0ustar charlescharles29 July 2013: limma 3.16.7 - duplicateCorrelation() now uses the weights matrix when block is set. Previously the weights were ignored when block was used. - edits to normalizeBetweenArrays help page (i) to further clarify which normalization methods are available for single-channel data and which are available for two-color data and (ii) to give a cross citation to the neqc() function for Illumina BeadChips. 14 July 2013: limma 3.16.6 - bug fix to eBayes(robust=TRUE) when some of the df.prior values are infinite. - voom() now outputs lib.size as a column of targets instead of as a separate component. - cbind for EList and EListRaw objects now recognizes a design matrix if it is present. - plotMDS() now checks explicitly that there are at least 3 samples to plot. - The legend argument to plotMA() can now take a character value giving the position to place the legend. - New merge methods for EList and EListRaw objects. - Fix minor typo in roast.Rd. 27 May 2013: limma 3.16.5 - normexp.fit.detection.p() now tolerates some non-monotonicity in the detection p-pvalues as a function of expression. - A number of help pages have been updated, including a new reference for lmscFit. 17 May 2013: limma 3.16.4 - Update references on help page for voom(). 1 May 2013: limma 3.16.3 - Bug fix to ebayes(), which was not passing the 'robust' argument correctly on to squeezeVar(). 25 April 2013: limma 3.16.2 - bug fix and update to fitFDistRobustly(). 7 April 2013: limma 3.16.1 - topTable() and treat() now give more informative error messages when the argument fit is not a valid MArrayLM object. 4 April 2013: limma 3.16.0 (Bioconductor 2.12 Release Branch) 31 March 2013: limma 3.15.21 - minor change to fitFDistRobustly(), to ensure that df.prior for the largest statistic is not greater than the non-robust df.prior. - edit acknowledgements in User's Guide. 30 March 2013: limma 3.15.20 - final edits to NEWS.Rd and other help pages before BioC 2.12 release. 29 March 2013: limma 3.15.19 - revise RNA-seq case study in User's Guide. - bug fix to lmscFit() when the residual df = 1. - update NEWS.Rd for Bioc release 2.12. - add Phipson (2013) reference to genas.Rd and predFCm.Rd. - add Law (2013) reference to voom.Rd and vooma.Rd. 16 March 2013: limma 3.15.18 - normalizeWithinArrays() with method="robustspline" now longer requires the layout argument to be set. 16 March 2013: limma 3.15.17 - bug fix to vennDiagram(), which was not restoring the graphics par() settings correctly on exit. 16 March 2013: limma 3.15.16 - bug fix to read.maimages(). Previously was not setting default annotation columns for source="agilent.mean". 10 March 2013: limma 3.15.15 - new function voomaByGroup(), similar to vooma() but with different variances for different groups. - vennDiagram() can now plot up to five sets (previously limited to three). - mroast() now outputs number of genes in each set. - new option method="mean" for propTrueNULL(). - bug fix for fitFDistRobustly with trend=FALSE and robust=TRUE. 4 Feb 2013: limma 3.15.14 - To make the interfaces more consistent, all functions that perform gene sets now use the argument 'index' to specify which genes are included in the test set. Previously this argument was called 'iset' for roast() and romer() and 'indices' for camera(). - section on time course experiments with many time points added to User's Guide. 24 Jan 2013: limma 3.15.13 - documentation added for fitGammaIntercept(). - bug fix to readTargets() to avoid warning message when targets$Label is used to set row names but targets$Label contains duplicated entries. 16 Jan 2013: limma 3.15.12 - bug fix to read.maimages(), which was not accepting source="agilent.mean". 8 Jan 2013: limma 3.15.11 - New function predFCm() to compute predictive (shrunk) log fold changes. - updating help pages for genas(). 8 Jan 2013: limma 3.15.10 - mroast() now an S3 generic function, with methods for EList and MAList objects. - mroast() has a new argument 'weights' for observational weights, to bring it into line with roast(). 4 Jan 2013: limma 3.15.9 - mroast() now produces a data.frame instead of a list of matrices. It also has a new argument 'sort' to indicate whether and how the output results should be sorted by p-value. - roast.Rd now cross-links to the camera help page instead of to geneSetTest. 4 Jan 2013: limma 3.15.8 - camera() now produces a data.frame instead of a matrix, and with different columns than previously. Instead of separate up and down p-value columns there is now a column indicating direction of change. A new column gives the FDR adjusted p-value. - camera() has a new argument 'sort' to indicate whether output results should be sorted by p-value. 4 Jan 2013: limma 3.15.7 - camera() is now an S3 generic function, with methods for EList and MAList objects. - Order of arguments changed for camera(). First argument is now y. 4 Jan 2013: limma 3.15.6 - roast() is now an S3 generic function, with methods for EList and MAList objects. - Order of arguments changed for roast() and mroast(). First argument is now y. 29 Nov 2012: limma 3.15.5 - New robust method for estimating the empirical Bayes prior, called by specifying robust=TRUE in the call to eBayes(). When this is TRUE the output df.prior is now a vector instead of a scalar. - New function fitFDistRobustly() estimates the parameters of a scaled F-distribution robustly using Winsorized values. Outlier observations receive smaller values for df.prior than non-outliers. This permits robust methods for squeezeVar(), ebayes() and eBayes(), all of which now have a new argument wins.tail.p to specify the tail proportions for Winsorizing. - fitFDist() now permits infinite values for covariate. It also gracefully handles cases where the covariate takes only a small number of distinct values. Similarly for eBayes() and squeezeVar() that call fitFDist(). - new function vooma() for computing precision weights based on a mean-variance trend. This is similar to voom() but for microarray data instead of RNA-Seq. - genas() now has the ability to automatically select which probes are used for the correlation analysis. A new argument controls the method used for this selection. - genas() now optionally draws a plot in which ellipses are used to represent the technical and biological components of correlation. - new function fitGammaIntercept() for estimating the intercept of a gamma glm with an offset. (No .Rd file at present.) - new function propTrueNull() for estimating the proportion of true null hypotheses from a vector of p-values. - new function zscoreHyper() for computing z-score equivalents of deviates from a hypergeometric distribution. - The layout argument for normalizeRobustSpline() now defaults to a single print-tip group. - Additional motivating comments added to normalizeRobustSpline.Rd. 13 Oct 2012: limma 3.15.4 - new function qqf() for qq-plots relative to an F-distribution. - minor help page improvements for squeezeVar(), fitFDist() and trigammaInverse(). 13 Oct 2012: limma 3.15.3 - Rewrite details section of read.maimages.Rd for extra clarity and to fix a typo concerning the meaning of source="agilent". - Bug fix for contrasts.fit() when the covariance matrix of the coefficients (cov.coefficients) is not found in the fitted model object. This situation doesn't arise using any of the standard limma analysis pipelines. 8 Oct 2012: limma 3.15.2 - Due to changes in R-devel, loessFit() no longer makes direct calls to foreign language code in the stats package, and instead calls R functions. This makes loessFit() about 25-30% slower when weights are used. 4 Oct 2012: limma 3.15.1 - fitFDist() now coerces degrees of freedom df1 below 1e-15 to zero. 2 Oct 2012: limma 3.15.0 (Bioconductor 2.12 Developmental Branch) 2 Oct 2012: limma 3.14.0 (Bioconductor 2.11 Release Branch) 1 Oct 2012: limma 3.13.25 - Two bug fixes for roast() when there are observational weights. 27 Sep 2012: limma 3.13.24 - roast() now accepts observation level weights, through a new argument 'weights'. 27 Sep 2012: limma 3.13.23 - Update NEWS.Rd ready for Bioconductor 2.11 release. 26 Sep 2012: limma 3.13.22 - fitFDist() now permits missing values for x or zero values for df1 with a non-null covariate. This means that squeezeVar() and eBayes() now work with trends even when not all the data values are informative. - Additions to test files to test the above changes, and to test eBayes() with trend=TRUE more generally. 25 Sep 2012: limma 3.13.21 - Minor edits to CITATION file and to User's Guide introduction. 9 Sep 2012: limma 3.13.20 - New argument 'file' for convest(), implementing edits contributed by Marcus Davy. Arguments doplot and dereport renamed to 'plot' and 'report'. 6 Sep 2012: limma 3.13.19 - loessFit() calls to foreign language code in the stats package are restored. Will be removed for R 2.16.X. 6 Sep 2012: limma 3.13.18 - loessFit() now applies minimum and maximum bounds to avoid zero or infinite weights. Equal weights are now treated as NULL, even all zero weights, so that lowess is called instead of loess. - plotMDS() now coerces labels to be character. 17 Aug 2012: limma 3.13.17 - limma license upgraded to GPL (>=2) instead of LGPL to match R itself. - loessFit() no longer makes direct calls to foreign language code in the stats package. Same values are returned as before, but now take 25-30% longer whenever weights are used. 31 July 2012: limma 3.13.16 - updating links to Apoa1, Weaver and Bob1 case study datasets in User's Guide. 30 July 2012: limma 3.13.15 - new function propTrueNull() for fast estimation of the proportion of true null hypotheses from a vector of p-values. 24 July 2012: limma 3.13.14 - plotMDS() now tries to make room on the plot for wider text labels. 22 July 2012: limma 3.13.13 - Update to User's Guide. The chapter on experimental designs has been split into three on single-channel, common reference and two-color respectively. The material on the fixed effect approach to technical replication has been deleted. 18 July 2012: limma 3.13.12 - new section on nested interactions for factorial designs in User's Guide. 18 July 2012: limma 3.13.11 - new section on multi-level designs in User's Guide. 16 July 2012: limma 3.13.10 - updated help page for geneSetTest(). In view of recent results from Wu and Smyth (NAR, 2012), the claim is no longer made that genes might be treated as independent when the experimental units are genetically identical mice. 8 July 2012: limma 3.13.9 - plotMDS() no longer gives an error when the requested number of top genes is greater than the total number of rows of data. 2 July 2012: limma 3.13.8 - fix to voom() so that it computes weights correctly even when the design matrix is not of full rank. 13 June 2012: limma 3.13.7 - new function zscore(). Includes old functions zscoreGamma() and zscoreT() as special cases. 10 June 2012: limma 3.13.6 - User's guide now has sections on reading single channel Agilent and Illumina data. 25 May 2012: limma 3.13.5 - camera() reference is published. 10 May 2012: limma 3.13.4 - bug fix for roast() when the fitted model has only one coefficient. - minor code simplification in loessFit(). 2 May 2012: limma 3.13.3 - help pages for camera() now cite published paper. 23 April 2012: limma 3.13.2 - any(duplicated()) replaced by anyDuplicated(). 22 April 2012: limma 3.13.1 - code speed-up for alias2SymbolTable() 30 Mar 2012: limma 3.13.0 (Bioconductor 2.11 Developmental Branch) 30 Mar 2012: limma 3.12.0 (Bioconductor 2.10 Release Branch) 29 March 2012: limma 3.11.19 - typo fixed in topTable.Rd. 24 March 2012: limma 3.11.18 - new argument 'allow.neg.cor' for camera(). - camera() now recognizes array weights as special case of weights. 9 March 2012: limma 3.11.17 - read.maimages() with source="agilent" now reads median foreground estimates instead of mean foreground. New option source= "agilent.mean" preserves earlier meaning of source="agilent". 4 March 2012: limma 3.11.16 - Agilent single-channel case study added to User's Guide. 26 Feb 2012: limma 3.11.15 - camera() now supports weights. - The 'statistics' argument to camera() has been removed. The default choice of moderated-t is now used always. 24 Feb 2012: limma 3.11.14 - camera() and mcamera() consolidated into one function. - rankSumTestWithCorrelation() now ignores correlation setting when the first group contains only one observation. - implicit documentation dependencies on the sma and marray packages removed. 11 Feb 2012: limma 3.11.13 - removeBatchEffect() now corrects for continuous covariates as well as qualitative factors. - new functions camera() and mcamera() that perform competitive gene set tests while adjusting for inter-gene correlation. - new function interGeneCorrelation() that estimates the average intergene correlation for a set of genes. - columns in output from roast() have been re-ordered. - arguments 'selected' and 'selected2' renamed to 'index' and 'index2' in functions barcodeplot(), geneSetTest() and wilcoxGST(). - default labels for barcodeplot() are now somewhat more explicit. - getEAWP() now coerces the expression values to a matrix if not already. This means that it do longer fails when given an EList object with component E a data.frame. - rankSumTestwithCorrelation() renamed to rankSumTestWithCorrelation(). 10 Feb 2012: limma 3.11.12 - RNA-Seq case study in the User's Guide updated to reflect changes to the tweeDEseqCountData package. 2 Feb 2012: limma 3.11.11 - default method for normalizeCyclicLoess() changed from "pairs" to "fast". - rankSumTestwithCorrelation() now uses a more exact variance calculation. Argument vif is removed. 23 Jan 2012: limma 3.11.10 - new function rankSumTestwithCorrelation, which extends the Wilcoxon-Mann-Whitney test to allow for correlation between cases in one of the groups. geneSetTest() now calls this function instead of wilcox.test, with a consequence improvement in speed. 22 Jan 2012: limma 3.11.9 - minor edit to topTable.Rd. 19 Jan 2012: limma 3.11.8 - The lfc (log-fold-change) cutoff argument of topTable() is now applied to the minimum absolute logFC when ranking by F-statistic. Previously lfc was only used when ranking by t-statistic. 11 Jan 2012: limma 3.11.7 - There were problems with using the argument gene.weights in mroast(). This argument is now permitted to be of the same length as the number of probes in the data set. It is then automatically subsetted for each gene set. 5 Jan 2012: limma 3.11.6 - new methods "fast" and "affy" for normalizeCyclicLoess(). New argument 'cyclic.method' for normalizeBetweenArrays() gives access to the different cyclic loess methods. 4 Jan 2012: limma 3.11.5 - improved documentation for object returned by mroast(). - mroast() now uses mid-p-values by default when adjusting for multiple testing. 1 Jan 2012: limma 3.11.4 - minor documentation correction for plotMA.Rd (default for cex is 0.3 rather than 0.2). - minor edit to error message from neqc() when no control probe information can be found. 19 Dec 2011: limma 3.11.3 - neqc(), nec() and normexp.fit.control() now give user-friendly error messages when no negative control probes or no regular probes are found. 25 Nov 2011: limma 3.11.2 - voom() now works on ExpressionSet objects. 11 Nov 2011: limma 3.11.1 - User's Guide RNA-Seq case study updated to use tweeDEseqCountData package instead of RNAseqCountData. 1 Nov 2011: limma 3.11.0 (Bioconductor 2.10 Developmental Branch) 1 Nov 2011: limma 3.10.0 (Bioconductor 2.9 Release Branch) 14 Oct 2011: limma 3.9.22 - Nigerian RNA-Seq case study expanded to include gene set tests for chromosomes. 30 Sep 2011: limma 3.9.21 - Introduction to User's Guide now mentions RNA-Seq. 26 Sep 2011: limma 3.9.20 - voom() now gives special treatment to DGEList objects. 25 Sep 2011: limma 3.9.19 - RNA-Seq case study added to User's Guide. - minor change to counts-per-million computation in voom(). - edits to voom.Rd. 21 Sep 2011: limma 3.9.18 - minor change to voom() code. Will now tend to give zero counts lower weight than previously. 17 Sep 2011: limma 3.9.17 - new function voom(), to compute expression values and weights from RNA-Seq data suitable for limma linear modelling. - getEAWP() now gets probe annotation from the expression rownames of an EList object, if no other probe annotation is available. 5 Sep 2011: limma 3.9.16 - topRomer() now ranks gene sets by secondary columns as well the primary criterion specified, to give a more meaningful ranking when the primary p-value is tied. 3 Sep 2011: limma 3.9.15 - change to p-value calculation in geneSetTest() when rank.only=FALSE. - wilcoxGST() now accepts signed or unsigned test statistics. 18 Aug 2011: limma 3.9.14 - plotMA() now recognizes ElistRaw and EList objects appropriately. - speed improvement for normalizeCyclicLoess when weights=NULL. 12 Aug 2011: limma 3.9.13 - default span for normalizeCyclicLoess increased from 0.4 to 0.7. 5 Aug 2011: limma 3.9.12 - bug fix for normalizeBetweenArrays() when object is an EListRaw and method="cyclicloess". Previously this function was applying cyclicloess to the raw intensities, then logging. Now it logs first, then applies cyclicloess. 4 July 2011: limma 3.9.11 - new argument trend.var for mroast(), with the same meaning as for roast(). 4 July 2011: limma 3.9.10 - Weaver case study (Section 11.5) in User's Guide is updated and rewritten. 1 July 2011: limma 3.9.9 - new argument trend.var for roast(). roast() also now accepts a vector value for argument var.prior. 1 July 2011: limma 3.9.8 - new argument batch2 for removeBatchEffect(). 25 June 2011: limma 3.9.7 - barcodeplot() and barcodeplot2() merged into one function. 24 June 2011: limma 3.9.6 - bug fixes for barcodeplot() and barcodeplot2(). They were not processing character values for arguments select and select2 correctly. Now fixed. - Data classes ElistRaw and Elist now described in the quick start section of the User's Guide. Other minor updates to User's Guide. 21 May 2011: limma 3.9.5 - plotMDS is now an S3 generic function. This allows MDS plots to be redrawn with new labels without needing to repeat the distance or scaling calculations. - new S4 class "MDS" to hold the multidimensional scaling information output from plotMDS. 20 May 2011: limma 3.9.4 - bug fix to avereps() for EList objects x when x$other is not empty. 19 May 2011: limma 3.9.3 - treat() now has an optional trend argument, same as eBayes(). 6 May 2011: limma 3.9.2 - plotMDS() now invisibly returns the distance.matrix and the x and y plotting coordinates. - plotMDS() now accepts xlab and ylab arguments. 15 April 2011: limma 3.9.1 - Updating package version numbers in introduction of User's Guide. - test file output updated to R 2.13.0 (not user visible). 14 April 2011: limma 3.9.0 (Bioconductor 2.9 Developmental Branch) 14 April 2011: limma 3.8.0 (Bioconductor 2.8 Release Branch) 31 March 2011: limma 3.7.27 - nec.Rd and neqc.Rd combined into one file. 21 March 2011: limma 3.7.26 - change to symbols2indices() so that it returns indices of all occurrences of each symbol on the array, not just the first occurrence. The argument names of symbols2indices() have been changed to be more easily understood. A new argument remove.empty has been added to optionally remove gene sets of length zero. Previously this was always done. 14 March 2011: limma 3.7.25 - minor bug fix to romer(). Change probably not user-visible. 24 February 2011: limma 3.7.24 - bug fix to squeezeVar(): the output var.posterior was too long when there was a non-null covariate and the prior variance was estimated to be infinite. Now fixed. 17 February 2011: limma 3.7.23 - gene symbol annotation (using getSYMBOL) added to the Estrogen case study in the User's Guide. 30 January 2011: limma 3.7.22 - topTable() and toptable() now optionally output confidence intervals for the log-fold-change. 28 January 2011: limma 3.7.21 - bug fix to plotMDS() when gene.selection="common". 26 January 2011: limma 3.7.20 - normalizeWithinArrays() no longer checks for printer layout information before doing "control" normalization. 24 January 2011: limma 3.7.19 - new function normalizeMedianValues(). This is now used by normalizeBetweenArrays() for method="scale" when the data object is a matrix or EListRaw object. 24 January 2011: limma 3.7.18 - new method "cyclicloess" for normalizeBetweenArrays(). 12 January 2011: limma 3.7.17 - minor changes to Illumina case study in the user guide. 7 January 2011: limma 3.7.17 - minor documentation edits. 5 January 2011: limma 3.7.16 - read.columns() and read.ilmn() now allow column names with leading or trailing blanks, although leading or trailing white space will be trimmed. 17 December 2010: limma 3.7.14 - fix to gls.series() so that it works correctly even when there is only one column of microarray data. 1 December 2010: limma 3.7.13 - bug fixes to avereps.default and avearrays.default, which had been treating NA expression values as if zero. Averages are now computed correctly over non-missing values. 30 November 2010: limma 3.7.12 - remove line from NAMESPACE requiring methods on loading. 27 November 2010: limma 3.7.11 - bug fix to mroast(), which had been assigning prior.df incorrectly for the second and subsequent gene sets. 3 November 2010: limma 3.7.10 - the total df used by ebayes to compute p-values (and therefore also by eBayes, topTable and so on) is now not allowed to be larger than the total residual df pooled over all probes. This limit will normally become active only when the prior df is estimated as Inf. Previously the total df was also allowed to be Inf in this case, so that p-values were computed as if the t-statistics followed a standard normal distibution. This change will not affect microarray analyses with thousands of genes, but can come into play with simulated data or with data sets with only a few genes or probes. In these cases, the ebayes p-values now agree with those from a pooled analysis in which the genewise variances are assumed equal. - df.total is now included as a component of the MArrayLM object output by ebayes() and eBayes(). - ebayes() and eBayes() now include an option to allow the prior variance to be intensity-dependent. Associated with this is a new optional argument 'covariate' to functions fitFDist() and squeezeVar(). 28 October 2010: limma 3.7.9 - update to installation instructions in User's Guide, no longer recommending dependencies=TRUE with biocLite. 27 October 2010: limma 3.7.8 - plotSA() now adds the prior variance estimated by eBayes() (if available) to the sigma vs A plot. 27 October 2010: limma 3.7.7 - neqc() function now supports normexp by control background correction using negative control values inferred from detection p-values. This is mainly applicable to Illumina BeadChip. - The default value of "other.columns" argument in read.ilmn() function is changed to "Detection". 26 October 2010: limma 3.7.6 - .read.oneilmnfile() and read.ilmn() are now careful to return the genes annotation as a data.frame, not a character vector, even when it only has one column. 26 October 2010: limma 3.7.5 - rbind.EList and rbind.EListRaw now behave correctly when one or more of the matrix components are simply undimensioned vectors. 26 October 2010: limma 3.7.4 - bug fix to rbind.EListRaw and rbind.EList. This bug also affected neqc() which calls rbind on EListRaw objects. - updating Introduction to User's Guide to reflect limma's new capabilities for pre-processing data from single-channel and Illumina platforms. 25 October 2010: limma 3.7.3 - Shi et al (2010) reference now given for neqc function in User's Guide. - use of sma package now commented out of code examples. 25 October 2010: limma 3.7.2 - minor updates to User's Guide. 21 October 2010: limma 3.7.1 - subsetting, cbind and rbind for EListRaw objects did not operate correctly on the Eb component of the objects. Now fixed. 18 October 2010: limma 3.7.0 (Bioconductor 2.8 Developmental Branch) 18 October 2010: limma 3.6.0 (Bioconductor 2.7 Release Branch) 24 September 2010: limma 3.5.21 - new function avearrays() to average over technical replicate arrays. 8 September 2010: limma 3.5.20 - new function normalizeVSN to apply vsn normalization to limma objects. normalizeBetweenArrays() now longer supports method="vsn". - avereps.MAList was not averaging the "other" data matrices correctly. Now fixed. - updates to the 04.Background help page, which gives an overview of background correction functions. 30 August 2010: limma 3.5.19 - The backgroundCorrect() code has been simplified and a new function backgroundCorrect.matrix() introduced for matrix arguments. The argument 'method' now defaults to "auto" instead of NULL, although the effect is the same. None of the changes to backgroundCorrect() are user- visible, except that background intensities are now used correctly when the argument RG is an EListRaw object. 20 August 2010: limma 3.5.18 - neqc() now subtracts background intensities Rb if found in data object. 19 August 2010: limma 3.5.17 - read.maimages() now supports ImaGene Version 9.0. 19 August 2010: limma 3.5.16 - minor non-user-visible changes to decideTests() code. - minor documentation update to plotMDS.Rd. 4 August 2010: limma 3.5.15 - Pomelo II reference added to User's Guide. 19 July 2010: limma 3.5.14 - minor documentation updates for roast() and romer(). 15 July 2010: limma 3.5.13 - marray no longer a suggested package - read.ilmn() now uses readGenericHeader() to skip over header information in BeadStudio files. - read.ilmn() no longer issues warning if control probe files are not provided. 5 July 2010: limma 3.5.12 - citation details updated for the roast() function. 28 June 2010: limma 3.5.11 - bug fix to normexp.fit.control() when the argument 'x' is a matrix. 18 June 2010: limma 3.5.10 - minor documentation improvements for roast.Rd and geneSetTest.Rd. 3 June 2010: limma 3.5.9 - new argument 'set.statistic' for romer() to control the sensitivity of the tests to sets with only a subset of genes differentially expressed. The old function romer2() and the old argument 'floor' are now retired. - romer() now longer outputs p-values for the "either" alternative hypothesis. P-values are output for "Up", "Down" or "Mixed". 2 June 2010: limma 3.5.8 - more complete documentation for roast(). 27 May 2010: limma 3.5.7 - new function topRomer() to summarize output from romer(). 19 May 2010: limma 3.5.6 - code simplifications to mroast(). Not user-visible. 19 May 2010: limma 3.5.5 - new S4 class "Roast" for output from the function roast(). - bug fix to roast(). The the fix affects situations with set.statistic="msq" and gene weights of changing sign. 11 May 2010: limma 3.5.4 - new function mroast(), which organizes roast() tests for multiple gene sets. - Cosmetic changes to row and column names in the output from roast(). 7 May 2010: limma 3.5.3 - new argument 'set.statistic' for roast(), which specifies the gene set summary statistic to be used. - the output from roast() no longer includes a column for the "either" alternative hypothesis. 7 May 2010: limma 3.5.2 - edits to romer.Rd, in particular a link to the curated database of gene sets. - bug fix to estimation of proportion of active genes in roast() when there are gene weights. 23 April 2010: limma 3.5.1 - Update reference for propexpr(). 23 April 2010: limma 3.5.0 (Bioconductor 2.7 Developmental Branch) 23 April 2010: limma 3.4.0 (Bioconductor 2.6 Release Branch) 22 April 2010: limma 3.3.22 - new function normalizeCyclicLoess(). 19 April 2010: limma 3.3.21 - Change to robust method for normexp.fit.control(). Robustness now uses the huber() function from the MASS package, and robustness is judged on the log-scale. 19 April 2010: limma 3.3.20 - bug fix to sigma calculation in normexp.fit.control(). - Add "quote" argument to read.ilmn(). 16 April 2010: limma 3.3.19 - new argument robust for normexp.fit.control() and neqc(). This gives the option of robust estimation of the background mean and standard deviation. - Faster computation of background mean and standard deviation in normexp.fit.control(). 9 April 2010: limma 3.3.18 - bug fix to the probe filtering in illumina case study in the user guide. Also update the analysis results for this case study. 7 April 2010: limma 3.3.17 - read.maimages() now has a new argument green.only which replaces the older argument channels. read.maimages() now outputs an EListRaw object whenever single channel data is read, and an RGList object when two color data is read. 2 April 2010: limma 3.3.16 - avedups() and avereps() now have methods for EList objects. - The function makeContrasts() requires coefficient names (levels) to be syntactically valid variable names in R. The intercept column name "(Intercept)", which is often produced by the model.matrix() function, is now automatically converted. A more detailed diagnostic message is also output in the case of non-valid names. 28 March 2010: limma 3.3.15 - speed improvement to avereps(), achieved by calling the base package's rowsum() function, following a suggestion of Michael Lawrence. 17 March 2010: limma 3.3.14 - bug fix: topTreat() now allows genelist to be a vector or a data.frame. Previously failed when a vector was input. 16 March 2010: limma 3.3.13 - bug fix to p.value computation in treat(). This affects only p-values greater than 0.5. 12 March 2010: limma 3.3.12 - default value for offset in neqc() function reduced from 50 to 16. - The raw data for the "IlluminaWG-6 Case Study: Mammary Progenitor Cell Populations" in the User's Guide is now available online, with URL given in User's Guide. - output from vennDiagram() improved to draw complete unbroken circles. 2 March 2010: limma 3.3.11 - bug fix: the output from treat() now includes a component df.prior. 10 February 2010: limma 3.3.10 - read.maimages() now provides the option of reading Agilent Feature Extraction data with using median foreground summaries. 3 February 2010: limma 3.3.9 - spelling error corrections to documentation files. 1 February 2010: limma 3.3.8 - minor documentation fix to alias2Symbol() example. 17 January 2010: limma 3.3.7 - sma package (which no longer exists) removed from normalizeBetweenArrays.Rd example. 13 January 2010: limma 3.3.6 - MArrayLM objects now re-calculate F-statistics if they are subsetted by columns. This ensures that the F-statistics always match the contrast columns in the object. 21 Dec 2009: limma 3.3.5 - bug fix to row numbers from toptable() and topTable() when the arguments p or lfc are specified. - documentation fixes for alias2SymbolTable() - truth argument of auROC() can now be logical 15 Dec 2009: limma 3.3.4 - minor bug fix in treat() code. 11 Dec 2009: limma 3.3.3 - as.dataframe methods for MAList, EList and EListRaw objects. 6 Dec 2009: limma 3.3.2 - new argument gene.selection for plotMDS() 28 October 2009: limma 3.3.1 - bug fix to backgroundCorrect() so ensure that normexp.method is always correctly passed to normexp.fit. Previously the normexp.method argument was being ignored, in favour of the default, when RG was an RGList object. 28 October 2009: limma 3.3.0 (Bioconductor 2.6 Developmental Branch) 28 October 2009: limma 3.2.0 (Bioconductor 2.5 Release Branch) 22 October 2009: limma 3.0.3 - Case study with Illumina BeadChip microarrays added to User's Guide. 22 October 2009: limma 3.0.2 - strsplit2() now uses ... to pass arguments to strsplit. - minor updates to User's Guide. - propexpr() now accepts EListRaw objects, or any other data object with an as.matrix method. - read.ilmn() now accepts more variations in the name of the ProbeID column. 15 October 2009: limma 3.0.1 - documentation links to 00Index.html removed. - minor corrections to help page for vennDiagram(). 5 October 2009: limma 3.0.0 - New function genas() which tests for associations between contrasts in a linear model. - New options and improved power for the romer() function. There are now two versions, romer() and romer2(), which use different test statistics. Both new versions should give better statistical power than the old version. The new romer() is also computationally quicker. - new functions read.ilmn() and read.ilmn.targets() for reading in Illumina Whole Genome Expression BeadChip data. - new functions normexp.fit.control() and neqc() which perform normexp background correction using negative control information. This is especially useful for Illumina BeadChip data. neqc() undertakes background correction and quantile normalization in one step for EListRaw data objects with negative control probes. - new function propexpr() for estimating the proportion of expressed probes in a microarray, using negative control probe information. Especially useful for Illumina BeadChip data. - new function barcodeplot2() for displaying directional gene sets with up and down genes shown separately. - removed sma from list of suggested packages - update normalizeBetweenArrays help page for changes to vsnMatrix used in method="vsn" option. - new function alias2SymbolTable() for converting a set of alias names to a vector of official gene symbols of the same length. - new function wilcoxGST() introduced as a synonym for geneSetTest() with ranks.only=TRUE. - backgroundCorrect() and normalizeWithinArrays() now accept EListRaw objects. - Oshlack et al (2007) reference on normalization of boutique arrays added to normalizeWithinArrays.Rd and to the User's Guide. 31 Aug 2009: limma 2.19.4 - bug fix to removeBatchEffect(), which gave incorrect results when design=NULL. 19 Aug 2009: limma 2.19.3 - speed improvements to avereps() (following suggestions from Axel Klenk) 15 June 2009: limma 2.19.2 - new function topTreat() for listing top results by treat(). - treat() now outputs thresholded t-statistics. - reference added to intraspotCorrelation.Rd. - romer() now outputs the number of genes in each gene set. - arrayWeights() now displays convergence info when TRACE=TRUE for method="genebygene" (for every 1000th gene). 28 May 2009: limma 2.19.1 - Barnard (1963) reference added to roast.Rd. - rewording of details in romer.Rd. - two fixes to contrasts.fit() when there are non-estimable coefficients in the linear model. The function previously gave a warning about coercing double to logical, which no longer appears. The function also failed in this situation when the contrast was a single vector instead of a matrix. - convergence criterion for arrayWeightsSimple() is now more lenient for large data sets. About 5 decimal place accuracy is still achieved. - arrayWeightsSimple() now checks for failed convergence from floating point errors and returns a diagnostic message. - getEAWP() and lmFit() now return Amean values for EList objects. - calculation of rotation p-values in roast() and romer() changed to be (x+1)/(nrot+1) instead of x/nrot, where x is the number of random rotations giving a more extreme statistic than that observed. 21 April 2009: limma 2.19.0 (Bioconductor 2.5 Devel Branch) 21 April 2009: limma 2.18.0 (Bioconductor 2.4 Release Branch) 18 April 2009: limma 2.17.21 - basic (matrix-like) methods added for ElistRaw objects, including cbind, rbind, subsetting etc. 14 April 2009: limma 2.17.20 - bug fix to printHead() to handle object components which are neither atomic nor recursive. 13 April 2009: limma 2.17.19 - ebayes() now returns lods as a matrix. This ensures that MArrayLM objects always be subsetted by column names, even when there is only one column. - new argument channels for read.maimages(), which allows the function to read one-channel data. - new class EListRaw for non-normalized one-channel data. - printHead() now prints compactly for recursive lists of arbitrary depth. 03 April 2009: limma 2.17.18 - Bug fixes to the calculations of up, mixed and down p-values in romer(). 02 April 2009: limma 2.17.17 - Bug fixes to the calculations of p-values in romer() 30 March 2009: limma 2.17.16 - Bug fix to the calculations of either and down p-values in romer(). - Utility function .meanTop() removed and replaced with .meanHalf(), which gives means of top and bottom halves of a vector. 27 March 2009: limma 2.17.15 - further work on plotMDS() to make arguments and help page clearer. 27 March 2009: limma 2.17.14 - New function romer() for rotation gene set enrichment analysis. This can be viewed as a version of GSEA for linear models. - New function symbols2indices() which matches a list of gene sets as symbols against of vector of gene symbols. 23 March 2009: limma 2.17.13 - New class EList for one-channel microarray data. - New function plotMDS(), which makes a multidimensional scaling plot, using a particular distance measure. 20 March 2009: limma 2.17.12 - Bug fix to rowname assignment for MAList and RGList objects containing matrices in 'other' component - lmFit() warning message on NA coefficients is now more refined. It now appears only when the coef vector is partially NA for some probes. - Fix to gls.series() so that it does not fail when the weight matrix contains NA values. 20 March 2009: limma 2.17.11 - biocViews entry of Statistics changed to Bioinformatics 5 February 2009: limma 2.17.10 - update to backgroundCorrect help page to reflect published papers. - update to treat help page to reflect published paper. - lmFit now looks for a design matrix in an MAList data object, if one exists. 19 Jan 2009: limma 2.17.9 - fix to a toptable() bug, which caused t-statistics to be out of order when p<1 or lfc>0. - color of the trend line drawn by plotSA() changed to red. 15 Jan 2009: limma 2.17.8 - C code dynamic library is not unloaded when package is unloaded. (Not user visible.) - Some additions to alias2Symbol help page. 15 Jan 2009: limma 2.17.7 - new argument expand.symbols for alias2Symbol(). This can be used to prevent aliases from being expanded if they are already official symbols. 14 Jan 2009: limma 2.17.6 - new function plotSA(), which produces a "sigma vs A" plot for a fitted microarray linear model. 13 Jan 2009: limma 2.17.5 - paragraph added to details section of roast() help file to explain simulation method used to estimate p-values. 4 Jan 2009: limma 2.17.4 - C code dynamic library is loaded when package is loaded rather than when it is attached, to enable other packages to import limma. (Not user visible.) - minor edits to geneSetTest and roast help files. 10 Nov 2008: limma 2.17.3 - fix to a toptable() bug which caused an error when user selected p<1 and lfc>0 23 October 2008: limma 2.17.2 - minor improvements to the help page for topTable and topTableF. - bug fixes to the way that topTable() and topTableF() handle sort="none". 22 October 2008: limma 2.17.1 - minor updates to User's Guide to refer to R 2.8.0 22 October 2008: limma 2.17.0 (Bioconductor 2.4 Developmental Branch) 22 October 2008: limma 2.16.0 (Bioconductor 2.3 Release Branch) 21 October 2008: limma 2.15.18 - refinements to barcodeplot() to make the graphic a bit prettier 20 October 2008: limma 2.15.17 - new function barcodeplot(), which gives a graphical representation of geneSetTest() using ranks. 15 October 2008: limma 2.15.16 - getLayout() with guessdups=TRUE can now handle values for ndups greater than 2. - new function getDupSpacing() which determines duplicate spacing from a vector of gene IDs. - getSpacing() now recognizes a new value "subarrays" which means that all the probes on an array are repeated in two or more subarrays. - bug fix to removeBatchEffect(), which previously returned an error. 9 October 2008: limma 2.15.15 - the criterion for the "Active" column output by roast() is changed to be more discriminating. - new method "mallowscp" for selectModel(). 1 October 2008: limma 2.15.14 - minor improvements to several help files - correction to the "bic" method of selectModel(). 28 Sept 2008: limma 2.15.13 - more efficient memory management in normexp.c (not user-visible) - argument bg removed from internal functions .normexp.m2loglik, .normexp.gm2loglik and .normexp.hm2loglik (not user-visible) 25 Sept 2008: limma 2.15.12 - substantial tidying up of normexp.fit() code, although very little of this will be visible to users. The old pure-R normexp.fit() is removed and replaced by the function previously called normexp.fit.C(). The old method "neldermead" is now replaced by "saddle". The old methods "bfgs", "nlminb" and "nlminblog" now replaced by "mle". - all user-visible functions previously called by normexp.fit() are now removed including: dnormexp(), dnormexp.saddle(), normexp.m2loglik() and normexp.m2loglik.saddle(). There are now just 4 utility functions, none of which are exported from the limma NAMESPACE, namely .normexp.m2loglik, .normexp.gm2loglik, .normexp.hm2loglik and .bg.parameters.rma75. - More comments added to C code supporting normexp.fit(). The source code file is renamed from find_saddle_theta2.c to normexp.c. - backgroundCorrect() has a new argument normexp.method to specify the parametrization estimation method when for normexp background correction. The options are "mle", "saddle", "rma" and "rma75". - in read.maimages(), support added for ArrayVision data files with 'Artifact-removed' (ARM) density values. - new function selectModel() which implements Akaike Information Criterion (AIC) or Bayesian Information Criterion model (BIC) selection between alternative linear models. - new function alias2Symbol() to convert gene aliases to official symbols. Uses the data packages org.Hs.eg.db etc. - new arguments sort.by and p.value for topTableF(). This makes it more consistent with topTable(). - topTableF() now allows the input argument number to be larger than the number of rows of the fitted model object. In this case the requested number is set to the number of available rows. - non user-visible improvements to toptable() code. 21 August 2008: limma 2.15.11 - new option "none" for the sort argument of topTable(). - new function roast() which does rotation gene set testing for linear models. - new function treat() which computes empirical Bayes moderated-t p-values relative to a minimum required fold change threshold. - new function removeBatchEffects() which removes batch effects from microarray data. - tableF() now gives a friendlier error message when the fitted model object doesn't contain F-statistics. 11 July 2008: limma 2.15.10 - Better treatment of array weights in linear modelling. lm.series() and gls.series() now treat array weights as a special case, when there are no missing values in the expression data and now probe-specific weights. This means that the array weights are now incorporated into fit$cov.coefficients, meaning that contrasts.fit() will correctly take array weights into account when computing the contrast standard errors, which it did not do previously. It also means that lmFit() is much faster when array weighting is used. - Speed improvement to gls.series() when there are no missing values and no probe-specific weights. 16 June 2008: limma 2.15.9 - new capabilities and arguments for write.fit(). The argument method allows p-values to be adjusted globally instead of separately, and the argument F.adjust allows the F-statistic P-values to be adjusted. 11 June 2008: limma 2.15.8 - further bug fixes to getEAWP() when object is of PLMset class: weights and Amean components were not being set. 4 June 2008: limma 2.15.7 - new S3 generic function avereps() for averaging over irregularly spaced replicate spots. A method is defined for MAList objects and a default method intended for matrices. 1 June 2008: limma 2.15.6 - gls.series() now preserves rownames (probe IDs) of the expression object. This affects lmFit() when ndups>1 or block is non NULL. This makes gls.series() consistent with other fitting functions lm.series() and mrlm(). 22 May 2008: limma 2.15.5 - fix bug introduced to plotMA() in version 2.13.6: plotMA() ignored array argument when object was of class RGList. Correct function now restored. 20 May 2008: limma 2.15.4 - Cleaning up of source code in find_saddle_theta2.c and corresponding calls in background-normexp-mle.R. No user visible changes. The C code now passes R CMD check without warnings, and superfluous utility functions are removed from background-normexp-mle.R 12 May 2008: limma 2.15.3 - The optimisation step of normexp.fit is now done in C, making a new function normexp.fit.C, speeding up the computation several fold. normexp.fit.C() has two new methods available "nlminb" and "nlminblog" which compute maximum likelihood estimates. backgroundCorrect(method="normexp") now calls normexp.fit.C() with method="saddle". 8 May 2008: limma 2.15.2 - the following obsolete functions (deprecated Dec 2006 in favour of read.maimages) are now removed: m.spot, a.spot, read.matrix, read.series, rg.series.spot, rg.genepix, rg.quantarray, rg.spot 8 May 2008: limma 2.15.1 - fix bug introduced to plotMA() in version 2.13.6: plotMA() was not working for MArrayLM objects. Function now restored. - getEAWP() now gets probe names correctly from the rownames of exprs when object is of PLMset class. - edits to read.columns help page to explain that some arguments cannot be passed to read.table through ... because they are already used by read.columns. 30 April 2008: limma 2.15.0 (Bioconductor 2.3 Branch) 25 April 2008: limma 2.13.10 - getEAWP() now gets probe names correctly from the rownames of object when object is a matrix. 24 April 2008: limma 2.13.9 - normalizeBetweenArrays(method="vsn") now gives an error if object is an MAList. - normalizeBetweenArrays(method="vsn") now uses vsnMatrix() when the data object is a matrix. 16 April 2008: limma 2.13.8 - bug fix to normalizeBetweenArrays(method="vsn"). When the function was updated on 14 December 2007 to use vsnMatrix, it had not been noticed that vsnMatrix returns log2 results whereas the older vsn function returned loge results. The results returned by normalizeBetweenArrays(method="vsn") are again now log2, similar to before 14 December 2007. - method option "neldermean" for normexp.fit() corrected to "neldermead" - deprecated function splitName() removed - the help page for backgroundCorrect edited for improved readability 26 March 2008: limma 2.13.7 - the function rlm.series(), deprecated in 2004, is now removed - add comments in the geneSetTest help file to warn that the test assumes genewise independence. 8 March 2008: limma 2.13.6 - Streamlining of plotMA() code. plotMA() should now work correctly for any object class that can be coerced to a matrix, for example LumiBatch objects. - lmFit() now warns if coefficients become inestimable due to missing values. - Bug fix when matrix data object passed to lmFit() containing missing values. The check for log-intensities vs log-ratios introduced 27 Oct 2007 did not remove missing values and hence produced an error. - New function getEAWP() introduced to unify the treatment of different classes of microarray data objects as input to linear model functions such as lmFit(), arrayWeights() and printtipWeights(). - Class exprSet2 removed. 27 February 2008: limma 2.13.5 - All usage of Biobase's exprSet class removed or replaced with ExpressionSet. - Fortran call in .vsimpleLoess() function updated. 13 February 2008: limma 2.13.4 - all uses of I() in data.frame() arguments removed and replaced with stringsAsFactors=FALSE. This ensures that the appropriate columns in data.frames will have class "character" instead of "AsIs". - arrayWeights() now gives nice error message if the number of arrays is too few to give statistically useful results. 2 January 2008: limma 2.13.3 - Section on Mutiple Testing Across Contrasts added to the User's Guide. - The bibTeX entry returned by citation("limma") now uses @incollection styole instead of @inbook, thanks to Joern Toedling. 14 December 2007: limma 2.13.2 - update normalizeBetweenArrays(method="vsn") to reflect changes in the vsn package version 3.4.1. - additions to the help file for MArrayLM-class objects 27 October 2007: limma 2.13.1 - lmFit() now tries to guess whether a data matrix contains log-ratios or log-intensities. When the input data object is a matrix, it is not possible to know for certain whether the data are log-ratios or log-intensities, and so lmFit() did not set the component Amean in the MArrayLM output object. lmFit() now sets Amean if the input data values are all positive, because the data are almost certainly log-ratios in that case. 8 October 2007: Bioconductor Developmental Version 2.2: limma 2.13.0 Bioconductor Release 2.1: limma 2.12.0 25 Sep 2007: limma 2.11.14 - plot character and size can now be passed to volcanoplot() as arguments - add backgroundCorrect(method="normexp") to automatic test suite (not user visible) 19 Sep 2007: limma 2.11.13 - bug fix for as.matrix.vsn. This allows vsn objects from vsn2() to be used directly in lmFit. 8 Sep 2007: limma 2.11.12 - edits to loessfit.Rd to better acknowledge lowess and loess authors. 31 Aug 2007: limma 2.11.11 - correction to loessFit() because lowess() function now in stats instead of base. - other documentation fixes to pass package check in R 2.6.0 - Ritchie et al (2007) reference added to User's Guide and to the backgroundCorrect and normexp help pages. 17 Aug 2007: limma 2.11.10 - topTable() and toptable() have new arguments p.value and lfc, allowing users to cut the gene list on adjusted p.value and fold change, rather than just taking a set number of genes as before. 22 July 2007: limma 2.11.9 - improvements to the numeric computations of dnormexp.saddle(), which is used by backgroundCorrect(method="normexp") - new function normexp.m2loglik.saddle(), which is the same as normexp.m2loglik() but using the saddle-point approximation. - normexp.fit() has a new argument 'methods' - default for n.pts in normexp.fit() changed to NULL, meaning use all the points. The rule used to choose the quantiles if n.pts is improved to give more nearly unbiased parameter estimators. 9 July 2007: limma 2.11.8 - contrasts.fit() now warns if row names of contrast matrix don't match column names of contrasts. - plotMA3by2 has a new argument 'device' to specify the graphic format. 24 June 2007: limma 2.11.7 - decideTests(method="hierarchical") now passes the adjust.method down to the second (t-test) level of testing. Previously the second level testing was always "holm". The spelling is also corrected from "heirarchical" to "hierarchical". 8 June 2007: limma 2.11.6 - new argument n.pts for normexp.fit. n.pts=2^10 becomes the default for method="normexp" in backgroundCorrect(). This decreases computation time and introduces some robustness. - backgroundCorrect() now accepts a matrix argument. 30 May 2007: limma 2.10.5 and 2.11.5 - as.matrix method for vsn objects added. 18 May 2007: limma 2.10.4 and 2.11.4 - as.matrix methods for ExpressionSet and LumiBatch added to the limma NAMESPACE. 17 May 2007: limma 2.10.3 and 2.11.3 - added as.matrix method for LumiBatch class - corrected as.matrix method for ExpressionSet class to allow that the assayData slot may be a list instead of an environment. 16 May 2007: limma 2.11.2 - fixed some non-matching braces '}' in .Rd files. (Not user-visible.) 1 May 2007: limma 2.11.1 - Bug fix to read.columns() to stop spurious warning message when text.to.search has length greater than one. 26 April 2007: Bioconductor Developmental Version 2.1: limma 2.11.0 Bioconductor Release 2.0: limma 2.10.0 24 Apr 2007: limma 2.9.19 - Minor documentation bug fix: 'F.stat' to 'F' in MArrayLM.Rd 18 Apr 2007: limma 2.9.18 - User's Guide case studies updated for current version of limma. A couple of changes to Weaver case study: multiple testing method is now "global" instead of "nestedF", and heat diagram is removed. 4 Apr 2007: limma 2.9.17 - bug fix to read.maimages() for source="arrayvision". Now reads arrayvision files again for the first time since version 2.3.1. 27 Mar 2007: limma 2.9.16 - new tests for topTable() added to limma-Tests.R - bug fix to topTable(). sort="M" and resort.by="M" needed to be updated to sort="logFC" and resort.by="logFC". Also sort="AveExpr" and resort.by="AveExpr" are now allowed. 26 Mar 2007: limma 2.9.15 - bug fix to read.columns, to read SPOT files with a leading column of row numbers. Was failing because the number of headers was less than the number of columns. 10 Mar 2007: limma 2.9.14 - lmFit() was giving error with marrayNorm object, because of incorrect setting of Amean. Fixed. 24 Feb 2007: limma 2.9.13 - write.fit() was using write ambiguous column names for the coef, t-statistic and p-value when the MArrayLM object had only one column and these components were matrices with one named column. Now fixed. - default changed in write.fit() to digits=3. 22 Feb 2007: limma 2.9.12 - lm.series() gls.series() were returning errors when the design matrix was not of full rank and the columns were names. Bug fixed. 17 Feb 2007: limma 2.9.11 - changes in 2.9.10 broke read.maimages() for Agilent and generic source files. Bug fixed. 12 Feb 2007: limma 2.9.10 - functions getColClasses() and namesInFun() removed and replacad with the new function read.columns(). read.columns() is a more generally useful function which is similar to read.delim() but reads specified columns only. - Argument \dots added to all as.matrix methods for compatibility with R 2.5.0. 2 Feb 2007: limma 2.9.9 - normalizeRobustSpline() now works with only one print-tip group - new function mergeScansRG() 5 Jan 2007: limma 2.9.8 - User's Guide sections on spot quality weights and quality assessment expanded. - unnecessary backlashs removed from gsub() calls in protectMetachar() - normalizeForPrintorder(plot=TRUE) now produces no output to agree with the documentation. 1 Jan 2007: limma 2.9.7 - old functions designed to read image data files into data.frames are now deprecated. This affects functions: read.matrix, rg.series.spot, read.series, m.spot, a.spot, rg.spot, rg.quantarray, rg.genepix. - wtVariables() renamed to namesInFun() - new argument other.columns for read.imagene() 19 Dec 2006: limma 2.9.6 - new function as.matrix.ExpressionSet - section on array quality weights added to User's Guide 17 Nov 2006: limma 2.9.5 - correction of several minor typos. 5 November 2006: limma 2.9.4 - function .onAttach() replaces the old .First.lib() 27 October 2006: limma 2.9.3 - Changes to column headings from topTable: M is now logFC, A is now AveExpr - lmFit() now supports ExpressionSet objects - volcanoplot() now allows NULL value for 'names' argument - new function strsplit2() replaces splitName(). - splitName() deprecated. 16 October 2006: limma 2.9.2 - NAMESPACE introduced to package. Funtion matvec() and vecmat() renamed to .matvec and .vecmat and are not exported. All objects with names not starting with "." are exported. 4 October 2006: limma 2.9.1 4 October 2006: limma 2.8.1 - read.maimages() with source="quantarray" now sets annotation columns. - bug fix to read.maimages() with source="quantarray". Searching for "Begin Data" in 2nd and following files read too few lines. - fix to unprotected "%" character in decideTests.Rd. 4 October 2006: limma 2.9.0 (Bioconductor Developmental version) 4 October 2006: limma 2.8.0 (Bioconductor Release 1.9) 21 September 2006: limma 2.7.17 - new arguments for vennDiagram() to allow colors and printing of multiple tests of counts on the same diagram. - warning about lmscFit being "experimental" removed from lmscFit.Rd 14 September 2006: limma 2.7.16 - improvements to lm.series, gls.series and rlm.series to better preserve column names. - topTable() with coef=NULL now ranks genes by F-statistic for all the contrasts. 11 September 2006: limma 2.7.15 - topTable() now accepts vector argument coef. If length(coef)>1, topTableF() is called to produce a ranking by F-statistic. - new arguments col and lwd for plotlines() 2 September 2006: limma 2.7.14 - normalizeWithinArrays() now uses asMatrixWeights() to process weights arguments. This allows to the weights to be a vector of probe weights, or a vector of array weights, or a matrix of spot weights. - weights argument of modifyWeights() now has a default value 2 September 2006: limma 2.7.13 - new argument lfc for decideTests() to require a minimum fold-change 30 August 2006: limma 2.7.12 - subsetting for MArrayLM revised so that contrast matrix is subsetted rather than design matrix. - revision to writefit.Rd to clarify that p-value adjustment is by columns - bug fix to plotlines() 30 August 2006: limma 2.7.11 - new argument ... added to write.fit() - new function exprs.MA() to extract log-expression matrix from MAList - array2channel() previously deprecated now removed - new function plotlines() 27 August 2006: limma 2.7.10 - new argument 'coefficients' for contrasts.fit(). This provides a simple way to specify the contrast matrix when the contrasts are just a subset of the original coefficients. - new function topTableF() to rank genes on the basis of F-statistics - normalizeWithinArrays() was incorrect with method="composite" and weights=NULL, now fixed. - makeContrasts() now gives informative error message if parameter names are not syntactically valid. - edit eBayes.Rd to make meaning of F-statistic clearer 6 August 2006: limma 2.7.9 - new argument 'contrasts' for makeContrasts() which will accept a character vector of contrasts. - the matrix produced by makeContrasts() now has named dimensions. 3 August 2006: limma 2.7.8 - CARMAweb reference added to User's Guide - In read.maimages(), flush=TRUE added to all instances of read.table(). This makes read.maimages() tolerant of spurious columns added to the end of data lines. 30 July 2006: limma 2.7.7 - wtflags() has new argument cutoff. Argument w renamed to weight. - new section Fitted Model Objects in User's Guide - table of image analysis programs added to Section 4.4 of User's Guide - read.imagene() now uses mean background instead of median if the auto segmentation method has been set. 27 July 2006: limma 2.7.6 - readImaGeneHeader() updated to allow for extraneous trailing white space in the lines of the data files. - In geneSetTest() values "two.sided", "less" or "greater" are now permitted as synonyms for "either", "down" or "up". - geneSetTest() now longer issues warning with type="t" and all positive values for statistic. - new function as.matrix.PLMset. This allows lmFit() to work correctly on PLMset objects. - Bob case study updated in Limma User's Guide. 22 June 2006: limma 2.7.5 - bug fix to read.maimages: remove mention of readBlueFuseHeader(), which is no longer a function. - editing of RGList.Rd and MAList.Rd to improve clarity - improvement to normalizeQuantiles() to reduce memory requirements 1 June 2006: limma 2.7.4 - decideTests() now preserves probe row names - as.data.frame.MArrayLM now has ... argument conditionally in R 2.4.0 higher to fit in with change in R base. 29 May 2006: limma 2.7.3 - minor bug fix to kooperberg() - fix to read.maimages(). Using readGenericHeader() to get column names was not working when sep or quote were different from defaults. Now gone back to using scan() to read column names. - new function plotFG() for foreground-background plots. 5 May 2006: limma 2.6.2 and 2.7.2 - fix to plotMA3by2() which was not passing on the setting of the zero.weights arguments to plotMA(). 3 May 2006: limma 2.6.1 and 2.7.1 - bug fix to read.imagene(), which was trying to read too many data rows when there were multiple ImaGene fields. read.imagene() now attempts to sent printer layout for ImaGene files created using GAL layout files. 27 April 2006: limma 2.7.0 Bioconductor developmental version 27 April 2006: limma 2.6.0 Bioconductor release 1.8 20 April 2006: limma 2.4.15 - correction in User's Guide: definition of interaction in Weaver case study was incorrect. 13 April 2006: limma 2.4.14 - improved topTable.Rd to better explain differences between toptable() and topTable(). - read.maimages() was setting RG$ngrid.c incorrectly when source ="genepix" and the meta-grid layout could not be determined. Now fixed. 7 April 2006: limma 2.4.13 - changes to the argument list and defaults for geneSetTest() to make it more intuitive. - in fitFDist(), the bounding of standard deviations away from zero now uses a smaller bound. - new generic function avedups(), with methods for default and MAList object. - read.maimages() now uses readGenericHeader() to get skip and column names for generic source files. - readGenericHeader() now uses protectMetachar() so that special characters can be used in column headings. 5 April 2006: limma 2.4.12 - Non-user-visible change to the way that dimnames<-.RGList and dimnames<-.MAList are assigned, so as to pass RCMD check in R2.3. - new function plotFB() - read.maimages() no longer tries to guess ndups for GenePix data (was found to be unreliable for small boutique arrays). 10 March 2006: limma 2.4.11 - Now reads BlueFuse v3.2 image analysis output files correctly. The old function readBlueFuseHeader() is removed and replaced by readGenericHeader(). 3 March 2006: limma 2.4.10 - limma now passes R CMD check in R 2.3.0dev - usage of La.chol() in replaced by chol() in lm.R - bug fix to topTable: separate raw and adjusted p-values (introduced 2.4.8) was failing when some p-values were missing. - bug fix: in read.maimages(source="imagene") was confusing a data.frame of file names with a targets file - editing and expansion of normalizeWithinArrays.Rd - support for ScanArray Express added to read.maimages() 22 January 2006: limma 2.4.9 - New example using the sma mouse.data for arrayWeights() - All the linear model functions now use asMatrixWeights(), so that they will accept vectors of probe or array weights in place of the full matrix of weights. - new function asMatrixWeights() which will convert vectors of probe weights or array weights to a full matrix of weights. - new argument 'maxratio' for arrayWeightsSimple(). This causes the iteration to stop when the ratio of largest to smallest weights becomes large. The default tol also changed for arrayWeightsSimple(). 20 January 2006: limma 2.4.8 - Use of parent=NULL in new.env() removed from makeContrasts(), because this use is deprecated in R 2.3.0. - topTable now includes separate columns for raw and adjusted p-values - when an MArrayLM object is subsetted, the targets frame no longer subsets and the design matrix subsets only on columns. Previously the design matrix was incorrectly using j to subset rows. - bug fix to as.data.frame.MArrayLM when row subset is of length 1 3 January 2006: limma 2.4.7 - wtVariables() didn't work correctly when the variable names contained meta characters, now fixed. 2 January 2006: limma 2.4.5 - All functions normexp.*() now use simpler arguments: 'x' instead of 'foreground' and 'background' and a vector argument 'par' instead of arguments for each parameter. - normexp.fit() now uses a saddlepoint approximation to the normexp density and reverts to the Nelder-Mead optimisation method. This gives gives numerically reliable computations. - new functions dnormexp() and dnormexp.saddle() - arrayWeights() now returns a vector instead of a matrix - bug fixes to arrayWeights(), now faster and returns more accurate weights - new function arrayWeightsSimple() - subsetting of RGList, MAList and MArrayLM objects by rownames now works correctly even if not all components have rownames - S3 methods for dimnames<- now defined for RGList and MAList objects - readTargets() now checks that Labels are unique before making row.names - files argument of read.maimages() can now be a data.frame, assumed to be the targets frame. 29 November 2005: limma 2.4.4 - bug fix for decideTests() which still didn't work with adjust.method="BH" - new S3 methods fitted() and residuals() for class MArrayLM 22 November 2005: limma 2.4.3 - bug fix: read.maimages(source="genepix.*") was failing when there was only one block of spots - section on Paired Samples added to User's Guide 15 November 2005: limma 2.4.2 - note about bg.correct.rma added to normexpfit.Rd - Swirl and ApoAi case studies in User's Guide updated for limma 2.4.1 14 November 2005: limma 2.4.1 - examples for lmFit expanded and those for lm.series, gls.series and mrlm removed - instraspotCorrelation() output all.correlations renamed to atanh.correlations - duplicateCorrelation() now returns atanh-correlations, output components renamed to atanh.correlations - read.maimages(source="genepix") now uses X position column to determine printer layout information 11 November 2005: limma 2.4.0 - fitFDist() now treats very small and zero variances in a unified way. The change will change slightly the hyperparameter estimates and significance results produced eBayes(). - new option "rma" for method argument of backgroundCorrect() - minor edits to User's Guide - read.maimages() now uses check.names=FALSE to preserve annotation column names as input 9 November 2005: limma 2.3.7 - bug fix to ensure that makeContrasts() works correctly when level names happen to be the same as local variable names - edited help files for lm.series, gls.series and mrlm to make clarify that they are utility functions called by lmFit - edited lmFit.Rd to make clearer the role of correlation argument - correlation argument in lmFit() now has no default value - vennDiagram example now uses decideTests() instead of classifyTestsF() 6 November 2005: limma 2.3.6 - MAList subsetting now supports 'other' component - cbind and rbind now support 'other' component in RGList and MAList objects - limma now formally depends on R >= 2.2.0 (because of allowEscapes in read.table) - editing of help files to clarify difference between decideTests() and classifyTests - decideTests() failed with method="nestedF",adjust.method="BH", now fixed - decideTests() now supports adjust.method="BY" 31 October 2005: limma 2.3.5 - kooperberg() now gives informative error message if input not RGList 27 October 2005: limma 2.3.4 - bug fix to merge.RGList and merge.MAList. These used to break there were any components to the data objects other than intensity matrices. 25 October 2005: limma 2.3.3 - read.maimages(souce="genepix.custom",verbose=TRUE) outputs background correction method again. - calls to statmod:randomizedBlockFit changed to statmod:mixedModel2Fit - deprecated function dupcor.series() removed 19 October 2005: limma 2.3.2 - normalizeMedianDeviations and normalizeMedians replaced by normalizeMedianAbsValues. New function resistant to floating underflow. - default method for normalizeBetweenArrays changed to "Aquantile" 15 October 2005: limma 2.3.1 - read.maimages() now uses the colClasses argument to read.table, resulting in a several-fold speed improvement. Changes courtesy of Marcus Davy. - new path argument and slightly changed output names for plotMA3by2, to bring into line with imageplot3by2 changes - fix to normexp.m2loglik to prevent infinite likelihoods - fix to normexp.fit to prevent non-positive alpha - kooperberg_old() deleted 11 October 2005: limma 2.3.0 Bioconductor developmental version 11 October 2005: limma 2.2.0 Bioconductor release 1.7 - kooperberg() now accepts an RGList object instead of requiring each gpr file to be read into a separate data.frame. The old function is renamed to kooperberg_old() 6 October: limma 2.0.12 - formatting changes to User's Guide. Guide converted to LaTeX report style. 2 October: limma 2.0.11 - update citation, installation and help sections of User's Guide 30 September: limma 2.0.10 - "fdr" changed to "BH" throughout as p.adjust() method - default for topTable adjust.method changed to "BH" - point size 20 and new path argument added to imageplot3by2 - fix errors in technical replication section of User's Guide - normalizeWithinArrays now checks whether M or A are vectors 29 September: limma 2.0.9 - biocViews added to DESCRIPTION - fix to normexp.signal to allow NAs in signal 18 September: limma 2.0.8 - readImaGeneHeader entirely re-written: now supports ImaGene 6.0 and multiple sub-array fields - fixed documentation bug in normalizeWithinArrays.Rd: RG.MA produces unlogged intensities - Koorperberg ref added to User's Guide - methods package added to Depends field of DESCRIPTION file - note added to dupcor.Rd about minimum number of arrays needed for duplicateCorrelation() to return statistically useful results. 26 August: limma 2.0.7 - new option source="genepix.custom" for read.maimages() - new method "control" for normalizeWithinArrays() 23 August 2005: limma 2.0.6 - arrayWeights() was returning an error for PLMset objects, now works correctly on the chip level coefficients - eBayes now returns F.p.value component as vector rather than matrix - changes to write.fit to make it tolerant of not finding expected components such as Amean in fit object - bug fix to as.data.frame.MArrayLM when the fit contains only one contrast and there are matrices stored as vectors - several updates to Weaver case study in User's Guide: new url to download data, wt.fun error fixed, and work-around for R 2.1 bug which affects readSpotTypes() - new sections on getting help and on citation in User's Guide 8 August 2005: limma 2.0.5 - Dentritic cell direct comparison example in User's Guide now uses modelMatrix() - arrayWeights() now includes full "reml" option - modelMatrix() was not giving helpful error message if 'targets' was missing - normalizeWithinArrays(method="printtiploess") now gives informative error if layout is incompatible with data dimension 26 July 2005: limma 2.0.4 - the general form for 'columns' in read.maimages() introduced in limma 2.0.3 caused an error with agilent input. Now fixed. - added Duffinck et al 2005 reference to User's Guide - new option souce="genepix.median" for read.maimages() - default value for source argument of read.maimages() is now NULL 18 July 2005: limma 2.0.3 - documentation on components Amean, F.stat and F.p.value added to MArrayLM.Rd - columns argument of read.maimages() now can be arbitrary, provided the two foreground channels are included. Inclusion of background columns is now optional. - support for BlueFuse files added to read.maimages() - new function readBlueFuseHeader() - re-wording revision of CITATION entry, now points to http://bioinf.wehi.edu.au - normalizeWithinArrays(method="median") now uses a weighted median where appropriate - new function weighted.median() - bug fix to RGList subsetting: targets component was subsetted incorrectly with j but missing i - small fix to readGPRHeader.Rd 20 June 2005: limma 2.0.2 - last mentions of designMatrix and classifyTests removed from help docs 20 June 2005: limma 2.0.1 - work around in eBayes() for pf(q,df1,df2=Inf) bug in R 2.1.0 - all mentions of rlm.series in help changed to mrlm - New introductory chapters 04.Background and 08.Tests for the online help system. Cleaning up of chapter system. - Extensive clean-up of background correction functions based on the normexp distribution. fit.normexp0 and m2loglik.normexp removed. Functions now called normexp.fit, normexp.m2loglik, normexp.grad and normexp.signal. - deprecated functions designMatrix() and classifyTests() removed - makeContrasts() now accepts expression- or character-valued variable arguments - Weng et al (2004) and Uppalapati et al (2005) references added to User's Guide 2 June 2005: limma 2.0.0 - fix background correction bug in plotDensities(), Rb was subtracted twice - changelog.txt used to refer to the Bionconductor NEWS log for changes prior to Dec 2003. Since the NEWS file is no longer on the Bioconductor site, the early information has now been incorporated into this file. - better starting value estimation for fit.normexp() - convest() now checks that input p-values are between 0 and 1. 21 May 2005: limma 1.10.0 Same as limma 1.9.6. Version number bumped for Bioconductor devel repository. 5 May 2005: limma 1.9.6 - updates to arrayWeights() to better handle NAs, no change to API 2 May 2005: limma 1.9.5 - fix to regular expression in readGAL(), because R 2.1.0 follows stricter reg expression syntax - update reference in User's Guide (within-array paper published 1 May 2005) 26 April 2005: limma 1.9.4 - further fix to bibtex references in User's Guide - fix to [.MArrayLM when components are vectors rather than matrices - added reference to lmscfit.Rd - added comments about 'correlation' to lmfit.Rd 25 April 2005: limma 1.9.3 - updates to references in User's Guide - syntax fix to TestResults.Rd - change to wording of error message with decideTests(method="nestedF") and NA p-values 23 April 2005: limma 1.9.2 - edits to topTable.Rd and decideTests.Rd - gls.series() now returns error when ndups>2 and block is non-NULL 14 April 2005: limma 1.9.1 - In read.maimages() and readImaGeneHeader: argument allowEscapes=FALSE added to use of scan() to prevent new "feature" in R 2.1.0 - new method as.data.frame.MArrayLM 6 April 2005: limma 1.9.0 - bug fix to getLayout2() when GAL-file has no header 6 April 2005: limma 1.8.23 - readImaGeneHeader now allows for headers up to 100 lines (previously 60) - comments in Between Arrays Normalization of usersguide.pdf about non-negative background correction - some additions to venn.Rd, say explicitly now that Venn diagrams for no more than three contrasts - corrections to code in Time Course Experiments section of User's Guide - duplicateCorrelation() now traps error condition when all non-missing observations for a gene belong to same block - topTable() default column name for gene names is now 'ProbeID' - lmFit() captures rownames if object is matrix - update to topTable.Rd on adjusted p-values 24 Feb 2005: limma 1.8.22 - note added to dupcor.Rd that the function may issue some warnings - section added to User's Guide on "software packages using limma" - corrected text version component of CITATION 8 Feb 2005: limma 1.8.21 - new version of arrayWeights() by Matt Ritchie, old version renamed to arrayWeightsQuick() - modifications to m2loglik.normexp function and derivatives, grloglik() removed 2 Feb 2005: limma 1.8.20 - Note on possibility of adjusted p-values all equal to one added to topTable.Rd - bug fix in normalizeRobustSpline when Sigma0==0, i.e., when method reduces to global spline - CITATION updated to Bioconductor book chapter 1 Feb 2005: limma 1.8.19 - New BFGS version of fit.normexp by Jeremy Silver introduced, old Nelder-Mead version renamed to fit.normexp0. Several new utilities functions compute the likelihood and gradient for the BFGS version. - signal.normexp() more resistant to floating overflow/underflow - decideTests() now allows for NA p-values for method="separate" or "global" (was giving wrong answers) - summary.TestResults now allowed for NA p-values - User's Guide starts to use bibtex, not fully converted yet - new sections "Time Course Experiments" and "Separate Channel Analyses" in user's guide - 'columns' argument no longer overwrites 'source' argument of read.maimages() - readTargets() now looks for columns "Label" or "FileName" to make row.names if row.names arg is NULL - removeExt() now coerces argument to character 13 Jan 2005: limma 1.8.18 - Bug fixes to lmFit with NoWts and df.residual equal to 0 or 1 - new section "Several Groups" in user's guide 10 Jan 2005: limma 1.8.17 - uniquegenelist() now preserves data.frame or matrix class. This fixes a bug when fitting a model to an exprSet object with duplicate probes. 9 Jan 2004: limma 1.8.16 - bug fix for lmFit() when no weights or NAs (NoWts) but non-estimable coefficients 8 Jan 2004: limma 1.8.15 - lm.series() and lmFit() now treat linear model with no weights or NAs (NoWts) as a special case, with great increase in speed for typical Affymetrix analysis - lmFit() better recognises when an marrayNorm object has a non-empty list of gene names - new User's Guide section of Adjusting for Multiple Testing 16 Dec 2004: limma 1.8.14 - fix !is.infinite bug in starting values for fit.normexp() - tests for version of R removed from trigamma.inverse() and .vsimpleLoess() 9 Dec 2004: limma 1.8.13 - log and unlog arguments removed from MA.RG() and RG.MA(). RGLists are now always assumed to contain unlogged intensities. - changes to plotDensities() to accommodate above - bug fix to normalizeBetweenArrays with method="Gquantile" or "Rquantile". Now changes only the A-values. 2 Dec 2004: limma 1.8.12 - fix to last section of User's Guide: quantile normalization code example was garbled - bug fix in plotDensities(): object=MAList and log.transform=TRUE should give log not log-log scale 1 Dec 2004: limma 1.8.11 - log.transform=TRUE now the default for plotDensities(), corresponding changes to help doc - new argument unlog for RG.MA() 23 Nov 2004: limma 1.8.10 - bug fix for summary.TestResults to remove reference to 'results' - fit.normexp() now catches and reports optimization errors - decideTests() now runs eBayes() if MArrayLM object found not to contain t-statistics 4 Nov 2004: limma 1.8.9 - new argument '...' for readTargets() - intraspotCorrelation() now uses try() to tolerate some fit errors from remlscore() - decideTests.Rd now longer says 'object' arg can be a matrix - convest() now plots pi0 in title of plot for doplot=TRUE - bug fix: changeLog() was always displaying 20 lines, also assumed "/" separator 29 Oct 2004: limma 1.8.8 - bug fix: lmFit() should call mrlm() not rlm.series() 29 Oct 2004: limma 1.8.7 - limma now officially requires R 2.0 (because of lazyloading) - new function convest() - new function arrayWeights() - as.matrix() methods for all data classes 27 Oct 2004: limma 1.8.6 - new function volcanoplot() - further editing of all sections of the User's Guide, especially the Weaver case study and the section on between-array normalization - limmaUsersGuide() now outputs file format rather than URL format, i.e., no file:/// prefix - slicker summary.TestResults 23 Oct 2004: limma 1.8.5 - limma.Rtex no longer refers to openVignette(), because this won't find the User's Guide - html version of User's Guide removed - limmaguideURL() replaced with limmaUsersGuide() - aaa.R containing 'library("methods")' removed 22 Oct 2004: limma 1.8.4 - lm.series now preserves rownames in M (when ndups=1) - updates to geneSetTest.Rd: (i) warning re use with F-like statistics, (ii) better example 20 Oct 2004: limma 1.8.3 - fix bug (introduced 1.7.8 or later) for read.maimages() with Agilent data - further development of "Special Designs" section of User's Guide 14 Oct 2004: limma 1.8.2 - New section on "Special Designs" for User's Guide - heatDiagram() now chooses col range more carefully so that red is associated only with positive fold changes and green with negative - new argument 'mar' for heatDiagram() 10 October 2004: limma 1.8.1 - new argument other.columns for read.maimages() - [.RGList and MA.RG() now accommodate an 'other' component - many edits to text of User's Guide - usersguide.pdf updated from usersguide.tex - usersguide.html converted to usersguide.tex 8 October 2004: limma 1.8.0 - install.R file removed, replaced with LazyLoad: yes in DESCRIPTION - MA.RG() and normalizeWithinArrays() now accept arguments 'bc.method' and 'offset' 4 October 2004: limma 1.7.9 - bug fix for lmFit() for PLMset object 25 September 2004: limma 1.7.8 - read.maimages() now tries to set $printer layout with Agilent data - citation entry for limma - contrasts.fit() now stops with error message if attempt to take contrast of non-estimable parameter - further bug fix to contrasts.fit() when there are non-estimable coefficients - new function changeLog() - limmaguideURL() now uses system.file() - heatDiagram() now separates primary up and down genes with white space 18 September 2004: limma 1.7.7 - new section on Installation for User's Guide - bug fix to kooperberg() when background is zero - new function geneSetTest() - help doc for imageplot updated - imageplot() now traps infinite z values and issues an informative error - update to swirl example in User's Guide (warnings on p-values) - update to ApoAI example in User's Guide (comments on scale normalization, more recent version of data object) 6 September 2004: limma 1.7.6 - bug fixes to decideTests() for method="heirarchical" and method="nestedF" 2 September 2004: limma 1.7.5 This version was the first posted to CRAN as well as to Bioconductor - Now passes R CMD check under R 2.0 - example into User's Guide of wt.fun arg of read.maimages() using multiple columns - rlm.series() deprecated in favor of mrlm() - new function decideTests() for global multiple testing across probes and contrasts - anova.MAList checks if design matrix has more than one column - new function nonEstimable() - lmFit() now reports non-estimable coefficients - bug fix to contrasts.fit() when there are non-estimable coefficients 20 July 2004: limma 1.7.4 - normalizeWithinArrays(method="composite") now allows for NAs - added fill=TRUE to read.table() in readTargets() - fix bug causing dim on RGList, MAList and MArrayLM to return NULL when just one column - write.fit() now works on MArrayLM objects when eBayes has not been used 3 July 2004: limma 1.7.3 - plotMA() now does single-channel MA-plots and accepts exprSet and matrix objects - imageplot legend now rounds numbers to 1 decimal place - GenePix Allocation List to GenePix Array List throughout 2 July 2004: limma 1.7.2 - in Windows, loading limma twice no longer creates extra "Vignettes" menus - bug fixes to read.imagene() to account for changes to readImaGeneHeader() on 8 June 28 June 2004: limma 1.7.1 - cex=16,pch=0.2 now default in plotMA() - cex=16,pch=0.1 changed to cex=16,pch=0.2 throughout User's Guide - calls in normalizeRobustSpline() to rlm() now explicitly set prior weights 28 June 2004: limma 1.7.0 All the linear modelling functions now pass the covariance matrix Of the estimated coefficients. This improves support for models with covariance structures: random effects models for technical replicates, mixed models for log-intensity analysis of two color data, duplicate spots etc. Lots of updates to help files. pdf of User's Guide updated. Reading of GPR headers now supported. - pdf version of User's Guide updated - estrogen case study re-done for User's Guide - many .Rd files revised - instances of missing() changed to is.null() is modelMatrix() - lm.series(), rlm.series(), gls.series() and lmscFit() now save cov matrix of coefficients - contrasts.fit() and classifyTestF() now use cov matrix of coefficients in data object - changed many external links in .Rd files to reflect movement of functions from base to stats and graphics in R 1.9.0 - readGPRHeader() no longer assumes any known fields - lmFit() now accepts PLMset objects - changelog.txt moved to /inst/doc 21 June 2004: limma 1.6.14 - eBayes() checks design for full rank before computing F-statistic - Fix link to convert:coerce in array2channel.Rd - plotMA() now accepts MarrayLM objects - new background correction method "normexp" and associated functions - summary methods for RGList, MAList and MArrayLM 14 June 2004: limma 1.6.13 - changelog.txt (this file) included in /archive - new function imageplot3by2() to write plots to files - imageplot() now shows z-range legend - new argument 'offset' for backgroundCorrect() 8 June 2004: limma 1.6.12 - updates to read.maimages() to handle new format SMD files - periods removed from names of output from readImaGeneHeader() - read.maimages() now calls readGPRHeader() to get skip records for each gpr file - readGPRHeaders() renamed to readGPRHeader() - readImageneHeaders() renamed to readImaGeneHeader() - new function protectMetachar() - new function trimWhiteSpace() - update to kooperberg() help page example - kooperberg() now returns RGList - new function getLayout2() which reads GAL file headers - fill=TRUE added to read.table() calls in read.maimages() - "Quick Start" section in User's Guide now uses readTargets() - new function readSMDHeader() - new function tZscore(), updates to zscore help page - bug fix for vennCounts() when no sig results for one or more contrasts - eBayes() now returns F-statistics and corresponding p-values 29 May 2004: limma 1.6.11 - expanded function descriptions in 7.Diagnostics.Rd - fix Satterthwaite spelling errors - new function plotMA3by2() - plotMA() no longer plots points with zero weight by default 25 May 2004: limma 1.6.10 - example and help page updates for lmscFit() and intraspotCorrelation() - bug fix to array2channel() when Cy3/Cy5 are the only columns 24 May 2004: limma 1.6.9 - further comments on "vsn" normalization in the help entry for normalizeBetweenArrays() 22 May 2004: limma 1.6.8 - update contrasts.fit help page to cover general design matrices, lmFit() - new argument 'design' for contrasts.fit 21 May 2004: limma 1.6.7 - update User's Guide to refer to marray package - fix numerical bug in contrasts.fit for non-orthog design matrix 14 May 2004: limma 1.6.6 - new argument 'grep' for array2channel() - Estrogen case study redone for user's guide. - Made pdf of User's Guide. 14 May 2004: limma 1.6.5 - smooothVar() renamed to squeezeVar() - array2channel() behaves nicely for zero-size data.frames - dim() correctly returns c(0,0) for zero-size RGList, MAList, MArrayLM objects - optional arguments in normalizeBetweenArrays() changed to ... - default for 'ties' in normalizeQuantiles() changed to TRUE 10 May 2004: limma 1.6.4 - method="vsn" added to normalizeBetweenArrays() 7 May 2004: limma 1.6.3 - merge method for MAList objects - functions FStat, dupcor.series, classifyTests now use match.call() and eval() - clean up help entry for auROC() - fix documentation bug for topTable(adjust=NULL) 19 April 2004: limma 1.6.2 - new documentation entry on single channel analysis - new function intraspotCorrelation() - lmsc.series() renamed to lmscFit(), now produces an MArrayLM object 7 April 2004: limma 1.6.1 - fix to printHead to treat factors as as vectors - new argument cex for vennDiagram 6 April 2004: limma 1.6.0 - additional argument block to duplicateCorrelation, gls.series and lmFit to treat technical replicates as randomized blocks - new methods Rquantile, Gquantile, Tquantile for normalizeBetweenArrays - lmFit now extracts probe IDs from exprSet object - Ecoli-lrp case study added to User's Guide 29 March 2004: limma 1.5.9 - backgroundCorrect(,method="edwards") now handles NAs - bug fixes to backgroundCorrect(,method="edwards") - classifyTests() renamed to classifyTestsF() - classifyTestsP() now extracts degrees of freedom from object - read.maimages no longer disallows source= and columns= together 20 March 2004: limma 1.5.8 - internal links added to contents section of User's Guide - changed calling sequence in duplicateCorrelation() to randomizedBlockFit, limma now depends on package statmod >= 1.0.6 - two changes to plotPrintTipLoess() to avoid warning messages - bug fix to duplicateCorrelation() to avoid test on rho[i] when NA 15 March 2004: limma 1.5.7 - fixes to write.fit() to accomodate TestResults class - Sweave-style vignette added, as well as User's Guide - new function array2channel() to targets files from by-array to by-channel representation - removed warning about Cy3, Cy5 columns from readTargets() - more general use of 'ref' in modelMatrix(), doesn't have to occur on every array - target names are sorted in modelMatrix() - designMatrix() renamed to modelMatrix(), designMatrix deprecated - new function lmsc.series() for single-channel linear models 12 March 2004: limma 1.5.6 - tetragamma() changed to psigamma(x,deriv=2) with R version check 9 March 2004: limma 1.5.5 - bug fix to normalizeRobustSpline() to prevent error when spline basis becomes singular - La.eigen() to eigen() in is.fullrank() - case study Estrogen added to User's Guide 8 Mar 2004: limma 1.5.4 Now passes R CMD check in R 1.9.0dev. - new argument 'mar' for vennDiagram(), reduces white-space for venn Diagrams - new argument 'annotation' for read.maimages() - fix bug in gls.series to ensure that spacing and weights arguments are passed to duplicateCorrelation() - check for R version when setting package argument for .C and .Fortran calls 4 Mar 2004: limma 1.5.3 - new function smoothVar() - fix 'ProbUID' typo for source="agilent" 26 Feb 2004: limma 1.5.2 - source="agilent" added to read.maimages - bug fixed in heatdiagram() and heatDiagram() which caused over-printing when using par(mfrow) - vennCounts() now uses table() for major computation and is therefore much faster - new function FStat() - S3 class "classification" replaced by S4 class "TestResults", including 'show' and 'summary' methods - classifyTests(), classifyTestsT() and classifyTestsP() now produce "TestResults" objects 21 Feb 2004: limma 1.5.1 - removed package argument from calls to .C and .Fortran loess hooks in modreg package. Edited package dependencies in DESCRIPTION file. These two changes allow the code to pass R cmd check in both R 1.8.1 and R 1.9.0 (dev) and allows the development and release versions of limma to be consolidated. 30 Dec 2003: limma 1.5.0 (Bioconductor devel version only) - bug fix for designMatrix() (was giving wrong matrix when common reference was Cy5 for first array) - bug fix to printorder() with spacing="topbottom" (was returning vectors of wrong length) - new function modifyWeights() - designMatrix() now uses zapsmall() to eliminate small non-zero entries - readGAL() now sorts GAL files into standard order if they are not already - read.maimages() function now sets the genelist directly from the gpr files, so readGAL() will usually no longer be required - new function auROC() to compute exact area under ROC 18 Feb 2004: limma 1.3.18 - fix bug in duplicateCorrelation() which was not finding the M matrix when object was not an MArrayLM 17 Feb 2004: limma 1.3.17 - new argument 'resort.by' for toptable() and topTable() 16 Feb 2004: limma 1.3.16 - changes to loessFit() to avoid errors with small numbers of observations - argument 'path' added to readSpotTypes() and readTargets() - check in duplicateCorrelation() for correlation less than -1 - more expository comments added to 2.Classes.Rd 8 Feb 2004: limma 1.3.15 - duplicateCorrelation now uses randomizedBlockFit from the statmod package instead of gls from the nlme package. This results in a several-fold increase in speed for duplicateCorrelation and dupcor.series. - dupcor.series now deprecated - getLayout() now has option to guess spacing between duplicate spots - new function blockDiag() to form block diagonal matrices - fix bug in imageplot() which caused overprinting of plots when using par(mfrow) 23 Jan 2004: limma 1.3.14 - new function poolVar to Welch-style pooling of sample variances with unequal variances - new functions usersguideURL() and .First.lib() to implement limma entry in Windows drop-down Vignettes menu 18 Jan 2004: limma 1.3.13 - bug fix for write.fit() (was failing when adjust p-values with multiple contrasts) - Updates to references - linear modelling paper now accepted for publication 30 Dec 2003: limma 1.3.12 - bug fix for designMatrix() (was giving wrong matrix when common reference was Cy5 for first array) 29 Dec 2003: limma 1.3.11 - bug fix to printorder() with spacing="topbottom" (was returning vectors of wrong length) - new function modifyWeights() - designMatrix() now uses zapsmall() to eliminate small non-zero entries 26 Dec 2003: limma 1.3.10 - readGAL() now sorts GAL files into standard order if they are not already - read.maimages() function now sets the genelist directly from the gpr files, so readGAL() will usually no longer be required - new function auROC() to compute exact area under ROC 20 Dec 2003: limma 1.3.9 - new function getSpacing() - upgrades to printorder() to accommodate spacing by rows or topbottom - corrections and updates to try to pass R CMD check in R1090dev, but cannot get around that package nlme seems to be broken. 13 Dec 2003: limma 1.3.8 - bug fix to backGroundCorrect(method="edwards") - bug fix to plotPrintTipLoess() - refinements to estimation of var.prior in ebayes and related functions - coerce (setAs) method for RGList to exprSet2 7 Dec 2003: limma 1.3.7 rbind method for MAList objects 6 Dec 2003: limma 1.3.6 - fix to readSpotTypes() to read column names as.is - new ... argument for readSpotTypes() - rbind method for RGList objects - bug fix for designMatrix() 1 Dec 2003: limma 1.3.5 - designMatrix() now has new arguments and now handles direct designs - new function write.fit() for outputing results of linear model fit 18 Nov 2003: limma 1.3.4 - fix bug with exprSet object in lmFit() 15 Nov 2003: limma 1.3.3 - new function write.fit 11 Nov 2003: limma 1.3.2 - substantial upgrade to functions which identify and track control spots from the gene list including readTargets(), readSpotTypes(), controlStatus() and plotMA() - Routine edits to User's Guide Nov 05 2003: limma 1.3.1 - Bug fix for as.MAList - Slightly changed comments in install.R and aaa.R 7 October 2003: limma 1.2.8 - new function readGPRHeaders() - getImageneHeaders() renamed to readImageneHeaders 2 October 2003: limma 1.2.7 - read.imagene now allows for changes of header info between arrays - bug fix in "minimum" method for backgroundCorrect() 1 October 2003: limma 1.2.6 - new method "edwards" for backgroundCorrect() - added html index of vignettes for R 1.8.0 - update to manual 27 Sep 2003: limma 1.2.5 - changes to read.maimages for ArrayVision data - bug fix for wtIgnore.Filter with GenePix data - new argument 'ties' for normalizeBetweenArrays. GKS 20 Sep 2003: limma 1.2.4 - ensure that limma passes rcmd check for R 1.8.0 - fix bug in toptable which affected the displayed A-values - new option 'none' for method argument of backgroundCorrect() - new argument 'mar' for imageplot() 15 Sep 2003: limma 1.2.0 - fix bug in quantarray read - classifyTests now returns F-statistic 9 September 2003: limma 1.1.18 - new function plotDensities - new section in User's Guide on single channel normalization, both by Natalie Thorne 6 September 2003: limma 1.1.17 - new backgroundCorrect options "half", "minimum" and "movingmin" 4 September 2003: limma 1.1.16 - new argument 'include' in vennCounts and vennDiagram - Support for correlated design matrices added to contrasts.fit() 3 September 2003: limma 1.1.15 - new class exprSet2 - new function topTable - New argument 'bin' in loessFit - Fine tuning of interpolation settings used by loessFit. Corresponding changes to documentation 2 September 2003: limma 1.1.14 - read.maimages now supports SMD data files 29 August 2003: limma 1.1.13 - reorganization of heatdiagram and classifyTests functions 28 August 2003: limma 1.1.12 - add ArrayVision support to read.maimages - Many other small changes including a backgroundCorrect method to ensure positive intensities - Expansion of sections on reading data in User's Guide. 15 Aug 2003: limma 1.1.11 - added functionality to read Imagene data to read.maimages 4 August 2003: limma 1.1.9 - bug fix to loessFit - Gradually introducing object orientated versions eBayes of ebayes, topTable of toptable, heatDiagram of heatdiagram 5 July 2003: limma 1.1.7 - support for much extra structure in RGList and MAList objects - representation of MArrayLM class reverts to list - support for marrayNorm and exprSet objects by lmFit - new function makeContrasts to construct contrast matrices - new function duplicateCorrelation - classifyTests now supports MArrayLM objects - new function classifyTests43 for simple t-stat thresholding - new functions vennCounts and vennDiagram for Venn diagram plots - update of LinearModels documentation to reflect changes 29 June 2003: limma 1.1.5 - subsetting methods for RGList and MAList objects - Bug fix for cbind method for RGLists 28 June 2003: limma 1.1.4. - New function designMatrix to construct design matrices for microarray experiments with common references - cbind methods for MAList and RGList objects - New function loessFit giving substantial speed improvements for loess normalization 23 June 2003: limma 1.1.3 - extra arguments added to kooperberg function - Internal kooperberg functions now hidden from user - New affy example added to User's Guide. June 19, 2003: limma 1.1.2 - bug fixes to classifyTests - normalizeForPrintorder (no longer generic) and plotPrintorder - ClassifyTests now accepts design and contrast matrices June 15, 2003: limma 1.1.1 - new functions for Kooperberg Bayesian background correction - modreg now required for R earlier than 1.7.0 - normalizeWithinArrays no longer generic to simplify documentation - Documentation for normalizeBetweenArrays also consolidated - New virtual class LargeDataObject and associated show method June 12, 2003: limma 1.1.0. - New function lmFit() - classifyTests fixed June 11, 2003: limma 1.0.9 - first version of MArrayLM class - Start on bug fix to classifyTests May 23, 2003: limma 1.0.8 - corrected bug in read.maimages for quantarray data - Added wtIgnore.Filter function for quantarray data May 19 2003: limma 1.0.7 - printable pdf version of User's Guide - use of chol pivot in classifyTests.vector - couple of typos corrected May 18 2003: limma 1.0.6 - minor cleaning up of documentation files and vignette ready for BioC release. 10 May, 2003: limma 1.0.5 - new function 'printorder', - added sma to dependencies in DESCRIPTION - updates and corrections to User's Guide May 7 2003: limma 1.0.4 basically a file permission change. May 4 2003: limma 1.0.3 New function printorder. Correct typo in DESCRIPTION. Alias for merge method to reflect dispatching on two arguments. Apr 29 2003: limma 1.0.2 Fixed bug in ebayes when more than two coefficients (bug introduced on Apr 25). Added new normalization method, robust splines. Changes to plotPrintTipLoess. Several changes to .Rd files. Apr 27 2003: limma 1.0.1 Several new help topics and consolidation of a couple of old ones. Correction of a couple of small code bugs concerning creation of classed objects by MA.RG and backgroundCorrect. Other minor changes to help topics entries. Apr 26 2003: limma 1.0 Apr 25 2003: limma 0.9.7 The smawehi package was renamed to limma, with the title "Linear Models for Microarray Data" and became part of the Bioconductor project. 11 November 2002: smawehi 0.1 smawehi package made publicly available for the first time, through the repository http://bioinf.wehi.edu.au/smawehi, for the One Day Course "Statistics for Microarray Data Analysis" at the Australian Genstat Conference, Perth, Australia, 2 December 2002. This package was intended to be used in conjunction with sma from UC Berkeley. PRE-HISTORY The limma package was originally called the smawehi package, which was made public for the first time as SMAWEHI Version 0.1 for the One Day Course "Statistics for Microarray Data Analysis" at the Australian Genstat Conference, Perth, Australia, 2 December 2002. Presenters were Terry Speed, Gordon Smyth and Natalie Thorne. The package was served from an R repository at http://bioinf.wehi.edu.au. With version 0.9.7 the package was renamed to 'limma' and became part of the Bioconductor project at http://www.bioconductor.org. limma/inst/doc/limma.Rnw0000755007451300017500000000325712127125250015330 0ustar charlescharles%\VignetteIndexEntry{Limma Vignette} %\VignetteDepends{} %\VignetteKeywords{microarray linear model} %\VignettePackage{limma} \documentclass[12pt]{article} \textwidth=6.2in \textheight=8.5in \oddsidemargin=0.2in \evensidemargin=0.2in \headheight=0in \headsep=0in \begin{document} \title{Limma Package Vignette} \author{Gordon Smyth} \date{23 October 2004} \maketitle Limma is an R package for the analysis of gene expression microarray data, especially the use of linear models for analysing designed experiments and the assessment of differential expression. Limma provides the ability to analyse comparisons between many RNA targets simultaneously in arbitrary complicated designed experiments. Empirical Bayesian methods are used to provide stable results even when the number of arrays is small. The normalization and data analysis functions are for two-color spotted microarrays. The linear model and differential expression functions apply to all microarray technologies including Affymetrix and other single-channel oligonucleotide platforms. The full Limma User's Guide is available as part of the online documentation. To reach the User's Guide you need to install the limma package. If you've installed the package and you're using Windows, type \texttt{library(limma)} at the R prompt then click on ``limma'' from the drop-down menu called ``Vignettes''. If you're not using Windows, you can type \begin{Schunk} \begin{Sinput} > library(limma) > limmaUsersGuide() \end{Sinput} \end{Schunk} or alternatively \begin{Schunk} \begin{Sinput} > help.start() \end{Sinput} \end{Schunk} and follow the links to the limma package help. \end{document} limma/src/0000755007451300017500000000000012175636024012605 5ustar charlescharleslimma/src/normexp.c0000644007451300017500000002257012175636024014447 0ustar charlescharles/* normexp fitting Jeremy Silver, Dec 2007 Minor modifications by Gordon Smyth, Sep 2008 Minor change to memory allocation by Jeremy Silver, Sep 2008 */ #include #include #include #include #include double *x; int *n; void ex(){} double normexp_m2loglik_saddle(int m, double *par, void *ex){ // normexp minus-twice log-likelihood // Function of mu, log(sigma) and log(alpha) extern int *n; extern double *x; double mu; mu = par[0]; double sigma, sigma2; sigma = exp(par[1]); sigma2 = sigma*sigma; double alpha; alpha = exp(par[2]); double upperbound1; double upperbound2; double *upperbound; double *theta; double k1,k2,k3,k4; double err; double c0; double c1; double c2; double logf; double omat, omat2; double loglik; double thetaQuadratic; int keepRepeating = 1; int j,i; double maxDeviation; int *hasConverged; // vector of 0/1 indicators, // hasConverged[i] = 0 if theta[i] has not yet converged, // hasConverged[i] = 1 if theta[i] has converged, int nConverged = 0; // the sum of hasConverged double alpha2 = alpha * alpha; double alpha3 = alpha * alpha2; double alpha4 = alpha2 * alpha2; double dK, ddK, delta; upperbound = (double *) Calloc(*n, double); theta = (double *) Calloc(*n, double); hasConverged = (int *) Calloc(*n, int); c2 = sigma2 * alpha; for(i = 0; i < *n; i++){ err = x[i] - mu; // Sigma small approximation upperbound1 = fmax(0.0, ((err - alpha)/( alpha * fabs(err)))); // alpha small approximation upperbound2 = err/sigma2; upperbound[i] = fmin(upperbound1, upperbound2); c1 = -sigma2 - err * alpha; c0 = -alpha + err; // Solve quadratic approximation // Theoretically exact, but subject to subtractive cancellation thetaQuadratic = (-c1 - sqrt(c1*c1 - 4 * c0 * c2) ) / (2*c2); theta[i] = fmin(thetaQuadratic,upperbound[i]); hasConverged[i] = 0; } // Globally convergence Newton iteration j = 0; while(keepRepeating == 1){ j++; maxDeviation = 0.0; for(i = 0; i < *n; i++){ // Only loop over entries of theta[.] that haven't yet converged if(hasConverged[i] == 0){ omat = 1 - alpha * theta[i]; dK = mu + sigma2 * theta[i] + alpha / omat; ddK = sigma2 + alpha2 / (omat*omat); delta = (x[i] - dK)/ddK; theta[i] += delta; if (j == 1){ theta[i] = fmin(theta[i], upperbound[i]); } if(fabs(delta) < 1e-10){ hasConverged[i] = 1; nConverged++; } } } if(nConverged == *n || j > 50){ keepRepeating = 0; } } R_CheckUserInterrupt(); loglik = 0.0; for(i = 0; i < *n; i++){ omat = 1 - alpha * theta[i]; omat2 = omat*omat; k1 = mu * theta[i] + 0.5 * sigma2 * theta[i] * theta[i] - log(omat); k2 = sigma2 + alpha2/omat2; logf = -0.5 * log(2.0 * M_PI * k2) - x[i] * theta[i] + k1; k3 = 2.0 * alpha3/(omat * omat2); k4 = 6.0 * alpha4/(omat2 * omat2); logf += k4/(8.0 * k2 * k2) - (5.0 * k3 * k3)/(24.0 * k2 * k2 * k2); loglik += logf; } Free(upperbound); Free(theta); Free(hasConverged); return -2.0 * loglik; } /* k <- mu * theta + 0.5 * sigma^2 * theta^2 - log(1 - alpha * theta) k2 <- sigma^2 + alpha^2/(1 - alpha * theta)^2 logf <- -0.5 * log(2 * pi * k2) - x * theta + k if (secondorder) { k3 <- 2 * alpha^3/(1 - alpha * theta)^3 k4 <- 6 * alpha^4/(1 - alpha * theta)^4 logf <- logf + 1/8 * k4/k2^2 - 5/24 * k3^2/k2^3 } */ void fit_saddle_nelder_mead(double *par, double *X, int *N, int *fail, int *fncount, double *Fmin){ // Minimize normexp m2loglik by Nelder-Mead // as a function of mu, log(sigma) and log(alpha) double parsOut[3]; parsOut[0] = par[0]; parsOut[1] = par[1]; parsOut[2] = par[2]; double abstol = -1e500; // infinity double intol = 1.490116e-08; // square root of machine precision void ex(); double alpha = 1.0; double beta = 0.5; double gamma = 2.0; int trace = 0; int maxit = 500; extern int *n; extern double *x; n = N; x = X; nmmin(3, par, parsOut, Fmin, normexp_m2loglik_saddle, fail, abstol, intol, &ex, alpha, beta, gamma, trace, fncount, maxit); par[0] = parsOut[0]; par[1] = parsOut[1]; par[2] = parsOut[2]; } void normexp_m2loglik(double *mu, double *s2, double *al, int *n, double *f, double *m2LL){ // normexp minus-twice log-likelihood // as a function of mu, sigma^2 and alpha double e; double mu_sf; double s2onal = *s2/ *al; double logal = log(*al); double s2on2al2 = 0.5 * *s2/(*al * *al); double s = sqrt(*s2); int i; *m2LL = 0.0; for(i = 0; i < *n; i++){ e = f[i] - *mu; mu_sf = e - s2onal; *m2LL += -logal - e/ *al + s2on2al2 + pnorm(0.0,mu_sf,s,0,1); } // -2*sum(-log(al) - e/al + 0.5*s2/(al^2) + pnorm(0,mu.sf,sqrt(s2),lower.tail = FALSE,log.p = TRUE)) *m2LL *= -2.0; } void normexp_gm2loglik(double *mu, double *s2, double *al, int *n, double *f, double *dm2LL){ // gradient of normexp m2loglik // with respect to mu, log(sigma^2) and log(alpha) double e; double mu_sf; double s2onal = *s2/ *al; double s = sqrt(*s2); double v1onal = 1/ *al; double psionPsi; double al2 = *al * *al; double s2onal3 = *s2/(al2 * *al); double v1on2al2 = 0.5/al2; double s2onal2 = *s2/al2; double v1on2s2 = 0.5/ *s2; int i; for(i = 0; i < 3; i++){ dm2LL[i] = 0.0; } // Calculate derivatives for(i = 0; i < *n; i++){ e = f[i] - *mu; mu_sf = e - s2onal; psionPsi = exp(dnorm(0.0,mu_sf,s,1) - pnorm(0.0,mu_sf,s,0,1)); dm2LL[0] += v1onal - psionPsi; dm2LL[1] += v1on2al2 - (v1onal + v1on2s2 * mu_sf) * psionPsi; dm2LL[2] += e/al2 - v1onal - s2onal3 + psionPsi * s2onal2; } // correct for taking derivatives wrt -2 times the log(likelihood) for(i = 0; i < 3; i++){ dm2LL[i] *= -2.0; } // correct for differentiation wrt log(alpha) and log(sigma^2) dm2LL[1] *= *s2; dm2LL[2] *= *al; } void normexp_hm2loglik(double *mu, double *s2, double *al, int *n, double *f, double *d2m2LL){ // Hessian of normexp m2loglik // with respect to mu, log(sigma^2) and log(alpha) double e; double mu_sf; double s2onal = *s2/ *al; double s2onalsq = s2onal*s2onal; double s2onalcu = s2onalsq*s2onal; double s = sqrt(*s2); double v1onal = 1/ *al; double v1onal2 = v1onal*v1onal; double v1onal3 = v1onal2*v1onal; double v1onal4 = v1onal3*v1onal; double v3s2onal4 = 3.0 * *s2*v1onal4; double psionPsi; double psionPsi2; double al2 = *al * *al; double s2onal3 = *s2/(al2 * *al); double v1on2al2 = 0.5/al2; double s2onal2 = *s2/al2; double s4onal4 = s2onal2*s2onal2; double s2onal4 = *s2*v1onal4; double v1on2s2 = 0.5/ *s2; double v1on2s4 = v1on2s2/ *s2; double v1on2s2sq = v1on2s2*v1on2s2; double v2onal3 = 2.0*v1onal3; double v3al = 3.0 * *al; double v2al = 2.0 * *al; double v1on4s6 = v1on2s2sq/ *s2; double eps2onal; double e2; double eps2onalsq; int i; double dL_dal = 0.0; double dL_ds2 = 0.0; double d2L_dbtdbt = 0.0; double d2L_dbtds2 = 0.0; double d2L_dbtdal = 0.0; double d2L_dalds2 = 0.0; double d2L_ds2ds2 = 0.0; double d2L_daldal = 0.0; for(i = 0; i < *n; i++){ e = f[i] - *mu; mu_sf = e - s2onal; eps2onal = e + s2onal; e2 = e*e; eps2onalsq = eps2onal*eps2onal; psionPsi = dnorm(0.0,mu_sf,s,1) - pnorm(0.0,mu_sf,s,0,1); psionPsi2 = 2.0 * psionPsi; psionPsi = exp(psionPsi); psionPsi2 = exp(psionPsi2); dL_dal += v1on2al2 - (v1onal + v1on2s2 * mu_sf) * psionPsi; dL_ds2 += e/al2 - v1onal - s2onal3 + psionPsi * s2onal2; d2L_dbtdbt += - psionPsi2 - psionPsi*mu_sf/ *s2; d2L_dbtds2 += -0.5*eps2onal*psionPsi2/ *s2 + (-eps2onalsq + 2.0*s2onal*eps2onal + *s2)*psionPsi*v1on2s4; d2L_dbtdal += -v1onal2 + s2onal2*psionPsi2 + mu_sf*psionPsi*v1onal2; d2L_ds2ds2 += -v1on2s2sq*eps2onalsq*psionPsi2 + psionPsi*(-e2*e + e*(v3al - e)*s2onal + (e + *al)*s2onalsq + s2onalcu)*v1on4s6; d2L_dalds2 += -v1onal3 + v1on2al2*(psionPsi2*eps2onal + (e2 + *s2 - s2onalsq)*psionPsi/ *s2); d2L_daldal += v1onal2 - v2onal3*e + v3s2onal4 - psionPsi2*s4onal4 - psionPsi*(mu_sf + v2al)*s2onal4; } /* d2L.dbtdbt <- sum(-psionPsi2 - psionPsi*mu.sf/s2) d2L.dbtds2 <- sum( -0.5*(e + s2onal)*psionPsi2/s2 + 0.5*(-((e + s2onal)^2) + 2*s2onal*(e + s2onal) + s2)*psionPsi/(s2^2)) # OK TO 3 DP d2L.dbtdal <- sum( -al^-2 + s2onal*psionPsi2/al + mu.sf*psionPsi/(al^2)) d2L.ds2ds2 <- sum( -(0.25/(s2^2))*((e + s2onal)^2)*psionPsi2 + psionPsi*(-e^3 + e*(3*al - e)*s2onal + (e + al)*(s2onal^2) + (s2onal^3))/(4*(s2^3)) ) d2L.dalds2 <- sum( -1/(al^3) + (al^-2)*0.5*(psionPsi2*(e + s2onal) + (e^2 + s2 - (s2onal^2))*psionPsi/s2)) d2L.daldal <- sum( (al^-2) - 2*e/(al^3) + 3*s2/(al^4) - psionPsi2*((s2^2)/(al^4)) - psionPsi*(mu.sf + 2*al)*((s2)/(al^4))) */ d2m2LL[0] = -2.0 * d2L_dbtdbt; d2m2LL[1] = -2.0 * *s2 * d2L_dbtds2; d2m2LL[2] = -2.0 * *al * d2L_dbtdal; d2m2LL[3] = -2.0 * *s2 * d2L_dbtds2; d2m2LL[4] = -2.0 * ( *s2 * *s2 * d2L_ds2ds2 + *s2 * dL_ds2); d2m2LL[5] = -2.0 * *al * *s2 * d2L_dalds2; d2m2LL[6] = -2.0 * *al * d2L_dbtdal; d2m2LL[7] = -2.0 * *al* *s2 * d2L_dalds2; d2m2LL[8] = -2.0 * ( *al * *al * d2L_daldal + *al * dL_dal); /* -2*rbind( c(d2L.dbtdbt, s2*d2L.dbtds2, al*d2L.dbtdal), c(s2*d2L.dbtds2, (s2^2)*d2L.ds2ds2 + s2*dL.ds2, al*s2*d2L.dalds2), c(al*d2L.dbtdal, al*s2*d2L.dalds2, (al^2)*d2L.daldal + al*dL.dal)) */ }