Answers.Body: <p>You can use <a href="https://github.com/ekg/freebayes" rel="noreferrer">Freebayes</a>, provided you have your BAM file and the reference genome.</p>
  
  <p>Example:</p>
  
  <pre><code>freebayes -f genome.fa aln.bam &gt; var.vcf
  </code></pre>
  
  <p>I'd suggest you go through the whole github documentation, and choose the option(s) more suitable for your needs (ploidy, read support, etc.)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-13T19:58:08.663Z
Answers.Text: Thanks. Unfortunately when I tried this approach I didn’t get any variant readings along the mapped portion of the refseq. Not sure why. I know there are a few variants.
Answers.UserDisplayName: Lou_A
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-23T15:46:19.350Z
Answers.Text: This answer would be more useful if it included a cautionary comment about how what the OP is asking about is not a format conversion, but an analytical process, ie variant calling, like Kamil S Jaron provided. In addition, the recommendation to "go through the whole github documentation" is unlikely to be satisfying given the OP is probably new to the field. Kamil's pointers to specific resources are much more helpful.
Answers.UserDisplayName: Geraldine_VdAuwera
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-08T14:21:47.900Z
Answers.LastActivityDate: 2018-04-08T14:21:47.900Z
Answers.UserDisplayName: aechchiki
Answers.Body: <p>It's not really possible to <strong>convert</strong> <code>bam</code> to <code>vcf</code>. <code>bam</code> is a mapping file, it does not contain the information about variants, this information needs to be inferred in process called variant calling. I find important to mention that it's not just a different format of the same thing.</p>
  
  <p>How to <strong>call variants</strong> (a <code>vcf</code> file) from mapped reads (a <code>bam</code> file) is very broad question, it depends on the sequencing technology (Illumina, PacBio, ...), the type of sequencing (whole genome sequencing, RAD, RNA-seq, ...), the sampling (calling of individuals vs population variability), the quality of a reference (human vs denovo assembly made by a postdoc in your lab)... For a lot of cases the answer is simply <a href="https://software.broadinstitute.org/gatk/" rel="noreferrer">GATK</a>, partially because it has well written manual, but mainly just because many people use it.</p>
  
  <p>Some more detailed cases are well answered in more specific questions :</p>
  
  <ul>
  <li><a href="https://bioinformatics.stackexchange.com/questions/654/how-do-i-generate-a-variant-list-i-e-vcf-file-using-illumina-reads-from-a-hum">How do I generate a variant list (i.e. VCF file) using Illumina reads from a human genome?</a></li>
  <li><a href="https://bioinformatics.stackexchange.com/questions/2744/somatic-tumor-only-variant-calling">Somatic tumor only variant calling?</a></li>
  <li><a href="https://bioinformatics.stackexchange.com/questions/672/why-are-there-missing-calls-in-a-vcf-file-from-exome-sequencing">Why are there missing calls in a VCF file from exome sequencing?</a></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-11T10:37:53.150Z
Answers.Text: Indeed, relevant to this question, GATK have a Variants from RNA-seq best practices. Or they used to, and now it seems to have disappeared.
Answers.UserDisplayName: Ian Sudbery
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-11T10:56:53.063Z
Answers.Text: Honestly, I think good practices do not involve GATK. But it's true that GATK is what makes a review process much smoother (reviewers want GATK).
Answers.UserDisplayName: Kamil S Jaron
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-04-08T15:53:07.300Z
Answers.LastActivityDate: 2018-10-07T21:40:47.400Z
Answers.LastEditDate: 2018-10-07T21:40:47.400Z
Answers.UserDisplayName: Kamil S Jaron
Body: <p>I have NGS illumina RNA-seq reads from <em>M. musculus</em> (mm10). I am trying to find variants along the strand portion of the reads in the refseq (mm10).</p>
  
  <p>I mapped a pair of sequence files and generated a BAM file. Now I need to generate a VCF file from this BAM file. I’ve checked Galaxy for direct tools, but I couldn’t identify one. Any suggestions on how to turn a BAM file into VCF? Thank you in advance.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-07T23:48:41.317Z
