简体   繁体   English

写入制表符分隔的文件或csv文件

[英]writing to a tab-delimited file or a csv file

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. 我有一个RMA规范化数据(来自CEL文件),并想将其写入可以在excel中打开但有一些问题的文件中。

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 : 输出是在使用上述命令写入的文本文件中按行排列的,因此当导出到excel时,输出格式错误,并且随着最大行数的使用,许多信息将被切断。以下方式:

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 ? 如何以正确的格式将R中的CEL文件写入记事本或excel?

You need to extract the values from the normalised probes using the exprs function. 您需要使用exprs函数从标准化探针中提取值。 Something like: 就像是:

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

should do the trick. 应该可以。

I'm not totally clear about what the problem is, what do you mean by "proper format"? 我不清楚问题是什么,“格式正确”是什么意思? Excel will struggle with huge tables and doing your analysis in R with Bioconductor is likely a better way to go, you could then export a smaller results or summary table to excel. Excel将难以处理庞大的表格,并且使用Bioconductor在R中进行分析可能是更好的方法,然后可以导出较小的结果或汇总表以取得卓越效果。

Nevertheless, if you want the file written columnwise, you could try: 不过,如果您希望文件按列写入,则可以尝试:

write.csv(t(pre),file="norm.txt")

But excel (at least used to) allow many more rows than columns. 但是excel(至少过去)允许的行多于列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM