I have 3 VCF files.
A1.vcf
A2.vcf
A3.vcf
I want to get the common SNPs that are present in all these three files. And output must be in vcf format.
output:
common_A.vcf
Bioinformatics Stack Exchange is a question and answer site for researchers, developers, students, teachers, and end users interested in bioinformatics. It only takes a minute to sign up.
Sign up to join this communityI have 3 VCF files.
A1.vcf
A2.vcf
A3.vcf
I want to get the common SNPs that are present in all these three files. And output must be in vcf format.
output:
common_A.vcf
A potential solution is to compress and index the files using bgzip and tabix, then use bcftools isec to find SNPs common to all three files, e.g.
for files in A1.vcf A2.vcf A3.vcf
do
bgzip "$files"
tabix "$files"
done
bcftools isec -n=3 -c all -o all_common_SNPs.vcf A1.vcf.gz A2.vcf.gz A3.vcf.gz
```
-c all
I've seen -c none
-c all/both
I'm unable to understand/follow this flag.
$\endgroup$
Aug 24 at 22:59
-c all
flag will treat these as a 'common to the two files' (i.e. there is a variant at chr1:10001 and it will be 'kept' when you isec). If you specify -c none
, the REF/ALTs need to match exactly (i.e. both vcfs need to be e.g. T->A to be kept). With -c both
, the variant must be the same type e.g. both SNPs or both INDELs, regardless of the ALTs. More details here: samtools.github.io/bcftools/bcftools.html#common_options
$\endgroup$
Aug 24 at 23:29