Entering edit mode
2.8 years ago
User000
▴
710
Dear all,
I have multiple vcf files like this, each containing 3 individuals. I would like to extract only the first individual from each vcf and save each as separate vcf file. Is this possible in batch without specifing the individual name as I have many vcfs?
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NAME1 NAME2 NAME3
chr1 1666251 . G A 139 MQ BRF=0.46;FR=0.1667 GT:GL:GOF:GQ:NR:NV 1/0:-143.73,0.0,-79.13:20:99:100:60 0/0:0.0,-12.67,-236.1:12:99:117:2 0/0:0.0,-16.47,-244.0:13:99:129:1
chr1 2408213 . T G 164 QD BRF=0.05;FR=0.1667 GT:GL:GOF:GQ:NR:NV 1/0:-21.02,0.0,-55.12:44:99:77:24 0/0:0.0,-13.94,-147.2:5:99:58:0 0/0:0.0,-8.73,-90.8:3:87:37:0
chr1 2408232 . T G 122 QD BRF=0.04;FR=0.1667 GT:GL:GOF:GQ:NR:NV 1/0:-16.82,0.0,-33.02:51:99:57:23 0/0:0.0,-10.38,-111.1:9:99:37:0 0/0:0.0,-5.92,-60.6:8:59:25:0
Expected output:
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NAME1
chr1 1666251 . G A 139 MQ BRF=0.46;FR=0.1667 GT:GL:GOF:GQ:NR:NV 1/0:-143.73,0.0,-79.13:20:99:100:6
chr1 2408213 . T G 164 QD BRF=0.05;FR=0.1667 GT:GL:GOF:GQ:NR:NV 1/0:-21.02,0.0,-55.12:44:99:77:24
chr1 2408232 . T G 122 QD BRF=0.04;FR=0.1667 GT:GL:GOF:GQ:NR:NV 1/0:-16.82,0.0,-33.02:51:99:57:23
simple:
For many:
sure, but it could be vcf.gz or bcf and bcftools will fix AC.
user can use zcat for gz.
Is the first individual's ID always "NAME1"? Something like this:
no, that's the problem..
I see, then go with Pierre's solution.