Comments.Text: Possible duplicate of [How do I generate a variant list (i.e. VCF file) using Illumina reads from a human genome?](https://bioinformatics.stackexchange.com/questions/654/how-do-i-generate-a-variant-list-i-e-vcf-file-using-illumina-reads-from-a-hum)
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-11T10:39:18.063Z
Comments.Text: @gringer: The question asks about RNA-seq reads, where as your flagged potential duplicate is asking about DNA reads as best I can see. The process is not quite the same.
Comments.UserDisplayName: Ian Sudbery
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-11T22:02:04.280Z
Comments.Text: The approach works with RNASeq reads as well. All it needs is sufficient coverage across mapped reads. Where coverage is too high, reads can be sub-sampled via digital normalisation to reduce high-coverage regions without compromising coverage for low-coverage regions.
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-12-24T06:40:56.697Z
Comments.Text: Freebayes giving me following error: terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::substr: __pos (which is 166) > this->size() (which is 0)
  Aborted (core dumped)
Comments.UserDisplayName: user22673
Tags: <sam><vcf><variant-calling><variation>
Title: Converting a BAM file into VCF
ThreadText: # Converting a BAM file into VCF
  
  (Asked by: username_0 on 2018-04-07)
  
  I have NGS illumina RNA-seq reads from *M. musculus* (mm10). I am trying to find variants along the strand portion of the reads in the refseq (mm10).
  
  I mapped a pair of sequence files and generated a BAM file. Now I need to generate a VCF file from this BAM file. I’ve checked Galaxy for direct tools, but I couldn’t identify one. Any suggestions on how to turn a BAM file into VCF? Thank you in advance.
  
  **Tags:** sam, vcf, variant-calling, variation
  
  > **Comments:**
  > **username_1**: Possible duplicate of [How do I generate a variant list (i.e. VCF file) using Illumina reads from a human genome?](https://bioinformatics.stackexchange.com/questions/654/how-do-i-generate-a-variant-list-i-e-vcf-file-using-illumina-reads-from-a-hum)  
  > **username_2**: @username_1: The question asks about RNA-seq reads, where as your flagged potential duplicate is asking about DNA reads as best I can see. The process is not quite the same.  
  > **username_1**: The approach works with RNASeq reads as well. All it needs is sufficient coverage across mapped reads. Where coverage is too high, reads can be sub-sampled via digital normalisation to reduce high-coverage regions without compromising coverage for low-coverage regions.  
  > **username_3**: Freebayes giving me following error: terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::substr: __pos (which is 166) > this->size() (which is 0) Aborted (core dumped)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_6 on 2018-04-08. Score: 19 | Accepted answer
  
  It's not really possible to **convert** `bam` to `vcf`. `bam` is a mapping file, it does not contain the information about variants, this information needs to be inferred in process called variant calling. I find important to mention that it's not just a different format of the same thing.
  
  How to **call variants** (a `vcf` file) from mapped reads (a `bam` file) is very broad question, it depends on the sequencing technology (Illumina, PacBio, ...), the type of sequencing (whole genome sequencing, RAD, RNA-seq, ...), the sampling (calling of individuals vs population variability), the quality of a reference (human vs denovo assembly made by a postdoc in your lab)... For a lot of cases the answer is simply [GATK](https://software.broadinstitute.org/gatk/), partially because it has well written manual, but mainly just because many people use it.
  
  Some more detailed cases are well answered in more specific questions :
  
  * [How do I generate a variant list (i.e. VCF file) using Illumina reads from a human genome?](https://bioinformatics.stackexchange.com/questions/654/how-do-i-generate-a-variant-list-i-e-vcf-file-using-illumina-reads-from-a-hum)
  * [Somatic tumor only variant calling?](https://bioinformatics.stackexchange.com/questions/2744/somatic-tumor-only-variant-calling)
  * [Why are there missing calls in a VCF file from exome sequencing?](https://bioinformatics.stackexchange.com/questions/672/why-are-there-missing-calls-in-a-vcf-file-from-exome-sequencing)
  
  > **Comments:**
  > **username_2**: Indeed, relevant to this question, GATK have a Variants from RNA-seq best practices. Or they used to, and now it seems to have disappeared.  
  > **username_6**: Honestly, I think good practices do not involve GATK. But it's true that GATK is what makes a review process much smoother (reviewers want GATK).  
  
  ---
  
  ### Answer by username_4 on 2018-04-08. Score: 5
  
  You can use [Freebayes](https://github.com/ekg/freebayes), provided you have your BAM file and the reference genome.
  
  Example:
  
  ```
  freebayes -f genome.fa aln.bam > var.vcf
  
  ```
  
  I'd suggest you go through the whole github documentation, and choose the option(s) more suitable for your needs (ploidy, read support, etc.)
  
  > **Comments:**
  > **username_0**: Thanks. Unfortunately when I tried this approach I didn’t get any variant readings along the mapped portion of the refseq. Not sure why. I know there are a few variants.  
  > **username_5**: This answer would be more useful if it included a cautionary comment about how what the OP is asking about is not a format conversion, but an analytical process, ie variant calling, like username_6 provided. In addition, the recommendation to "go through the whole github documentation" is unlikely to be satisfying given the OP is probably new to the field. username_6's pointers to specific resources are much more helpful.  
  
  ---
  
  