<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AntibodyForests - a framework for network analysis on single-cell immune receptors • Platypus</title>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png">
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/yeti/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><meta property="og:title" content="AntibodyForests - a framework for network analysis on single-cell immune receptors">
<meta property="og:description" content="Platypus">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-spy="scroll" data-target="#toc">
    

    <div class="container template-article">
      <header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">Platypus</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">3.4.1</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
<li>
  <a href="../index.html">
    <span class="fa fa-home fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="../articles/quickstart.html">Get started</a>
</li>
<li>
  <a href="../vignette_index.html">Vignettes</a>
</li>
<li>
  <a href="../PlatypusDB_index.html">PlatypusDB</a>
</li>
<li>
  <a href="../reference/index.html">Functions</a>
</li>
<li>
  <a href="../news/index.html">News</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
    Other Packages
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
<li>
      <a href="https://immunesim.readthedocs.io/en/latest/" class="external-link">ImmuneSIM</a>
    </li>
  </ul>
</li>
<li>
  <a href="../cute_monotremes.html">Cute Monotremes</a>
</li>
      </ul>
<ul class="nav navbar-nav navbar-right">
<li>
  <a href="https://twitter.com/alexyermanos" class="external-link">
    <span class="fa fa-twitter"></span>
     
  </a>
</li>
<li>
  <a href="https://github.com/alexyermanos/Platypus" class="external-link">
    <span class="fa fa-github"></span>
     
  </a>
</li>
      </ul>
</div>
<!--/.nav-collapse -->
  </div>
<!--/.container -->
</div>
<!--/.navbar -->

      

      </header><div class="row">
  <div class="col-md-9 contents">
    <div class="page-header toc-ignore">
      <h1 data-toc-skip>AntibodyForests - a framework for network
analysis on single-cell immune receptors</h1>
                        <h4 data-toc-skip class="author">Tudor-Stefan
Cotet, Alexander Yermanos</h4>
            
            <h4 data-toc-skip class="date">16/06/2022</h4>
      
      <small class="dont-index">Source: <a href="https://github.com/alexyermanos/Platypus/tree/mastervignettes/AntibodyForests.Rmd" class="external-link"><code>vignettes/AntibodyForests.Rmd</code></a></small>
      <div class="hidden name"><code>AntibodyForests.Rmd</code></div>

    </div>

    
    
