[BioC] merging fit and MA objects

Ido M. Tamir tamir at imp.univie.ac.at
Thu Dec 1 15:22:59 CET 2005


On Wednesday 30 November 2005 20:24, Guoneng Zhong wrote:
> Hi,
>
> Is there an easy way to merge data from a fit object (from lmFit) and MA
> data (from normalizeWithinArrays) based on the genes?  I mean, I want
> the p values from the fit object and the different M values (each column
> represents an original file), matching the data based on fit$gene or
> MA$gene.
>
> Basically, what I have now is:
>         targets <- readTargets(targetFile)
> RG<-read.maimages(targets$FileName,columns=list(Rf="C5_Signal_Median",Rb="C
>5_Signal_SD",Gf="C3_Signal_Median",Gb="C3_Signal_SD"),annotation=c('Sel_Crt'
>,'Probe_Seq','Feature_ID')) RG.noBG <- backgroundCorrect(RG,method='none')
>         MA.lnorm <- normalizeWithinArrays(RG.noBG, method="loess")
>         design <- modelMatrix(targets,ref="Reference")
>         fit<-lmFit(MA.lnorm,design)
>         fit<-eBayes(fit)
>

I currently save tables of each of the contrasts together with the original 
values like this:
But I will (and you should) change a little bit

fit2Tables <- function(fit, expname, path, data ){
  contrasts <- colnames(fit$lods)
  for( ci in 1:length(contrasts)){
    tt <- topTable( fit, coef=contrasts[ci], number=nrow(fit), 
adjust.method="BH", sort.by="M" )
    ttna <- topTable( fit, coef=contrasts[ci], number=nrow(fit), 
adjust.method="none", sort.by="M" )
    tt$p_unad <- ttna$P.Value
    df <- data.frame( tt, data$M[as.integer(rownames(tt)),] )
    colnames(df) <- c(colnames(tt),paste(colnames(data$M),"M",sep="_"))
    write.table( df, file=paste( path,"/", expname, "_", contrasts[ci], 
".tab", sep=""), sep="\t", row.names=FALSE, quote=FALSE )
  }
}

change by untested:
tt$p_unad <- ttna$P.Value
to:
tt$p_unad <- ttna$P.Value[rownames(tt)]
just in case some probes have the same M values

Hope this helps
Ido



More information about the Bioconductor mailing list