<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/deep-learning-for-cancer-immunotherapy/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://tensorflow.rstudio.com/blog/dl-for-cancer-immunotherapy.html"> TensorFlow for R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>This is a guest post from Leon Eyrich Jessen, a postdoctoral researcher in the <a rel="nofollow" href="http://www.bioinformatics.dtu.dk/english/Research_new/Health-informatics/Immunoinformatics-and-machine-learning" target="_blank">Immunoinformatics and Machine Learning Group</a> at the Technical University of Denmark.</p>
</div>
<div>
<h2>Introduction</h2>
<div>
<p><a rel="nofollow" href="https://i0.wp.com/commons.wikimedia.org/wiki/File:Adoptive_T-cell_therapy.png?ssl=1" target="_blank"> <img src="https://i0.wp.com/tensorflow.rstudio.com/blog/images/deep-learning-cancer-immunotherapy/Adoptive_T-cell_therapy.png?w=350&ssl=1" data-recalc-dims="1"></a></p>
<p> <a rel="nofollow" href="https://commons.wikimedia.org/wiki/User:Simoncaulton" target="_blank">Simon Caulton</a>, <a rel="nofollow" href="https://commons.wikimedia.org/wiki/File:Adoptive_T-cell_therapy.png" target="_blank">Adoptive T-cell therapy</a>, <a rel="nofollow" href="https://creativecommons.org/licenses/by-sa/3.0/legalcode" target="_blank">CC BY-SA 3.0</a></p>
</div>
<p>In my research, I apply deep learning to unravel molecular interactions in the human immune system. One application of my research is within cancer immunotherapy (Immuno-oncology or Immunooncology) – a cancer treatment strategy, where the aim is to utilize the cancer patient’s own immune system to fight the cancer.</p>
<p>The aim of this post is to illustrates how deep learning is successfully being applied to model key molecular interactions in the human immune system. Molecular interactions are highly context dependent and therefore non-linear. Deep learning is a powerful tool to capture non-linearity and has therefore proven invaluable and highly successful. In particular in modelling the molecular interaction between the Major Histocompability Complex type I (MHCI) and peptides (The state-of-the-art model <a rel="nofollow" href="http://www.cbs.dtu.dk/services/NetMHCpan/" target="_blank">netMHCpan</a> identifies 96.5% of natural peptides at a very high specificity of 98.5%).</p>
<div>
<h3>Adoptive T-cell therapy</h3>
<p>Some brief background before diving in. Special immune cells (T-cells) patrol our body, scanning the cells to check if they are healthy. On the surface of our cells is the MHCI – a highly specialized molecular system, which reflects the health status inside our cells. This is done by displaying small fragments of proteins called peptides, thus reflecting the inside of the cell. T-cells probe these molecular displays to check if the peptides are from our own body (self) or foreign (non-self), e.g. from a virus infection or cancer. If a displayed peptide is non-self, the T-cells has the power to terminate the cell.</p>
<p>Adoptive T-cell therapy is a form of cancer immunotherapy that aims to isolate tumor infiltrating T-cells from the tumor in the patient, possibly genetically engineer them to be cancer-specific, grow them in great numbers and reintroduce them into the body to fight the cancer. In order to terminate cancer cells, the T-cell needs to be activated by being exposed to tumor peptides bound to MHCI (pMHCI). By analyzing the tumor genetics, relevant peptides can be identified and depending on the patients particular type of MHCI, we can predict which pMHCI are likely to be present in the tumor in the patient and thus which pMHCIs should be used to activate the T-cells.</p>
</div>
</div>
<div>
<h2>Peptide Classification Model</h2>
<p>For this use case, we applied three models to classify whether a given peptide is a ‘strong binder’ <code>SB</code>, ‘weak binder’ <code>WB</code> or ‘non-binder’ <code>NB</code>. to MHCI (Specific type: <code>HLA-A*02:01</code>). Thereby, the classification uncovers which peptides, will be presented to the T-cells. The models we tested were:</p>
<ul>
<li>A deep feed forward fully connected ANN</li>
<li>A convolutional ANN (connected to a FFN)</li>
<li>A random forest (for comparison)</li>
</ul>
<p>Next, we’ll dive into building the artificial neural network. If you want to a more detailed explanation of cancer immunotherapy and how it interacts with the human immune system before going further, see the <a rel="nofollow" href="https://tensorflow.rstudio.com/blog/dl-for-cancer-immunotherapy.html#primer-on-cancer-immunotherapy" target="_blank">primer on cancer immunotherapy</a> at the end of the post.</p>
<div>
<h3>Prerequisites</h3>
<p>This example utilizes the <a rel="nofollow" href="https://tensorflow.rstudio.com/keras" target="_blank">keras</a> package, several <a rel="nofollow" href="https://tidyverse.org/" target="_blank">tidyverse</a> packages, as well as the <a rel="nofollow" href="https://github.com/omarwagih/ggseqlogo" target="_blank">ggseqlogo</a> and <a rel="nofollow" href="https://github.com/leonjessen/PepTools" target="_blank">PepTools</a> packages. You can install these packages as follows:</p>
<div>
<pre><code><span># Keras + TensorFlow and it's dependencies</span>
<span>install.packages</span>(<span>&quot;keras&quot;</span>)
<span>library</span>(keras)
<span><a rel="nofollow" href="https://tensorflow.rstudio.com/keras/reference/install_keras.html" target="_blank">install_keras</a></span>()