<div class="section level2">
<h2 id="introduction">1. Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
</h2>
<p>The Platypus family of packages are meant to provide potential
pipelines and examples relevant to the broad field of computational
immunology. The core set of functions can be found at <a href="https://github.com/alexyermanos/Platypus" class="external-link uri">https://github.com/alexyermanos/Platypus</a> and examples of
use can be found in the publications <a href="https://doi.org/10.1093/nargab/lqab023" class="external-link uri">https://doi.org/10.1093/nargab/lqab023</a> and
<strong>insert biorxiv database manuscript here</strong>.</p>
<p>AntibodyForests is a part of the Platypus ecosystem designed entirely
for network inference and analysis on single-cell immune receptor
repertoires <strong>insert biorxiv AntibodyForests manuscript
here</strong>. The main method of inferring networks in AntibodyForests
is the minimum spanning tree algorithm (nodes are added iteratively
based on the minimum string distance, resulting in the minimum total
edge weight in a single tree) with custom tie solving implementations
for edges with equal string distances. Moreover, AntibodyForests has
been extended to complex similarity networks: graphs are built by first
creating a complex network across all available sequences in a
clonotype/reperoire, then edges are pruned according to a pruning
threshold. Several other network inference algorithms have been added
(e.g., inferring phylogenetic trees via the phangorn and ape packages or
the IQ-TREE software, then converting those into network objects).</p>
<p>Lastly, AntibodyForests integrates a suite of network analysis
methods, visualization, and unique graph types. For example, shortest
paths from specific nodes can be computed via AntibodyForests_paths,
then the nodes that are traversed can be visualized via barplots in the
same function; or bipartite networks can be created via
AntibodyForests_heterogeneous: these combine the two modalities
available in the VGM object - receptor sequences and cell expression,
for an intuitive visualization and analysis of complex features (and
relating cell phenotypes to sequence graph properties).</p>
<p>In this vignette, we will first see how Platypus is connected to
AntibodyForests, the network-building algorithms available in
AntibodyForests, how an AntibodyForests object is organized, how to
visualize networks via AntibodyForests_plot, as well as the suite of
custom graph types and network analyses available.</p>
</div>
<div class="section level2">
<h2 id="loading-sample-data-and-preprocessing">2. Loading sample data and preprocessing<a class="anchor" aria-label="anchor" href="#loading-sample-data-and-preprocessing"></a>
</h2>
<p>Here we use only the first sample of the larger dataset explored in
<a href="https://doi.org/10.1101/2021.11.09.467876" class="external-link uri">https://doi.org/10.1101/2021.11.09.467876</a> We load raw
data from PlatypusDB and preprocess via the VDJ_GEX_matrix function.</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va">Platypus</span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://tidyverse.tidyverse.org" class="external-link">tidyverse</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co">#Fetch only sample 1</span></span>
<span><span class="fu"><a href="../reference/PlatypusDB_fetch.html">PlatypusDB_fetch</a></span><span class="op">(</span>PlatypusDB.links <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"agrafiotis2021a/TNFR2.BM.3m.S1/ALL"</span><span class="op">)</span>, </span>
<span>                                     load.to.enviroment <span class="op">=</span> <span class="cn">T</span>, combine.objects <span class="op">=</span> <span class="cn">T</span><span class="op">)</span></span>
<span></span>
<span><span class="va">VGM</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/VDJ_GEX_matrix.html">VDJ_GEX_matrix</a></span><span class="op">(</span>Data.in <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="va">agrafiotis2021a_TNFR2.BM.3m.S1_VDJGEXdata</span><span class="op">)</span>, parallel.processing <span class="op">=</span> <span class="st">"parlapply"</span>, trim.and.align <span class="op">=</span> <span class="cn">T</span><span class="op">)</span></span>
<span></span>
<span><span class="co">#saveRDS(VGM, file = "VGM.rds")</span></span>
<span><span class="co">#VGM &lt;- readRDS("VGM.rds")</span></span></code></pre></div>
<p>The output of the VDJ_GEX_matrix is the main object for all
downstream functions in Platypus, as well as AntibodyForests. We can
create this directly into the R session by using the public data
available on PlatypusDB. For the AntibodyForests ecosystem, we will
mostly focus on the VDJ/sequence part of the VGM object (VGM[[1]]),
unless the GEX/Seurat object is needed for some specific analyses (e.g.,
for the bipartite networks in AntibodyForests_heterogeneous or for
annotating the community membership in AntibodyForests_communities).</p>
</div>
<div class="section level2">
<h2 id="create-immune-receptor-networks-via-antibodyforests">3. Create immune receptor networks via AntibodyForests<a class="anchor" aria-label="anchor" href="#create-immune-receptor-networks-via-antibodyforests"></a>
</h2>
<p>AntibodyForests offers a set of network inference algorithms, ranging
from evolutionary networks via minimum spanning trees/phylogenetic trees
to complex similarity networks.</p>
<p>We will showcase these inference methods, as well as how the graph
construction process can be customized according to several parameters:
either custom tie solving methods for the minimum spanning trees,
sequence and cell filtering, feature filtering, and distance thresholds
for the similarity networks.</p>
<div class="section level3">
<h3 id="creating-minimum-spanning-trees">3.1. Creating minimum spanning trees<a class="anchor" aria-label="anchor" href="#creating-minimum-spanning-trees"></a>
</h3>
<p>Minimum spanning trees are created by iteratively adding nodes into a
network, selecting the edges with the minimum weight/string distance
between the nodes already in the network and the nodes to be added,
until convergence. An issue arises when we have multiple nodes with
equal-weight links to the nodes already in the graph: selecting a single
node per iteration can be customized inside the AntibodyForests function
via the resolve.ties parameter. Moreover, multiple tie solving options
can be chained together in case ties are still present after a
resolve.ties filtering step. This ensures tree convergence, as well as
finer control over the inference algorithm according to the desired
biological priors.</p>
<p>To create such trees, the network.algorithm parameter needs to be set
to ‘tree’ (default). We will also create networks for a single clonotype
for easier visualization.</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype7'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="cn">NULL</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-3-1.png" width="768"></p>
<div class="section level4">
<h4 id="selecting-the-sequence-type">Selecting the sequence type<a class="anchor" aria-label="anchor" href="#selecting-the-sequence-type"></a>
</h4>
<p>First, the sequence types for network building can be selected via
the sequence.type parameter. AntibodyForests covers all sequences
available in the Platypus VDJ dataframe. These are documented inside the
AntibodyForests function.</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                sequence.type <span class="op">=</span> <span class="st">'VDJ.VJ.nt.trimmed'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype7'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="cn">NULL</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-4-1.png" width="768"></p>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                sequence.type <span class="op">=</span> <span class="st">'cdr3.aa'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype7'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="cn">NULL</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 13  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 13  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-5-1.png" width="768"></p>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                sequence.type <span class="op">=</span> <span class="st">'VDJ.nt.raw'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype7'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="cn">NULL</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 47  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 47  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-6-1.png" width="768"></p>
</div>
<div class="section level4">
<h4 id="including-a-germline">Including a germline<a class="anchor" aria-label="anchor" href="#including-a-germline"></a>
</h4>
<p>Including a germline can be done via include.germline. If this
parameter is NULL (as seen above), germlines will not be added to the
tree inference step. Otherwise, ‘trimmed.ref’ adds germlines from the
VDJ_trimmed_ref and VJ_trimmed_ref columns in a VDJ - these are often
the 10x alignment references as long as VDJ_GEX_matrix was run with
trim.and.align set to T. More germline options/ germline inference
algorithms will be added in the future!</p>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                include.germline <span class="op">=</span> <span class="st">'trimmed.ref'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype7'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="st">'rank'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-7-1.png" width="768"></p>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                include.germline <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype7'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="st">'rank'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-8-1.png" width="768"></p>
<p>We can see how adding a germline changes the overall tree topology
(as the first nodes to be added into the network are different). In this
case, node labels are determined by the sequence order (ordered by
expansion/number of cells).</p>
</div>
<div class="section level4">
<h4 id="selecting-different-tie-solving-algorithms">Selecting different tie solving algorithms<a class="anchor" aria-label="anchor" href="#selecting-different-tie-solving-algorithms"></a>
</h4>
<p>As described above, the iterative approach in our minimum spanning
tree algorithm can often end up with tied edges between nodes already in
the tree and nodes to be added. Picking a desired node to be added first
can be controlled via the resolve.ties parameter. The options available
are all documented in the AntibodyForests function: one could choose
from picking the first node in the tied node list (‘first’), picking a
random one, picking the most or least expanded node - most/least amount
of cells (‘max.expansion’, ‘min.expansion’), picking the node closest to
the germline (‘closest.germline.distance’), etc. Moreover, nodes can
also be prioritized based on additional features/ VDJ columns: e.g.,
prioritize adding OVA binder nodes (‘yes-OVA_binder’): first part
separated by ‘-’ represent the feature to be added, second is the VDJ
column name of those sequence features/attributes.</p>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                resolve.ties <span class="op">=</span> <span class="st">'first'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype8'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="st">'rank'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 27  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 27  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype8 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-9-1.png" width="768"></p>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                resolve.ties <span class="op">=</span> <span class="st">'random'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype8'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="st">'rank'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 27  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 27  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype8 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-10-1.png" width="768"></p>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                resolve.ties <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype8'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="st">'rank'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 27  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 27  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype8 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-11-1.png" width="768"></p>
<p>Ties can be visualized when setting resolve.ties to NULL. These
options can have a rather meaningful effects on the resulting tree
topology, therefore a tie solving option with relevant biological priors
should be picked.</p>
</div>
<div class="section level4">
<h4 id="hierarchical-tie-solving">Hierarchical tie solving<a class="anchor" aria-label="anchor" href="#hierarchical-tie-solving"></a>
</h4>
<p>In case ties are still not solved after picking a tie-solving
mechanism, more mechanisms can be chained together to ensure
convergence. Moreover, resolve.ties always ends with the ‘first’ option
which will always pick a node: e.g., resolve.ties =
‘closest.germline.distance’ gets converted into resolve.ties =
c(‘closest.germline.distance’, ‘first’) to ensure tree building always
converges (in case nodes with tied edge distances also have the same
string distance to the germline).</p>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                resolve.ties <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">'far.germline.distance'</span>, <span class="st">'min.expansion'</span><span class="op">)</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype8'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="st">'rank'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 27  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 27  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype8 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-12-1.png" width="768"></p>
</div>
</div>
<div class="section level3">
<h3 id="creating-phylogenetic-trees">3.2. Creating phylogenetic trees<a class="anchor" aria-label="anchor" href="#creating-phylogenetic-trees"></a>
</h3>
<p>Phylogenetic trees can be inferred using various algorithms - the
resulting phylo object are then converted into igraph objects. This can
be done by setting the network.algorithm parameter to
‘phylogenetic.tree’ followed by the inference algorithm
(‘phylogenetic.tree.nj). The algorithms available are neighbour-joining
(’phylogenetic.tree.nj’), maximum-likelihood (‘phylogenetic.tree.ml’),
and maximum parsimony (‘phylogenetic.tree.mp’)</p>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'phylogenetic.tree.nj'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype8'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="cn">NULL</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 27  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 26  intermediate nodes </span></span>
<span><span class="co">## 53  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype8 </span></span>
<span><span class="co">## Networks/analyses available:  phylogenetic.tree.nj, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-13-1.png" width="768"></p>
</div>
<div class="section level3">
<h3 id="creating-similarity-networks">3.3. Creating similarity networks<a class="anchor" aria-label="anchor" href="#creating-similarity-networks"></a>
</h3>
<p>Complex similarity networks can be creating by setting the
network.algorithm to ‘prune’, followed by a pruning option: for example,
‘prune.distance’ will remove edges according to a distance threshold
(specified as an integer in the distance.threshold parameter),
‘prune.expansion’ removes nodes with fewer cells than mentioned in
pruning.threshold, ‘prune.degree’ remove nodes with a smaller degree
than the pruning.threshold. These options can also be chained
(‘prune.distance.expansion’ first prunes based on edge weights/string
similarity, then number of cells per sequence, as long as
pruning.threshold is a vector of 2 integers).</p>
<p>We will create networks for the CDRH3 sequences across our sample, to
reduce running time (as creating complex networks for really large
sequences has a bottleneck in the stringdistmatrix function from the
stringdist package).</p>
<p>We will also change the plotting layout to ‘nice’ (the
igraph::layout_nicely).</p>
<div class="section level4">
<h4 id="pruning-edges-based-on-a-distance-threshold">Pruning edges based on a distance threshold<a class="anchor" aria-label="anchor" href="#pruning-edges-based-on-a-distance-threshold"></a>
</h4>
<p>We set keep.largest.cc to T to only keep the largest connected
component in the resulting network (and remove
singletons/doubletons/etc.). If keep.largest.cc or remove.singletons
were set to NULL, we would included all nodes in the final network, with
pruned/remaining edges. This is further described in the
‘AntibodyForests for similarity network construction and analysis’
vignette.</p>
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                sequence.type <span class="op">=</span> <span class="st">'VDJ.cdr3s.aa'</span>,</span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'prune.distance'</span>,</span>
<span>                keep.largest.cc <span class="op">=</span> <span class="cn">T</span>,</span>
<span>                pruning.threshold <span class="op">=</span> <span class="fl">3</span>,</span>
<span>                directed <span class="op">=</span> <span class="cn">F</span>,</span>
<span>                include.germline <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>                network.level <span class="op">=</span> <span class="st">'global'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="cn">NULL</span>, node.scale.factor <span class="op">=</span> <span class="fl">4</span>, network.layout <span class="op">=</span> <span class="st">'nice'</span>, show.legend <span class="op">=</span> <span class="cn">F</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Warning in vattrs[[name]][index] &lt;- value: number of items to replace is not a</span></span>
<span><span class="co">## multiple of replacement length</span></span></code></pre>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 471  sequence nodes across  1  sample(s) and  353  clonotype(s) </span></span>
<span><span class="co">## 471  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype1, clonotype2, clonotype3, clonotype4, clonotype5, clonotype6, clonotype7, clonotype8, clonotype9, clonotype10, clonotype11, clonotype12, clonotype13, clonotype14, clonotype15, clonotype16, clonotype17, clonotype18, clonotype19, clonotype21, clonotype22, clonotype23, clonotype24, clonotype25, clonotype26, clonotype27, clonotype28, clonotype29, clonotype30, clonotype31, clonotype32, clonotype33, clonotype34, clonotype35, clonotype36, clonotype37, clonotype38, clonotype39, clonotype40, clonotype41, clonotype42, clonotype43, clonotype44, clonotype45, clonotype46, clonotype47, clonotype48, clonotype49, clonotype50, clonotype51, clonotype52, clonotype53, clonotype54, clonotype55, clonotype56, clonotype57, clonotype58, clonotype59, clonotype60, clonotype61, clonotype62, clonotype63, clonotype64, clonotype65, clonotype66, clonotype67, clonotype68, clonotype69, clonotype70, clonotype71, clonotype73, clonotype74, clonotype75, clonotype76, clonotype77, clonotype78, clonotype79, clonotype80, clonotype81, clonotype82, clonotype83, clonotype85, clonotype86, clonotype87, clonotype88, clonotype89, clonotype90, clonotype91, clonotype92, clonotype93, clonotype94, clonotype95, clonotype96, clonotype97, clonotype98, clonotype99, clonotype100, clonotype101, clonotype102, clonotype103, clonotype104, clonotype105, clonotype106, clonotype107, clonotype108, clonotype109, clonotype110, clonotype111, clonotype112, clonotype113, clonotype114, clonotype115, clonotype116, clonotype117, clonotype118, clonotype119, clonotype120, clonotype121, clonotype122, clonotype123, clonotype124, clonotype125, clonotype126, clonotype127, clonotype128, clonotype129, clonotype130, clonotype131, clonotype132, clonotype133, clonotype134, clonotype135, clonotype136, clonotype137, clonotype138, clonotype139, clonotype140, clonotype141, clonotype142, clonotype143, clonotype144, clonotype145, clonotype146, clonotype147, clonotype148, clonotype149, clonotype150, clonotype151, clonotype152, clonotype153, clonotype154, clonotype155, clonotype156, clonotype157, clonotype158, clonotype159, clonotype160, clonotype161, clonotype162, clonotype163, clonotype164, clonotype165, clonotype166, clonotype167, clonotype169, clonotype170, clonotype171, clonotype172, clonotype173, clonotype174, clonotype175, clonotype176, clonotype177, clonotype179, clonotype180, clonotype181, clonotype182, clonotype183, clonotype184, clonotype185, clonotype186, clonotype187, clonotype188, clonotype189, clonotype190, clonotype191, clonotype192, clonotype193, clonotype194, clonotype195, clonotype196, clonotype197, clonotype198, clonotype199, clonotype200, clonotype201, clonotype202, clonotype203, clonotype204, clonotype205, clonotype206, clonotype207, clonotype208, clonotype209, clonotype210, clonotype211, clonotype212, clonotype213, clonotype214, clonotype215, clonotype216, clonotype217, clonotype218, clonotype219, clonotype220, clonotype221, clonotype222, clonotype223, clonotype224, clonotype225, clonotype226, clonotype227, clonotype228, clonotype230, clonotype231, clonotype232, clonotype233, clonotype234, clonotype235, clonotype236, clonotype237, clonotype238, clonotype239, clonotype240, clonotype241, clonotype242, clonotype243, clonotype244, clonotype245, clonotype246, clonotype247, clonotype248, clonotype249, clonotype250, clonotype251, clonotype252, clonotype253, clonotype254, clonotype255, clonotype256, clonotype257, clonotype258, clonotype259, clonotype260, clonotype261, clonotype262, clonotype263, clonotype264, clonotype265, clonotype266, clonotype267, clonotype310, clonotype317, clonotype329, clonotype348, clonotype353, clonotype363, clonotype370, clonotype373, clonotype385, clonotype387, clonotype388, clonotype391, clonotype411, clonotype413, clonotype421, clonotype436, clonotype445, clonotype466, clonotype471, clonotype484, clonotype488, clonotype494, clonotype495, clonotype496, clonotype497, clonotype498, clonotype505, clonotype508, clonotype510, clonotype524, clonotype546, clonotype553, clonotype554, clonotype569, clonotype575, clonotype583, clonotype584, clonotype591, clonotype594, clonotype598, clonotype600, clonotype601, clonotype603, clonotype605, clonotype631, clonotype632, clonotype633, clonotype634, clonotype641, clonotype643, clonotype658, clonotype663, clonotype668, clonotype671, clonotype678, clonotype695, clonotype703, clonotype725, clonotype727, clonotype728, clonotype735, clonotype737, clonotype746, clonotype750, clonotype757, clonotype772, clonotype781, clonotype790, clonotype798, clonotype799, clonotype804, clonotype805, clonotype806, clonotype809, clonotype820, clonotype821, clonotype832, clonotype836, clonotype841, clonotype843, clonotype854, clonotype858, clonotype859, clonotype861, clonotype866, clonotype868, clonotype878, clonotype879, clonotype881, clonotype882, clonotype884, clonotype893 </span></span>
<span><span class="co">## Networks/analyses available:  prune.distance, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-14-1.png" width="768"></p>
</div>
<div class="section level4">
<h4 id="pruning-edges-based-on-a-distance-and-expansion-threshold-">Pruning edges based on a distance and expansion threshold.<a class="anchor" aria-label="anchor" href="#pruning-edges-based-on-a-distance-and-expansion-threshold-"></a>
</h4>
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                sequence.type <span class="op">=</span> <span class="st">'VDJ.cdr3s.aa'</span>,</span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'prune.distance.expansion'</span>,</span>
<span>                pruning.threshold <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">3</span>,<span class="fl">0</span>,<span class="fl">2</span><span class="op">)</span>,</span>
<span>                keep.largest.cc <span class="op">=</span> <span class="cn">T</span>,</span>
<span>                directed <span class="op">=</span> <span class="cn">F</span>,</span>
<span>                include.germline <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>                network.level <span class="op">=</span> <span class="st">'global'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="cn">NULL</span>, node.scale.factor <span class="op">=</span> <span class="fl">4</span>, network.layout <span class="op">=</span> <span class="st">'nice'</span>, show.legend <span class="op">=</span> <span class="cn">F</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Warning in vattrs[[name]][index] &lt;- value: number of items to replace is not a</span></span>
<span><span class="co">## multiple of replacement length</span></span></code></pre>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 105  sequence nodes across  1  sample(s) and  85  clonotype(s) </span></span>
<span><span class="co">## 105  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype1, clonotype2, clonotype3, clonotype4, clonotype5, clonotype6, clonotype7, clonotype8, clonotype9, clonotype10, clonotype11, clonotype12, clonotype13, clonotype14, clonotype15, clonotype16, clonotype17, clonotype18, clonotype19, clonotype21, clonotype22, clonotype23, clonotype24, clonotype25, clonotype26, clonotype27, clonotype28, clonotype29, clonotype30, clonotype31, clonotype32, clonotype33, clonotype34, clonotype35, clonotype36, clonotype37, clonotype38, clonotype39, clonotype40, clonotype41, clonotype42, clonotype43, clonotype44, clonotype47, clonotype48, clonotype49, clonotype50, clonotype51, clonotype52, clonotype54, clonotype55, clonotype56, clonotype57, clonotype58, clonotype59, clonotype60, clonotype61, clonotype62, clonotype63, clonotype64, clonotype65, clonotype66, clonotype67, clonotype69, clonotype71, clonotype73, clonotype74, clonotype75, clonotype76, clonotype78, clonotype82, clonotype89, clonotype95, clonotype96, clonotype103, clonotype109, clonotype111, clonotype130, clonotype145, clonotype363, clonotype663, clonotype757, clonotype790, clonotype804, clonotype805 </span></span>
<span><span class="co">## Networks/analyses available:  prune.distance.expansion, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-15-1.png" width="768"></p>
</div>
<div class="section level4">
<h4 id="the-global-option">The ‘global’ option<a class="anchor" aria-label="anchor" href="#the-global-option"></a>
</h4>
<p>‘global’ is a custom option to easily create
whole-repertoire/multi-repertoire similarity networks: it defaults to
the ‘prune.distance’ option, while also changing some other parameters
to ensure consistency (directed is set to F, include.germline is set to
F, network.level is set to ‘global’, keep.largest.cc to T). This option
will be further explored in the ‘AntibodyForests for similarity network
construction and analysis’ vignette.</p>
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                sequence.type <span class="op">=</span> <span class="st">'VDJ.cdr3s.aa'</span>,</span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'global'</span>,</span>
<span>                pruning.threshold <span class="op">=</span> <span class="fl">3</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="cn">NULL</span>, node.scale.factor <span class="op">=</span> <span class="fl">4</span>, network.layout <span class="op">=</span> <span class="st">'nice'</span>, show.legend <span class="op">=</span> <span class="cn">F</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Warning in vattrs[[name]][index] &lt;- value: number of items to replace is not a</span></span>
<span><span class="co">## multiple of replacement length</span></span></code></pre>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 471  sequence nodes across  1  sample(s) and  353  clonotype(s) </span></span>
<span><span class="co">## 471  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype1, clonotype2, clonotype3, clonotype4, clonotype5, clonotype6, clonotype7, clonotype8, clonotype9, clonotype10, clonotype11, clonotype12, clonotype13, clonotype14, clonotype15, clonotype16, clonotype17, clonotype18, clonotype19, clonotype21, clonotype22, clonotype23, clonotype24, clonotype25, clonotype26, clonotype27, clonotype28, clonotype29, clonotype30, clonotype31, clonotype32, clonotype33, clonotype34, clonotype35, clonotype36, clonotype37, clonotype38, clonotype39, clonotype40, clonotype41, clonotype42, clonotype43, clonotype44, clonotype45, clonotype46, clonotype47, clonotype48, clonotype49, clonotype50, clonotype51, clonotype52, clonotype53, clonotype54, clonotype55, clonotype56, clonotype57, clonotype58, clonotype59, clonotype60, clonotype61, clonotype62, clonotype63, clonotype64, clonotype65, clonotype66, clonotype67, clonotype68, clonotype69, clonotype70, clonotype71, clonotype73, clonotype74, clonotype75, clonotype76, clonotype77, clonotype78, clonotype79, clonotype80, clonotype81, clonotype82, clonotype83, clonotype85, clonotype86, clonotype87, clonotype88, clonotype89, clonotype90, clonotype91, clonotype92, clonotype93, clonotype94, clonotype95, clonotype96, clonotype97, clonotype98, clonotype99, clonotype100, clonotype101, clonotype102, clonotype103, clonotype104, clonotype105, clonotype106, clonotype107, clonotype108, clonotype109, clonotype110, clonotype111, clonotype112, clonotype113, clonotype114, clonotype115, clonotype116, clonotype117, clonotype118, clonotype119, clonotype120, clonotype121, clonotype122, clonotype123, clonotype124, clonotype125, clonotype126, clonotype127, clonotype128, clonotype129, clonotype130, clonotype131, clonotype132, clonotype133, clonotype134, clonotype135, clonotype136, clonotype137, clonotype138, clonotype139, clonotype140, clonotype141, clonotype142, clonotype143, clonotype144, clonotype145, clonotype146, clonotype147, clonotype148, clonotype149, clonotype150, clonotype151, clonotype152, clonotype153, clonotype154, clonotype155, clonotype156, clonotype157, clonotype158, clonotype159, clonotype160, clonotype161, clonotype162, clonotype163, clonotype164, clonotype165, clonotype166, clonotype167, clonotype169, clonotype170, clonotype171, clonotype172, clonotype173, clonotype174, clonotype175, clonotype176, clonotype177, clonotype179, clonotype180, clonotype181, clonotype182, clonotype183, clonotype184, clonotype185, clonotype186, clonotype187, clonotype188, clonotype189, clonotype190, clonotype191, clonotype192, clonotype193, clonotype194, clonotype195, clonotype196, clonotype197, clonotype198, clonotype199, clonotype200, clonotype201, clonotype202, clonotype203, clonotype204, clonotype205, clonotype206, clonotype207, clonotype208, clonotype209, clonotype210, clonotype211, clonotype212, clonotype213, clonotype214, clonotype215, clonotype216, clonotype217, clonotype218, clonotype219, clonotype220, clonotype221, clonotype222, clonotype223, clonotype224, clonotype225, clonotype226, clonotype227, clonotype228, clonotype230, clonotype231, clonotype232, clonotype233, clonotype234, clonotype235, clonotype236, clonotype237, clonotype238, clonotype239, clonotype240, clonotype241, clonotype242, clonotype243, clonotype244, clonotype245, clonotype246, clonotype247, clonotype248, clonotype249, clonotype250, clonotype251, clonotype252, clonotype253, clonotype254, clonotype255, clonotype256, clonotype257, clonotype258, clonotype259, clonotype260, clonotype261, clonotype262, clonotype263, clonotype264, clonotype265, clonotype266, clonotype267, clonotype310, clonotype317, clonotype329, clonotype348, clonotype353, clonotype363, clonotype370, clonotype373, clonotype385, clonotype387, clonotype388, clonotype391, clonotype411, clonotype413, clonotype421, clonotype436, clonotype445, clonotype466, clonotype471, clonotype484, clonotype488, clonotype494, clonotype495, clonotype496, clonotype497, clonotype498, clonotype505, clonotype508, clonotype510, clonotype524, clonotype546, clonotype553, clonotype554, clonotype569, clonotype575, clonotype583, clonotype584, clonotype591, clonotype594, clonotype598, clonotype600, clonotype601, clonotype603, clonotype605, clonotype631, clonotype632, clonotype633, clonotype634, clonotype641, clonotype643, clonotype658, clonotype663, clonotype668, clonotype671, clonotype678, clonotype695, clonotype703, clonotype725, clonotype727, clonotype728, clonotype735, clonotype737, clonotype746, clonotype750, clonotype757, clonotype772, clonotype781, clonotype790, clonotype798, clonotype799, clonotype804, clonotype805, clonotype806, clonotype809, clonotype820, clonotype821, clonotype832, clonotype836, clonotype841, clonotype843, clonotype854, clonotype858, clonotype859, clonotype861, clonotype866, clonotype868, clonotype878, clonotype879, clonotype881, clonotype882, clonotype884, clonotype893 </span></span>
<span><span class="co">## Networks/analyses available:  prune.distance, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-16-1.png" width="768"></p>
</div>
</div>
<div class="section level3">
<h3 id="creating-minimum-spanning-trees-via-igraphmst">3.4. Creating minimum spanning trees via igraph::mst()<a class="anchor" aria-label="anchor" href="#creating-minimum-spanning-trees-via-igraphmst"></a>
</h3>
<p>Lastly, another tree inference option is the minimum spanning tree
function available in the igraph package.</p>
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'mst'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype7'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="st">'rank'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  mst, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-17-1.png" width="768"></p>
</div>
<div class="section level3">
<h3 id="filtering-options">3.5 Filtering options<a class="anchor" aria-label="anchor" href="#filtering-options"></a>
</h3>
<p>There are several methods to filter your networks:</p>
<p>cell.limits and node.limits impose an upper and lower bound on the
number of cells per sequence (otherwise those sequences are removed from
the network) and number of nodes per intraclonal network (if lower,
remove the network entirely, higher - removes the least expanded nodes
to get to the upper bound).</p>
<p>filter.na.features removes networks if all their feature values are
NA (for the VDJ column mentioned).</p>
<p>filter.specific.features ensures at least a specific feature value of
a feature column is present (e.g., filter.specific.features =
list(‘OVA_binder’, ‘yes’) for networks with at least one OVA binder
node).</p>
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                         network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                         node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>,<span class="cn">NULL</span><span class="op">)</span>, <span class="co">#only a lower bound of 5, no upper bound</span></span>
<span>                         specific.networks <span class="op">=</span> <span class="fl">3</span><span class="op">)</span> <span class="co">#selects the top 5 networks</span></span>
<span><span class="va">networks</span></span></code></pre></div>
<pre><code><span><span class="co">## $s1</span></span>
<span><span class="co">## $s1$clonotype7</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $s1$clonotype8</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 27  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 27  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype8 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $s1$clonotype9</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 15  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 15  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype9 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span></code></pre>
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                         network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                         cell.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">10</span>,<span class="cn">NULL</span><span class="op">)</span>, <span class="co">#only a lower bound of 10, no upper bound</span></span>
<span>                         specific.networks <span class="op">=</span> <span class="fl">3</span><span class="op">)</span> <span class="co">#selects the top 5 networks</span></span>
<span><span class="va">networks</span></span></code></pre></div>
<pre><code><span><span class="co">## $s1</span></span>
<span><span class="co">## $s1$clonotype1</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 1  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 1  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype1 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $s1$clonotype2</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 2  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 2  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype2 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $s1$clonotype3</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 3  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 3  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype3 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span></code></pre>
</div>
<div class="section level3">
<h3 id="network-level-options">3.6 Network level options<a class="anchor" aria-label="anchor" href="#network-level-options"></a>
</h3>
<p>Networks can be built at different levels/for different groups across
the VDJ object:</p>
<p>The default option for the tree inference algorithms is network.level
= ‘intraclonal’ - this builds a network per clonotype, per sample - the
resulting AntibodyForests object is a nested list where trees[[1]][[2]]
is the network for the first sample, second clonotype.</p>
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                         network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                         network.level <span class="op">=</span> <span class="st">'intraclonal'</span>,</span>
<span>                         specific.networks <span class="op">=</span> <span class="fl">3</span><span class="op">)</span></span>
<span><span class="va">networks</span></span></code></pre></div>
<pre><code><span><span class="co">## $s1</span></span>
<span><span class="co">## $s1$clonotype1</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 1  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 1  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype1 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $s1$clonotype2</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 2  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 2  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype2 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $s1$clonotype3</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 4  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 4  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype3 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span></code></pre>
<p>‘global’ will pool all clonotypes across all samples, creating a
single ‘global’ network.</p>
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                         network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                         network.level <span class="op">=</span> <span class="st">'global'</span>,</span>
<span>                         specific.networks <span class="op">=</span> <span class="fl">3</span><span class="op">)</span></span>
<span><span class="va">networks</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 7  sequence nodes across  1  sample(s) and  3  clonotype(s) </span></span>
<span><span class="co">## 7  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype1, clonotype2, clonotype3 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span></code></pre>
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.label <span class="op">=</span> <span class="cn">NULL</span>, node.color <span class="op">=</span> <span class="st">'clonotype_id'</span>, node.scale.factor <span class="op">=</span> <span class="fl">4</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 7  sequence nodes across  1  sample(s) and  3  clonotype(s) </span></span>
<span><span class="co">## 7  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype1, clonotype2, clonotype3 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-22-1.png" width="768"></p>
<p>The other options include ‘forest.global’, ‘forest.per.sample’,
‘global.clonotype’, which are thoroughly described in the
AntibodyForests function documentation.</p>
</div>
</div>
<div class="section level2">
<h2 id="a-look-at-the-antibodyforests-object">4. A look at the AntibodyForests object<a class="anchor" aria-label="anchor" href="#a-look-at-the-antibodyforests-object"></a>
</h2>
<p>As we have seen, the resulting output of the AntibodyForests function
is an AntibodyForests object or a nested list of such objects. This acts
as a way to store important parameters (e.g., cell barcodes per
sequence, unique sequence, feature names) and downstream analyses
(heterogeneous graphs, metric dataframes) for easier accessibility and
better function pipelines.</p>
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                            network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                            node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                            specific.networks <span class="op">=</span> <span class="fl">3</span><span class="op">)</span></span>
<span><span class="va">networks</span></span></code></pre></div>
<pre><code><span><span class="co">## $s1</span></span>
<span><span class="co">## $s1$clonotype7</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $s1$clonotype8</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 27  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 27  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype8 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $s1$clonotype9</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 15  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 15  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype9 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span></code></pre>
<div class="sourceCode" id="cb47"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span><span class="op">$</span><span class="va">s1</span><span class="op">$</span><span class="va">clonotype7</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree</span></span></code></pre>
<p>We can also access the attributes of a single AntibodyForests object.
For example, the igraph object created is stored under the tree
attribute, whereas the cell barcodes per sequence under barcode.</p>
<div class="sourceCode" id="cb49"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span><span class="op">$</span><span class="va">s1</span><span class="op">$</span><span class="va">clonotype7</span><span class="op">@</span><span class="va">tree</span></span></code></pre></div>
<pre><code><span><span class="co">## IGRAPH 91fd1d8 D-W- 36 35 -- </span></span>
<span><span class="co">## + attr: label (v/n), network_sequences (v/c), cell_number (v/n),</span></span>
<span><span class="co">## | node_type (v/c), most_expanded (v/c), hub (v/c), clonotype_id (v/c),</span></span>
<span><span class="co">## | sample_id (v/c), cell_barcodes (v/x), distance_from_germline (v/n),</span></span>
<span><span class="co">## | leaf (v/c), weight (e/n)</span></span>
<span><span class="co">## + edges from 91fd1d8:</span></span>
<span><span class="co">##  [1]  1-&gt; 8  1-&gt;11  1-&gt;32  4-&gt; 1  4-&gt;30  4-&gt;34  5-&gt;25  7-&gt; 2  7-&gt; 5  7-&gt; 9</span></span>
<span><span class="co">## [11]  7-&gt;13  7-&gt;18  7-&gt;22  7-&gt;24  7-&gt;31  7-&gt;33  9-&gt;19 11-&gt;23 12-&gt;15 12-&gt;17</span></span>
<span><span class="co">## [21] 12-&gt;27 13-&gt;21 16-&gt;10 19-&gt;16 20-&gt;14 20-&gt;29 20-&gt;35 22-&gt; 6 25-&gt;28 28-&gt; 4</span></span>
<span><span class="co">## [31] 30-&gt; 3 30-&gt;12 30-&gt;26 33-&gt;20 36-&gt; 7</span></span></code></pre>
<div class="sourceCode" id="cb51"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span><span class="op">$</span><span class="va">s1</span><span class="op">$</span><span class="va">clonotype7</span><span class="op">@</span><span class="va">barcodes</span><span class="op">[</span><span class="fl">1</span><span class="op">:</span><span class="fl">5</span><span class="op">]</span></span></code></pre></div>
<pre><code><span><span class="co">## [[1]]</span></span>
<span><span class="co">## [1] "s1_AACGTTGCAACTTGAC-1" "s1_AACTCTTGTACCGTAT-1" "s1_GCAATCAAGACTTGAA-1"</span></span>
<span><span class="co">## [4] "s1_GCTGCGAAGTGAACAT-1"</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## [[2]]</span></span>
<span><span class="co">## [1] "s1_ACGAGCCCATCGGGTC-1" "s1_TGCCCATTCTTGCATT-1"</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## [[3]]</span></span>
<span><span class="co">## [1] "s1_ACTTACTGTAGGGACT-1" "s1_GAAACTCCAGGGTACA-1"</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## [[4]]</span></span>
<span><span class="co">## [1] "s1_AGATTGCTCATGTCTT-1" "s1_CATTCGCTCAGTGTTG-1"</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## [[5]]</span></span>
<span><span class="co">## [1] "s1_AGCAGCCGTGTGAAAT-1" "s1_TCACGAATCAGTCAGT-1"</span></span></code></pre>
</div>
<div class="section level2">
<h2 id="plotting-the-resulting-treesnetworks-via-antibodyforests_plot">5. Plotting the resulting trees/networks via
AntibodyForests_plot<a class="anchor" aria-label="anchor" href="#plotting-the-resulting-treesnetworks-via-antibodyforests_plot"></a>
</h2>
<p>The AntibodyForests plotting function is highly customizable (unique
node colors, gradient node colors, pie-chart nodes, different network
layouts, etc.,). It takes as input an AntibodyForests object or a nested
list of such objects and outputs a list of plots or plot-ready
AntibodyForests objects - the resulting plots can also be saved as
PDF.</p>
<div class="section level3">
<h3 id="adding-new-node-level-features-to-plot">5.1. Adding new node-level features to plot<a class="anchor" aria-label="anchor" href="#adding-new-node-level-features-to-plot"></a>
</h3>
<p>We will first need to add those features when creating the
AntibodyForests objects. This is done via the node.features parameter,
which takes as input a vector of strings denoting column names in the
VDJ object. We will add the isotype and Seurat clusters as node
features.</p>
<div class="sourceCode" id="cb53"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">network</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                node.features <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">'VDJ_cgene'</span>, <span class="st">'seurat_clusters'</span><span class="op">)</span>,</span>
<span>                node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="fl">1</span><span class="op">)</span> <span class="co">#picks a single network (with highest cell counts)</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="changing-the-node-color">5.2. Changing the node color<a class="anchor" aria-label="anchor" href="#changing-the-node-color"></a>
</h3>
<p>As feature values are pooled by each cell barcode per sequence, we
could have multiple different values per one sequence. When coloring our
nodes, we pick the most frequent feature (highest number of cells). We
can also plot our networks with pie-chart shapes to see the overall
feature distribution by setting node.shape to ‘pie’.</p>
<div class="sourceCode" id="cb54"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">plot_network</span> <span class="op">&lt;-</span> <span class="va">network</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.color <span class="op">=</span> <span class="st">'VDJ_cgene'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-28-1.png" width="768"></p>
<p>We can see how a new slot has been added to our AntibodyForests
object: plot_ready, which is the same igraph object with the plot
annotations (node colors, sizes, etc.,) added.</p>
<div class="sourceCode" id="cb55"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">plot_network</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<div class="sourceCode" id="cb57"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="va">plot_network</span><span class="op">@</span><span class="va">plot_ready</span><span class="op">)</span></span></code></pre></div>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-30-1.png" width="768"></p>
<div class="sourceCode" id="cb58"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">network</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.color <span class="op">=</span> <span class="st">'seurat_clusters'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-31-1.png" width="768"></p>
<div class="sourceCode" id="cb60"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">network</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.color <span class="op">=</span> <span class="st">'seurat_clusters'</span>, node.shape <span class="op">=</span> <span class="st">'pie'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-32-1.png" width="768"></p>
<p>Moreover, we can select specific node color via the
specific.node.colors parameters (which takes as input a named vector of
our desired colors).</p>
<div class="sourceCode" id="cb62"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">network</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.color <span class="op">=</span> <span class="st">'VDJ_cgene'</span>, node.scale.factor <span class="op">=</span> <span class="fl">8</span>, specific.node.colors <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">'IGHA'</span> <span class="op">=</span> <span class="st">'blue'</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-33-1.png" width="768"></p>
</div>
<div class="section level3">
<h3 id="changing-the-node-sizes">5.3. Changing the node sizes<a class="anchor" aria-label="anchor" href="#changing-the-node-sizes"></a>
</h3>
<p>The node sizes are proportional to the number of cells per sequence.
These can also be scaled by centrality metrics: ‘scaleByCloseness’ -
closeness centrality; ‘scaleByBetweenness’ - betweenness, ‘scaleByEigen’
- eigenvector centrality, ‘scaleByExpansion’ - default option to scale
by cell count per nodes.</p>
<p>Node sizes can further be modulated by node.scale.factor and
max.node.size.</p>
<div class="sourceCode" id="cb64"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">network</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.color <span class="op">=</span> <span class="st">'VDJ_cgene'</span>, node.size <span class="op">=</span> <span class="st">'scaleByCloseness'</span>, node.scale.factor <span class="op">=</span> <span class="fl">1000</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-34-1.png" width="768"></p>
</div>
<div class="section level3">
<h3 id="other-customization-options">5.6 Other customization options<a class="anchor" aria-label="anchor" href="#other-customization-options"></a>
</h3>
<p>There are several other ways to customize your networks (different
labels, node shapes, edge widths and colors), described in the
AntibodyForests_plot function documentation.</p>
</div>
</div>
<div class="section level2">
<h2 id="infer-intermediate-nodes-via-antibodyforests_expand_intermediates">6. Infer intermediate nodes via
AntibodyForests_expand_intermediates<a class="anchor" aria-label="anchor" href="#infer-intermediate-nodes-via-antibodyforests_expand_intermediates"></a>
</h2>
<p>Intermediate nodes can be inferred by expanding the edges of the
existing Levenshtein-distance network: for example, if two adjacent
nodes have an edge of weight = 3 (LV distance = 3), 2 new intermediate
nodes will be added in-between, and all resulting edges will have weight
= 1.</p>
<div class="sourceCode" id="cb66"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">network</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_expand_intermediates.html">AntibodyForests_expand_intermediates</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.scale.factor <span class="op">=</span> <span class="fl">4</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-35-1.png" width="768"></p>
</div>
<div class="section level2">
<h2 id="join-treesnetworks-via-antibodyforests_join_trees">7. Join trees/networks via AntibodyForests_join_trees<a class="anchor" aria-label="anchor" href="#join-treesnetworks-via-antibodyforests_join_trees"></a>
</h2>
<p>Networks can be joined into a single igraph object for downstream
analyses or better visualization. Moreover, AntibodyForests_join_trees
includes options for joining trees at the same germline, all documented
in the AntibodyForests_join_trees function.</p>
<div class="sourceCode" id="cb68"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">joined_network</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                  network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                  node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                  specific.networks <span class="op">=</span> <span class="fl">3</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span><span class="fu"><a href="../reference/AntibodyForests_join_trees.html">AntibodyForests_join_trees</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span><span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.color <span class="op">=</span> <span class="st">'clonotype_id'</span><span class="op">)</span></span></code></pre></div>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-36-1.png" width="768"></p>
<div class="sourceCode" id="cb69"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">joined_network</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 77  sequence nodes across  1  sample(s) and  3  clonotype(s) </span></span>
<span><span class="co">## 77  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7, clonotype8, clonotype9 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
</div>
<div class="section level2">
<h2 id="additional-network-types">8. Additional network types<a class="anchor" aria-label="anchor" href="#additional-network-types"></a>
</h2>
<div class="section level3">
<h3 id="antibodyforests_infer_ancestral-phylogenetic-inference-and-ancestral-sequence-reconstruction-via-iq-tree">8.1. AntibodyForests_infer_ancestral: Phylogenetic inference and
ancestral sequence reconstruction via IQ-TREE<a class="anchor" aria-label="anchor" href="#antibodyforests_infer_ancestral-phylogenetic-inference-and-ancestral-sequence-reconstruction-via-iq-tree"></a>
</h3>
<p>We can use the IQ-TREE software to infer phylogenies and reconstruct
ancestral sequences. The resulting AntibodyForests object can then be
analyzed normally (as it is compatible with all downstream analyses
implemented in AntibodyForests).</p>
<p>We will need to download the latest versions of IQ-TREE and MAFFT,
and specify the IQ-TREE directory. If MAFFT is not available,
AntibodyForests_infer_ancestral should default to using an alignment
option available in the ape package (e.g., ape::clustal())</p>
<div class="sourceCode" id="cb71"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">inferred_tree</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                                  network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                                  node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                                  specific.networks <span class="op">=</span> <span class="fl">1</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span>                  <span class="fu"><a href="../reference/AntibodyForests_infer_ancestral.html">AntibodyForests_infer_ancestral</a></span><span class="op">(</span>alignment.method <span class="op">=</span> <span class="st">'mafft'</span>, iqtree.directory <span class="op">=</span> <span class="st">'/Users/tudorcotet/Desktop/AntibodyForests/iqtree-1.6.12-MacOSX'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span>                  <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>specific.node.colors <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">'inferred'</span> <span class="op">=</span> <span class="st">'orange'</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<div class="sourceCode" id="cb72"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">df</span> <span class="op">&lt;-</span> <span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/graph_from_data_frame.html" class="external-link">as_data_frame</a></span><span class="op">(</span><span class="va">inferred_tree</span><span class="op">@</span><span class="va">tree</span>, what <span class="op">=</span> <span class="st">'vertices'</span><span class="op">)</span></span>
<span><span class="va">df</span><span class="op">$</span><span class="va">network_sequences</span><span class="op">[</span><span class="va">df</span><span class="op">$</span><span class="va">node_type</span> <span class="op">==</span> <span class="st">'inferred'</span><span class="op">]</span><span class="op">[</span><span class="fl">1</span><span class="op">:</span><span class="fl">5</span><span class="op">]</span></span></code></pre></div>
<p>Networks can also be converted into phylo object using
AntibodyForests_phylo. A new attribute called phylo is added for these
objects.</p>
<div class="sourceCode" id="cb73"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">network_w_phylo</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                                  network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                                  node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                                  specific.networks <span class="op">=</span> <span class="fl">1</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> </span>
<span>                   <span class="fu"><a href="../reference/AntibodyForests_phylo.html">AntibodyForests_phylo</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="va">network_w_phylo</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, phylo</span></span></code></pre>
<div class="sourceCode" id="cb75"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="va">network_w_phylo</span><span class="op">@</span><span class="va">phylo</span><span class="op">)</span></span></code></pre></div>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-41-1.png" width="768"></p>
</div>
<div class="section level3">
<h3 id="antibodyforests_dynamics-dynamictemporal-networks">8.2. AntibodyForests_dynamics: Dynamic/temporal networks<a class="anchor" aria-label="anchor" href="#antibodyforests_dynamics-dynamictemporal-networks"></a>
</h3>
<p>Dynamic networks can be assembled using AntibodyForests_dynamics:
this function inverts the nested list = output of AntibodyForests - the
main list preserves only the clonotypes found in all timepoints, while
the secondary lists include the objects per timepoint/sample. Moreover,
each of such objects pools together all nodes across all respective
timepoints, but only keeps the edges for its own timepoint. This
facilitates downstream analyses (e.g., tracking a specific node across
multiple timepoints).</p>
<p>We recommend to use this function after ensure your clonotype
definitions are consistent across all timepoints (e.g., clonotype 1 in
timepoint/sample 1 has the same VDJ_cdr3_aa as clonotype 1 in
timepoint/sample 2). You can use the VDJ_call_enclone function to merge
multiple samples together and reclonotype via the enclone software.</p>
<p>We will showcase this on a dataset with more samples/timepoints.</p>
<div class="sourceCode" id="cb76"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/PlatypusDB_fetch.html">PlatypusDB_fetch</a></span><span class="op">(</span>PlatypusDB.links <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"neumeier2021b//VDJmatrix"</span><span class="op">)</span>, </span>
<span>                                     load.to.enviroment <span class="op">=</span> <span class="cn">T</span>, combine.objects <span class="op">=</span> <span class="cn">F</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## 2022-08-17 20:51:35: Starting download of neumeier2021b__VDJmatrix.RData...</span></span></code></pre>
<pre><code><span><span class="co">## [1] "neumeier2021b__VDJmatrix"</span></span></code></pre>
<div class="sourceCode" id="cb79"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">OVA_VDJ</span> <span class="op">&lt;-</span> <span class="va">neumeier2021b__VDJmatrix</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span></span></code></pre></div>
<div class="sourceCode" id="cb80"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">dynamic_networks</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">OVA_VDJ</span>,</span>
<span>                                    network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                                    sequence.type <span class="op">=</span> <span class="st">'cdr3.nt'</span>,</span>
<span>                                    include.germline <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>                                    node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span>                   <span class="fu"><a href="../reference/AntibodyForests_dynamics.html">AntibodyForests_dynamics</a></span><span class="op">(</span>timepoints.order <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">'s2'</span>, <span class="st">'s1'</span>, <span class="st">'s3'</span>, <span class="st">'s4'</span><span class="op">)</span><span class="op">)</span> <span class="co">#setting a predefined timepoints order in the resulting object</span></span>
<span><span class="va">dynamic_networks</span></span></code></pre></div>
<pre><code><span><span class="co">## $clonotype11</span></span>
<span><span class="co">## $clonotype11$s2</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 9  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 9  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s2 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype11 </span></span>
<span><span class="co">## Networks/analyses available:  tree, dynamic</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $clonotype11$s1</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 8  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 8  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype11 </span></span>
<span><span class="co">## Networks/analyses available:  tree, dynamic</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $clonotype11$s3</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 10  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 10  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s3 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype11 </span></span>
<span><span class="co">## Networks/analyses available:  tree, dynamic</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $clonotype11$s4</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 8  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 8  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s4 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype11 </span></span>
<span><span class="co">## Networks/analyses available:  tree, dynamic</span></span></code></pre>
<p>We can see how only clonotype 11 is shared across all samples. We can
also plot a single dynamic network to see how it is configured. Make
sure graph.type is set to ‘dynamic’ when plotting our new object.</p>
<div class="sourceCode" id="cb82"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">dynamic_networks</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>graph.type <span class="op">=</span> <span class="st">'dynamic'</span>, </span>
<span>                                          node.color <span class="op">=</span> <span class="st">'sample_id'</span>, </span>
<span>                                          node.label <span class="op">=</span> <span class="st">'cells'</span>, </span>
<span>                                          network.layout <span class="op">=</span> <span class="st">'nice'</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## $clonotype11</span></span>
<span><span class="co">## $clonotype11$s2</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 9  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 9  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s2 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype11 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready, dynamic</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $clonotype11$s1</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 8  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 8  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype11 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready, dynamic</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $clonotype11$s3</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 10  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 10  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s3 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype11 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready, dynamic</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $clonotype11$s4</span></span>
<span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 8  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 8  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s4 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype11 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready, dynamic</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-44-1.png" width="768"><img src="AntibodyForests_files/figure-html/unnamed-chunk-44-2.png" width="768"><img src="AntibodyForests_files/figure-html/unnamed-chunk-44-3.png" width="768"><img src="AntibodyForests_files/figure-html/unnamed-chunk-44-4.png" width="768"></p>
</div>
<div class="section level3">
<h3 id="antibodyforests_heterogeneous-heterogeneousbipartite-networks">8.3. AntibodyForests_heterogeneous: Heterogeneous/bipartite
networks<a class="anchor" aria-label="anchor" href="#antibodyforests_heterogeneous-heterogeneousbipartite-networks"></a>
</h3>
<p>AntibodyForests allows for the inference of heterogeneous networks:
these multimodal networks consists of a pre-built sequence network
(e.g., via our evolutionary tree algorithm) and the SNN/KNN cell graphs
computed by Seurat (<a href="https://satijalab.org/seurat/reference/findneighbors" class="external-link uri">https://satijalab.org/seurat/reference/findneighbors</a>).
Interlevel edges are added between sequences and their respective cell
barcodes.</p>
<p>This framework allows for the visualization of more complex features
(e.g., isotypes along cell clusters), with plans for more analyses to be
added to make use of this network type.</p>
<p>To plot these bipartite networks, the Seurat/VGM[[2]] object must be
included in the AntibodyForests_heterogeneous function, as well as the
specified graph type in AntibodyForests_plot should be
‘heterogeneous’.</p>
<div class="sourceCode" id="cb84"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">bipartite_network</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                                    network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                                    node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                                    specific.networks <span class="op">=</span> <span class="fl">1</span>,</span>
<span>                                    node.features <span class="op">=</span> <span class="st">'VDJ_cgene'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span>                     <span class="fu"><a href="../reference/AntibodyForests_heterogeneous.html">AntibodyForests_heterogeneous</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>, snn.threshold <span class="op">=</span> <span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="co">#setitng up the pruning threshold for the SNN cell graph obtained from Seurat (https://satijalab.org/seurat/reference/findneighbors)</span></span>
<span>                     <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>graph.type <span class="op">=</span> <span class="st">'heterogeneous'</span>, node.color <span class="op">=</span> <span class="st">'VDJ_cgene'</span>, node.label <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Computing nearest neighbor graph</span></span></code></pre>
<pre><code><span><span class="co">## Computing SNN</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-45-1.png" width="768"></p>
<div class="sourceCode" id="cb87"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">bipartite_network</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready, heterogeneous</span></span></code></pre>
<div class="sourceCode" id="cb89"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">bipartite_network</span><span class="op">@</span><span class="va">heterogeneous</span></span></code></pre></div>
<pre><code><span><span class="co">## IGRAPH a9a95f8 UNWB 82 629 -- </span></span>
<span><span class="co">## + attr: name (v/c), network_sequences (v/c), cell_number (v/n),</span></span>
<span><span class="co">## | node_type (v/c), most_expanded (v/c), hub (v/c), clonotype_id (v/c),</span></span>
<span><span class="co">## | sample_id (v/c), cell_barcodes (v/x), distance_from_germline (v/n),</span></span>
<span><span class="co">## | leaf (v/c), VDJ_cgene (v/x), VDJ_cgene_counts (v/x), type (v/c),</span></span>
<span><span class="co">## | seurat_clusters (v/n), lvl (v/n), weight (e/n), type (e/c)</span></span>
<span><span class="co">## + edges from a9a95f8 (vertex names):</span></span>
<span><span class="co">##  [1] sequence1--sequence8  sequence1--sequence11 sequence1--sequence32</span></span>
<span><span class="co">##  [4] sequence1--sequence4  sequence4--sequence30 sequence4--sequence34</span></span>
<span><span class="co">##  [7] sequence5--sequence25 sequence2--sequence7  sequence5--sequence7 </span></span>
<span><span class="co">## [10] sequence7--sequence9  sequence7--sequence13 sequence7--sequence18</span></span>
<span><span class="co">## + ... omitted several edges</span></span></code></pre>
<p>As the visualization via igraph::plot.igraph is often limited, we can
plot these bipartite networks using the ggraph and graphlayouts
packages. We will also highlight the interlevel connections between the
most expanded sequence node and its corresponding cells.</p>
<div class="sourceCode" id="cb91"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://ggraph.data-imaginist.com" class="external-link">ggraph</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="http://graphlayouts.schochastics.net/" class="external-link">graphlayouts</a></span><span class="op">)</span></span>
<span></span>
<span><span class="va">g</span> <span class="op">&lt;-</span> <span class="va">bipartite_network</span><span class="op">@</span><span class="va">plot_ready</span></span>
<span><span class="va">tree_layout</span> <span class="op">&lt;-</span> <span class="fu">purrr</span><span class="fu">::</span><span class="fu"><a href="https://purrr.tidyverse.org/reference/partial.html" class="external-link">partial</a></span><span class="op">(</span><span class="fu">igraph</span><span class="fu">::</span><span class="va"><a href="https://rdrr.io/pkg/igraph/man/layout_as_tree.html" class="external-link">layout_as_tree</a></span>, root <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/which.html" class="external-link">which</a></span><span class="op">(</span><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/V.html" class="external-link">V</a></span><span class="op">(</span><span class="va">g</span><span class="op">)</span><span class="op">$</span><span class="va">node_type</span> <span class="op">==</span> <span class="st">'germline'</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="va">xy</span> <span class="op">&lt;-</span> <span class="fu"><a href="http://graphlayouts.schochastics.net/reference/layout_multilevel.html" class="external-link">layout_as_multilevel</a></span><span class="op">(</span><span class="va">g</span>,</span>
<span>  type <span class="op">=</span> <span class="st">"separate"</span>,</span>
<span>  FUN1 <span class="op">=</span> <span class="va">tree_layout</span>,</span>
<span>  FUN2 <span class="op">=</span> <span class="fu">graphlayouts</span><span class="fu">::</span><span class="va"><a href="http://graphlayouts.schochastics.net/reference/layout_stress.html" class="external-link">layout_with_stress</a></span>,</span>
<span>  alpha <span class="op">=</span> <span class="fl">25</span>, beta <span class="op">=</span> <span class="fl">45</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="va">sequence_color_list</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"IGHA"</span> <span class="op">=</span> <span class="st">"red"</span>, <span class="st">"germline"</span> <span class="op">=</span> <span class="st">"black"</span><span class="op">)</span></span>
<span><span class="va">cells_color_list</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span></span>
<span>  <span class="st">"#E99093"</span>,  <span class="st">"#1A5878"</span>, <span class="st">"#C44237"</span>, <span class="st">"#AD8941"</span>,</span>
<span>  <span class="st">"#50594B"</span>, <span class="st">"#8968CD"</span>, <span class="st">"#9ACD32"</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">ggraph</span><span class="op">(</span><span class="va">g</span>, <span class="st">"manual"</span>, x <span class="op">=</span> <span class="va">xy</span><span class="op">[</span>, <span class="fl">1</span><span class="op">]</span>, y <span class="op">=</span> <span class="va">xy</span><span class="op">[</span>, <span class="fl">2</span><span class="op">]</span><span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu">geom_edge_link0</span><span class="op">(</span></span>
<span>    <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>filter <span class="op">=</span> <span class="op">(</span><span class="va">node1.lvl</span> <span class="op">==</span> <span class="fl">1</span> <span class="op">&amp;</span> <span class="va">node2.lvl</span> <span class="op">==</span> <span class="fl">1</span><span class="op">)</span><span class="op">)</span>,</span>
<span>    edge_colour <span class="op">=</span> <span class="st">"black"</span>,</span>
<span>    alpha <span class="op">=</span> <span class="fl">0.5</span>,</span>
<span>    edge_width <span class="op">=</span> <span class="fl">0.3</span></span>
<span>  <span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu">geom_edge_link0</span><span class="op">(</span></span>
<span>    <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>filter <span class="op">=</span> <span class="op">(</span><span class="va">node1.lvl</span> <span class="op">!=</span> <span class="va">node2.lvl</span><span class="op">)</span><span class="op">)</span>,</span>
<span>    alpha <span class="op">=</span> <span class="fl">0.5</span>,</span>
<span>    edge_width <span class="op">=</span> <span class="fl">0.05</span>,</span>
<span>    edge_colour <span class="op">=</span> <span class="st">"gray24"</span></span>
<span>  <span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu">geom_edge_link0</span><span class="op">(</span></span>
<span>    <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>filter <span class="op">=</span> <span class="op">(</span><span class="va">node1.lvl</span> <span class="op">==</span> <span class="fl">2</span> <span class="op">&amp;</span></span>
<span>      <span class="va">node2.lvl</span> <span class="op">==</span> <span class="fl">2</span><span class="op">)</span>, edge_width <span class="op">=</span> <span class="va">weight</span><span class="op">)</span>,</span>
<span>    edge_colour <span class="op">=</span> <span class="st">"black"</span>,</span>
<span>    alpha <span class="op">=</span> <span class="fl">0.1</span></span>
<span>  <span class="op">)</span><span class="op">+</span></span>
<span>  <span class="fu">geom_edge_link0</span><span class="op">(</span></span>
<span>    <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>filter <span class="op">=</span> <span class="op">(</span><span class="va">node1.most_expanded</span> <span class="op">==</span> <span class="st">'yes'</span> <span class="op">&amp;</span> <span class="co">#We can also highlight the interlevel edges connecting the most expanded node to its cells</span></span>
<span>      <span class="va">node2.lvl</span> <span class="op">==</span> <span class="fl">2</span> <span class="op">&amp;</span> <span class="va">node1.lvl</span> <span class="op">!=</span> <span class="va">node2.lvl</span><span class="op">)</span><span class="op">)</span>,</span>
<span>    edge_colour <span class="op">=</span> <span class="st">"blue"</span>,</span>
<span>    alpha <span class="op">=</span> <span class="fl">0.8</span></span>
<span>  <span class="op">)</span><span class="op">+</span></span>
<span>  <span class="fu">scale_edge_width</span><span class="op">(</span>range <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">0.2</span>, <span class="fl">2</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu">geom_node_point</span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>filter <span class="op">=</span> <span class="op">(</span><span class="va">lvl</span> <span class="op">==</span> <span class="fl">1</span><span class="op">)</span>, color <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/unlist.html" class="external-link">unlist</a></span><span class="op">(</span><span class="va">VDJ_cgene</span><span class="op">)</span>, size <span class="op">=</span> <span class="va">cell_number</span> <span class="op">*</span> <span class="fl">2</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu">geom_node_point</span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>filter <span class="op">=</span> <span class="va">lvl</span> <span class="op">==</span> <span class="fl">2</span>, fill <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html" class="external-link">as.factor</a></span><span class="op">(</span><span class="va">seurat_clusters</span><span class="op">)</span>, size <span class="op">=</span> <span class="va">cell_number</span> <span class="op">*</span> <span class="fl">3</span><span class="op">)</span>, shape <span class="op">=</span> <span class="fl">22</span><span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_manual.html" class="external-link">scale_color_manual</a></span><span class="op">(</span>values <span class="op">=</span> <span class="va">sequence_color_list</span><span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_manual.html" class="external-link">scale_fill_manual</a></span><span class="op">(</span>values <span class="op">=</span> <span class="va">cells_color_list</span><span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_manual.html" class="external-link">scale_shape_manual</a></span><span class="op">(</span>values <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">21</span>, <span class="fl">22</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu">theme_graph</span><span class="op">(</span><span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html" class="external-link">theme</a></span><span class="op">(</span>legend.position <span class="op">=</span> <span class="st">'none'</span><span class="op">)</span> <span class="op">+</span></span>
<span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/coord_cartesian.html" class="external-link">coord_cartesian</a></span><span class="op">(</span>clip <span class="op">=</span> <span class="st">"off"</span>, expand <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
</div>
</div>
<div class="section level2">
<h2 id="network-analysis-methods-implemented-in-antibodyforests">9. Network analysis methods implemented in AntibodyForests<a class="anchor" aria-label="anchor" href="#network-analysis-methods-implemented-in-antibodyforests"></a>
</h2>
<p>Several network analysis methods/algorithms have been implemented in
AntibodyForests, with plans to extend them to the heterogeneous and
dynamic graph types.</p>
<div class="section level3">
<h3 id="obtaining-node-metric-via-antibodyforests_metrics">9.1. Obtaining node metric via AntibodyForests_metrics<a class="anchor" aria-label="anchor" href="#obtaining-node-metric-via-antibodyforests_metrics"></a>
</h3>
<p>Node-level metrics can be calculated via AntibodyForests_metrics for
a list of AntibodyForests objects or a single object. The metrics can be
selected via a vector of strings in the metrics parameter. Moreover, for
bipartite networks, metrics can be calculated for the whole graph or for
each segment (sequence graph and cell graph) separately. This can be
done by setting separate.bipartite to T and graph.type to
‘heterogeneous’.</p>
<p>The currently implemented node metrics are: 1. Betweenness centrality
- ‘betweenness’ 2. Closeness centrality - ‘closeness’ 3. Eigenvector
centrality - ‘eigenvector’ 4. Authority score - ‘authority’ 5. Local and
average clustering coefficients - ‘local_cluster_coefficient’,
‘average_cluster_coefficient’ 6. Strength or weighted vertex degree -
‘strength’ 7. Degree - ‘degree’ 8. Daughter nodes for directed graphs -
‘daughters’ 9. Vertex eccentricity (shortest path distance from the
farthest other node in the graph) - ‘eccentricity’ 10. Pagerank
algorithm values - ‘pagerank’ 11. Shortest (weighted) paths from
germline - ‘path_from_germline’, ‘weighted_path_from_germline’ 12.
Shortest(weighted) paths from the most expanded node -
‘path_from_most_expanded’, ‘weighted_path_from_most_expanded’, 13.
Shortest(weighted) paths from the hub node (highest degree) -
‘path_from_hub’, ‘weighted_path_from_hub’</p>
<p>By default, all of these metrics will be computed per graph, with the
possibility to select only a subset of metrics in the metrics
parameter.</p>
<div class="sourceCode" id="cb92"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks_with_metrics</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                                        network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                                        node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                                        specific.networks <span class="op">=</span> <span class="fl">5</span>,</span>
<span>                                        node.features <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">'VDJ_cgene'</span>,<span class="st">'seurat_clusters'</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> </span>
<span>                         <span class="fu"><a href="../reference/AntibodyForests_metrics.html">AntibodyForests_metrics</a></span><span class="op">(</span>graph.type <span class="op">=</span> <span class="st">'tree'</span><span class="op">)</span></span></code></pre></div>
<p>The resulting object(s) will contain a metrics slot - a dataframe of
metric values per node for easier downstream statistics.</p>
<div class="sourceCode" id="cb93"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks_with_metrics</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, metrics</span></span></code></pre>
<div class="sourceCode" id="cb95"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/colnames.html" class="external-link">colnames</a></span><span class="op">(</span><span class="va">networks_with_metrics</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span><span class="op">@</span><span class="va">metrics</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">##  [1] "label"                            "network_sequences"               </span></span>
<span><span class="co">##  [3] "cell_number"                      "node_type"                       </span></span>
<span><span class="co">##  [5] "most_expanded"                    "hub"                             </span></span>
<span><span class="co">##  [7] "clonotype_id"                     "sample_id"                       </span></span>
<span><span class="co">##  [9] "cell_barcodes"                    "distance_from_germline"          </span></span>
<span><span class="co">## [11] "leaf"                             "VDJ_cgene"                       </span></span>
<span><span class="co">## [13] "seurat_clusters"                  "betweenness"                     </span></span>
<span><span class="co">## [15] "closeness"                        "eigenvector"                     </span></span>
<span><span class="co">## [17] "authority_score"                  "degree"                          </span></span>
<span><span class="co">## [19] "strength"                         "local_cluster_coefficient"       </span></span>
<span><span class="co">## [21] "average_cluster_coefficient"      "daughters"                       </span></span>
<span><span class="co">## [23] "pagerank"                         "eccentricity"                    </span></span>
<span><span class="co">## [25] "path_from_germline"               "weighted_path_from_germline"     </span></span>
<span><span class="co">## [27] "path_from_most_expanded"          "weighted_path_from_most_expanded"</span></span>
<span><span class="co">## [29] "path_from_hub"                    "weighted_path_from_hub"</span></span></code></pre>
</div>
<div class="section level3">
<h3 id="plotting-metrics-via-antibodyforests_plot_metrics">9.2. Plotting metrics via AntibodyForests_plot_metrics<a class="anchor" aria-label="anchor" href="#plotting-metrics-via-antibodyforests_plot_metrics"></a>
</h3>
<p>After obtaining our metrics with AntibodyForests_metrics, we can also
visualize them using AntibodyForests_plot_metrics. The currently
supported analyses include PCA reduction across all metrics values (for
node clustering analysis) and violin plots across specific groups and/or
samples. These can be selected via the plot.format parameter, with plans
to add more analyses in the future!</p>
<div class="section level4">
<h4 id="metrics-pca">Metrics PCA<a class="anchor" aria-label="anchor" href="#metrics-pca"></a>
</h4>
<div class="sourceCode" id="cb97"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks_with_metrics</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot_metrics.html">AntibodyForests_plot_metrics</a></span><span class="op">(</span>plot.format <span class="op">=</span> <span class="st">'pca'</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## [[1]]</span></span>
<span><span class="co">## [[1]]$VDJ_cgene</span></span></code></pre>
<pre><code><span><span class="co">## </span></span>
<span><span class="co">## [[1]]$seurat_clusters</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-52-1.png" width="768"><img src="AntibodyForests_files/figure-html/unnamed-chunk-52-2.png" width="768"></p>
<p>As you can see, plots are automatically colored by the node.features
we have selected when creating our networks.</p>
</div>
<div class="section level4">
<h4 id="metrics-violin-plots">Metrics violin plots<a class="anchor" aria-label="anchor" href="#metrics-violin-plots"></a>
</h4>
<p>For violin plots, we can select custom groups via the group.by
parameter (e.g., grouping by ‘clonotype_id’ or by ‘seurat_clusters’). We
can also select a maximum number of groups (max.groups) or specific
groups to plot (specific.groups).</p>
<p>The specific metrics for our violin plots can be selected via the
metrics.to.plot parameter.</p>
<div class="sourceCode" id="cb100"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co">#Pagerank and degree grouped by clonotypes</span></span>
<span><span class="va">networks_with_metrics</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot_metrics.html">AntibodyForests_plot_metrics</a></span><span class="op">(</span>plot.format <span class="op">=</span> <span class="st">'violin'</span>,</span>
<span>                                                       metrics.to.plot <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">'pagerank'</span>, <span class="st">'degree'</span><span class="op">)</span>,</span>
<span>                                                       group.by <span class="op">=</span> <span class="st">'clonotype_id'</span></span>
<span>                                                       <span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## [[1]]</span></span>
<span><span class="co">## [[1]]$pagerank</span></span></code></pre>
<pre><code><span><span class="co">## </span></span>
<span><span class="co">## [[1]]$degree</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-53-1.png" width="768"><img src="AntibodyForests_files/figure-html/unnamed-chunk-53-2.png" width="768"></p>
<div class="sourceCode" id="cb103"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co">#Pagerank grouped by Seurat clusters</span></span>
<span><span class="va">networks_with_metrics</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot_metrics.html">AntibodyForests_plot_metrics</a></span><span class="op">(</span>plot.format <span class="op">=</span> <span class="st">'violin'</span>,</span>
<span>                                                       metrics.to.plot <span class="op">=</span> <span class="st">'pagerank'</span>,</span>
<span>                                                       group.by <span class="op">=</span> <span class="st">'seurat_clusters'</span></span>
<span>                                                       <span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## [[1]]</span></span>
<span><span class="co">## [[1]]$pagerank</span></span></code></pre>
<pre><code><span><span class="co">## Warning: Groups with fewer than two data points have been dropped.</span></span>
<span><span class="co">## Groups with fewer than two data points have been dropped.</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-54-1.png" width="768"></p>
</div>
</div>
<div class="section level3">
<h3 id="network-communities-and-cluster-analysis-via-antibodyforests_communities">9.3. Network communities and cluster analysis via
AntibodyForests_communities<a class="anchor" aria-label="anchor" href="#network-communities-and-cluster-analysis-via-antibodyforests_communities"></a>
</h3>
<p>Communities/clusters can be detected on a complex similarity network
via AntibodyForests_communities. The resulting AntibodyForests object
includes a ‘community’ vertex attribute, which can be used inside
AntibodyForests_plot (or for grouping inside
AntibodyForests_plot_metrics/ as groups in AntibodyForests_overlap,
etc.,). AntibodyForests_communities will also output a barplot of
feature counts per community - features can be counted at the sequence
level (single unique feature per node = most frequent one), or at the
cell level (all feature counts per single node, for all cells per node)
- this is controlled by the count.level parameter (‘cells’ or
‘sequences’).</p>
<p>Currently, the community detection algorithms are implemented as
wrappers to their respective igraph functions. Specific algorithms can
be selected in the community.algorithm parameter. These algorithms
include:</p>
<ol style="list-style-type: decimal">
<li>The edge betweenness algorithm - ‘edge_betweenness’</li>
<li>Louvain algorithm - ’louvain</li>
<li>Label propagation - ‘label_prop’</li>
<li>Leading eigen - ‘leading_eigen’</li>
<li>Leiden - ‘leiden’</li>
<li>Optimal - ‘optimal’</li>
<li>Spinglass - ‘spinglass’</li>
<li>Walktrap - ‘walktrap’</li>
</ol>
<p>Nonetheless, for bipartite graphs, communities can be identified on
each graph separately (which.bipartire = ‘sequences’ or ‘cells’) or both
(which.bipartite = ‘both’).</p>
<div class="sourceCode" id="cb106"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks_with_clusters</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, </span>
<span>                                          sequence.type <span class="op">=</span> <span class="st">'VDJ.cdr3s.aa'</span>,</span>
<span>                                          network.algorithm <span class="op">=</span> <span class="st">'global'</span>,</span>
<span>                                          pruning.threshold <span class="op">=</span> <span class="fl">3</span>,</span>
<span>                                          node.features <span class="op">=</span> <span class="st">'seurat_clusters'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span>                          <span class="fu"><a href="../reference/AntibodyForests_metrics.html">AntibodyForests_metrics</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span>                          <span class="fu"><a href="../reference/AntibodyForests_communities.html">AntibodyForests_communities</a></span><span class="op">(</span>community.algorithm <span class="op">=</span> <span class="st">'louvain'</span>,</span>
<span>                                                      additional.parameters <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span>resolution <span class="op">=</span> <span class="fl">0.15</span><span class="op">)</span><span class="op">)</span> </span></code></pre></div>
<pre><code><span><span class="co">## Warning in vattrs[[name]][index] &lt;- value: number of items to replace is not a</span></span>
<span><span class="co">## multiple of replacement length</span></span></code></pre>
<div class="sourceCode" id="cb108"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co">#additional parameters can be added for each clustering option as a named list - check the igraph documentation for such parameters (https://igraph.org/r/doc/cluster_louvain.html)</span></span></code></pre></div>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-55-1.png" width="768"></p>
<p>The resulting barplot with cell counts per feature, per cluster.</p>
<div class="sourceCode" id="cb109"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks_with_clusters</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.color <span class="op">=</span> <span class="st">'community'</span>, </span>
<span>                                                network.layout <span class="op">=</span> <span class="st">'nice'</span>, </span>
<span>                                                node.label <span class="op">=</span> <span class="cn">NULL</span>, </span>
<span>                                                node.scale.factor <span class="op">=</span> <span class="fl">3</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 471  sequence nodes across  1  sample(s) and  353  clonotype(s) </span></span>
<span><span class="co">## 471  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype1, clonotype2, clonotype3, clonotype4, clonotype5, clonotype6, clonotype7, clonotype8, clonotype9, clonotype10, clonotype11, clonotype12, clonotype13, clonotype14, clonotype15, clonotype16, clonotype17, clonotype18, clonotype19, clonotype21, clonotype22, clonotype23, clonotype24, clonotype25, clonotype26, clonotype27, clonotype28, clonotype29, clonotype30, clonotype31, clonotype32, clonotype33, clonotype34, clonotype35, clonotype36, clonotype37, clonotype38, clonotype39, clonotype40, clonotype41, clonotype42, clonotype43, clonotype44, clonotype45, clonotype46, clonotype47, clonotype48, clonotype49, clonotype50, clonotype51, clonotype52, clonotype53, clonotype54, clonotype55, clonotype56, clonotype57, clonotype58, clonotype59, clonotype60, clonotype61, clonotype62, clonotype63, clonotype64, clonotype65, clonotype66, clonotype67, clonotype68, clonotype69, clonotype70, clonotype71, clonotype73, clonotype74, clonotype75, clonotype76, clonotype77, clonotype78, clonotype79, clonotype80, clonotype81, clonotype82, clonotype83, clonotype85, clonotype86, clonotype87, clonotype88, clonotype89, clonotype90, clonotype91, clonotype92, clonotype93, clonotype94, clonotype95, clonotype96, clonotype97, clonotype98, clonotype99, clonotype100, clonotype101, clonotype102, clonotype103, clonotype104, clonotype105, clonotype106, clonotype107, clonotype108, clonotype109, clonotype110, clonotype111, clonotype112, clonotype113, clonotype114, clonotype115, clonotype116, clonotype117, clonotype118, clonotype119, clonotype120, clonotype121, clonotype122, clonotype123, clonotype124, clonotype125, clonotype126, clonotype127, clonotype128, clonotype129, clonotype130, clonotype131, clonotype132, clonotype133, clonotype134, clonotype135, clonotype136, clonotype137, clonotype138, clonotype139, clonotype140, clonotype141, clonotype142, clonotype143, clonotype144, clonotype145, clonotype146, clonotype147, clonotype148, clonotype149, clonotype150, clonotype151, clonotype152, clonotype153, clonotype154, clonotype155, clonotype156, clonotype157, clonotype158, clonotype159, clonotype160, clonotype161, clonotype162, clonotype163, clonotype164, clonotype165, clonotype166, clonotype167, clonotype169, clonotype170, clonotype171, clonotype172, clonotype173, clonotype174, clonotype175, clonotype176, clonotype177, clonotype179, clonotype180, clonotype181, clonotype182, clonotype183, clonotype184, clonotype185, clonotype186, clonotype187, clonotype188, clonotype189, clonotype190, clonotype191, clonotype192, clonotype193, clonotype194, clonotype195, clonotype196, clonotype197, clonotype198, clonotype199, clonotype200, clonotype201, clonotype202, clonotype203, clonotype204, clonotype205, clonotype206, clonotype207, clonotype208, clonotype209, clonotype210, clonotype211, clonotype212, clonotype213, clonotype214, clonotype215, clonotype216, clonotype217, clonotype218, clonotype219, clonotype220, clonotype221, clonotype222, clonotype223, clonotype224, clonotype225, clonotype226, clonotype227, clonotype228, clonotype230, clonotype231, clonotype232, clonotype233, clonotype234, clonotype235, clonotype236, clonotype237, clonotype238, clonotype239, clonotype240, clonotype241, clonotype242, clonotype243, clonotype244, clonotype245, clonotype246, clonotype247, clonotype248, clonotype249, clonotype250, clonotype251, clonotype252, clonotype253, clonotype254, clonotype255, clonotype256, clonotype257, clonotype258, clonotype259, clonotype260, clonotype261, clonotype262, clonotype263, clonotype264, clonotype265, clonotype266, clonotype267, clonotype310, clonotype317, clonotype329, clonotype348, clonotype353, clonotype363, clonotype370, clonotype373, clonotype385, clonotype387, clonotype388, clonotype391, clonotype411, clonotype413, clonotype421, clonotype436, clonotype445, clonotype466, clonotype471, clonotype484, clonotype488, clonotype494, clonotype495, clonotype496, clonotype497, clonotype498, clonotype505, clonotype508, clonotype510, clonotype524, clonotype546, clonotype553, clonotype554, clonotype569, clonotype575, clonotype583, clonotype584, clonotype591, clonotype594, clonotype598, clonotype600, clonotype601, clonotype603, clonotype605, clonotype631, clonotype632, clonotype633, clonotype634, clonotype641, clonotype643, clonotype658, clonotype663, clonotype668, clonotype671, clonotype678, clonotype695, clonotype703, clonotype725, clonotype727, clonotype728, clonotype735, clonotype737, clonotype746, clonotype750, clonotype757, clonotype772, clonotype781, clonotype790, clonotype798, clonotype799, clonotype804, clonotype805, clonotype806, clonotype809, clonotype820, clonotype821, clonotype832, clonotype836, clonotype841, clonotype843, clonotype854, clonotype858, clonotype859, clonotype861, clonotype866, clonotype868, clonotype878, clonotype879, clonotype881, clonotype882, clonotype884, clonotype893 </span></span>
<span><span class="co">## Networks/analyses available:  prune.distance, plot_ready, metrics</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-56-1.png" width="768"></p>
</div>
<div class="section level3">
<h3 id="edge-overlap-via-antibodyforests_overlap">9.4. Edge overlap via AntibodyForests_overlap<a class="anchor" aria-label="anchor" href="#edge-overlap-via-antibodyforests_overlap"></a>
</h3>
<p>AntibodyForests_overlap counts the unique features a set of edges
connect - the result is an incidence/‘community’ matrix of ‘species’
(unique edges) per ‘sites’ (features connected by that edge). This
matrix can then be analysed for feature overlap across all edges -
either via the Jaccard similarity (method = ‘jaccard’) or simple counts
(method = ‘overlap’), visualized as heatmaps.</p>
<div class="sourceCode" id="cb111"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks_with_clusters</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_overlap.html">AntibodyForests_overlap</a></span><span class="op">(</span>method <span class="op">=</span> <span class="st">'overlap'</span>, </span>
<span>                                                   group.by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">'community'</span>, <span class="st">'seurat_clusters'</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-57-1.png" width="768"></p>
<div class="sourceCode" id="cb112"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks_with_clusters</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_overlap.html">AntibodyForests_overlap</a></span><span class="op">(</span>method <span class="op">=</span> <span class="st">'jaccard'</span>, </span>
<span>                                                   group.by <span class="op">=</span> <span class="st">'seurat_clusters'</span><span class="op">)</span></span></code></pre></div>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-58-1.png" width="768"></p>
</div>
<div class="section level3">
<h3 id="node-transitions-via-antibodyforests_node_transitions">9.5. Node transitions via AntibodyForests_node_transitions<a class="anchor" aria-label="anchor" href="#node-transitions-via-antibodyforests_node_transitions"></a>
</h3>
<p>Node transitions are computed by counting the number of edges
connecting a each unique pair of features (similar to the overlap
calculation, but resulting in an abundance dataframe instead of an
incidence one).</p>
<div class="sourceCode" id="cb113"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                node.features <span class="op">=</span> <span class="st">'VDJ_cgene'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span>            <span class="fu"><a href="../reference/AntibodyForests_join_trees.html">AntibodyForests_join_trees</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span>            <span class="fu"><a href="../reference/AntibodyForests_node_transitions.html">AntibodyForests_node_transitions</a></span><span class="op">(</span>features <span class="op">=</span> <span class="st">'VDJ_cgene'</span><span class="op">)</span></span></code></pre></div>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-59-1.png" width="768"></p>
<div class="sourceCode" id="cb114"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span> </span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 258  sequence nodes across  1  sample(s) and  24  clonotype(s) </span></span>
<span><span class="co">## 258  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7, clonotype8, clonotype9, clonotype11, clonotype13, clonotype17, clonotype18, clonotype22, clonotype24, clonotype25, clonotype26, clonotype28, clonotype29, clonotype31, clonotype32, clonotype34, clonotype45, clonotype46, clonotype48, clonotype50, clonotype57, clonotype61, clonotype69, clonotype71 </span></span>
<span><span class="co">## Networks/analyses available:  tree, node_transitions</span></span></code></pre>
<div class="sourceCode" id="cb116"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span><span class="op">@</span><span class="va">node_transitions</span></span></code></pre></div>
<pre><code><span><span class="co">##      from     to counts feature_name</span></span>
<span><span class="co">## 4    IGHA   IGHA    212    VDJ_cgene</span></span>
<span><span class="co">## 5    IGHA IGHG2B      2    VDJ_cgene</span></span>
<span><span class="co">## 6    IGHA IGHG2C      1    VDJ_cgene</span></span>
<span><span class="co">## 7   IGHG1 IGHG2B      1    VDJ_cgene</span></span>
<span><span class="co">## 8  IGHG2B   IGHA      2    VDJ_cgene</span></span>
<span><span class="co">## 9  IGHG2B   IGHM      2    VDJ_cgene</span></span>
<span><span class="co">## 10   IGHM  IGHG1      1    VDJ_cgene</span></span>
<span><span class="co">## 11   IGHM IGHG2B      1    VDJ_cgene</span></span>
<span><span class="co">## 12   IGHM   IGHM     10    VDJ_cgene</span></span>
<span><span class="co">##                                                                                                                                                                                                                                                                                    clonotype_id</span></span>
<span><span class="co">## 4  clonotype7;clonotype8;clonotype9;clonotype11;clonotype13;clonotype17;clonotype18;clonotype22;clonotype24;clonotype25;clonotype26;clonotype28;clonotype29;clonotype31;clonotype32;clonotype34;clonotype45;clonotype46;clonotype48;clonotype50;clonotype57;clonotype61;clonotype69;clonotype71</span></span>
<span><span class="co">## 5  clonotype7;clonotype8;clonotype9;clonotype11;clonotype13;clonotype17;clonotype18;clonotype22;clonotype24;clonotype25;clonotype26;clonotype28;clonotype29;clonotype31;clonotype32;clonotype34;clonotype45;clonotype46;clonotype48;clonotype50;clonotype57;clonotype61;clonotype69;clonotype71</span></span>
<span><span class="co">## 6  clonotype7;clonotype8;clonotype9;clonotype11;clonotype13;clonotype17;clonotype18;clonotype22;clonotype24;clonotype25;clonotype26;clonotype28;clonotype29;clonotype31;clonotype32;clonotype34;clonotype45;clonotype46;clonotype48;clonotype50;clonotype57;clonotype61;clonotype69;clonotype71</span></span>
<span><span class="co">## 7  clonotype7;clonotype8;clonotype9;clonotype11;clonotype13;clonotype17;clonotype18;clonotype22;clonotype24;clonotype25;clonotype26;clonotype28;clonotype29;clonotype31;clonotype32;clonotype34;clonotype45;clonotype46;clonotype48;clonotype50;clonotype57;clonotype61;clonotype69;clonotype71</span></span>
<span><span class="co">## 8  clonotype7;clonotype8;clonotype9;clonotype11;clonotype13;clonotype17;clonotype18;clonotype22;clonotype24;clonotype25;clonotype26;clonotype28;clonotype29;clonotype31;clonotype32;clonotype34;clonotype45;clonotype46;clonotype48;clonotype50;clonotype57;clonotype61;clonotype69;clonotype71</span></span>
<span><span class="co">## 9  clonotype7;clonotype8;clonotype9;clonotype11;clonotype13;clonotype17;clonotype18;clonotype22;clonotype24;clonotype25;clonotype26;clonotype28;clonotype29;clonotype31;clonotype32;clonotype34;clonotype45;clonotype46;clonotype48;clonotype50;clonotype57;clonotype61;clonotype69;clonotype71</span></span>
<span><span class="co">## 10 clonotype7;clonotype8;clonotype9;clonotype11;clonotype13;clonotype17;clonotype18;clonotype22;clonotype24;clonotype25;clonotype26;clonotype28;clonotype29;clonotype31;clonotype32;clonotype34;clonotype45;clonotype46;clonotype48;clonotype50;clonotype57;clonotype61;clonotype69;clonotype71</span></span>
<span><span class="co">## 11 clonotype7;clonotype8;clonotype9;clonotype11;clonotype13;clonotype17;clonotype18;clonotype22;clonotype24;clonotype25;clonotype26;clonotype28;clonotype29;clonotype31;clonotype32;clonotype34;clonotype45;clonotype46;clonotype48;clonotype50;clonotype57;clonotype61;clonotype69;clonotype71</span></span>
<span><span class="co">## 12 clonotype7;clonotype8;clonotype9;clonotype11;clonotype13;clonotype17;clonotype18;clonotype22;clonotype24;clonotype25;clonotype26;clonotype28;clonotype29;clonotype31;clonotype32;clonotype34;clonotype45;clonotype46;clonotype48;clonotype50;clonotype57;clonotype61;clonotype69;clonotype71</span></span>
<span><span class="co">##    sample_id</span></span>
<span><span class="co">## 4         s1</span></span>
<span><span class="co">## 5         s1</span></span>
<span><span class="co">## 6         s1</span></span>
<span><span class="co">## 7         s1</span></span>
<span><span class="co">## 8         s1</span></span>
<span><span class="co">## 9         s1</span></span>
<span><span class="co">## 10        s1</span></span>
<span><span class="co">## 11        s1</span></span>
<span><span class="co">## 12        s1</span></span></code></pre>
</div>
<div class="section level3">
<h3 id="paths-in-graphs-via-antibodyforests_paths">9.6. Paths in graphs via AntibodyForests_paths<a class="anchor" aria-label="anchor" href="#paths-in-graphs-via-antibodyforests_paths"></a>
</h3>
<p>Shortest or longest paths in a graph are calculated using
AntibodyForests_paths. The resulting AntibodyForests object will have a
new slot - paths, which can be used in the AntibodyForests_plot
function. Starting and end-points of a path can be specified using the
path.from and path.to parameters.</p>
<p>There are several options for these: for example, paths can be
calculated from a germline node (path.from or to = ‘germline’), the most
expanded node (‘most_expanded’), hubs (‘hub’), leaves (‘leaf’), or from
specific node features (for example, paths from all IGHG nodes to the
hub are computed by setting path.from to c(‘VDJ_cgene’, ‘IGHG’) and
path.to to ‘hub’). Lastly, paths can be computed from a node identified
by an integer (paths from the first node in a network - path.from =
1).</p>
<div class="sourceCode" id="cb118"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                node.features <span class="op">=</span> <span class="st">'seurat_clusters'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="fl">10</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span>            <span class="fu"><a href="../reference/AntibodyForests_paths.html">AntibodyForests_paths</a></span><span class="op">(</span>path.from <span class="op">=</span> <span class="st">'germline'</span>, </span>
<span>                                  path.to <span class="op">=</span> <span class="st">'leaf'</span>, </span>
<span>                                  cell.frequency <span class="op">=</span> <span class="cn">T</span>, <span class="co">#barplot y axis as cell counts per feature instead of node counts</span></span>
<span>                                  color.by <span class="op">=</span> <span class="st">'seurat_clusters'</span><span class="op">)</span> <span class="co">#will color the nodes/cells in the path by seurat_clusters in the output barplot</span></span></code></pre></div>
<div class="sourceCode" id="cb119"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 35  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 35  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype7 </span></span>
<span><span class="co">## Networks/analyses available:  tree, paths</span></span></code></pre>
<div class="sourceCode" id="cb121"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span><span class="op">@</span><span class="va">paths</span></span></code></pre></div>
<pre><code><span><span class="co">## $shortest</span></span>
<span><span class="co">## $shortest[[1]]</span></span>
<span><span class="co">## + 3/36 vertices, from c597807:</span></span>
<span><span class="co">## [1] 36  7 31</span></span></code></pre>
</div>
<div class="section level3">
<h3 id="node-embeddings-via-antibodyforests_embeddings">9.7. Node embeddings via AntibodyForests_embeddings<a class="anchor" aria-label="anchor" href="#node-embeddings-via-antibodyforests_embeddings"></a>
</h3>
<p>AntibodyForests_embeddings infers structural node embeddings (from
the graph structure, without additional features such from the encoded
sequence/GEX) using either node2vec (<a href="https://arxiv.org/abs/1607.00653" class="external-link uri">https://arxiv.org/abs/1607.00653</a>) or spectral embeddings
on the adjacency/laplacian matrices. The next AntibodyForests update
will include Graph Variational Autoencoder models for graph embeddings
(including sequence and cell-level features).</p>
<p>The node2vec implementation requires the R version of keras to be
installed. There are several hyperparameters to control the epochs,
batch size, how the random walk is performed, and the skip-gram model,
all described extensively in the AntibodyForests_embeddings
documentation. The resulting node vector can be projected using either
T-SNE (dim.reduction = ‘tsne’), UMAP (dim.reduction = ‘umap’) or PCA
(dim.reduction = ‘pca’).</p>
<div class="sourceCode" id="cb123"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">network</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                node.features <span class="op">=</span> <span class="st">'seurat_clusters'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="fl">15</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span>           <span class="fu"><a href="../reference/AntibodyForests_join_trees.html">AntibodyForests_join_trees</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
<div class="sourceCode" id="cb124"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">network</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_embeddings.html">AntibodyForests_embeddings</a></span><span class="op">(</span>graph.type <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                                     embedding.method <span class="op">=</span> <span class="st">'node2vec'</span>, <span class="co">#or spectral_adjacency, spectral_laplacian</span></span>
<span>                                     dim.reduction <span class="op">=</span> <span class="st">'pca'</span>,</span>
<span>                                     color.by <span class="op">=</span> <span class="st">'seurat_clusters'</span>, <span class="co">#features = node colors in the output PCA plot</span></span>
<span>                                     num.walks <span class="op">=</span> <span class="fl">5</span>, <span class="co">#small number of walks to speed up computation</span></span>
<span>                                     num.steps <span class="op">=</span> <span class="fl">10</span>, </span>
<span>                                     window.size <span class="op">=</span> <span class="fl">5</span>, </span>
<span>                                     num.negative.samples <span class="op">=</span> <span class="fl">4</span>,</span>
<span>                                     embedding.dim <span class="op">=</span> <span class="fl">128</span>,</span>
<span>                                     batch.size <span class="op">=</span> <span class="fl">64</span>,</span>
<span>                                     epochs <span class="op">=</span> <span class="fl">20</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="node-labelfeature-propagation-via-antibodyforests_label_propagation">9.8 Node label/feature propagation via
AntibodyForests_label_propagation<a class="anchor" aria-label="anchor" href="#node-labelfeature-propagation-via-antibodyforests_label_propagation"></a>
</h3>
<p>To propagate specific features, AntibodyForests_label_propagation
takes as input a nested list of AntibodyForests objects or a single
object. This is useful in conjunction with
AntibodyForest_expand_intermediates or on sparsely labeled similarity
networks. The features parameter specifies to labels on which to
propagate. There are currently two algorithms available: iterative graph
diffusion - propagation.algorithm = ‘diffusion’ (X. Zhu and Z.
Ghahramani, Learning from Labeled and Unlabeled Data with Label
Propagation (2002), Technical Report) and a community detection
algorithm assigning the new communities their respective labels (<a href="https://arxiv.org/abs/0709.2938" class="external-link uri">https://arxiv.org/abs/0709.2938</a>) via
igraph::cluster_label_prop - propagation.algorithm = ‘communities’.</p>
<p>To plot the new propagated features, use node.color =
‘feature_label_propagation’ inside AntibodyForests_plot.</p>
<div class="sourceCode" id="cb125"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                node.features <span class="op">=</span> <span class="st">'seurat_clusters'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype8'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span><span class="fu"><a href="../reference/AntibodyForests_expand_intermediates.html">AntibodyForests_expand_intermediates</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span><span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.color <span class="op">=</span> <span class="st">'seurat_clusters'</span>, </span>
<span>                     node.scale.factor <span class="op">=</span> <span class="fl">4</span>, </span>
<span>                     node.label <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 27  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 27  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype8 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-67-1.png" width="768"></p>
<div class="sourceCode" id="cb127"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                node.features <span class="op">=</span> <span class="st">'seurat_clusters'</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="st">'clonotype8'</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span><span class="fu"><a href="../reference/AntibodyForests_expand_intermediates.html">AntibodyForests_expand_intermediates</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span><span class="fu"><a href="../reference/AntibodyForests_label_propagation.html">AntibodyForests_label_propagation</a></span><span class="op">(</span>propagation.algorithm <span class="op">=</span> <span class="st">'diffusion'</span>,</span>
<span>                                  diffusion.n.iter <span class="op">=</span> <span class="fl">20</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span><span class="fu"><a href="../reference/AntibodyForests_plot.html">AntibodyForests_plot</a></span><span class="op">(</span>node.color <span class="op">=</span> <span class="st">'seurat_clusters_label_propagation'</span>, </span>
<span>                     node.scale.factor <span class="op">=</span> <span class="fl">4</span>, </span>
<span>                     node.label <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AntibodyForests object </span></span>
<span><span class="co">## 27  sequence nodes across  1  sample(s) and  1  clonotype(s) </span></span>
<span><span class="co">## 27  total network nodes </span></span>
<span><span class="co">## Sample id(s):  s1 </span></span>
<span><span class="co">## Clonotype id(s):  clonotype8 </span></span>
<span><span class="co">## Networks/analyses available:  tree, plot_ready</span></span></code></pre>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-68-1.png" width="768"></p>
</div>
<div class="section level3">
<h3 id="kernel-based-methods-to-compare-networks-via-antibodyforests_kernels">9.9 Kernel-based methods to compare networks via
AntibodyForests_kernels<a class="anchor" aria-label="anchor" href="#kernel-based-methods-to-compare-networks-via-antibodyforests_kernels"></a>
</h3>
<p>Kernel methods are useful for comparing the topology of several
networks. In AntibodyForests_kernels, graph kernel methods are
implemented via the graphkernels R package. The methods available
include: the Weisfeilfer-Lehman kernel (kernel.method =
‘weisfeiler_lehman’), the graphlets-based kernel (kernel.method =
‘graphlet’), and the random-walk graph kernel (kernel.method =
‘random_walk’).</p>
<p>This function takes as input a list of AntibodyForests object.</p>
<div class="sourceCode" id="cb129"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">networks</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/AntibodyForests.html">AntibodyForests</a></span><span class="op">(</span><span class="va">VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,</span>
<span>                network.algorithm <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                node.limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="fl">5</span>, <span class="cn">NULL</span><span class="op">)</span>,</span>
<span>                specific.networks <span class="op">=</span> <span class="fl">15</span><span class="op">)</span> </span>
<span><span class="va">networks</span> <span class="op">&lt;-</span> <span class="va">networks</span><span class="op">$</span><span class="va">s1</span></span>
<span></span>
<span><span class="va">networks</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/AntibodyForests_kernels.html">AntibodyForests_kernels</a></span><span class="op">(</span>graph.type <span class="op">=</span> <span class="st">'tree'</span>,</span>
<span>                                     kernel.method <span class="op">=</span> <span class="st">'weisfeiler_lehman'</span><span class="op">)</span></span></code></pre></div>
<p><img src="AntibodyForests_files/figure-html/unnamed-chunk-69-1.png" width="768"></p>
</div>
<div class="section level3">
<h3 id="dynamictemporal-node-tracking-via-antibodyforests_track_nodes">9.10 Dynamic/temporal node tracking via
AntibodyForests_track_nodes<a class="anchor" aria-label="anchor" href="#dynamictemporal-node-tracking-via-antibodyforests_track_nodes"></a>
</h3>
<p>WORK IN PROGRESS!</p>
</div>
</div>
<div class="section level2">
<h2 id="version-information">10. Version information<a class="anchor" aria-label="anchor" href="#version-information"></a>
</h2>
<div class="sourceCode" id="cb130"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/utils/sessionInfo.html" class="external-link">sessionInfo</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## R version 4.2.1 (2022-06-23 ucrt)</span></span>
<span><span class="co">## Platform: x86_64-w64-mingw32/x64 (64-bit)</span></span>
<span><span class="co">## Running under: Windows 10 x64 (build 19044)</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## Matrix products: default</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## locale:</span></span>
<span><span class="co">## [1] LC_COLLATE=German_Germany.utf8  LC_CTYPE=German_Germany.utf8   </span></span>
<span><span class="co">## [3] LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C                   </span></span>
<span><span class="co">## [5] LC_TIME=German_Germany.utf8    </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## attached base packages:</span></span>
<span><span class="co">## [1] stats     graphics  grDevices utils     datasets  methods   base     </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## other attached packages:</span></span>
<span><span class="co">##  [1] forcats_0.5.1   stringr_1.4.0   purrr_0.3.4     readr_2.1.2    </span></span>
<span><span class="co">##  [5] tidyr_1.2.0     tibble_3.1.8    ggplot2_3.3.6   tidyverse_1.3.2</span></span>
<span><span class="co">##  [9] Platypus_3.4.1  dplyr_1.0.9    </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## loaded via a namespace (and not attached):</span></span>
<span><span class="co">##   [1] utf8_1.2.2              reticulate_1.25         tidyselect_1.1.2       </span></span>
<span><span class="co">##   [4] htmlwidgets_1.5.4       grid_4.2.1              combinat_0.0-8         </span></span>
<span><span class="co">##   [7] Rtsne_0.16              munsell_0.5.0           codetools_0.2-18       </span></span>
<span><span class="co">##  [10] ragg_1.2.2              ica_1.0-3               graphkernels_1.6.1     </span></span>
<span><span class="co">##  [13] future_1.27.0           miniUI_0.1.1.1          withr_2.5.0            </span></span>
<span><span class="co">##  [16] spatstat.random_2.2-0   colorspace_2.0-3        progressr_0.10.1       </span></span>
<span><span class="co">##  [19] highr_0.9               knitr_1.39              rstudioapi_0.13        </span></span>
<span><span class="co">##  [22] Seurat_4.1.1            ROCR_1.0-11             tensor_1.5             </span></span>
<span><span class="co">##  [25] listenv_0.8.0           labeling_0.4.2          mnormt_2.1.0           </span></span>
<span><span class="co">##  [28] polyclip_1.10-0         pheatmap_1.0.12         farver_2.1.1           </span></span>
<span><span class="co">##  [31] rprojroot_2.0.3         coda_0.19-4             parallelly_1.32.1      </span></span>
<span><span class="co">##  [34] vctrs_0.4.1             treeio_1.20.1           generics_0.1.3         </span></span>
<span><span class="co">##  [37] clusterGeneration_1.3.7 xfun_0.31               R6_2.5.1               </span></span>
<span><span class="co">##  [40] graphlayouts_0.8.0      spatstat.utils_2.3-1    cachem_1.0.6           </span></span>
<span><span class="co">##  [43] gridGraphics_0.5-1      assertthat_0.2.1        promises_1.2.0.1       </span></span>
<span><span class="co">##  [46] scales_1.2.0            googlesheets4_1.0.0     rgeos_0.5-9            </span></span>
<span><span class="co">##  [49] gtable_0.3.0            globals_0.15.1          phangorn_2.9.0         </span></span>
<span><span class="co">##  [52] goftest_1.2-3           rlang_1.0.4             systemfonts_1.0.4      </span></span>
<span><span class="co">##  [55] scatterplot3d_0.3-41    splines_4.2.1           lazyeval_0.2.2         </span></span>
<span><span class="co">##  [58] gargle_1.2.0            spatstat.geom_2.4-0     broom_1.0.0            </span></span>
<span><span class="co">##  [61] yaml_2.3.5              reshape2_1.4.4          abind_1.4-5            </span></span>
<span><span class="co">##  [64] modelr_0.1.8            backports_1.4.1         httpuv_1.6.5           </span></span>
<span><span class="co">##  [67] tools_4.2.1             ggplotify_0.1.0         ellipsis_0.3.2         </span></span>
<span><span class="co">##  [70] spatstat.core_2.4-4     jquerylib_0.1.4         RColorBrewer_1.1-3     </span></span>
<span><span class="co">##  [73] ggridges_0.5.3          Rcpp_1.0.9              plyr_1.8.7             </span></span>
<span><span class="co">##  [76] rpart_4.1.16            deldir_1.0-6            viridis_0.6.2          </span></span>
<span><span class="co">##  [79] pbapply_1.5-0           cowplot_1.1.1           zoo_1.8-10             </span></span>
<span><span class="co">##  [82] SeuratObject_4.1.0      haven_2.5.0             ggrepel_0.9.1          </span></span>
<span><span class="co">##  [85] cluster_2.1.3           fs_1.5.2                magrittr_2.0.3         </span></span>
<span><span class="co">##  [88] data.table_1.14.2       scattermore_0.8         lmtest_0.9-40          </span></span>
<span><span class="co">##  [91] reprex_2.0.1            RANN_2.6.1              googledrive_2.0.0      </span></span>
<span><span class="co">##  [94] fitdistrplus_1.1-8      matrixStats_0.62.0      hms_1.1.1              </span></span>
<span><span class="co">##  [97] patchwork_1.1.1         mime_0.12               evaluate_0.15          </span></span>
<span><span class="co">## [100] xtable_1.8-4            readxl_1.4.0            gridExtra_2.3          </span></span>
<span><span class="co">## [103] compiler_4.2.1          maps_3.4.0              KernSmooth_2.23-20     </span></span>
<span><span class="co">## [106] crayon_1.5.1            htmltools_0.5.3         ggfun_0.0.6            </span></span>
<span><span class="co">## [109] mgcv_1.8-40             later_1.3.0             tzdb_0.3.0             </span></span>
<span><span class="co">## [112] aplot_0.1.6             expm_0.999-6            lubridate_1.8.0        </span></span>
<span><span class="co">## [115] DBI_1.1.3               dbplyr_2.2.1            MASS_7.3-57            </span></span>
<span><span class="co">## [118] Matrix_1.4-1            cli_3.3.0               quadprog_1.5-8         </span></span>
<span><span class="co">## [121] parallel_4.2.1          igraph_1.3.4            pkgconfig_2.0.3        </span></span>
<span><span class="co">## [124] pkgdown_2.0.6           numDeriv_2016.8-1.1     sp_1.5-0               </span></span>
<span><span class="co">## [127] plotly_4.10.0           spatstat.sparse_2.1-1   xml2_1.3.3             </span></span>
<span><span class="co">## [130] foreach_1.5.2           ggtree_3.4.1            bslib_0.4.0            </span></span>
<span><span class="co">## [133] stringdist_0.9.8        rvest_1.0.2             yulab.utils_0.0.5      </span></span>
<span><span class="co">## [136] digest_0.6.29           sctransform_0.3.3       RcppAnnoy_0.0.19       </span></span>
<span><span class="co">## [139] phytools_1.0-3          spatstat.data_2.2-0     fastmatch_1.1-3        </span></span>
<span><span class="co">## [142] rmarkdown_2.14          cellranger_1.1.0        leiden_0.4.2           </span></span>
<span><span class="co">## [145] tidytree_0.3.9          uwot_0.1.11             curl_4.3.2             </span></span>
<span><span class="co">## [148] shiny_1.7.2             lifecycle_1.0.1         nlme_3.1-157           </span></span>
<span><span class="co">## [151] jsonlite_1.8.0          desc_1.4.1              viridisLite_0.4.0      </span></span>
<span><span class="co">## [154] fansi_1.0.3             pillar_1.8.0            lattice_0.20-45        </span></span>
<span><span class="co">## [157] plotrix_3.8-2           fastmap_1.1.0           httr_1.4.3             </span></span>
<span><span class="co">## [160] survival_3.3-1          glue_1.6.2              png_0.1-7              </span></span>
<span><span class="co">## [163] iterators_1.0.14        stringi_1.7.8           sass_0.4.2             </span></span>
<span><span class="co">## [166] textshaping_0.3.6       memoise_2.0.1           irlba_2.3.5            </span></span>
<span><span class="co">## [169] future.apply_1.9.0      ape_5.6-2</span></span></code></pre>
</div>
  </div>

  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

        <nav id="toc" data-toggle="toc"><h2 data-toc-skip>Contents</h2>
    </nav>
</div>

</div>



      <footer><div class="copyright">
  <p></p>
<p>Developed by Alexander Yermanos.</p>
</div>

<div class="pkgdown">
  <p></p>
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.6.</p>
</div>

      </footer>
</div>

  


  

  </body>
</html>
