0

I am trying to take a list of text files (which have the extension .annotation but are still text files) and merge them together into one file. I also want to create a new column with the original file name so I can later sort the table by file name.

I have a list of files that look like this -

> read.table("Sample2-1_nucleotideRate.annotation")
                  V1         V2    V3    V4 V5 V6           V7   V8   V9          V10
1    pJW316-17_beforeNGS non-coding    29    29  G  A 0.9657791941   NA   NA         <NA>
2    pJW316-17_beforeNGS non-coding    54   299  A  G 0.0064375000   NA   NA         <NA>
3    pJW316-17_beforeNGS non-coding    64   349  T  C 0.0111019737   NA   NA         <NA>
4    pJW316-17_beforeNGS       nsps    85   644  A  G 0.0044375000    9    3 synonymous>K

I would like a new file to look like this -

> read.csv("all_data.csv", header = T)
          X samplename            X.region    feature position coverage reference alternate alt_frequency CDS_position AA_position    AA_change
1         1  Sample2-1 pJW316-17_beforeNGS non-coding       29       29         G         A   0.965779194           NA          NA         <NA>
2         2  Sample2-1 pJW316-17_beforeNGS non-coding       54      299         A         G   0.006437500           NA          NA         <NA>
3         3  Sample2-1 pJW316-17_beforeNGS non-coding       64      349         T         C   0.011101974           NA          NA         <NA>
4         4  Sample2-1 pJW316-17_beforeNGS       nsps       85      644         A         G   0.004437500            9           3 synonymous>K
5         5  Sample2-1 pJW316-17_beforeNGS       nsps       96      808         A         G   0.003437500           20           7          D

0 Answers0