<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Comparative Identification and Assessment of Single Nucleotide Variants Through Shifts in Base Call Frequencies</title>
<!-- 2014-08-14 Do 20:52 -->
<meta  http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta  name="generator" content="Org-mode" />
<meta  name="author" content="Julian Gehring, Simon Anders, Bernd Klaus (EMBL Heidelberg)" />

<script type="text/javascript" src="http://orgmode.org/org-info.js">
/**
 * @source: http://orgmode.org/org-info.js
 * @licstart  The following is the entire license notice for the
 *  JavaScript code in http://orgmode.org/org-info.js.
 * @licend  The above is the entire license notice
 * for the JavaScript code in http://orgmode.org/org-info.js.
 */
</script>
<script type="text/javascript">
/*
@licstart  The following is the entire license notice for the
JavaScript code in this tag.
@licend  The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
org_html_manager.set("TOC_DEPTH", "4");
org_html_manager.set("LINK_HOME", "");
org_html_manager.set("LINK_UP", "");
org_html_manager.set("LOCAL_TOC", "0");
org_html_manager.set("VIEW_BUTTONS", "0");
org_html_manager.set("MOUSE_HINT", "underline");
org_html_manager.set("FIXED_TOC", "1");
org_html_manager.set("TOC", "1");
org_html_manager.set("VIEW", "showall");
org_html_manager.setup();  // activate after the parameters are set
/*]]>*///-->
</script>
<script type="text/javascript">
/*
@licstart  The following is the entire license notice for the
JavaScript code in this tag.

Copyright (C) 2012-2013 Free Software Foundation, Inc.

The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version.  The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.

As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.


@licend  The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
 function CodeHighlightOn(elem, id)
 {
   var target = document.getElementById(id);
   if(null != target) {
     elem.cacheClassElem = elem.className;
     elem.cacheClassTarget = target.className;
     target.className = "code-highlighted";
     elem.className   = "code-highlighted";
   }
 }
 function CodeHighlightOff(elem, id)
 {
   var target = document.getElementById(id);
   if(elem.cacheClassElem)
     elem.className = elem.cacheClassElem;
   if(elem.cacheClassTarget)
     target.className = elem.cacheClassTarget;
 }
/*]]>*///-->
</script>
<script type="text/javascript" src="http://orgmode.org/mathjax/MathJax.js"></script>
<script type="text/javascript">
<!--/*--><![CDATA[/*><!--*/
    MathJax.Hub.Config({
        // Only one of the two following lines, depending on user settings
        // First allows browser-native MathML display, second forces HTML/CSS
        //  config: ["MMLorHTML.js"], jax: ["input/TeX"],
            jax: ["input/TeX", "output/HTML-CSS"],
        extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js",
                     "TeX/noUndefined.js"],
        tex2jax: {
            inlineMath: [ ["\\(","\\)"] ],
            displayMath: [ ['$$','$$'], ["\\[","\\]"], ["\\begin{displaymath}","\\end{displaymath}"] ],
            skipTags: ["script","noscript","style","textarea","pre","code"],
            ignoreClass: "tex2jax_ignore",
            processEscapes: false,
            processEnvironments: true,
            preview: "TeX"
        },
        showProcessingMessages: true,
        displayAlign: "center",
        displayIndent: "2em",

        "HTML-CSS": {
             scale: 100,
             availableFonts: ["STIX","TeX"],
             preferredFont: "TeX",
             webFont: "TeX",
             imageFont: "TeX",
             showMathMenu: true,
        },
        MMLorHTML: {
             prefer: {
                 MSIE:    "MML",
                 Firefox: "MML",
                 Opera:   "HTML",
                 other:   "HTML"
             }
        }
    });
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<h1 class="title">Comparative Identification and Assessment of Single Nucleotide Variants Through Shifts in Base Call Frequencies</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">1. Motivation</a></li>
<li><a href="#sec-2">2. Methodology</a>
<ul>
<li><a href="#sec-2-1">2.1. Comparative shift of non-consensus base call frequencies</a></li>
<li><a href="#sec-2-2">2.2. Confidence intervals</a>
<ul>
<li><a href="#sec-2-2-1">2.2.1. Decision making with confidence intervals</a></li>
</ul>
</li>
<li><a href="#sec-2-3">2.3. Distinguishing event classes</a></li>
<li><a href="#sec-2-4">2.4. Identifying variant sites in large datasets</a></li>
</ul>
</li>
<li><a href="#sec-3">3. Workflow</a>
<ul>
<li><a href="#sec-3-1">3.1. Multiple Sample Simulation Study</a></li>
</ul>
</li>
<li><a href="#sec-4">4. Supplementary Information</a>
<ul>
<li><a href="#sec-4-1">4.1. Strand-specific analysis</a></li>
<li><a href="#sec-4-2">4.2. Assessing performance of confidence interval methods</a></li>
<li><a href="#sec-4-3">4.3. Benchmarking of performance and resources</a></li>
</ul>
</li>
<li><a href="#sec-5">5. Frequently Asked Questions</a>
<ul>
<li><a href="#sec-5-1">5.1. Getting help</a></li>
<li><a href="#sec-5-2">5.2. Installing the package</a></li>
</ul>
</li>
<li><a href="#sec-6">6. References</a></li>
<li><a href="#sec-7">7. Session Info</a></li>
</ul>
</div>
</div>
<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Rariant}
%\VignettePackage{Rariant}
-->

