## # mae.loessPlot() - generate loess line and fitted plots for # for two samples if doPlot is true. The plots include: # M vs A (loess line) # M vs A (loess fitted) plots # Parameters: # x and y single sample matrices or data frames # xName and yName are sample names # doPlot = TRUE, if do a plot, else just compute the loess data # Return: # AValue is c(log10(as.matrix(x)) + log10(as.matrix(y)))/2 # MValue is c(log2(as.matrix(x)/as.matrix(y))) # dMvsA is data.frame(ID=(cbind(x,y)[,1]),AVAL=AValue, MVAL=MValue) # dMvsA.lo is loess fit of (MValue ~ AValue) # fitted is (MValue-dMvsA.lo$fitted) # sNames is c(xName,yName) # # Developer: S. Sundaram, P. Lemkin, G. Thornwal # Date: 06/30/2003 ## mae.loessPlot <- function(x,y,xName,yName,doPlot=TRUE) { # mae.loessPlot AValue <- c(log10(as.matrix(x)) + log10(as.matrix(y)))/2 MValue <- c(log2(as.matrix(x)/as.matrix(y))) dMvsA <- data.frame(ID=(cbind(x,y)[,1]), AVAL=AValue, MVAL=MValue) dMvsA.lo <- loess(MVAL ~ AVAL, dMvsA, degree=1, span=.5) samplesTitle <- paste(xName,"vs.",yName) # mTitleL <- paste("M vs A (loess line for",samplesTitle,")") if(doPlot) plot(AValue,MValue,main=mTitleL,xlab="A(log10)",ylab="M(log2)") points(AValue,dMvsA.lo$fitted, col="red", pch=18); mTitleF <- paste("M vs. A (loess fitted for",samplesTitle,")") fitted <- MValue-dMvsA.lo$fitted if(doPlot) plot(AValue,fitted,main=mTitleF,xlab="A(log10)", ylab="M(log2)") sNames=c(xName,yName) return(AValue=AValue, MValue=MValue, dMvsA=dMvsA, dMvsA.lo=dMvsA.lo, fitted=fitted, sNames=sNames) } # end of mae.loessPlot