Yes, this works , the only problem is that I get a huge empty space after the final row. How can I get rid of this blank space? thanks for your help.
Attaching genotypes in the vcf files to individual ID
I got a vcf file (header and individual ID have been removed form the vcf file), which contains only genotype information for 1000 positions, looks like this (for the fist position)
head all_unique.vcf
5 49444858 rs12513792 C A 100 PASS AC=3353;AF=0.669529;AN=5008;NS=2504;DP=17854;EAS_AF=0.5625;AMR_AF=0.7075;AFR_AF=0.7489;EUR_AF=0.672;SAS_AF=0.6431;AA=.|||;VT=SNP GT 0|1 1|0 0|1 1|0 0|1 0|1 1|1 1|0 1|0 1|1 1|1 1|0 0|1 1|1 1|1 0|1 1|1 0|1 0|1 0|1 0|0 0|0 0|1 0|1 1|1 0|1 1|0 1|1 1|0 1|0 1|0 0|0 1|1 1|0 1|1 1|0 1|1 1|1 1|1 1|1 1|1 0|0 1|1 0|1 0|1 1|1 1|1 1|0 1|1 1|1 0|1 1|1 1|1 1|1 1|1 1|0 1|1 0|1 0|0 1|1 1|0 1|1 1|1 1|1 1|1 1|1 1|0 1|0 1|1 0|1 0|1 1|1 1|0 1|0 1|0 0|0 0|1 1|0 0|1 1|1 0|0 1|0 1|0 0|1 1|1 1|1 1|1 1|1 1|0 1|1 1|1 1|0 0|1 1|1 0|1 0|1 0|1 0|0 1|1 0|1 1|1 0|1 0|1 1|1 0|1
I have another file which contains the individual ID:
head individual_id
HG00096
HG00097
HG00099
HG00100
HG00101
HG00102
HG00103
HG00105
HG00106
HG00107
HG00108
HG00109
the first individual in the ID file corresponds to the first genotype in the vcf file, and so on. For each position,I want to attach ID to each genotype and get an output and save the output in a seperate file like this :
head desired_output_pos49444858
HG00096 0|1
HG00097 1|0
HG00099 0|1
HG00100 1|0
HG00101 0|1
Does anyone have an idea how can I make this file? Thanks
• 2,131 views
•
link
1 answer
assuming that the number of lines in individual_id is the same as the number of genotypes in the vcf...
cat all_unique.vcf | while read L ; do P=$(echo "$L" | cut -f2);paste <(cat individual_id ) <(echo "$L"| cut -f 10- | tr "\t" "\n" ) > "desired_output_pos${P}";done
• 0 views
•
link
Log in to answer this question.