<!--begin.rcode results='hide', echo=FALSE, message=FALSE, warning=FALSE
set.seed(1)

options(width = 70)

style_file = "bioc.css"

library(knitr)

style = if(file.exists(style_file))
            paste(readLines(style_file), collapse = "\n")

opts_knit$set(self.contained = TRUE,
              upload.fun = image_uri,
              header = c(highlight = style))

opts_chunk$set(comment = "  ",
               fig.path = "",
               fig.align = "center",
               out.width = "100%",
               dpi = 300,
               indent = 10,
               cache = FALSE,
               cache.path = "../cache")

knit_hooks$set(fig.cap = function(before, options, envir) {
    if(!before) {
        paste('<p class="caption">',options$fig.cap,"</p>",sep="")
    }
})
end.rcode-->

<p class="author-top">Julian Gehring, Simon Anders, Bernd Klaus (EMBL Heidelberg)</p>


<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> Motivation</h2>
<div class="outline-text-2" id="text-1">
<p>
The advances in high-throughput nucleotide sequencing have lead to new
possibilities of identifying genomic alterations, which is of particular interest
for cancer research.  While the detection of genomic variants is often conducted
by comparing against a population-based reference sequence (such as the human GRCh
37), in the investigation of tumors a comparison between matched samples is
predominantly pursued.  Considering a test sample \(T\) and a control sample \(C\),
the aim is to identify single nucloetide variants (SNVs) which show significant
changes between the two.  Typically, this is applied for comparing
a tumor sample against a matched normal/constitutive sample of the same patient,
focusing on alterations that may have occurred in the transition to the
cancerous tissue, and therefore are often termed <i>somatic</i> variants.  However, a
broader range of questions can be addressed by extending the focus to include
genomic changes of temporally or spatially separated samples to each other, to
investigate tumor evolution and subclonal shifts [<a href="#yates_evolution_2012">11</a>].
</p>

<p>
Extending the scope of comparative variant analyses in a cancer related setting
may require an accompanying change in definitions.  In the classical tumor
versus normal setting, a <i>somatic</i> event is characterized by both the presence
of the variant in the tumor and the absence in the matched normal
[<a href="#roberts_comparative_2013">16</a>].  This definition is not satisfactory for
comparing different tumor stages against each other.  If we imagine two stages
of a tumor haboring multiple subclones, variants may be present in both stages
with changing abundances.  Here, the classical definition of a <i>somatic</i> variant
would result in missing the event.  In the following, we will therefore focus on
estimating the shift in variant allele frequencies between a test and a control
sample.  The classical somatic definition requiring the variant to be absent in the
control constitutes a special case of this.
</p>

<p>
Numerous approaches focus on more narrowly defined somatic comparisons,
motivated by scientific questions in the field of cancer genomics
[<a href="#kim_comparing_2013">15</a>] [<a href="#roberts_comparative_2013">16</a>].  Most existing methods 
do not allow an explicit statement about the evidence for the absence of a
putative variant in a sample, and a clear distinction is needed whether a <i>negative</i> call
results from a true negative site or the lack of statistical power to detect it.
As an example, imagine a variant calling approach using a hypothesis test with the
null hypothesis that the variant frequencies at a locus are identical for both
samples.  While a significant p-value provides evidence for the presence of a
variant, inverting this argument does not work: A non-significant p-value can
both be indicative of the absence or insufficient power.  Furthermore, most
methods return only a point estimate for the variant frequency in the tumor,
without stating the confidence of the estimate.  However, this information would
be critical to reliably differentiate between variants arising from competing
subclonal populations.
</p>

<p>
With the <code>Rariant</code> package, we pursue a generalized approach for identifying and
quantifying SNV alterations from high-throughput sequencing data in comparative
settings. By focusing on shifts of the non-consensus base call frequencies,
events like loss of heterozygosity and clonal expansions in addition to somatic
variants can be detected.  In the following, we will 1) outline the methodological
framework, 2) provide an example workflow on how to obtain a call set starting
from short-read alignments, and 3) illustrate potential benefits of the methods on
a biological cancer data set.  This methodology can be used for a high
performance identification of variant sites as well as to quantitatively assess
the presence or absence in comparisons between matched samples.
</p>
</div>
</div>


<div id="outline-container-sec-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Methodology</h2>
<div class="outline-text-2" id="text-2">
</div><div id="outline-container-sec-2-1" class="outline-3">
<h3 id="sec-2-1"><span class="section-number-3">2.1</span> Comparative shift of non-consensus base call frequencies</h3>
<div class="outline-text-3" id="text-2-1">
<p>
Starting with a set of aligned reads we observe the sequencing depth \(N^{S}_{i}\)
and the number of non-consensus base calls \(K^{S}_{i}\) for a sample \(S\) at
position \(i\).  Non-consensus is here defined as base calls that differ from the
consensus sequence, which can be either the reference sequence or, in a
comparative setting, the most abundant base call in the control sample.  The
non-consensus rate \(p^{S}_{i}\), which we assume to be binomially distributed,
can then be estimated as
</p>

<p>
$$\hat{p}^{S}_{i} = \frac{K^{S}_{i}}{N^{S}_{i}}$$
</p>

