简体   繁体   English

以床格式从R导出文件

[英]export file from R in bed format

I have a data.frame like this: 我有一个像这样的data.frame:

 tab ->
                                    elements   scaffold   start     end Lengths
1             Dong-1_NVe_R4_Nematostella12_1 KQ415659.1   14193   14540     347
2                  OK_SINE2/tRNA_Octopus44_1 KQ415659.1   68391   68626     235
3               RTE-8_NV_RTE_Nematostella6_1 KQ415659.1   69123   69884     761
4                    Simple_repeat_(TCTT)n_1 KQ415659.1   70693   70827     134
5                RTE1-N1_LA_RTE_Loxodonta1_1 KQ415659.1   83088   83298     210
6                  OK_SINE2/tRNA_Octopus93_5 KQ415659.1   91375   91569     194
7             Mariner1_BT_Mariner/Tc1_Bos3_3 KQ415659.1  101964  102378     414
8       Simple_repeat_(TA)nSimple_repeat96_1 KQ415659.1  104735  104877     142
9                       AmnSINE2SINE/Deu30_2 KQ415659.1  110117  110255     138
10     Simple_repeat_(CATA)nSimple_repeat4_1 KQ415659.1  110622  111165     543
11      Simple_repeat_(TTA)nSimple_repeat9_1 KQ415659.1  112842  112959     117
12                       TS2_SINE_Solanum4_1 KQ415659.1  117206  117467     261
13              RTE-8_NV_RTE_Nematostella6_3 KQ415659.1  118195  118433     238

and I would to export it into bed format from R. does anyone can help me? 并将其从R导出为床格式。有人可以帮助我吗?

Specifications like BED, GFF, and a few others attempt to standardize columns of your dataframe. 诸如BED,GFF之类的规范以及其他一些规范试图标准化数据框的列。 So, just get the columns of your dataframe in the correct order and then write your table. 因此,只需以正确的顺序获取数据框的列,然后编写表即可。

There's 3 required fields and then several more optional ones, as described by the folks at UCSC . 有3个必填字段,然后还有几个可选字段, 如UCSC的人员所述 Stick to the descriptions, write your data frame to a table, and you're good to go. 坚持说明,将数据框写到表中,一切就很好了。

bed <- tab[,c('scaffold', 'start', 'end', 'elements')]
colnames(bed) <- c('chrom', 'chromStart', 'chromEnd', 'name')
write.table(bed, "file.bed")

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

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