2

I have a data.frame like this:

 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?

jonny jeep
  • 383
  • 3
  • 12
  • 1
    I am not at all familiar with that format, but a quick search got me here: https://www.rdocumentation.org/packages/nucleR/versions/2.4.0/topics/export.bed – tim Jul 22 '19 at 23:12

1 Answers1

1

Specifications like BED, GFF, and a few others attempt to standardize columns of your dataframe. 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. 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")