<p>
for sites with \(N^{S}_{i} > 0\).  Since \(K^{S}_{i} \leq N^{S}_{i}\), the rates are
bound to the range \([0,1]\).
</p>

<p>
The true non-consensus rate
</p>

<p>
$$p^{S}_{i} = v^{S}_{i} + e^{S}_{i}$$
</p>

<p>
comprises the presence of a putative variant with a frequency \(v^{S}_{i}\) and a
technical error rate \(e^{S}_{i}\).  In order to detect and describe the change in
the variant frequency, we focus on the shift \(d_{i}\) in non-consensus rates
as the difference of the rates between the test and control samples, which we
estimate as
</p>

<p>
$$\hat{d}_{i} = \hat{p}^{T}_{i} - \hat{p}^{C}_{i}.$$
</p>

<p>
If we assume that the true site-specific technical error rates are identical
between the two matched samples  [<a href="#muralidharan_detecting_2012">10</a>], the difference
of the rates yields an unbiased estimate for the change in the variant
frequency.  Thus, positions not haboring biological alterations will result in
\(\hat{d}_{i} \approx 0\).
</p>
</div>
</div>


<div id="outline-container-sec-2-2" class="outline-3">
<h3 id="sec-2-2"><span class="section-number-3">2.2</span> Confidence intervals</h3>
<div class="outline-text-3" id="text-2-2">
<p>
Distinguishing biological variants from noise requires knowledge
about the variance of the point estimate \(\hat{d_{i}}\).  By constructing a
confidence interval (CI) for \(d_{i}\) with confidence level \(\beta\)
[<a href="#agresti_categorical_2013">14</a>], we assess the certainty of the estimated shift in
non-consensus frequencies.  The probability of the true value being outside the
confidence interval is less than \(\alpha = 1 - \beta\).  This is in concordance
with the type I or \(\alpha\) error definition in statistical testing.
</p>

<p>
Under the assumption that the non-consensus counts \(K^{S}_{i}\) in our samples
follow binomial distributions with parameters \(p^{S}_{i}\) and \(N^{S}_{i}\),
several methods have been established for estimating confidence intervals for
the difference of two rate parameters [<a href="#fleiss_statistical_2013">12</a>]
[<a href="#fagerland_recommended_2011">7</a>].  The performance of an approach is generally
described in terms of its coverage probability indicating the probability of a
confidence interval to cover the true value (see <a href="#sec-4-2">4.2</a>).  Coverage probabilities greater and less than the
confidence level \(\beta\) describe conservative and liberal behaviors,
respectively. Due to the conservative coverage probabilities and high
computational effort of exact confidence interval estimates, approximate methods
are generally preferred [<a href="#agresti_approximate_1998">1</a>]
[<a href="#fagerland_recommended_2011">7</a>].
</p>

<p>
The Agresti-Caffo (AC) confidence interval [<a href="#agresti_simple_2000">2</a>]
</p>

<p>
$$\tilde{p}^{T} - \tilde{p}^{C} \pm z \sqrt{ \frac{\tilde{p}^{T} (1 -
\tilde{p}^{T})} {\tilde{N}^{T}} + \frac{\tilde{p}^{C}(1 - \tilde{p}^{C})}
{\tilde{N}^{C}} }$$
</p>

<p>
with 
</p>

<p>
$$\tilde{p}^{X} = \frac{K^{X}+\zeta}{N^{X}+2\zeta},$$
</p>

<p>
$$\tilde{N}^{X} = N^{X} + 2\zeta,$$
</p>

<p>
$$\zeta = \frac{1}{4} z^2,$$
</p>

<p>
and \(z = z_{(1-\beta)/2}\) as the upper \((1-\beta)/2\) percentile of the standard
normal distribution), is an approximation of the score test-based
confidence interval.  Several publications emphasize the usefulness and
advantages of the AC method over related approaches
[<a href="#fagerland_recommended_2011">7</a>] [<a href="#piegorsch_sample_2004">3</a>]
[<a href="#schaarschmidt_approximate_2008">5</a>].
</p>
</div>


<div id="outline-container-sec-2-2-1" class="outline-4">
<h4 id="sec-2-2-1"><span class="section-number-4">2.2.1</span> Decision making with confidence intervals</h4>
<div class="outline-text-4" id="text-2-2-1">
<p>
While the estimate for the shift in the non-consenus frequency \(\hat{d}\)
indicates the change in abundance and direction of a variant, the corresponding
confidence interval gives us information about the precision and power of the
estimate.  Generally, wide confidence intervals will be present at sites with
little statistical power, as due to low sequencing depths.
</p>

<p>
For the case that we compare a tumor to a matched normal sample, we show a set
of hypothetical cases that can be distinguished by regarding the point estimate
and its confidence interval:
</p>

<ol class="org-ol">
<li>Presence of a somatic, heterozygous variant
</li>
<li>Presence of a somatic, subclonal variant
</li>
<li>Presence of loss of heterozygosity
</li>
<li>Absence of a somatic variant
</li>
<li>Presence or absence of a variant cannot be distinguished due to the low
certainty of the estimate
</li>
<li>No power due to insufficient sequencing depth
</li>
</ol>