<span># Tidyverse (readr, ggplot2, etc.)</span>
<span>install.packages</span>(<span>&quot;tidyverse&quot;</span>)

<span># Packages for sequence logos and peptides</span>
devtools<span>::</span><span><a rel="nofollow" href="http://www.rdocumentation.org/packages/devtools/topics/install_github?tap_a=5644-dce66f&tap_s=10907-287229" target="_blank">install_github</a></span>(<span>&quot;omarwagih/ggseqlogo&quot;</span>)
devtools<span>::</span><span><a rel="nofollow" href="http://www.rdocumentation.org/packages/devtools/topics/install_github?tap_a=5644-dce66f&tap_s=10907-287229" target="_blank">install_github</a></span>(<span>&quot;leonjessen/PepTools&quot;</span>)</code></pre>
</div>
<p>We can now load all of the packages we need for this example:</p>
<div>
<pre><code><span>library</span>(keras)
<span>library</span>(tidyverse)
<span>library</span>(PepTools)</code></pre>
</div>
</div>
<div>
<h3>Peptide Data</h3>
<p>The input data for this use case was created by generating 1,000,000 random <code>9-mer</code> peptides by sampling the one-letter code for the 20 amino acids, i.e. <code>ARNDCQEGHILKMFPSTWYV</code>, and then submitting the peptides to MHCI binding prediction using the current state-of-the-art model <a rel="nofollow" href="http://www.cbs.dtu.dk/services/NetMHCpan/" target="_blank">netMHCpan</a>. Different variants of MHCI exists, so for this case we chose <code>HLA-A*02:01</code>. This method assigns ‘strong binder’ <code>SB</code>, ‘weak binder’ <code>WB</code> or ‘non-binder’ <code>NB</code> to each peptide.</p>
<p>Since <code>n(SB) &lt; n(WB) &lt; n(NB)</code>, the data was subsequently balanced by down sampling, such that <code>n(SB) = n(WB) = n(NB) = 7,920</code>. Thus, <a rel="nofollow" href="https://raw.githubusercontent.com/leonjessen/tensorflow_rstudio_example/master/data/ran_peps_netMHCpan40_predicted_A0201_reduced_cleaned_balanced.tsv" target="_blank">a data set with a total of 23,760 data points was created</a>. 10% of the data points were randomly assigned as <code>test</code> data and the remainder as <code>train</code> data. It should be noted that since the data set originates from a model, the outcome of this particular use case will be a model of a model. However, netMHCpan is very accurate (96.5% of natural ligands are identified at a very high specificity 98.5%).</p>
<p>In the following each peptide will be encoded by assigning a vector of 20 values, where each value is the probability of the amino acid mutating into 1 of the 20 others as defined by the <a rel="nofollow" href="https://en.wikipedia.org/wiki/BLOSUM#An_example_-_BLOSUM62" target="_blank">BLOSUM62 matrix</a> using the <code><a rel="nofollow" href="http://www.rdocumentation.org/packages/PepTools/topics/pep_encode?tap_a=5644-dce66f&tap_s=10907-287229" target="_blank">pep_encode()</a></code> function from the <a rel="nofollow" href="https://github.com/leonjessen/PepTools/" target="_blank">PepTools</a> package. This way each peptide is converted to an ‘image’ matrix with 9 rows and 20 columns.</p>
<p>Let’s load the data:</p>
<div>
<pre><code>pep_file &lt;-<span> </span><span><a rel="nofollow" href="https://tensorflow.rstudio.com/keras/reference/get_file.html" target="_blank">get_file</a></span>(<span>&quot;ran_peps_netMHCpan40_predicted_A0201_reduced_cleaned_balanced.tsv&quot;</span>, 
                     <span>origin =</span> <span>&quot;https://git.io/vb3Xa&quot;</span>) 
pep_dat &lt;-<span> </span><span>read_tsv</span>(<span>file =</span> pep_file)</code></pre>
</div>
<p>The example peptide data looks like this:</p>
<div>
<pre><code>pep_dat <span>%>%</span><span> </span><span>head</span>(<span>5</span>)</code></pre>
</div>
<pre><code># A tibble: 5 x 4
  peptide   label_chr label_num data_type
  </code></pre></div></div>