Extract several columns from a VCF file
2
0
Entering edit mode
4.7 years ago
User000 ▴ 710

Hello,

I have a vcf file with 100 genotypes. I want to extract information on 10 specific genotypes and I have a list of their ID's. Any ideas which tool could be used?

vcf • 1.5k views
ADD COMMENT
0
Entering edit mode

bcftools is the go to for me in such cases.

ADD REPLY
0
Entering edit mode

a bit more details would be much appreciated, as I studied it, but without any success.

ADD REPLY
0
Entering edit mode

You need to study and experiment with it more, then. It's a pretty straightforward tool.

ADD REPLY
0
Entering edit mode

I've edited my answer above

ADD REPLY
1
Entering edit mode
4.7 years ago
User000 ▴ 710

Yes, now I found a solution:

bcftools view -S in.txt in.vcf > out.vcf

If you were polite and just wrote your latest comment, we would have avoided upsetting each other. Don't take for granted that understanding some concepts are easy for everybody like they are for you. Sometimes we just need one keyword to move on. Thanks

ADD COMMENT
0
Entering edit mode

I'm glad you found a solution. "You need to read (the documentation) more" and "Read the manual" are not upsetting statements, they are plain facts. The disconnect was between the words you were using to think about the problems and the words the community uses to describe those concepts.

When we encounter an obstacle, we can either choose to learn or complain how difficult it is for us. On a personal note, I struggle with this a lot myself too. We cannot expect people to coddle us, especially in a professional setting.

ADD REPLY
0
Entering edit mode
4.7 years ago
tacrolimus ▴ 140

Do you mean you have the SNP IDs?

bcftools view -i ID==@text file_of_SNP_IDs yourvcf > output.vcf

Further to your question I think you want:

bcftools view -s sample1,sample2 file.vcf > filtered.vcf
bcftools view -S sample_file.txt file.vcf > filtered.vcf
ADD COMMENT
0
Entering edit mode

vcf format

#header1
#header2
#etc
#CHROM  POS ID REF ALT QUAL FILTER INFO FORMAT ID1 ID2 ID3 ID4 ID5...ID100

I need to get some of this ID's

ADD REPLY
0
Entering edit mode

Figure out how to use bcftools to subset a VCF file to have only a few samples. Read the manual, it is the single most useful tool you'll need to work with VCF files.

ADD REPLY
0
Entering edit mode

I wouldn't be asking questions here if I wasn't stuck. So sorry I am not as brilliant as you are! Also, if you are not willing to help, just do not comment, as I am a grown up person and I know how to study! thanks

ADD REPLY
0
Entering edit mode

if you are not willing to help, just do not comment

Please don't take things so personally. If you were to read the comment properly, you'd see I gave you the exact keywords to search for in the manual. subset and samples are the keywords you need to get to where you want. Use those and you won't be stuck.

ADD REPLY

Login before adding your answer.

Traffic: 1985 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6