<!--begin.rcode ci_cases_plot, echo=FALSE, message=FALSE, fig.width=14, fig.height=7, fig.cap='Illustrative cases of confidence intervals for somatic variant frequency estimates'
library(ggplot2)

df = data.frame(
    x = factor(rep(c(""), times = 6)),
    case = factor(1:6),
    d = c(0.5, 0.3, -0.525, 0, 0.2, 0),
    cil = c(0.45, 0.2, -0.60, -0.05, -0.3, -1),
    ciu = c(0.55, 0.4, -0.45, 0.05, 0.7, 1)
    )

p = ggplot(df) + geom_hline(aes(yintercept = 0), color = "darkgray") +
geom_pointrange(aes(x = x, y = d, ymin = cil, ymax = ciu), size = 1, color =
"black") + facet_grid( ~ case) + ylim(-1, 1) + theme_bw() +
theme(legend.position = "none") + xlab("") + ylab("pT - pC")

print(p)
end.rcode-->
</div>
</div>
</div>


<div id="outline-container-sec-2-3" class="outline-3">
<h3 id="sec-2-3"><span class="section-number-3">2.3</span> Distinguishing event classes</h3>
<div class="outline-text-3" id="text-2-3">
<p>
Focusing on the comparative shift of non-consensus frequencies allows us to detect and
distinguish different types of events.  Since <code>Rariant</code> does not make explicit
assumptions about the abundance of a potential variant in the control sample, we
are further able to find clonal shifts, for example between different tumor
samples, or losses of heterozygocity. Generally, gains and losses of variant
alleles are characterized by positive and negative values of \(d\), respectively.
For a differentiated interpretation of the results, we classify a variant into
one of four classes:
</p>

<dl class="org-dl">
<dt> somatic </dt><dd>A somatic variant that does not occur in the control sample
</dd>
<dt> hetero/LOH </dt><dd>A shift away from heterozygous SNP in the control sample
</dd>
<dt> undecided </dt><dd>Both of the 'somatic' or 'hetero' are possible
</dd>
<dt> powerless </dt><dd>A distinction between the two classes cannot be made due to a
lack of power
</dd>
</dl>

<p>
The classification is based on two binomial tests for each position:
</p>

<ol class="org-ol">
<li>Somatic variants where the variant allele is not present in the control
sample, rejecting a binomial test with the alternative hypothesis \(H_{1}:
   p^{C} > 0\).
</li>

<li>Sites with a loss of heterozygosity with a shift away from a heterozygous
variant in the control sample, rejecting a binomial test with the
alternative hypothesis \(H_{1}: p^{C} \neq \frac{1}{2}\).
</li>
</ol>
</div>
</div>


<div id="outline-container-sec-2-4" class="outline-3">
<h3 id="sec-2-4"><span class="section-number-3">2.4</span> Identifying variant sites in large datasets</h3>
<div class="outline-text-3" id="text-2-4">
<p>
The method that we have described before is suited for detecting variant
positions efficiently in large sequencing datasets, including whole-exome and
whole-genome sequencing.  For this purpose, we test for a shift in non-consensus
frequencies between two samples at each genomic position individually:
</p>

<ol class="org-ol">
<li>Form the base counts table for four bases A, C, G, T from the aligned
reads.  In order to reduce the number of false counts, we can optionally
exclude reads with low base calling quality and clip the head of each read.
</li>

<li>Determine the consensus sequence: In a comparative setting, we will use the
most abundant base call.
</li>

<li>Calculate the sequencing depth \(N^{S}_{i}\), mismatch counts \(K^{S}_{i}\), and
derived statistics for both samples, based on the consensus sequence (see
<a href="#sec-2-1">2.1</a>).
</li>

<li>Find potential variant sites with a Fisher's Exact Test, comparing the number
of mismatching and total bases between the samples: \({K^{T}_{i}, N^{T}_{i},
   K^{C}_{i}, N^{C}_{i}}\).  The p-values are corrected for multiple testing
according to the Benjamini-Hochberg procedure.  Only positions rejecting the
null hypothesis at a significance level \(\alpha\) are further on considered as
potential variants.
</li>

<li>Calculate Agresti-Caffo confidence intervals with confidence level \(\beta\),
in order to evaluate presence or absence of the variant (see <a href="#sec-2-2">2.2</a>).
</li>

<li>Classify variant sites into the groups: somatic, LOH, undecided, and
powerless (see <a href="#sec-2-3">2.3</a>).
</li>
</ol>
</div>
</div>
</div>


<div id="outline-container-sec-3" class="outline-2">
<h2 id="sec-3"><span class="section-number-2">3</span> Workflow</h2>
<div class="outline-text-2" id="text-3">
</div><div id="outline-container-sec-3-1" class="outline-3">
<h3 id="sec-3-1"><span class="section-number-3">3.1</span> Multiple Sample Simulation Study</h3>
<div class="outline-text-3" id="text-3-1">
<p>
We want to further demostrate the usage and abilities of the <code>Rariant</code> package
on a real-life data set.  Due to legal and privacy issues, most human cancer
sequencing data is not publicly accessible and therefore cannot serve as an
example data set here.  Alternatively, we conduct an analysis to mimic the
characteristics of current cancer sequencing studies.
</p>

