Body: <p>I have an excel file that I created from VCF file for common SNPs across 6 samples. This excel have the chromosomes and the position of the SNPs only (see example table1) <a href="https://i.sstatic.net/dMsTq.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dMsTq.jpg" alt="enter image description here" /></a>
  Now I would like to obtain the other information (eg. allels, Genotype, depth, etc) from the VCF files of the 6 samples (i.e. the one that contains these positions).
  I tried using AWK command like here for position 23432 on chr. 1 for the 6 file :</p>
  <pre><code>awk -F &quot; &quot; '<span class="math-container">$1=="1" &amp;&amp; $</span>2==&quot;23432&quot;' file1.vcf
  awk -F &quot; &quot; '<span class="math-container">$1=="1" &amp;&amp; $</span>2==&quot;23432&quot;' file2.vcf
  awk -F &quot; &quot; '<span class="math-container">$1=="1" &amp;&amp; $</span>2==&quot;23432&quot;' file3.vcf
  awk -F &quot; &quot; '<span class="math-container">$1=="1" &amp;&amp; $</span>2==&quot;23432&quot;' file4.vcf
  awk -F &quot; &quot; '<span class="math-container">$1=="1" &amp;&amp; $</span>2==&quot;23432&quot;' file5.vcf
  awk -F &quot; &quot; '<span class="math-container">$1=="1" &amp;&amp; $</span>2==&quot;23432&quot;' file6.vcf
  </code></pre>
  <p>he issue is that these SNPs I have are thousands positions, so I need an automated way to do this</p>
  <p>Could you advise on that ?</p>
  <p>Thanks</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-24T17:52:59.977Z
Comments.Text: Is this related to your previous question? Is this the sites file that you opened using Excel? Please read the bcftools manual, they have everything you need.
Comments.UserDisplayName: Ram RS
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-24T18:04:57.127Z
Comments.Text: When working with VCF files, a tab-separated format, you want `-F '\t'`. And you never want `-F " "`, unless you truly want to break on spaces and only spaces. By default awk will split on any whitespace character (including tabs and spaces) so you don't need this.
Comments.UserDisplayName: terdon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-24T19:44:04.517Z
Comments.Text: Don’t use awk or excel, please just use bcftools and save yourself a lot of trouble
Comments.UserDisplayName: user438383
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-24T21:03:41.097Z
Comments.Text: @user438383 OP has a separate thread going on with bcftools involved in solving this problem, looks like they chose to open a new thread for no apparent reason.
Comments.UserDisplayName: Ram RS
Tags: <vcf><snp>
Title: Extracting information from VCF file for many specific positions in specific chromosomes?
ThreadText: # Extracting information from VCF file for many specific positions in specific chromosomes?
  
  (Asked by: username_0 on 2023-05-24)
  
  I have an excel file that I created from VCF file for common SNPs across 6 samples. This excel have the chromosomes and the position of the SNPs only (see example table1) [![enter image description here](https://i.sstatic.net/dMsTq.jpg)](https://i.sstatic.net/dMsTq.jpg)
  Now I would like to obtain the other information (eg. allels, Genotype, depth, etc) from the VCF files of the 6 samples (i.e. the one that contains these positions).
  I tried using AWK command like here for position 23432 on chr. 1 for the 6 file :
  
  ```
  awk -F " " '$1=="1" && $2=="23432"' file1.vcf
  awk -F " " '$1=="1" && $2=="23432"' file2.vcf
  awk -F " " '$1=="1" && $2=="23432"' file3.vcf
  awk -F " " '$1=="1" && $2=="23432"' file4.vcf
  awk -F " " '$1=="1" && $2=="23432"' file5.vcf
  awk -F " " '$1=="1" && $2=="23432"' file6.vcf
  
  ```
  
  he issue is that these SNPs I have are thousands positions, so I need an automated way to do this
  
  Could you advise on that ?
  
  Thanks
  
  **Tags:** vcf, snp
  
  > **Comments:**
  > **username_1**: Is this related to your previous question? Is this the sites file that you opened using Excel? Please read the bcftools manual, they have everything you need.  
  > **username_2**: When working with VCF files, a tab-separated format, you want `-F '\t'`. And you never want `-F " "`, unless you truly want to break on spaces and only spaces. By default awk will split on any whitespace character (including tabs and spaces) so you don't need this.  
  > **username_3**: Don’t use awk or excel, please just use bcftools and save yourself a lot of trouble  
  > **username_1**: @username_3 OP has a separate thread going on with bcftools involved in solving this problem, looks like they chose to open a new thread for no apparent reason.  
  
  ---
  
  ## 0 answers
  
  