<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>

CC BY-SA 4.0
2023-05-24T17:52:59.977Z
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.
Ram RS
CC BY-SA 4.0
2023-05-24T18:04:57.127Z
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.
terdon
CC BY-SA 4.0
2023-05-24T19:44:04.517Z
Don’t use awk or excel, please just use bcftools and save yourself a lot of trouble
user438383
CC BY-SA 4.0
2023-05-24T21:03:41.097Z
@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.
Ram RS
<vcf><snp>
Extracting information from VCF file for many specific positions in specific chromosomes?
# 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) 
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**: @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.  

---

## 0 answers