<p>
For the purpose of the analysis, we compare three samples from the 1000 Genomes
project [<a href="#the_1000_genomes_project_consortium_map_2010">6</a>], serving as a
control/normal (<code>control</code>) and two related test/tumor samples (<code>test</code> and
<code>test2</code>).  Further, we simulate a clonal mixture (<code>mix</code>) of the two test samples
by combining their reads.
</p>

<!--begin.rcode results='hide', message=FALSE, warning=FALSE
library(Rariant)

library(GenomicRanges)
library(ggbio)
end.rcode-->


<!--begin.rcode 
tp53_region = GRanges("chr17", IRanges(7565097, 7590856))
end.rcode-->


<!--begin.rcode 
control_bam = system.file("extdata", "platinum", "control.bam", package = "Rariant", mustWork = TRUE)
test1_bam = system.file("extdata", "platinum", "test.bam", package = "Rariant", mustWork = TRUE)
test2_bam = system.file("extdata", "platinum", "test2.bam", package = "Rariant", mustWork = TRUE)
mix_bam = system.file("extdata", "platinum", "mix.bam", package = "Rariant", mustWork = TRUE)
end.rcode-->

<!--begin.rcode 
v_test1 = rariant(test1_bam, control_bam, tp53_region, select = FALSE)
v_test2 = rariant(test2_bam, control_bam, tp53_region, select = FALSE)
v_mix = rariant(mix_bam, control_bam, tp53_region, select = FALSE)
end.rcode-->

<!--begin.rcode 
v_all = GenomicRangesList(T1 = v_test1, T2 = v_test2, M = v_mix)

v_all = endoapply(v_all, updateCalls)
end.rcode-->

<p>
To better understand the evidence for the presence or absence of
particular variants across samples, we plot the confidence intervals, colored
according to the predicted event type, and abundance shifts for all sites of
interest, colored according to the sign of the shift.
</p>

<!--begin.rcode fig.width=14, fig.height=7, fig.cap='Confidence intervals for simulation study'
t_ci = tracks(lapply(v_all, plotConfidenceIntervals, color = "verdict")) + verdictColorScale()

print(t_ci)
end.rcode-->

<!--begin.rcode fig.width=14, fig.height=7, fig.cap='Confidence intervals for simulation study'
t_ci = tracks(lapply(v_all, plotConfidenceIntervals, color = "eventType"))

print(t_ci)
end.rcode-->

<!--begin.rcode fig.width=14, fig.height=7, fig.cap='Abundance shifts for simulation study'
t_rates = tracks(lapply(v_all, plotAbundanceShift))

print(t_rates)
end.rcode-->

<p>
In the following, we look at positions which showed a significant effect in at
least one sample.  This gives us 12 positions to consider in the following.
</p>

<p>
While most of the variants are somatic, i.e. they do not appear in the control
sample, the last variant position shows a loss of a heterozygous SNP.  Looking
for example in more detail into the group of 5 variant sites around 7.85 Mbp: We
can identify them as consistent with a heterozygous somatic variant in the first
sample, since their 95% CIs overlap the value of 0.5.  In contrast, we can show
the absence of the same variants in the second sample.  The third sample again
shows the presence of the variants, as seen in the first case, but with lower
abundance.  Such a result could be expected in a mixture of subclones, in which
some clones carry a somatic variant and others not.  Further, we can also see
the case of the next variant which consistently exists in all three samples with
the same abundance.
</p>

<!--begin.rcode 
z = filterCalls(v_all, verdict %in% c("present", "inbetween", "dontknow"))

elementNROWS(z)
end.rcode-->

<!--begin.rcode fig.width=7, fig.height=7
evidenceHeatmap(z, fill = "d", color = "verdict") + verdictColorScale()
end.rcode-->
</div>
</div>
</div>



<div id="outline-container-sec-4" class="outline-2">
<h2 id="sec-4"><span class="section-number-2">4</span> Supplementary Information</h2>
<div class="outline-text-2" id="text-4">
</div><div id="outline-container-sec-4-1" class="outline-3">
<h3 id="sec-4-1"><span class="section-number-3">4.1</span> Strand-specific analysis</h3>
<div class="outline-text-3" id="text-4-1">
<p>
By comparing the confidence intervals between the two strands, we can further detect and
characterize effects such as variations in sequencing depth and strand biases.
We illustrate this with a set of hypothetical cases for confidence intervals for
two strands.  The upper row (cases 4-7) corresponds to sites with overlapping
CIs, whereas the lower row (cases 1-3) shows cases of disagreements between the
CIs indicative of strand biases.  When analyzing the probability for the overlap
of confidence intervals, an adjustment of the confidence level has to be taken
into account [<a href="#knol_misuse_2011">8</a>].
</p>

<!--begin.rcode echo=FALSE, message=FALSE, fig.width=14, fig.height=7, fig.cap='Illustrative cases of confidence intervals for somatic variant frequency estimates for two strands'
library(ggplot2)

df = data.frame(
    x = factor(rep(c("A", "B"), times = 7)),
    case = factor(rep(c(5, 6, 7, 4, 1, 2, 3), each = 2)),
    dx = c(0.65, -0.65,  0.65,  0.20,  0.65,  0,  0.65,  0.55, 0.65, 0, 0.05, -0.05, -0.05, 0.05),
    cil = c(0.5, -0.8, 0.5, 0.1, 0.5, -0.2, 0.5, 0.4, 0.5, -0.7, -0.1, -0.2, -0.9, -0.8),
    ciu = c(0.8, -0.5, 0.8, 0.3, 0.8, 0.2, 0.8, 0.7, 0.8, 0.7, 0.2, 0.1, 0.8, 0.9),
    group = factor(c(rep("n", 2*3), rep("o", 2*4)))
    )

