merging fit and MA objects
1
0
Entering edit mode
Ido M. Tamir ▴ 320
@ido-m-tamir-1268
Last seen 10.2 years ago
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('S el_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
• 911 views
ADD COMMENT
0
Entering edit mode
Ido M. Tamir ▴ 320
@ido-m-tamir-1268
Last seen 10.2 years ago
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. > I could use the merge() function, but then I don't know before hand how > many data files are being read with read.maimages. I just saw the write.fit function, and I would suggest changing that a little bit. Thats much better than writing to different files as I suggested. best wishes ido
ADD COMMENT

Login before adding your answer.

Traffic: 731 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6