Copy a column of a VCF to another column within file
I have multiple VCF files, and I need to copy the elements of column 12 to column 13 while keeping the column names.
From this
$ cut -f12,13 sample_file.vcf | grep -v "##" | head
VD_SCLC_1 VCFM_SCLC_1
0/1:17,17:.:.:34,13:.:.:.:7,6:.:0.2766:.:13:.:47 0/1:.:.:.:.:.:.:.:.:.:.:.:.:.:.
0/1:111:.:39:.:0.3514:.:21,18:.:.:41,31:.:.:72,39:. 0/1:.:.:.:.:.:.:.:.:.:.:.:.:.:.
0/1:.:0.4118:.:.:.:28,22:50,35:.:.:19,16:85:.:.:35 0/1:.:.:.:.:.:.:.:.:.:.:.:.:.:.
0/1:.:.:.:9,12:.:21,20:.:7,13:.:0.4878:.:20:41:. 0/1:.:.:.:.:.:.:.:.:.:.:.:.:.:.
0/1:0.3654:.:10,9:.:.:18,15:.:33,19:.:.:.:52:19:. 0/1:.:.:.:.:.:.:.:.:.:.:.:.:.:.
To this
$ cut -f12,13 sample_file.vcf | grep -v "##" | head
VD_SCLC_1 VCFM_SCLC_1
0/1:17,17:.:.:34,13:.:.:.:7,6:.:0.2766:.:13:.:47 0/1:17,17:.:.:34,13:.:.:.:7,6:.:0.2766:.:13:.:47
0/1:111:.:39:.:0.3514:.:21,18:.:.:41,31:.:.:72,39:. 0/1:111:.:39:.:0.3514:.:21,18:.:.:41,31:.:.:72,39:.
0/1:.:0.4118:.:.:.:28,22:50,35:.:.:19,16:85:.:.:35 0/1:.:0.4118:.:.:.:28,22:50,35:.:.:19,16:85:.:.:35
0/1:.:.:.:9,12:.:21,20:.:7,13:.:0.4878:.:20:41:. 0/1:.:.:.:9,12:.:21,20:.:7,13:.:0.4878:.:20:41:.
0/1:0.3654:.:10,9:.:.:18,15:.:33,19:.:.:.:52:19:. 0/1:0.3654:.:10,9:.:.:18,15:.:33,19:.:.:.:52:19:.
• 930 views
•
link
1 answer
Try this:
grep -v '^##' sample_file.vcf | awk '$13=$12' > <output.vcf>
• 0 views
•
link
Log in to answer this question.