p = ggplot(df) + geom_hline(aes(yintercept = 0), color = "darkgray") + geom_hline(aes(yintercept = 0.6), color = "darkred", linetype = "dashed") + geom_pointrange(aes(x = x, y = dx, ymin = cil, ymax = ciu), size = 1, color = "black") + facet_wrap(~ case, nrow = 2) + ylim(-1, 1) +  theme_bw() + theme(legend.position = "none") + xlab("Strand") + ylab("Shift in non-consensus rate")

print(p)
end.rcode-->

<p>
Motivated by the analysis of different Illumina genome and exome sequencing, we
consider strand-biases, in which the non-consensus base call rates differ
significantly between strands at sites with sufficient sequencinq depth, a
neglectable problem with current data sets and analysis pipelines (see also <i>Best
practices for short-read processing</i>).  In the presence of strand biases, pooling
the counts of both plus and minus strand may be not desirable.  A possible
solution may be to perform a strand-specific analysis, and later combine the
resulting statistics. Gerstung and colleagues discuss different approaches for
combining p-values [<a href="#gerstung_reliable_2012">9</a>], in particular taking the
minimum, maximum, average, or Fisher combination.  These can be also applied for
confidence intervals, with Fisher's method being equivalent to taking the sum of
both strands.
</p>
</div>
</div>


<div id="outline-container-sec-4-2" class="outline-3">
<h3 id="sec-4-2"><span class="section-number-3">4.2</span> Assessing performance of confidence interval methods</h3>
<div class="outline-text-3" id="text-4-2">
<p>
As outlined before, an important property for assessing confidence intervals is
given by their coverage probabilities.  Ideally, we would expect a method to
have coverage probabilities close to the nominal confidence level &beta; over a
wide range in the parameter space.  Previous publications analyzing the
performance focus on parameter settings that deviate from those of sequencing
data sets [<a href="#fagerland_recommended_2011">7</a>].  Therefore, we perform a simulation
that demonstrates the behavior of the Agresti-Caffo methods for a whole-genome
sequencing study.  For a fixed sequencing depth of 30 in both test and control
sample, the coverage probability of 95% AC confidence intervals is computed for
all possible combinations of mismatch counts \(K^{T}\) and \(K^{C}\).
</p>


<!--begin.rcode 
## WGS
n1 = 30
n2 = 30
k1 = 0:(n1-1)
k2 = 0:(n2-1)
cl = 0.95
n_sample = 1e4

pars = expand.grid(k1 = k1, k2 = k2, n1 = n1, n2 = n2, conf_level = cl)

cp_ac = coverageProbability(pars, fun = acCi, n_sample = n_sample)
end.rcode-->


<!--begin.rcode fig.width=7, fig.height=7, out.width='60%', fig.cap='Coverage probabilities for whole-genome setting'
p_ac = ggplot(cp_ac) + geom_tile(aes(x = k1, y = k2, fill = cp)) +
    scale_fill_gradient2(midpoint = 0.95, limits = c(0.9, 1)) +
    theme_bw() + xlab("kT") + ylab("kC")

print(p_ac)
end.rcode-->

<p>
For mismatch rates close to 0 or 1 in both samples, the Agresti-Caffo method
shows a conservative perfomance.
</p>
</div>
</div>


<div id="outline-container-sec-4-3" class="outline-3">
<h3 id="sec-4-3"><span class="section-number-3">4.3</span> Benchmarking of performance and resources</h3>
<div class="outline-text-3" id="text-4-3">
<p>
For an analysis of two matched human tumor samples, we performed a benchmark to
assess the computational time and memory usage on a standard laptop (Thinkpad
X220 built in 2011).  Both samples contain about 95M reads mapped to the
1000genomes reference sequence reads that are considered in the analysis.  For
the analysis of chromosome 22, the analysis with default parameters required
~873s and 600MB of RAM.  For an analysis of all linear toplevel chromosomes
(autosomes and allosomes), this would require ~15h of time.  Please consider
that the current version of <code>Rariant</code> is under active development and
computational efficiency will increase with newer versions.
</p>
</div>
</div>
</div>



<div id="outline-container-sec-5" class="outline-2">
<h2 id="sec-5"><span class="section-number-2">5</span> Frequently Asked Questions</h2>
<div class="outline-text-2" id="text-5">
</div><div id="outline-container-sec-5-1" class="outline-3">
<h3 id="sec-5-1"><span class="section-number-3">5.1</span> Getting help</h3>
<div class="outline-text-3" id="text-5-1">
<p>
We welcome emails with questions or suggestions about our software, and want to
ensure that we eliminate issues if and when they appear.  We have a few requests
to optimize the process:
</p>

<ul class="org-ul">
<li>All emails and follow-up questions should take place over the <a href="http://bioconductor.org/help/mailing-list/">Bioconductor
mailing list</a>, which serves as a repository of information.
</li>

