writing to a tab-delimited file or a csv file

Stacey John picture Stacey John · Oct 30, 2012 · Viewed 14.2k times · Source

I have a RMA normalized data ( from the CEL files ) and would like to write it into a file that I could open in excel but have some problems.

library(affy)
cel <- ReadAffy()
pre<-rma(cel)
write.table(pre, file="norm.txt", sep="\t")
write.table(pre, file="norma.txt")

The outut is arranged row-wise in the text file that is written using the above command and hence when exported to excel it is in a wrong form and many of the information is cut off as the maximum rows are used up .The output looks the following way :

GSM 133971.CEL 5.85302 3.54678 6.57648 9.45634
GSM 133972.CEL 4.65784 3.64578 3.54213 7.89566
GSM 133973.CEL 6.78543 3.54623 2.54345 7.89767   

How to write it in a proper format from CEL files in R to a notepad or excel ?

Answer

csgillespie picture csgillespie · Oct 30, 2012

You need to extract the values from the normalised probes using the exprs function. Something like:

write.csv(exprs(pre), file="output.csv", row.names=FALSE)

should do the trick.