我试图保存的对象是在用chipseeker
库注释区域后生成的
class(peakAnnoList)
[1] "list"
因此,如果我尝试查看对象内的数据,我会得到这样的结果
peakAnnoList
$DOWN
Annotated peaks generated by ChIPseeker
9458/9458 peaks were annotated
Genomic Annotation Summary:
Feature Frequency
5 Promoter 12.359907
1 1st Exon 1.776274
4 Other Exon 5.783464
3 Downstream (<=300) 1.733982
2 Distal Intergenic 78.346373
$High
Annotated peaks generated by ChIPseeker
15395/15395 peaks were annotated
Genomic Annotation Summary:
Feature Frequency
5 Promoter 7.392010
1 1st Exon 1.779799
4 Other Exon 7.417993
3 Downstream (<=300) 2.949009
2 Distal Intergenic 80.461189
$Low
Annotated peaks generated by ChIPseeker
6043/6043 peaks were annotated
Genomic Annotation Summary:
Feature Frequency
5 Promoter 8.406421
1 1st Exon 1.472778
4 Other Exon 4.517624
3 Downstream (<=300) 1.373490
2 Distal Intergenic 84.229687
$UP
Annotated peaks generated by ChIPseeker
16628/16628 peaks were annotated
Genomic Annotation Summary:
Feature Frequency
5 Promoter 9.123166
1 1st Exon 1.677893
4 Other Exon 7.373106
3 Downstream (<=300) 3.103199
2 Distal Intergenic 78.722637
所以这些就像我注释的每个类别。
现在要访问更多信息并将它们保存到数据框中,我必须这样做
UP <- as.data.frame(peakAnnoList[["UP"]]@anno)
DOWN <- as.data.frame(peakAnnoList[["DOWN"]]@anno)
High <- as.data.frame(peakAnnoList[["High"]]@anno)
Low <- as.data.frame(peakAnnoList[["Low"]]@anno)
如何将其保存到单个文件中
任何建议或帮助都会非常有帮助
您可以使用任何应用系列函数为 .csv 文件中的每个列表项编写 csv peakAnnoList
。
这是一个带有Map
.
Map(function(x, y) write.csv(x@anno, y, row.names = FALSE),
peakAnnoList, paste0(names(peakAnnoList), '.csv'))
这应该创建一个名为新的CSV文件UP.csv
,DOWN.csv
在工作目录等。
使用 也可以实现相同的效果purrr::imap
。
purrr::imap(peakAnnoList, ~readr::write_csv(.x@anno, paste0(.y, '.csv')))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句