<li>The subject line should contain <i>Rariant</i> and a few words describing the
problem.  First search the <a href="http://bioconductor.org/help/mailing-list/">Bioconductor mailing list</a>, for past threads which might
have answered your question.
</li>

<li>If you have a question about the behavior of a function, read the sections of
the manual page for this function by typing a question mark and the function
name, e.g. <code>?rariant</code>.  Additionally, read through the vignette to understand
the interplay between different functions of the package.  We spend a lot of
time documenting individual functions and the exact steps that the software is
performing.
</li>

<li>Include all of your R code related to the question you are asking.
</li>

<li>Include complete warning or error messages, and conclude your message with the
full output of <code>sessionInfo()</code>.
</li>
</ul>
</div>
</div>



<div id="outline-container-sec-5-2" class="outline-3">
<h3 id="sec-5-2"><span class="section-number-3">5.2</span> Installing the package</h3>
<div class="outline-text-3" id="text-5-2">
<p>
Before you want to install the <code>Rariant</code> package, please ensure that
you have the latest version of <code>R</code> and <code>Bioconductor</code> installed.  For details on
this, please have a look at the help packages for <a href="http://cran.r-project.org/">R</a> and <a href="http://bioconductor.org/install/">Bioconductor</a>.  Then you
can open <code>R</code> and run the following commands which will install the latest
release version of <code>Rariant</code>:
</p>

<!--begin.rcode eval=FALSE
source("http://bioconductor.org/biocLite.R")
biocLite("Rariant")
end.rcode-->
</div>
</div>
</div>


<div id="outline-container-sec-6" class="outline-2">
<h2 id="sec-6"><span class="section-number-2">6</span> References</h2>
<div class="outline-text-2" id="text-6">
<div id="bibliography">
<h2>References</h2>

</div>
<table>

<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="agresti_approximate_1998">1</a>]
</td>
<td class="bibtexitem">
Alan Agresti and Brent&nbsp;A. Coull.
 Approximate is better than
  exact for interval estimation of
  binomial proportions.
 <em>The American Statistician</em>, 52(2):119126, 1998.
[&nbsp;<a href="http://www.tandfonline.com/doi/abs/10.1080/00031305.1998.10480550">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="agresti_simple_2000">2</a>]
</td>
<td class="bibtexitem">
Alan Agresti and Brian Caffo.
 Simple and effective confidence intervals for proportions and
  differences of proportions result from adding two successes and two failures.
 <em>The American Statistician</em>, 54(4):280288, 2000.
[&nbsp;<a href="http://amstat.tandfonline.com/doi/full/10.1080/00031305.2000.10474560">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="piegorsch_sample_2004">3</a>]
</td>
<td class="bibtexitem">
Walter&nbsp;W. Piegorsch.
 Sample sizes for improved binomial confidence intervals.
 <em>Computational Statistics &amp; Data Analysis</em>, 46(2):309-316, June
  2004.
[&nbsp;<a href="http://dx.doi.org/10.1016/j.csda.2003.10.002">DOI</a>&nbsp;| 
<a href="http://www.sciencedirect.com/science/article/pii/S0167947303002354">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="benjamini_false_2005">4</a>]
</td>
<td class="bibtexitem">
Yoav Benjamini and Daniel Yekutieli.
 False discovery rateadjusted multiple confidence
  intervals for selected parameters.
 <em>Journal of the American Statistical Association</em>,
  100(469):7181, 2005.
[&nbsp;<a href="http://amstat.tandfonline.com/doi/abs/10.1198/016214504000001907">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="schaarschmidt_approximate_2008">5</a>]
</td>
<td class="bibtexitem">
Frank Schaarschmidt, Martin Sill, and Ludwig&nbsp;A. Hothorn.
 Approximate simultaneous confidence intervals for multiple contrasts
  of binomial proportions.
 <em>Biometrical Journal</em>, 50(5):782792, 2008.
[&nbsp;<a href="http://dx.doi.org/10.1002/bimj.200710465">DOI</a>&nbsp;| 
<a href="http://onlinelibrary.wiley.com/doi/10.1002/bimj.200710465/abstract">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="the_1000_genomes_project_consortium_map_2010">6</a>]
</td>
<td class="bibtexitem">
The 1000 Genomes Project Consortium.
 A map of human genome variation from population-scale sequencing.
 <em>Nature</em>, 467(7319):1061-1073, October 2010.
[&nbsp;<a href="http://dx.doi.org/10.1038/nature09534">DOI</a>&nbsp;| 
<a href="http://www.nature.com/nature/journal/v467/n7319/full/nature09534.html">.html</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="fagerland_recommended_2011">7</a>]
</td>
<td class="bibtexitem">
Morten&nbsp;W. Fagerland, Stian Lydersen, and Petter Laake.
 Recommended confidence intervals for two independent binomial
  proportions.
 <em>Statistical methods in medical research</em>, 2011.
[&nbsp;<a href="http://smm.sagepub.com/content/early/2011/10/11/0962280211415469.abstract">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="knol_misuse_2011">8</a>]
</td>
<td class="bibtexitem">
Mirjam&nbsp;J. Knol, Wiebe&nbsp;R. Pestman, and Diederick&nbsp;E. Grobbee.
 The (mis)use of overlap of confidence intervals to assess effect
  modification.
 <em>European Journal of Epidemiology</em>, 26(4):253-254, April 2011.
 PMID: 21424218 PMCID: PMC3088813.
