I wondered if anyone could help me please? (apologies I can't give screen shots - as I work on a secure server). I want to extract all the sample IDs that relate to a specific variant. I have a multisample VCF file. My variant text file (tab delimited) contains: Chr Pos Ref Alt
I used to be able to extract this information using the code below and get all the IDs seperated by columns with the relevant VCF info (qual, filter, info, format, format_ouput).
bcftools view -R variants.txt mymultisample.vcf > newoutput.vcf
However, now all I get is a few columns with lots of mixed mish mash of information that doesn't make sense. I also tried bcftools view -t, bcftools view -r, different formatting of the variant.txt file but no luck.
I tried also the above code provided by Ram :
bcftools view -O v -R "$variants" "$vcf_in" \
| grep -Ef <(awk 'BEGIN{FS=OFS="\t";print "#"};{print "^"$1,$2,"[^\t]+",$3,$4"\t"}' "$variants") \
> "$vcf_out"
However, i only get a long line of IDs within one of the excel cells but no other information that I was previously getting.
Could it be the vcf fiel itself that is the problem?
Many thanks, Julia
hello, I was trying to use the above code but there are so many grep errors and, $3,$4"\t"}' "$variants")- for not recognizing the variant file(i used my file with the correct format) etc..errors are coming up, cld u pls share some code which works and I would be great if you could share some code having loops to extract a big list. Thanks
Please use
ADD COMMENT/ADD REPLYwhen responding to existing posts to keep threads logically organized.SUBMIT ANSWERis for new answers to original question.