Answers.Body: <p>Skipped references are similar to deletions, but the different symbols used are indicating that it's an <em>expected</em> deletion. The most common use for a skipped reference is when excluding intronic sequence from cDNA reads that are being matched to a genome reference.</p>
  
  <p>Note that the skipped reference bases are added by the mapping program, which generates the SAM/BAM/CRAM format and decides on whether to call a deletion or a skipped base.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-09T11:37:41.613Z
Answers.Text: How would samtools recognize that? Surely it doesn't mode splice sites! Does this mean we only see a reference skip if using a particular samtools flag to tell it we're feeding it cDNA? Otherwise, won't it just see a deletion?
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-09T18:11:21.820Z
Answers.Text: Samtools is a set of tools to operate on SAM/BAM/CRAM files; it doesn't generate them in the first place. I've added clarification to my answer.
Answers.UserDisplayName: gringer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-09T23:03:01.567Z
Answers.Text: thanks, I know what they are. What I'm wondering is how samtools will differentiate between a deletion and a skipped reference. Both will appear as a gapped alignment, presumably, so what's the difference between one and the other in the bam/sam file?
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-10T11:03:49.220Z
Answers.Text: The person who asked the question already mentioned that:
  
  "a '>' or '<' for a reference skip... a pattern `-[0-9]+[ACGTNacgtn]+' represents a deletion from the reference"
