Answers.Body: <p>You've used the right tool and gotten the right results. What you need to understand is that VCF contains variant loci as well as the genotypes for &gt;=1 sample(s) at those loci. The intersect operation will extract common loci, but it does not know which genotypes you're interested in, which is why it generates one file per input, giving you the genotypes from each VCF for the common loci.</p>
  <p>You could use the sites file to do a <code>bcftools merge</code> operation, limiting to just the common sites using the <code>-R &lt;regions-file&gt;</code> option so you'd get a VCF with all the samples across all 6 input VCFs but only for the variant loci.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-23T22:37:02.980Z
Answers.Text: Thanks a lot. For my understanding: Do you means that the output 6 files from isec tool I used is a VCF for each sample and contains the genotype (and other info) for only that common sites (that are also in site.txt) ? If so, do you assume that if I merge this using -R, then that merged VCF file contains all 6 samples. How can I get the genotype or alleles for the 6 individuals ?
Answers.UserDisplayName: Mohamed Samir
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-24T15:11:11.027Z
Answers.Text: Yes, each VCF output should contain information from its corresponding VCF input. You could either use sites file to merge all 6 original inputs or simply merge all 6 isec outputs get to the merged common-loci VCF.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-24T15:19:59.210Z
Answers.Text: So, merging the 6 VCF file will justput them side by side on  sample basis ? Could you advise on a code for that ?
Answers.UserDisplayName: Mohamed Samir
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-24T17:52:18.397Z
Answers.Text: Try the command, look at the output and come back if you have further questions.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-23T17:59:19.130Z
Answers.LastActivityDate: 2023-05-23T17:59:19.130Z
Answers.UserDisplayName: Ram RS
Body: <p>I have 6 VCF files, where I would like to obtain the SNPs that are common (by position) in all the 6 files. I have tried this command</p>
  <pre><code>bcftools isec  -p trial2 -n=6 -c all A2_SNP.vcf.gz A_SNP.vcf.gz B_SNP.vcf.gz C_SNP.vcf.gzD_SNP.vcf.gz E_SNP.vcf.gz
  </code></pre>
  <p>But this produces 6 files, and through the README file, I think each of the VCF contains the unique SNPs for each of the 6 files, and I could only get sites.txt file that ocntain the positions that are common. Are there any way to get a VCF file that have the common SNPs ?</p>
  <p>Thanks</p>
  
Tags: <rna-seq><snp><variant-calling><rna><gatk>
Title: Getting VCF file that contain common SNPs from 6 VCF file using isec
ThreadText: # Getting VCF file that contain common SNPs from 6 VCF file using isec
  
  (Asked by: username_0 on 2023-05-23)
  
  I have 6 VCF files, where I would like to obtain the SNPs that are common (by position) in all the 6 files. I have tried this command
  
  ```
  bcftools isec  -p trial2 -n=6 -c all A2_SNP.vcf.gz A_SNP.vcf.gz B_SNP.vcf.gz C_SNP.vcf.gzD_SNP.vcf.gz E_SNP.vcf.gz
  
  ```
  
  But this produces 6 files, and through the README file, I think each of the VCF contains the unique SNPs for each of the 6 files, and I could only get sites.txt file that ocntain the positions that are common. Are there any way to get a VCF file that have the common SNPs ?
  
  Thanks
  
  **Tags:** rna-seq, snp, variant-calling, rna, gatk
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-05-23. Score: 2
  
  You've used the right tool and gotten the right results. What you need to understand is that VCF contains variant loci as well as the genotypes for >=1 sample(s) at those loci. The intersect operation will extract common loci, but it does not know which genotypes you're interested in, which is why it generates one file per input, giving you the genotypes from each VCF for the common loci.
  
  You could use the sites file to do a `bcftools merge` operation, limiting to just the common sites using the `-R <regions-file>` option so you'd get a VCF with all the samples across all 6 input VCFs but only for the variant loci.
  
  > **Comments:**
  > **username_0**: Thanks a lot. For my understanding: Do you means that the output 6 files from isec tool I used is a VCF for each sample and contains the genotype (and other info) for only that common sites (that are also in site.txt) ? If so, do you assume that if I merge this using -R, then that merged VCF file contains all 6 samples. How can I get the genotype or alleles for the 6 individuals ?  
  > **username_1**: Yes, each VCF output should contain information from its corresponding VCF input. You could either use sites file to merge all 6 original inputs or simply merge all 6 isec outputs get to the merged common-loci VCF.  
  > **username_0**: So, merging the 6 VCF file will justput them side by side on  sample basis ? Could you advise on a code for that ?  
  > **username_1**: Try the command, look at the output and come back if you have further questions.  
  
  ---
  
  