<?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>SomaticCancerAlterations</title>
<!-- 2013-10-20 Sun 18:22 -->
<meta  http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta  name="generator" content="Org-mode" />
<meta  name="author" content="Julian Gehring, EMBL Heidelberg" />
<style type="text/css">
 <!--/*--><![CDATA[/*><!--*/
  .title  { text-align: center; }
  .todo   { font-family: monospace; color: red; }
  .done   { color: green; }
  .tag    { background-color: #eee; font-family: monospace;
            padding: 2px; font-size: 80%; font-weight: normal; }
  .timestamp { color: #bebebe; }
  .timestamp-kwd { color: #5f9ea0; }
  .right  { margin-left: auto; margin-right: 0px;  text-align: right; }
  .left   { margin-left: 0px;  margin-right: auto; text-align: left; }
  .center { margin-left: auto; margin-right: auto; text-align: center; }
  .underline { text-decoration: underline; }
  #postamble p, #preamble p { font-size: 90%; margin: .2em; }
  p.verse { margin-left: 3%; }
  pre {
    border: 1px solid #ccc;
    box-shadow: 3px 3px 3px #eee;
    padding: 8pt;
    font-family: monospace;
    overflow: auto;
    margin: 1.2em;
  }
  pre.src {
    position: relative;
    overflow: visible;
    padding-top: 1.2em;
  }
  pre.src:before {
    display: none;
    position: absolute;
    background-color: white;
    top: -10px;
    right: 10px;
    padding: 3px;
    border: 1px solid black;
  }
  pre.src:hover:before { display: inline;}
  pre.src-sh:before    { content: 'sh'; }
  pre.src-bash:before  { content: 'sh'; }
  pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
  pre.src-R:before     { content: 'R'; }
  pre.src-perl:before  { content: 'Perl'; }
  pre.src-java:before  { content: 'Java'; }
  pre.src-sql:before   { content: 'SQL'; }

  table { border-collapse:collapse; }
  td, th { vertical-align:top;  }
  th.right  { text-align: center;  }
  th.left   { text-align: center;   }
  th.center { text-align: center; }
  td.right  { text-align: right;  }
  td.left   { text-align: left;   }
  td.center { text-align: center; }
  dt { font-weight: bold; }
  .footpara:nth-child(2) { display: inline; }
  .footpara { display: block; }
  .footdef  { margin-bottom: 1em; }
  .figure { padding: 1em; }
  .figure p { text-align: center; }
  .inlinetask {
    padding: 10px;
    border: 2px solid gray;
    margin: 10px;
    background: #ffffcc;
  }
  #org-div-home-and-up
   { text-align: right; font-size: 70%; white-space: nowrap; }
  textarea { overflow-x: auto; }
  .linenr { font-size: smaller }
  .code-highlighted { background-color: #ffff00; }
  .org-info-js_info-navigation { border-style: none; }
  #org-info-js_console-label
    { font-size: 10px; font-weight: bold; white-space: nowrap; }
  .org-info-js_search-highlight
    { background-color: #ffff00; color: #000000; font-weight: bold; }
  /*]]>*/-->
</style>
<link rel="stylesheet" type="text/css" href="http://www.ebi.ac.uk/~jgehring/css/worg.css" />

<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.
 *
 * Copyright (C) 2012-2013  Sebastian Rose
 *
 *
 * 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 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.

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[/*><!--*/
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", "1");
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  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>
</head>
<body>
<div id="content">
<h1 class="title">SomaticCancerAlterations</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. Data Sets</a></li>
<li><a href="#sec-3">3. Exploring Mutational Data</a></li>
<li><a href="#sec-4">4. Exploring Multiple Studies</a></li>
<li><a href="#sec-5">5. Data Provenance</a>
<ul>
<li><a href="#sec-5-1">5.1. TCGA Data</a>
<ul>
<li><a href="#sec-5-1-1">5.1.1. Processing</a></li>
<li><a href="#sec-5-1-2">5.1.2. Selection Criteria of Data Sets</a></li>
<li><a href="#sec-5-1-3">5.1.3. Consistency Check</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#sec-6">6. Alternatives</a></li>
<li><a href="#sec-7">7. Session Info</a></li>
</ul>
</div>
</div>
<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{SomaticCancerAlterations - HTML}
%\VignettePackage{SomaticCancerAlterations}
-->

<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>
Over the last years, large efforts have been taken to characterize the somatic
landscape of cancers. Many of the conducted studies make their results publicly
available, providing a valuable resource for investigating beyond the level of
individual cohorts. The SomaticCancerAlterations package collects
mutational data of several tumor types, currently focusing on the TCGA calls
sets, and aims for a tight integration with  and 
workflows. In the following, we will illustrate how to access this data and give
examples for use cases.
</p>


<!--begin.rcode echo=FALSE
library(SomaticCancerAlterations)
library(GenomicRanges)
library(ggbio)
end.rcode-->
</div>
</div>

<div id="outline-container-sec-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Data Sets</h2>
<div class="outline-text-2" id="text-2">
<p>
The Cancer Genome Atlas (TCGA)<sup><a id="fnr.1" name="fnr.1" class="footref" href="#fn.1">1</a></sup> is a consortium effort
to analyze a variety of tumor types, including gene expression, methylation,
copy number changes, and somatic
mutations<sup><a id="fnr.2" name="fnr.2" class="footref" href="#fn.2">2</a></sup>. With the
SomaticCancerAlterations package, we provide the callsets of somatic
mutations for all publically available TCGA studies. Over time, more studies
will be added, as they become available and unrestriced in their usage.
</p>

<p>
To get started, we get a list of all available data sets and access the metadata
associated with each study.
</p>

<!--begin.rcode list_datasets
all_datasets = scaListDatasets()
print(all_datasets)
meta_data = scaMetadata()
print(meta_data)
end.rcode-->

<p>
Next, we load a single dataset with the scaLoadDataset function.
</p>

<!--begin.rcode load_dataset
ov = scaLoadDatasets("ov_tcga", merge = TRUE)
end.rcode-->
</div>
</div>

<div id="outline-container-sec-3" class="outline-2">
<h2 id="sec-3"><span class="section-number-2">3</span> Exploring Mutational Data</h2>
<div class="outline-text-2" id="text-3">
<p>
The somatic variants of each study are represented as a object,
ordered by genomic positions. Additional columns describe properties of the
variant and relate it the the affected gene, sample, and patient.
</p>

<!--begin.rcode print
head(ov, 3)
end.rcode-->

<!--begin.rcode summary
with(mcols(ov), table(Variant_Classification, Variant_Type))
end.rcode-->

<p>
With such data at hand, we can identify the samples and genes haboring the most
mutations.
</p>

<!--begin.rcode 
head(sort(table(ov$Sample_ID), decreasing = TRUE))
head(sort(table(ov$Hugo_Symbol), decreasing = TRUE), 10)
end.rcode-->
</div>
</div>

<div id="outline-container-sec-4" class="outline-2">
<h2 id="sec-4"><span class="section-number-2">4</span> Exploring Multiple Studies</h2>
<div class="outline-text-2" id="text-4">
<p>
Instead of focusing on an individual study, we can also import several at
once. The results are stored as a GRangesList in which each
element corresponds to a single study. This can be merged into a single GRanges
object with <code>merge = TRUE</code>.
</p>

<!--begin.rcode multiple_studies
three_studies = scaLoadDatasets(all_datasets[1:3])

print(elementNROWS(three_studies))

class(three_studies)
end.rcode-->

<!--begin.rcode merge_studies
merged_studies = scaLoadDatasets(all_datasets[1:3], merge = TRUE)

class(merged_studies)
end.rcode-->

<p>
We then compute the number of mutations per gene and study:
</p>

<!--begin.rcode mutated_genes_study
gene_study_count = with(mcols(merged_studies), table(Hugo_Symbol, Dataset))

gene_study_count = gene_study_count[order(apply(gene_study_count, 1, sum), decreasing = TRUE), ]

gene_study_count = addmargins(gene_study_count)

head(gene_study_count)
end.rcode-->

<p>
Further, we can subset the data by regions of interests, and compute descriptive
statistics only on the subset.
</p>

<!--begin.rcode subset_studies
tp53_region = GRanges("17", IRanges(7571720, 7590863))

tp53_studies = subsetByOverlaps(merged_studies, tp53_region)
end.rcode-->

<p>
For example, we can investigate which type of somatic variants can be found in
TP53 throughout the studies.
</p>

<!--begin.rcode variant_study_table
addmargins(table(tp53_studies$Variant_Classification, tp53_studies$Dataset))
end.rcode-->

<p>
To go further, how many patients have mutations in TP53 for each cancer type?
</p>

<!--begin.rcode mutateted_genes
fraction_mutated_region = function(y, region) {
    s = subsetByOverlaps(y, region)
    m = length(unique(s$Patient_ID)) / metadata(s)$Number_Patients
    return(m)
}

mutated_fraction = sapply(three_studies, fraction_mutated_region, tp53_region)

mutated_fraction = data.frame(name = names(three_studies), fraction =
mutated_fraction)
end.rcode-->


<!--begin.rcode plot_mutated_genes
library(ggplot2)

p = ggplot(mutated_fraction) + ggplot2::geom_bar(aes(x = name, y = fraction,
fill = name), stat = "identity") + ylim(0, 1) + xlab("Study") + ylab("Ratio") +
theme_bw()

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

<div id="outline-container-sec-5" class="outline-2">
<h2 id="sec-5"><span class="section-number-2">5</span> Data Provenance</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> TCGA Data</h3>
<div class="outline-text-3" id="text-5-1">
<p>
When importing the mutation data from the TCGA servers, we checked the data for
consistency and fix common ambiguities in the annotation.
</p>
</div>

<div id="outline-container-sec-5-1-1" class="outline-4">
<h4 id="sec-5-1-1"><span class="section-number-4">5.1.1</span> Processing</h4>
<div class="outline-text-4" id="text-5-1-1">
<ol class="org-ol">
<li>Selection of the most recent somatic variant calls for each study. These were
stored as <code>*.maf</code> files in the TCGA data
directory<sup><a id="fnr.3" name="fnr.3" class="footref" href="#fn.3">3</a></sup>. If
both manually curated and automatically generated variant calls were
available, the curated version was chosen.
</li>

<li>Importing of the <code>*.maf</code> files into  and checking for consistency with the
TCGA MAF
specifications<sup><a id="fnr.4" name="fnr.4" class="footref" href="#fn.4">4</a></sup>. Please
note that these guidelines are currently only suggestions and most TCGA files
violate some of these.
</li>

<li>Transformation of the imported variants into a GRanges object, with one row
for each reported variant. Only columns related to the genomic origin of the
somatic variant were stored, additional columns describing higher-level
effects, such as mutational consequences and alterations at the protein
level, were dropped. The seqlevels information defining the
chromosomal ranges were taken from the 1000genomes phase 2 reference assembly<sup><a id="fnr.5" name="fnr.5" class="footref" href="#fn.5">5</a></sup>.
</li>

<li>The patient barcode was extracted from the sample barcode.
</li>

<li>Metadata describing the design and analysis of the study was extracted.
</li>

<li>The processed variants were written to disk, with one file for each
study. The metadata for all studies were stored as a single, separate object.
</li>
</ol>
</div>
</div>

<div id="outline-container-sec-5-1-2" class="outline-4">
<h4 id="sec-5-1-2"><span class="section-number-4">5.1.2</span> Selection Criteria of Data Sets</h4>
<div class="outline-text-4" id="text-5-1-2">
<p>
We included data sets in the package that were
</p>

<ul class="org-ul">
<li>conducted by the Broad Institute.
</li>

<li>cleared for unrestricted access and usage<sup><a id="fnr.6" name="fnr.6" class="footref" href="#fn.6">6</a></sup>.
</li>

<li>sequenced with Illumina platforms.
</li>
</ul>
</div>
</div>

<div id="outline-container-sec-5-1-3" class="outline-4">
<h4 id="sec-5-1-3"><span class="section-number-4">5.1.3</span> Consistency Check</h4>
<div class="outline-text-4" id="text-5-1-3">
<p>
According to the TCGA specifications for the <code>MAF</code> files, we screened and
corrected for common artifacts in the data regarding annotation. This included:
</p>

<ul class="org-ul">
<li>Transfering of all genomic coordinates to the NCBI 37 reference notation (with
the chromosome always depicted as 'MT')
</li>

<li>Checking of the entries against all allowed values for this field (currently
for the columns <code>Hugo_Symbol</code>, <code>Chromosome</code>, <code>Strand</code>, <code>Variant_Classification</code>,
<code>Variant_Type</code>, <code>Reference_Allele</code>, <code>Tumor_Seq_Allele1</code>, <code>Tumor_Seq_Allele2</code>,
<code>Verification_Status</code>, <code>Validation_Status</code>, <code>Sequencer</code>).
</li>
</ul>
</div>
</div>
</div>
</div>

<div id="outline-container-sec-6" class="outline-2">
<h2 id="sec-6"><span class="section-number-2">6</span> Alternatives</h2>
<div class="outline-text-2" id="text-6">
<p>
The TCGA data sets can be accessed in different ways. First, the TCGA itself
offers access to certain types of its collected
data<sup><a id="fnr.7" name="fnr.7" class="footref" href="#fn.7">7</a></sup>. Another approach
has been taken by the cBioPortal for Cancer
Genomics<sup><a id="fnr.8" name="fnr.8" class="footref" href="#fn.8">8</a></sup> which has performed
high-level analyses of several TCGA data sources, such as gene expression and
copy number changes. This summarized data can be queried through an 
interface<sup><a id="fnr.9" name="fnr.9" class="footref" href="#fn.9">9</a></sup>.
</p>
</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
sessionInfo()
end.rcode-->
</div>
</div>
<div id="footnotes">
<h2 class="footnotes">Footnotes: </h2>
<div id="text-footnotes">

<div class="footdef"><sup><a id="fn.1" name="fn.1" class="footnum" href="#fnr.1">1</a></sup> <p><a href="http://cancergenome.nih.gov">http://cancergenome.nih.gov</a></p></div>

<div class="footdef"><sup><a id="fn.2" name="fn.2" class="footnum" href="#fnr.2">2</a></sup> <p><a href="https://wiki.nci.nih.gov/display/TCGA/TCGA+Home">https://wiki.nci.nih.gov/display/TCGA/TCGA+Home</a></p></div>

<div class="footdef"><sup><a id="fn.3" name="fn.3" class="footnum" href="#fnr.3">3</a></sup> <p><a href="https://tcga-data.nci.nih.gov/tcgafiles/ftp_auth/distro_ftpusers/anonymous/tumor/">https://tcga-data.nci.nih.gov/tcgafiles/ftp_auth/distro_ftpusers/anonymous/tumor/</a></p></div>

<div class="footdef"><sup><a id="fn.4" name="fn.4" class="footnum" href="#fnr.4">4</a></sup> <p><a href="https://wiki.nci.nih.gov/display/TCGA/Mutation+Annotation+Format+(MAF)">https://wiki.nci.nih.gov/display/TCGA/Mutation+Annotation+Format+(MAF)</a>+Specification</p></div>

<div class="footdef"><sup><a id="fn.5" name="fn.5" class="footnum" href="#fnr.5">5</a></sup> <p><a href="ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/technical/reference/phase2_reference_assembly_sequence/">ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/technical/reference/phase2_reference_assembly_sequence/</a></p></div>

<div class="footdef"><sup><a id="fn.6" name="fn.6" class="footnum" href="#fnr.6">6</a></sup> <p><a href="http://cancergenome.nih.gov/abouttcga/policies/publicationguidelines">http://cancergenome.nih.gov/abouttcga/policies/publicationguidelines</a></p></div>

<div class="footdef"><sup><a id="fn.7" name="fn.7" class="footnum" href="#fnr.7">7</a></sup> <p><a href="https://tcga-data.nci.nih.gov/tcga/tcgaDownload.jsp">https://tcga-data.nci.nih.gov/tcga/tcgaDownload.jsp</a></p></div>

<div class="footdef"><sup><a id="fn.8" name="fn.8" class="footnum" href="#fnr.8">8</a></sup> <p><a href="http://www.cbioportal.org/public-portal">http://www.cbioportal.org/public-portal</a></p></div>

<div class="footdef"><sup><a id="fn.9" name="fn.9" class="footnum" href="#fnr.9">9</a></sup> <p><a href="http://www.cbioportal.org/public-portal/cgds_r.jsp">http://www.cbioportal.org/public-portal/cgds_r.jsp</a></p></div>


</div>
</div></div>
<div id="postamble" class="status">
<p class="author">Author: Julian Gehring, EMBL Heidelberg</p>
<p class="date">Created: 2013-10-20 Sun 18:22</p>
<p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.1.1 (<a href="http://orgmode.org">Org</a> mode 8.2.1)</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>