[&nbsp;<a href="http://dx.doi.org/10.1007/s10654-011-9563-8">DOI</a>&nbsp;| 
<a href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3088813/">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="gerstung_reliable_2012">9</a>]
</td>
<td class="bibtexitem">
Moritz Gerstung, Christian Beisel, Markus Rechsteiner, Peter Wild, Peter
  Schraml, Holger Moch, and Niko Beerenwinkel.
 Reliable detection of subclonal single-nucleotide variants in tumour
  cell populations.
 <em>Nature Communications</em>, 3:811, May 2012.
[&nbsp;<a href="http://dx.doi.org/10.1038/ncomms1814">DOI</a>&nbsp;| 
<a href="http://www.nature.com/ncomms/journal/v3/n5/full/ncomms1814.html">.html</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="muralidharan_detecting_2012">10</a>]
</td>
<td class="bibtexitem">
Omkar Muralidharan, Georges Natsoulis, John Bell, Hanlee Ji, and Nancy&nbsp;R.
  Zhang.
 Detecting mutations in mixed sample sequencing data using empirical
  bayes.
 <em>The Annals of Applied Statistics</em>, 6(3):1047-1067, September
  2012.
 Zentralblatt MATH identifier06096521, Mathematical Reviews number
  (MathSciNet) MR3012520.
[&nbsp;<a href="http://dx.doi.org/10.1214/12-AOAS538">DOI</a>&nbsp;| 
<a href="http://projecteuclid.org/euclid.aoas/1346418573">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="yates_evolution_2012">11</a>]
</td>
<td class="bibtexitem">
Lucy&nbsp;R. Yates and Peter&nbsp;J. Campbell.
 Evolution of the cancer genome.
 <em>Nature Reviews Genetics</em>, 13(11):795, November 2012.
[&nbsp;<a href="http://dx.doi.org/10.1038/nrg3317">DOI</a>&nbsp;| 
<a href="http://www.nature.com/nrg/journal/v13/n11/abs/nrg3317.html">.html</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="fleiss_statistical_2013">12</a>]
</td>
<td class="bibtexitem">
Joseph&nbsp;L. Fleiss, Bruce Levin, and Myunghee&nbsp;Cho Paik.
 <em>Statistical methods for rates and proportions</em>.
 John Wiley &amp; Sons, 2013.
[&nbsp;<a href="http://books.google.de/books?hl=de&lr=&id=9VefO7a8GeAC&oi=fnd&pg=PT13&dq=Interval+Estimation+for+the+Difference+Between+Independent+Proportions&ots=po7iNMzBKT&sig=eSFnYXR3AbF3F4BbxIWpGfDUFHM">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="decrouez_split_2013">13</a>]
</td>
<td class="bibtexitem">
Geoffrey Decrouez and Peter Hall.
 Split sample methods for constructing confidence intervals for
  binomial and poisson parameters.
 <em>Journal of the Royal Statistical Society: Series B (Statistical
  Methodology)</em>, page n/an/a, 2013.
[&nbsp;<a href="http://dx.doi.org/10.1111/rssb.12051">DOI</a>&nbsp;| 
<a href="http://onlinelibrary.wiley.com/doi/10.1111/rssb.12051/abstract">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="agresti_categorical_2013">14</a>]
</td>
<td class="bibtexitem">
Alan Agresti.
 <em>Categorical data analysis</em>.
 Wiley, Hoboken, NJ, 2013.

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="kim_comparing_2013">15</a>]
</td>
<td class="bibtexitem">
Su&nbsp;Y. Kim and Terence&nbsp;P. Speed.
 Comparing somatic mutation-callers: beyond venn diagrams.
 <em>BMC Bioinformatics</em>, 14(1):189, June 2013.
 PMID: 23758877.
[&nbsp;<a href="http://dx.doi.org/10.1186/1471-2105-14-189">DOI</a>&nbsp;| 
<a href="http://www.biomedcentral.com/1471-2105/14/189/abstract">http</a>&nbsp;]

</td>
</tr>


<tr valign="top">
<td align="right" class="bibtexnumber">
[<a name="roberts_comparative_2013">16</a>]
</td>
<td class="bibtexitem">
Nicola&nbsp;D. Roberts, R.&nbsp;Daniel Kortschak, Wendy&nbsp;T. Parker, Andreas&nbsp;W. Schreiber,
  Susan Branford, Hamish&nbsp;S. Scott, Garique Glonek, and David&nbsp;L. Adelson.
 A comparative analysis of algorithms for somatic SNV detection in
  cancer.
 <em>Bioinformatics</em>, 29(18):2223-2230, September 2013.
 PMID: 23842810.
[&nbsp;<a href="http://dx.doi.org/10.1093/bioinformatics/btt375">DOI</a>&nbsp;| 
<a href="http://bioinformatics.oxfordjournals.org/content/29/18/2223">http</a>&nbsp;]

</td>
</tr>
</table>
</div>
</div>


<div id="outline-container-sec-7" class="outline-2">
<h2 id="sec-7"><span class="section-number-2">7</span> Session Info</h2>
<div class="outline-text-2" id="text-7">
<!--begin.rcode echo=FALSE, results='markup'
sessionInfo()
end.rcode-->
</div>
</div>
</div>
</body>
</html>
