Thank you! I used awk and now it gives this error: ID column contains non-unique names
vcf file column name error
Hello,
I have a vcf file and I did not have any ID for each of the SNP in that column. So I manually added unique IDs to the SNPs using:
awk '{OFS="\t"} NR<67 {print $0;next} {{$3=$1"_"$2} print}' sample.vcf > out.vcf
but it also changed the column name from ID to #CHROM_POS. Now I am getting an error
Error in x@fix[, "ID"] : subscript out of bounds
in the downstream analysis. I think its the replaced column names that's causing the error. Is there a way to keep the column name to ID in the awk command line? Thank you!
• 1,293 views
•
link
1 answer
I have a vcf file and I did not have any ID for each of the SNP in that column.
bcftools annotate
Usage: bcftools annotate [options] <in.vcf.gz>
(...)
-I, --set-id [+]<format> set ID column, see man page for details
(...)
if you really want awk:
awk '/^#/ {print;next} {OFS="\t";$3=sprintf("%s_%s",$1,$2); print}' sample.vcf
• 0 views
•
link
• 0 views
•
link
because using cols CHROM and POS is not enough (duplicates...). Try $3=sprintf("%s_%s_%d",$1,$2,NR)
• 0 views
•
link
Log in to answer this question.