This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Changing Column Order In Bed File

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

3 answers

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.
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.

Thanks. It worked.

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.

Log in to answer this question.