Changing Column Order In Bed File
3
0
Entering edit mode
11.6 years ago
bioinfo ▴ 830

Here is my data with A, B, C and D columns in my bed file.

   A.     B.     C.     D. 
  Chr 1.  1.    12.     +
  Chr 2.  24.   56.     +

How can I move my D column to position 1 where the Column A right now?

bedtools galaxy • 4.6k views
ADD COMMENT
3
Entering edit mode
11.6 years ago

Assuming a tab delimited file:

awk -F '\t' {'print $4"\t"$1"\t"$2"\t"$3'} data.tsv 

D.    A.    B.    C.
+    Chr 1.    1.    12.
+    Chr 2.    24.    56.
ADD COMMENT
1
Entering edit mode
11.6 years ago
JC 13k
perl -lane 'print join "\t", $F[3], $F[0], $F[1], $F[2]' < file > output

produces:

D.  A.     B.     C. 
+  Chr 1.  1.    12.
+  Chr 2.  24.   56.
ADD COMMENT
0
Entering edit mode

Thanks. It worked.

ADD REPLY
0
Entering edit mode
11.6 years ago
Anima Mundi ★ 2.9k

Also Galaxy will do the job: first upload your bed file (left column: Get Data > Upload File), then go to cut (left column: Text Manipulation > Cut) and insert in the first field "c4,c1,c2,c3"; finally download the output from the column at right. Hope this helps.

ADD COMMENT

Login before adding your answer.

Traffic: 1462 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6