Body: <p>I have four vcf files, <code>SNPs_s1.vcf</code>, <code>SNPs_s2.vcf</code>, <code>SNPs_s3.vcf</code>, and <code>SNPs_s4.vcf</code>, which contain information about SNPs. These vcf files were obtained by using the following methods: the initial input files were short-paired reads</p>
  <ol>
  <li><p>I did mapping with minimap2</p>
  <pre><code>./minimap2 -ax sr ref.fa read1.fq.gz read2.fq.gz &gt; aln.sam
  </code></pre>
  </li>
  <li><p>converted to bam file</p>
  <pre><code>samtools view -Sb aln.sam &gt; aln.bam
  </code></pre>
  </li>
  <li><p>Sorted the bam file</p>
  <pre><code>samtools sort aln.bam &gt; aln_sorted.bam
  </code></pre>
  </li>
  <li><p>created an index file</p>
  <pre><code>samtools index aln_sorted.bam
  </code></pre>
  </li>
  <li><p>created an index file of reference</p>
  <pre><code>samtools faidx ref.fa
  </code></pre>
  </li>
  <li><p>extracted the raw variants using freebayes</p>
  <pre><code>freebayes -f ref.fa aln_sorted.bam &gt; out_var_s1.vcf
  </code></pre>
  </li>
  <li><p>extracted SNPs using vcf tools</p>
  <pre><code>vcftools --vcf out_var_s1.vcf --remove-indels --recode \
     --recode-INFO-all --out SNPs_s1.vcf
  </code></pre>
  </li>
  </ol>
  <p>I would like to calculate the fixation index (Fst) between <code>SNPs_s1.vcf</code> and <code>SNPs_s2.vcf</code>, <code>SNPs_s1.vcf</code> and <code>SNPs_s3.vcf</code> etc. I attempted to calculate Fst using <code>bcftools</code>, but I have to provide the id list. I tried the code below for that.</p>
  <pre><code>bcftools query -l snps_s1.vcf
  </code></pre>
  <p>The output was &quot;unknown&quot;.</p>
  <p>How do I calculate Fst using the above vcf files? Your suggestions would be appreciated.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-09T09:29:41.757Z
Comments.Text: Can you please explain a bit more about Fst, and why you need to calculate it? I'm used to Fst being interpreted as a population statistic, and it doesn't [currently] make sense to me to calculate it for only a few individuals.
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-09T23:44:05.330Z
Comments.Text: @gringer I would like to use Fst to find the genetic diversity between populations. Which method is better for few individuals?
Comments.UserDisplayName: hina
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-10T06:11:39.163Z
Comments.Text: Who is asking you to calculate Fst, and why? If you're doing population genetics, you need populations. A few individuals do not make a population, unless it's kākāpō or kakī, or some other similarly endangered species.
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-10T14:15:48.213Z
Comments.Text: The first issue is easy, the name of your sample in your `snps_s1.vcf` is set to `unknown`. You can fix that bit with `sed -i '/^#CHROM/s/unknown/sample1/' snps_s1.vcf`. But gringer's points are the main issue. What are you really trying to do here with only 4 individuals?
Comments.UserDisplayName: terdon
Tags: <phylogenetics><vcf><fst>
Title: Fst calculation from VCF files
ThreadText: # Fst calculation from VCF files
  
  (Asked by: username_0 on 2023-12-08)
  
  I have four vcf files, `SNPs_s1.vcf`, `SNPs_s2.vcf`, `SNPs_s3.vcf`, and `SNPs_s4.vcf`, which contain information about SNPs. These vcf files were obtained by using the following methods: the initial input files were short-paired reads
  
  1. I did mapping with minimap2
  
     ```
     ./minimap2 -ax sr ref.fa read1.fq.gz read2.fq.gz > aln.sam
  
     ```
  2. converted to bam file
  
     ```
     samtools view -Sb aln.sam > aln.bam
  
     ```
  3. Sorted the bam file
  
     ```
     samtools sort aln.bam > aln_sorted.bam
  
     ```
  4. created an index file
  
     ```
     samtools index aln_sorted.bam
  
     ```
  5. created an index file of reference
  
     ```
     samtools faidx ref.fa
  
     ```
  6. extracted the raw variants using freebayes
  
     ```
     freebayes -f ref.fa aln_sorted.bam > out_var_s1.vcf
  
     ```
  7. extracted SNPs using vcf tools
  
     ```
     vcftools --vcf out_var_s1.vcf --remove-indels --recode \
        --recode-INFO-all --out SNPs_s1.vcf
  
     ```
  
  I would like to calculate the fixation index (Fst) between `SNPs_s1.vcf` and `SNPs_s2.vcf`, `SNPs_s1.vcf` and `SNPs_s3.vcf` etc. I attempted to calculate Fst using `bcftools`, but I have to provide the id list. I tried the code below for that.
  
  ```
  bcftools query -l snps_s1.vcf
  
  ```
  
  The output was "unknown".
  
  How do I calculate Fst using the above vcf files? Your suggestions would be appreciated.
  
  **Tags:** phylogenetics, vcf, fst
  
  > **Comments:**
  > **username_1**: Can you please explain a bit more about Fst, and why you need to calculate it? I'm used to Fst being interpreted as a population statistic, and it doesn't [currently] make sense to me to calculate it for only a few individuals.  
  > **username_0**: @username_1 I would like to use Fst to find the genetic diversity between populations. Which method is better for few individuals?  
  > **username_1**: Who is asking you to calculate Fst, and why? If you're doing population genetics, you need populations. A few individuals do not make a population, unless it's kākāpō or kakī, or some other similarly endangered species.  
  > **username_2**: The first issue is easy, the name of your sample in your `snps_s1.vcf` is set to `unknown`. You can fix that bit with `sed -i '/^#CHROM/s/unknown/sample1/' snps_s1.vcf`. But username_1's points are the main issue. What are you really trying to do here with only 4 individuals?  
  
  ---
  
  ## 0 answers
  
  