difficulty filtering vcf file with vcftools
1
0
Entering edit mode
2.0 years ago

I had a large VCF file named "common_known_variants.vcf " which contains all known human variants downloaded from https://ftp.ncbi.nlm.nih.gov/snp/organisms/human_9606_b151_GRCh38p7/VCF/00-common_all.vcf.gz as common_known_variants.vcf.gz

I'm trying to extract the known variants from only chromosomes 1,2,3,9,22, and X and write them in a new vcf file with the name targeted_known_variants.vcf so I created a txt file named targeted_chromosomes.txt each line had a no of chromosome from those I needed to extract and I used this command line in a jupyter notebook

!vcftools --vcf common_known_variants.vcf --positions targeted_chromosomes.txt --recode --recode-INFO-all --out targeted_known_variant

Unfortunately it created a new vcf file containing the headers only it seems that the command cannot read the txt file ,,, any help with this? I would be grateful

vcf vcftools • 900 views
ADD COMMENT
1
Entering edit mode

Welcome Phoebe. vcftools is very outdated now and is not under maintaience. Please use bcftools instead. Am I right in thinking you just want to subset common_known_variants.vcf to contain only chromosomes 1,2,3,9,22, and X?

ADD REPLY
0
Entering edit mode

Am I right in thinking you just want to subset common_known_variants.vcf to contain only chromosomes 1,2,3,9,22, and X?

yes that is exactly what I want to do

ADD REPLY
2
Entering edit mode
2.0 years ago
4galaxy77 2.8k
bcftools view \
    --regions 1,2,3,9,22,X \
    -O z \
    common_known_variants.vcf > targeted_known_variants.vcf

Note

  1. You will need to index the file first using bcftools index
  2. Check the naming of the chromosomes; i.e. whether they are chr1 or 1
ADD COMMENT
0
Entering edit mode

Many thanks for your response [4galaxy77][1] it worked with me and I extracted a subset of the "common_known_variants.vcf.gz" file to contain only chromosomes 1,2,3,9,22, and X in another file named "targeted_known_variants.vcf.gz"

ADD REPLY

Login before adding your answer.

Traffic: 1445 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