I have a text file with 61000 columns and 173 rows. I would like to merge data on every 2 columns i.e., columns 1 and 2 should be merged, 3 and 4 should be merged, 5 and 6 should be merged and so on.
Sample input (tab separated):
Ind Pop scaffold1 X scaffold1 X.1 scaffold3 X.2 scaffold4 X.3
a antartica 1 1 1 1 2 2 1 1
b antartica 1 1 1 1 2 1 1 2
c antartica 1 1 1 1 2 1 1 1
d antartica 1 1 1 1 2 1 1 2
e antartica 1 1 1 1 2 1 1 2
f arctic 1 1 1 1 2 1 1 1
g arctic 1 1 1 2 2 1 1 1
h arctic 1 1 1 1 2 1 1 1
I arctic 1 1 1 1 2 1 1 1
j arctic 1 1 1 1 2 1 1 1
desired output (tab separated):
Ind-Pop scaffold1-X scaffold2-X.1 scaffold3-X.2 scaffold4-X.3
a-antartica 1-1 1-1 2-2 1-1
b-antartica 1-1 1-1 2-1 1-2
c-antartica 1-1 1-1 2-1 1-1
d-antartica 1-1 1-1 2-1 1-2
e-antartica 1-1 1-1 2-1 1-2
f-arctic 1-1 1-1 2-1 1-1
g-arctic 1-1 1-2 2-1 1-1
h-arctic 1-1 1-1 2-1 1-1
I-arctic 1-1 1-1 2-1 1-1
j-arctic 1-1 1-1 2-1 1-1
I tried to do it with R using the unite function of tidyr package. I was able to manage to merge two columns at a time using the following command:
unite(df, newcol, c(scaffold1, X), remove=TRUE)
Not sure how to do it for multiple columns.
Any R or perl or linux command line approaches will be appreciated!