Answers.UserDisplayName: gringer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-10T13:38:25.080Z
Answers.Text: I know. I guess I must be missing something really obvious, but what I'm asking is how samtools differentiates between a normal deletion and a reference skip. Since a reference skip is just a deletion, I don't see how samtools would know to mark it specially. Presumably, the necessary information is somehow encoded in the bam, but what is that? How can samtools know whether this deletion is an _expected_ one, as you put it?
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-10T19:10:11.777Z
Answers.Text: Repeating myself a bit here... samtools doesn't know this. That information is provided (or not) by the mapper.
Answers.UserDisplayName: gringer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-11T09:09:03.183Z
Answers.Text: So it _is_ somehow encoded in the bam file, thanks. That's what I was wondering about.
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-11T11:42:04.713Z
Answers.Text: @terdon: The SAM specification is at <https://samtools.github.io/hts-specs/SAMv1.pdf>. CIGAR operators are described in §1.4 or you can search for “intron”.
Answers.UserDisplayName: John Marshall
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-09T02:26:41.753Z
Answers.LastActivityDate: 2019-11-09T18:09:50.773Z
Answers.LastEditDate: 2019-11-09T18:09:50.773Z
Answers.UserDisplayName: gringer
Answers.Body: <p>That documentation has been expanded recently (see <a href="https://github.com/samtools/samtools/pull/1055" rel="nofollow noreferrer">PR #1055</a>) and now describes the characters seen in this column in more detail:</p>
  
  <pre><code>Forward   Reverse                    Meaning
  ---------------------------------------------------------------
   . dot    , comma   Base matches the reference base
   ACGTN     acgtn    Base is a mismatch to the reference base
     &gt;         &lt;      Reference skip (due to CIGAR "N")
     *         *      Deletion of the reference base (CIGAR "D")
  </code></pre>
  
  <p>(And so on — see the pull request or <em>doc/samtools-mpileup.1</em> on the <a href="https://github.com/samtools/samtools" rel="nofollow noreferrer"><strong>develop</strong> branch</a> for the complete pileup format description. The documentation on that web page will be updated when this is released in a new samtools release.)</p>
  
  <p>As noted in <a href="https://bioinformatics.stackexchange.com/a/421/134">https://bioinformatics.stackexchange.com/a/421/134</a>, SAM has always had separate <code>D</code> (deletion from the reference) and <code>N</code> (skipped region from the reference) operators. These are treated similarly computationally but emitted intentionally by aligners to distinguish introns and the like from other deletions.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-11T11:37:19.250Z
Answers.LastActivityDate: 2019-11-11T12:03:15.920Z
Answers.LastEditDate: 2019-11-11T12:03:15.920Z
Answers.UserDisplayName: John Marshall
Body: <p>The samtools documentation for <a href="http://www.htslib.org/doc/samtools.html" rel="nofollow noreferrer">mpileup</a> states:</p>
  
  <blockquote>
    <p>At this column, a dot stands for a match to the reference base on the forward strand, a comma for a match on the reverse strand, a '>' or '&lt;' for a reference skip
    ...
    Similarly, a pattern `-[0-9]+[ACGTNacgtn]+' represents a deletion from the reference.</p>
  </blockquote>
  
  <p>What is a reference skip? </p>
  
Tags: <samtools><mpileup>
Title: What is a samtools mpileup reference skip?
ThreadText: # What is a samtools mpileup reference skip?
  
  (Asked by: username_0 on 2019-11-08)
  
  The samtools documentation for [mpileup](http://www.htslib.org/doc/samtools.html) states:
  
  > At this column, a dot stands for a match to the reference base on the forward strand, a comma for a match on the reverse strand, a '>' or '<' for a reference skip
  > ...
  > Similarly, a pattern `-[0-9]+[ACGTNacgtn]+' represents a deletion from the reference.
  
  What is a reference skip?
  
  **Tags:** samtools, mpileup
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2019-11-11. Score: 5 | Accepted answer
  
  That documentation has been expanded recently (see [PR #1055](https://github.com/samtools/samtools/pull/1055)) and now describes the characters seen in this column in more detail:
  
  ```
  Forward   Reverse                    Meaning
  ---------------------------------------------------------------
   . dot    , comma   Base matches the reference base
   ACGTN     acgtn    Base is a mismatch to the reference base
     >         <      Reference skip (due to CIGAR "N")
     *         *      Deletion of the reference base (CIGAR "D")
  
  ```
  
  (And so on — see the pull request or *doc/samtools-mpileup.1* on the [**develop** branch](https://github.com/samtools/samtools) for the complete pileup format description. The documentation on that web page will be updated when this is released in a new samtools release.)
  
  As noted in <https://bioinformatics.stackexchange.com/a/421/134>, SAM has always had separate `D` (deletion from the reference) and `N` (skipped region from the reference) operators. These are treated similarly computationally but emitted intentionally by aligners to distinguish introns and the like from other deletions.
  
  
  ---
  
  ### Answer by username_1 on 2019-11-09. Score: 1
  
  Skipped references are similar to deletions, but the different symbols used are indicating that it's an *expected* deletion. The most common use for a skipped reference is when excluding intronic sequence from cDNA reads that are being matched to a genome reference.
  
  Note that the skipped reference bases are added by the mapping program, which generates the SAM/BAM/CRAM format and decides on whether to call a deletion or a skipped base.
  
  > **Comments:**
  > **username_2**: How would samtools recognize that? Surely it doesn't mode splice sites! Does this mean we only see a reference skip if using a particular samtools flag to tell it we're feeding it cDNA? Otherwise, won't it just see a deletion?  
  > **username_1**: Samtools is a set of tools to operate on SAM/BAM/CRAM files; it doesn't generate them in the first place. I've added clarification to my answer.  
  > **username_2**: thanks, I know what they are. What I'm wondering is how samtools will differentiate between a deletion and a skipped reference. Both will appear as a gapped alignment, presumably, so what's the difference between one and the other in the bam/sam file?  
  > **username_1**: The person who asked the question already mentioned that:  "a '>' or '<' for a reference skip... a pattern `-[0-9]+[ACGTNacgtn]+' represents a deletion from the reference"  
  > **username_2**: I know. I guess I must be missing something really obvious, but what I'm asking is how samtools differentiates between a normal deletion and a reference skip. Since a reference skip is just a deletion, I don't see how samtools would know to mark it specially. Presumably, the necessary information is somehow encoded in the bam, but what is that? How can samtools know whether this deletion is an _expected_ one, as you put it?  
  > **username_1**: Repeating myself a bit here... samtools doesn't know this. That information is provided (or not) by the mapper.  
  > **username_2**: So it _is_ somehow encoded in the bam file, thanks. That's what I was wondering about.  
  > **username_3**: @username_2: The SAM specification is at <https://samtools.github.io/hts-specs/SAMv1.pdf>. CIGAR operators are described in §1.4 or you can search for “intron”.  
  
  ---
  
  