<!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>ABForests vignette • 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="ABForests vignette">
<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.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 class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
    Vignettes
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
<li>
      <a href="../articles/PlatypusV3_agedCNS.html">Platypus V3</a>
    </li>
    <li>
      <a href="../articles/PlatypusDB.html">PlatypusDB</a>
    </li>
    <li>
      <a href="../articles/Platypus_feature_barcodes.html">Platypus V3 Feature barcodes</a>
    </li>
    <li>
      <a href="../articles/ABForests.html">ABForests</a>
    </li>
    <li>
      <a href="../articles/Echidna.html">Echidna</a>
    </li>
  </ul>
</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" 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><script src="ABForests_files/header-attrs-2.11/header-attrs.js"></script><div class="row">
  <div class="col-md-9 contents">
    <div class="page-header toc-ignore">
      <h1 data-toc-skip>ABForests vignette</h1>
                        <h4 data-toc-skip class="author">Chrysa Papadopoulou</h4>
            
            <h4 data-toc-skip class="date">2021-09-21</h4>
      
      <small class="dont-index">Source: <a href="https://github.com/alexyermanos/Platypus/tree/mastervignettes/ABForests.Rmd" class="external-link"><code>vignettes/ABForests.Rmd</code></a></small>
      <div class="hidden name"><code>ABForests.Rmd</code></div>

    </div>

    
    
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><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://ggplot2.tidyverse.org" class="external-link">ggplot2</a></span><span class="op">)</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://scales.r-lib.org" class="external-link">scales</a></span><span class="op">)</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">gridExtra</span><span class="op">)</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">grid</span><span class="op">)</span></code></pre></div>
<div id="introduction" class="section level2">
<h2 class="hasAnchor">
<a href="#introduction" class="anchor" aria-hidden="true"></a>1. Introduction</h2>
<p>AbNetForests is a novel computational framework, which provides a consesus on how to process high-throughtput scSeq data and integrate the high-dimensional feature space of gene expression to the evolution of B cells. It increases the size of the computational toolbox available to study immunoglobulin repertoires and incorporates additional features for the quantification of B cell clonal selection. Firstly, it can extract and organize B cell data directly from the output alignment of any single-cell technology. The generated data, containing information such as germline gene usage, full-length heavy and light chain sequence and CDR3 sequences can be combined with the transcriptional analysis of the gene expression libraries from the cellranger and subsequently B cells are grouped into clonal lineages, using one of the several clonotyping strategies that have been developed from Platypus (Yermanos et. al, 2021) under default parameters. The generated single-cell immune repertoire sequencing datasets can relate somatic hypermutation and evolution with transcriptional phenotypes. AbNetForests can additionally infer and visualize B cell mutational networks, modeling the extensive diversification of unique full-length variable heavy and variable light chain (<span class="math inline">\(V_H\)</span> + <span class="math inline">\(V_L\)</span>) BCR sequences, integrating immune features such as antibody isotype or transcriptional cluster distribution and clonal expansion. In a last step, a qualitative and quantitative evaluation of the repertoire diversity takes place by computing both local and global summary statistics. Therefore, tree topologies and metrics are compared across one or several repertoires, disregarding whether they come from distinct individuals or organs.</p>
<p>An overview of the previously described workflow is demonstrated in Figure 1.</p>
<p>The user can set various parameters:</p>
<ul>
<li>DAG (TRUE/FALSE): specifies whether a directed acyclic graph will is produced</li>
<li>clonal_frequency (TRUE/FALSE): specifies whether the labeling of vertices in graphs will be based on clonal frequency</li>
<li>scaleByClonalFreq (TRUE/FALSE): specifies whether vertex size will be scaled by clonal frequency of corresponding node</li>
<li>weight (TRUE/FALSE): specifies whether the weights of outgoing edges from Germline node will be set to 1 (FALSE) or elsewhere they will be set to the difference between the number of mutations among sequences in germline and connected nodes(value in the corresponding distance matrix) and the absolute value of the difference between the sequence lengths of germline and corresponding connected nodes</li>
<li>tie_flag (‘rand’, ‘full’, ‘close_to_germ’, ‘far_from_germ’, ‘close_path_to_germ’,‘far_path_from_germ’, ‘most_expanded’,‘least_expanded’): ‘rand’ means random pruning in one of nodes, ‘full’ means keeping all nodes, close_to_germ means pruning of node(s) farthest from germline (based on number of intermediate nodes), ‘far_from_germ’ means pruning of node(s) closest to germline (based on number of intermediate nodes),‘close_path_to_germ’ means pruning of node(s) farthest from germline (based on edge path length), ‘far_path_from_germ’ meams pruning of node(s) closest to germline (based on edge path length),‘most_expanded’ means pruning of node(s) with the lowest B cell count(clonal frequency) and least_expanded, which means pruning of node(s) with the hightest B cell count(clonal frequency)</li>
<li>scaleBybetweenness (TRUE/FALSE): specifies whether the vertex size is scaled by the vertex betweenness centrality</li>
<li>scaleByclocloseness_metr (TRUE/FALSE): specifies whether vertex size is scaled by closeness centrality of vertices in graph</li>
<li>random.seed (interger): a random seed, specified by the user</li>
<li>alg_opt (‘naive’,‘two-step’): specifies the version of the edge selection algorithm that will be used in the construction of networks</li>
<li>cdr3 (0,1,NULL): specifies whether the user desires to select full length sequences (0) or CDR3 sequences (1) [only when the input is a list of csv files] and NULL otherwise</li>
</ul>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># Program parameters</span>
<span class="va">DAG</span><span class="op">&lt;-</span><span class="cn">TRUE</span>
<span class="va">clonal_frequency</span><span class="op">&lt;-</span><span class="cn">TRUE</span>
<span class="va">scaleByClonalFreq</span><span class="op">&lt;-</span><span class="cn">TRUE</span>
<span class="va">weight</span><span class="op">&lt;-</span><span class="cn">TRUE</span>
<span class="va">tie_flag</span><span class="op">&lt;-</span><span class="st">'rand'</span>
<span class="va">scaleBybetweenness</span><span class="op">&lt;-</span><span class="cn">FALSE</span>
<span class="va">scaleByclocloseness_metr</span><span class="op">&lt;-</span><span class="cn">FALSE</span>
<span class="va">topdf</span><span class="op">&lt;-</span><span class="cn">TRUE</span>
<span class="va">custom_mat</span><span class="op">&lt;-</span><span class="cn">NULL</span>
<span class="va">random.seed</span><span class="op">&lt;-</span><span class="fl">3</span>
<span class="va">alg_opt</span><span class="op">&lt;-</span><span class="st">'naive'</span></code></pre></div>
<p>When a user does not want to perform any prior filtering on the input data then he/she can conduct the following flow of commands. For the sake of the example, the isotype information is taken into account. Networks are depicted in tree format with the reference germline set to the root. Nodes in each network are both labeled and scaled by the clonal frequency.</p>
<ol style="list-style-type: lower-alpha">
<li>For the inference of networks:</li>
</ol>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#"new" is an example dataset loaded with the package (See ABForests_sysdata)</span>

<span class="va">graphs</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="va">new</span>,<span class="cn">FALSE</span>,<span class="cn">NULL</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"isotype"</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="cn">NULL</span><span class="op">)</span></code></pre></div>
<ol start="2" style="list-style-type: lower-alpha">
<li>For the visualization of networks:</li>
</ol>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/AbForests_PlotGraphs.html">AbForests_PlotGraphs</a></span><span class="op">(</span><span class="va">graphs</span>,<span class="cn">NULL</span>,<span class="va">topdf</span>,<span class="st">"Networks"</span><span class="op">)</span></code></pre></div>
<p>A user may also modify the igraph object graphs himself/herself apart from using the PlotGraphs function of the package.</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.01</span><span class="op">*</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">12</span><span class="op">+</span><span class="op">(</span><span class="fl">1.2</span><span class="op">*</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">cells.per.variant</span><span class="op">)</span><span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty<span class="op">=</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
<ol start="3" style="list-style-type: lower-alpha">
<li>For calculating metrics on networks:</li>
</ol>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">metrics</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_ForestMetrics.html">AbForests_ForestMetrics</a></span><span class="op">(</span><span class="va">graphs</span>,<span class="va">DAG</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="st">"isotype"</span><span class="op">)</span></code></pre></div>
<ol start="4" style="list-style-type: lower-alpha">
<li>For visualizing a specific metric: For example, we can inspect the shortest paths in each network (in position 6 of metrics list):</li>
</ol>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/AbForests_PlotGraphs.html">AbForests_PlotGraphs</a></span><span class="op">(</span><span class="va">metrics</span>,<span class="fl">6</span>,<span class="va">topdf</span>,<span class="st">"Metrics"</span><span class="op">)</span></code></pre></div>
<p>Similarly, we can infer the networks using the transcriptional cluster information.</p>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">graphs_cluster</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="va">new</span>,<span class="cn">FALSE</span>,<span class="cn">NULL</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"cluster"</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="cn">NULL</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/AbForests_PlotGraphs.html">AbForests_PlotGraphs</a></span><span class="op">(</span><span class="va">graphs_cluster</span>,<span class="cn">NULL</span>,<span class="va">topdf</span>,<span class="st">"Networks_cluster"</span><span class="op">)</span></code></pre></div>
<p>and modify the igraph object according to the user preferences.</p>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.01</span><span class="op">*</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">12</span><span class="op">+</span><span class="op">(</span><span class="fl">1.2</span><span class="op">*</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">cells.per.variant</span><span class="op">)</span><span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty<span class="op">=</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_cluster</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.35</span><span class="op">)</span></code></pre></div>
<p>The cluster “Unknown” indicates that the barcodes of cells are not included in the GEX library.</p>
</div>
<div id="dataset-format" class="section level2">
<h2 class="hasAnchor">
<a href="#dataset-format" class="anchor" aria-hidden="true"></a>2. Dataset Format</h2>
<p>To demonstrate the potential of AbNetForests, lineages were inferred using two previously described datasets following either chronic lymphocytic choriomeningitis virus (LCMV) infection or serial protein immunizations with Ovalbumin (Neumeier et al., 2021).</p>
<div id="experimental-dataset-following-lcmv-infection" class="section level3">
<h3 class="hasAnchor">
<a href="#experimental-dataset-following-lcmv-infection" class="anchor" aria-hidden="true"></a>Experimental dataset following LCMV infection</h3>
<p>The single-cell immune repertoire sequencing data from the bone marrow plasma cells of a mouse infected with high dose of LCMV ,from a recently published work (Neumeier et al., 2021), was used to investigate isotype-specific mutational signatures. This dataset was generated by performing single-cell immune repertoire sequencing of murine BM PCs 28 days following chronic LCMV infection. Bone marrow plasma cells were isolated via fluorescence-activated cell sorting (FACS) (CD138+, TACI+, CD19lo, B220lo), which was then used as input for single-cell immune repertoire sequencing using the 10X genomics 5’ V(D)J protocol. This experimental system recovers both gene expression and antibody repertoire sequencing data, relating clonal selection to cell phenotypes. B cells with identical heavy and light chain V and J germline genes, identical complementary determining region 3 sequence lengths for both heavy and light chain variable regions (CDRH3 for <span class="math inline">\(V_H\)</span> and CDRL3 for <span class="math inline">\(V_L\)</span>) and at least 70% sequence homology in the CDR3 regions were grouped together into clonal lineages.The clonal lineage data was generated using the R package Platypus under default parameters (Yermanos et al. 2021).</p>
<p>The dataset consists of a list of repertoires, each consisting of clonal lineages, represented as data.frames, each of which is a 49-column structure.</p>
<p>A subset of a clonal lineage of the dataset is provided for guiding the user in constructing its own data input.</p>
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/utils/head.html" class="external-link">head</a></span><span class="op">(</span><span class="va">new</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,<span class="fl">3</span><span class="op">)</span></code></pre></div>
<p>For simplicity of the input, the package can receive a list of clonal lineages, each of which is a two-column structure:</p>
<ul>
<li>Seq: full-length antibody sequences recovered from single cells after clonotyping</li>
<li>Name: isotype or/and transcriptional information for each single cell. The transcriptional clusters are supplied as numbers.The type of information (isotype or cluster), which is utilized in the analysis depends solely on the user’s purposes.</li>
</ul>
<p>During each network reconstruction procedure, from a vast pool of roots produced as a result of V(D)J recombination, a reference germline sequence is added in each clonal lineage. This germline sequence is characterized by the largest occurrence from the set of reference germline heavy and light sequences for each particular clone from the 10x Genomics cellranger.</p>
</div>
<div id="experimental-dataset-following-ova-infection" class="section level3">
<h3 class="hasAnchor">
<a href="#experimental-dataset-following-ova-infection" class="anchor" aria-hidden="true"></a>Experimental dataset following OVA infection</h3>
<p>The program is also capable of receiving input from a csv formatted file. Characteristic examples of such files are provided for the user’s convenience (Bcell_sequences_example_tree and Bcell_tree_2) and can assist in constructing its own data if he/she wants to diverge from the previously discussed structure. In such a case, column names can be modified, without altering the structure and the essence of data. These files contain 9 columns:</p>
<ul>
<li>X: Enumeration of cells</li>
<li>HCvgene: The name of heavy chain v-gene segment</li>
<li>LCjgene: The name of light chain j-gene segment</li>
<li>HCjgene: The name of heavy chain j-gene segment</li>
<li>LCvgene: The name of light chain v-gene segment</li>
<li>HCcdr3: The CDR3 sequence in heavy chain</li>
<li>LCcdr3: The CDR3 sequence in light chain</li>
<li>Cluster: The transcriptional cluster in hexadecimal RGB color specification</li>
<li>HCisotype: The isotype information</li>
<li>HCLC: The full-length antibody sequences prior clonotyping</li>
</ul>
<p>A subset of this dataset is provided for reference</p>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">file1</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/utils/data.html" class="external-link">data</a></span><span class="op">(</span><span class="st">"Bcell_sequences_example_tree"</span>, package <span class="op">=</span> <span class="st">"Platypus"</span><span class="op">)</span>
<span class="va">file1</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/get.html" class="external-link">get</a></span><span class="op">(</span><span class="va">file1</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/utils/head.html" class="external-link">head</a></span><span class="op">(</span><span class="va">file1</span>,<span class="fl">3</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">file2</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/utils/data.html" class="external-link">data</a></span><span class="op">(</span><span class="va">Bcell_tree_2</span>, package <span class="op">=</span> <span class="st">"Platypus"</span><span class="op">)</span>
<span class="va">file2</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/get.html" class="external-link">get</a></span><span class="op">(</span><span class="va">file2</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/utils/head.html" class="external-link">head</a></span><span class="op">(</span><span class="va">file2</span>,<span class="fl">3</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">files</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="op">)</span>
<span class="va">files</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/append.html" class="external-link">append</a></span><span class="op">(</span><span class="va">files</span>,<span class="va">file1</span><span class="op">)</span>
<span class="va">files</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/append.html" class="external-link">append</a></span><span class="op">(</span><span class="va">files</span>,<span class="va">file2</span><span class="op">)</span></code></pre></div>
<p>For the inference of networks, without modifying initial input data and using the full-length antibody sequences, we have</p>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">graphs_csv</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="va">files</span>,<span class="cn">TRUE</span>,<span class="cn">NULL</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"isotype"</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="fl">0</span><span class="op">)</span> </code></pre></div>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.01</span><span class="op">*</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">8</span><span class="op">+</span><span class="op">(</span><span class="fl">1.2</span><span class="op">*</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">cells.per.variant</span><span class="op">)</span><span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
<p>while when we consider only CDRH3 for <span class="math inline">\(V_H\)</span> and CDRL3 for <span class="math inline">\(V_L\)</span> sequences:</p>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">graphs_csv</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="va">files</span>,<span class="cn">TRUE</span>,<span class="cn">NULL</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"isotype"</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="fl">1</span><span class="op">)</span> </code></pre></div>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.01</span><span class="op">*</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">8</span><span class="op">+</span><span class="op">(</span><span class="fl">1.2</span><span class="op">*</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">cells.per.variant</span><span class="op">)</span><span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
</div>
</div>
<div id="data-summary-statistics" class="section level2">
<h2 class="hasAnchor">
<a href="#data-summary-statistics" class="anchor" aria-hidden="true"></a>3. Data Summary Statistics</h2>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">total_lineages</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/length.html" class="external-link">length</a></span><span class="op">(</span><span class="va">new</span><span class="op">)</span>
<span class="va">total_lineages</span></code></pre></div>
<p>The mouse single-cell immune repertoire is composed of 1662 clonal lineages.</p>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">df_total_lineages</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>total_lineages<span class="op">=</span><span class="va">total_lineages</span>,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">'black'</span><span class="op">)</span><span class="op">)</span>
<span class="va">df_total_lineages</span><span class="op">$</span><span class="va">x_values</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="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="st">"1"</span>,each<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/nrow.html" class="external-link">nrow</a></span><span class="op">(</span><span class="va">df_total_lineages</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>
<span class="va">df_total_lineages</span><span class="op">$</span><span class="va">colors</span><span class="op">&lt;-</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">df_total_lineages</span><span class="op">$</span><span class="va">colors</span><span class="op">)</span>

<span class="va">p_total_lineages</span><span class="op">&lt;-</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="va">df_total_lineages</span>, <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">x_values</span>, y <span class="op">=</span><span class="va">total_lineages</span> ,fill<span class="op">=</span><span class="va">colors</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">ylab</a></span><span class="op">(</span><span class="st">"Number of clonal lineages"</span><span class="op">)</span><span class="op">+</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><span class="op">)</span> <span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_discrete.html" class="external-link">scale_x_discrete</a></span><span class="op">(</span>expand <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/expansion.html" class="external-link">expansion</a></span><span class="op">(</span>add<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.6</span>,<span class="fl">0.5</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_continuous.html" class="external-link">scale_y_continuous</a></span><span class="op">(</span>expand <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</span>,<span class="fl">0</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> 
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_bar.html" class="external-link">geom_bar</a></span><span class="op">(</span>width<span class="op">=</span><span class="fl">0.5</span>,stat<span class="op">=</span><span class="st">"identity"</span>, position<span class="op">=</span><span class="st">"dodge"</span>,colour <span class="op">=</span> <span class="st">"black"</span>,show.legend <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html" class="external-link">theme</a></span><span class="op">(</span>aspect.ratio <span class="op">=</span><span class="fl">1</span>,
        axis.title.x<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.text.x<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.ticks.x<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.ticks.length<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">.3</span>, <span class="st">"cm"</span><span class="op">)</span>,
        axis.title.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">rel</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span>, angle <span class="op">=</span> <span class="fl">90</span><span class="op">)</span>,
        axis.text.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.8</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        axis.text <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fl">8</span><span class="op">)</span>,
        panel.grid.major <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        panel.grid.minor <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        panel.background <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.line <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_line</a></span><span class="op">(</span>colour <span class="op">=</span> <span class="st">"black"</span><span class="op">)</span><span class="op">)</span><span class="op">+</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="fu"><a href="https://rdrr.io/r/base/levels.html" class="external-link">levels</a></span><span class="op">(</span><span class="va">df_total_lineages</span><span class="op">$</span><span class="va">colors</span><span class="op">)</span><span class="op">)</span>

<span class="va">p_total_lineages</span></code></pre></div>
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">bcells_per_clonal_lineage</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/unname.html" class="external-link">unname</a></span><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="fu"><a href="https://rdrr.io/r/base/lapply.html" class="external-link">sapply</a></span><span class="op">(</span><span class="va">new</span>,<span class="kw">function</span><span class="op">(</span><span class="va">z</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/base/nrow.html" class="external-link">nrow</a></span><span class="op">(</span><span class="va">z</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>
<span class="va">df</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>Combinations<span class="op">=</span><span class="fl">1</span><span class="op">:</span><span class="va">total_lineages</span>, Freq<span class="op">=</span><span class="va">bcells_per_clonal_lineage</span><span class="op">)</span>
<span class="va">p_cells_all</span><span class="op">&lt;-</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="va">df</span>,<span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes_.html" class="external-link">aes_string</a></span><span class="op">(</span>x <span class="op">=</span> <span class="st">'Combinations'</span>, y <span class="op">=</span> <span class="st">'Freq'</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">xlab</a></span><span class="op">(</span><span class="st">"Clonal lineages"</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">ylab</a></span><span class="op">(</span><span class="st">"Number of cells"</span><span class="op">)</span><span class="op">+</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_bar.html" class="external-link">geom_bar</a></span><span class="op">(</span>stat<span class="op">=</span><span class="st">"identity"</span>, position<span class="op">=</span><span class="st">"dodge"</span>,colour <span class="op">=</span> <span class="st">"black"</span>,show.legend <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span><span class="op">+</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>expand <span class="op">=</span> <span class="cn">FALSE</span> <span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html" class="external-link">theme</a></span><span class="op">(</span>aspect.ratio<span class="op">=</span><span class="fl">1</span>,axis.title.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">rel</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span>, angle <span class="op">=</span> <span class="fl">90</span><span class="op">)</span>,
        axis.title.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">rel</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span>, angle <span class="op">=</span> <span class="fl">0</span><span class="op">)</span>,
        axis.line <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_line</a></span><span class="op">(</span>colour <span class="op">=</span> <span class="st">"black"</span><span class="op">)</span>,
        panel.grid.major <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        panel.grid.minor <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.ticks.length<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">.3</span>, <span class="st">"cm"</span><span class="op">)</span>,
        axis.text <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fl">8</span><span class="op">)</span>,
        axis.text.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.5</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        axis.ticks.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.text.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.5</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        panel.background <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,legend.title<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size<span class="op">=</span><span class="fl">10</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_colour_discrete.html" class="external-link">scale_fill_discrete</a></span><span class="op">(</span>name <span class="op">=</span> <span class="st">"Vertex Degrees"</span><span class="op">)</span>

<span class="va">p_cells_all</span></code></pre></div>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">mean_bcells_per_clonal_lineage</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/Round.html" class="external-link">round</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/mean.html" class="external-link">mean</a></span><span class="op">(</span><span class="va">bcells_per_clonal_lineage</span><span class="op">)</span><span class="op">)</span>
<span class="va">mean_bcells_per_clonal_lineage</span></code></pre></div>
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">std_bcells_per_clonal_lineage</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/Round.html" class="external-link">round</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/sd.html" class="external-link">sd</a></span><span class="op">(</span><span class="va">bcells_per_clonal_lineage</span><span class="op">)</span><span class="op">)</span>
<span class="va">std_bcells_per_clonal_lineage</span> </code></pre></div>
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">unique_Ab_variants_per_clonal_lineage</span><span class="op">&lt;-</span> <span class="fu"><a href="../reference/AbForests_UniqueAntibodyVariants.html">AbForests_UniqueAntibodyVariants</a></span><span class="op">(</span><span class="va">new</span>,<span class="st">"isotype"</span>,<span class="va">custom_mat</span>,<span class="va">tie_flag</span>,<span class="va">weight</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="cn">NULL</span><span class="op">)</span>
<span class="va">df_t</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>Combinations<span class="op">=</span><span class="fl">1</span><span class="op">:</span><span class="va">total_lineages</span>, Freq<span class="op">=</span><span class="va">unique_Ab_variants_per_clonal_lineage</span><span class="op">)</span>
<span class="va">p_variants_all</span><span class="op">&lt;-</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="va">df_t</span>,<span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes_.html" class="external-link">aes_string</a></span><span class="op">(</span>x <span class="op">=</span> <span class="st">'Combinations'</span>, y <span class="op">=</span> <span class="st">'Freq'</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">xlab</a></span><span class="op">(</span><span class="st">"Clonal lineages"</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">ylab</a></span><span class="op">(</span><span class="st">"Number of unique \n antibody variants"</span><span class="op">)</span><span class="op">+</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_bar.html" class="external-link">geom_bar</a></span><span class="op">(</span>stat<span class="op">=</span><span class="st">"identity"</span>, position<span class="op">=</span><span class="st">"dodge"</span>,colour <span class="op">=</span> <span class="st">"black"</span>,show.legend <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span><span class="op">+</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>expand <span class="op">=</span> <span class="cn">FALSE</span> <span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html" class="external-link">theme</a></span><span class="op">(</span>aspect.ratio<span class="op">=</span><span class="fl">1</span>,axis.title.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">rel</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span>, angle <span class="op">=</span> <span class="fl">90</span><span class="op">)</span>,
        axis.title.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">rel</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span>, angle <span class="op">=</span> <span class="fl">0</span><span class="op">)</span>,
        axis.text <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fl">8</span><span class="op">)</span>,axis.line <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_line</a></span><span class="op">(</span>colour <span class="op">=</span> <span class="st">"black"</span><span class="op">)</span>,
        panel.grid.major <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        panel.grid.minor <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.text.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.5</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        axis.ticks.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.text.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">00</span>, vjust <span class="op">=</span> <span class="fl">0.5</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        panel.background <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,legend.title<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size<span class="op">=</span><span class="fl">10</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_colour_discrete.html" class="external-link">scale_fill_discrete</a></span><span class="op">(</span>name <span class="op">=</span> <span class="st">"Vertex Degrees"</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">df_mean_cells_variants</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>Freq<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="va">bcells_per_clonal_lineage</span>,<span class="va">unique_Ab_variants_per_clonal_lineage</span><span class="op">)</span><span class="op">)</span>
<span class="va">df_mean_cells_variants</span><span class="op">$</span><span class="va">sample_name</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="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="st">"Cells"</span>,each<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/length.html" class="external-link">length</a></span><span class="op">(</span><span class="va">bcells_per_clonal_lineage</span><span class="op">)</span><span class="op">)</span>,<span class="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="st">"Variants"</span>,each<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/length.html" class="external-link">length</a></span><span class="op">(</span><span class="va">unique_Ab_variants_per_clonal_lineage</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>
<span class="va">df_mean_cells_variants</span><span class="op">$</span><span class="va">colors</span> <span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/vector.html" class="external-link">as.vector</a></span><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="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="st">"black"</span>,each<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/length.html" class="external-link">length</a></span><span class="op">(</span><span class="va">bcells_per_clonal_lineage</span><span class="op">)</span><span class="op">)</span>,<span class="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="st">"gray85"</span>,each<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/length.html" class="external-link">length</a></span><span class="op">(</span><span class="va">unique_Ab_variants_per_clonal_lineage</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>
<span class="va">df_mean_cells_variants</span><span class="op">$</span><span class="va">colors</span><span class="op">&lt;-</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">df_mean_cells_variants</span><span class="op">$</span><span class="va">colors</span><span class="op">)</span> 

<span class="va">p_mean_cells_variants</span><span class="op">&lt;-</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="va">df_mean_cells_variants</span>, <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span><span class="va">sample_name</span>, <span class="va">Freq</span> ,fill<span class="op">=</span><span class="va">colors</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">ylab</a></span><span class="op">(</span><span class="st">"Number per clonal lineage"</span><span class="op">)</span><span class="op">+</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><span class="op">)</span> <span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_linerange.html" class="external-link">geom_errorbar</a></span><span class="op">(</span>stat <span class="op">=</span> <span class="st">"summary"</span>, fun.data <span class="op">=</span> <span class="st">"mean_se"</span>, 
                fun.args <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>mult <span class="op">=</span> <span class="fl">1</span><span class="op">)</span>,
                position <span class="op">=</span><span class="st">"dodge"</span>, width <span class="op">=</span> <span class="fl">0.2</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_bar.html" class="external-link">geom_bar</a></span><span class="op">(</span>stat <span class="op">=</span> <span class="st">"summary"</span>, fun <span class="op">=</span> <span class="st">"mean"</span>, 
           position <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/position_dodge.html" class="external-link">position_dodge</a></span><span class="op">(</span>width <span class="op">=</span> <span class="fl">0.2</span><span class="op">)</span>, show.legend <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_continuous.html" class="external-link">scale_y_continuous</a></span><span class="op">(</span>expand <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</span>,<span class="fl">0</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> 
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_discrete.html" class="external-link">scale_x_discrete</a></span><span class="op">(</span>name <span class="op">=</span> <span class="st">"sample_name"</span><span class="op">)</span> <span class="op">+</span> 
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html" class="external-link">theme</a></span><span class="op">(</span>aspect.ratio <span class="op">=</span> <span class="fl">1</span>,axis.title.x<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
    axis.title.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">rel</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span>, angle <span class="op">=</span> <span class="fl">90</span><span class="op">)</span>,
    axis.text <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fl">8</span><span class="op">)</span>,axis.line <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_line</a></span><span class="op">(</span>colour <span class="op">=</span> <span class="st">"black"</span><span class="op">)</span>,
        panel.grid.major <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        panel.grid.minor <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.text.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.9</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        axis.ticks.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
    axis.text.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.8</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        panel.background <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,legend.title<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size<span class="op">=</span><span class="fl">10</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span><span class="op">)</span><span class="op">+</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="fu"><a href="https://rdrr.io/r/base/levels.html" class="external-link">levels</a></span><span class="op">(</span><span class="va">df_mean_cells_variants</span><span class="op">$</span><span class="va">colors</span><span class="op">)</span><span class="op">)</span>

<span class="va">p_mean_cells_variants</span></code></pre></div>
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">mean_unique_Ab_variants_per_clonal_lineage</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/Round.html" class="external-link">round</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/mean.html" class="external-link">mean</a></span><span class="op">(</span><span class="va">unique_Ab_variants_per_clonal_lineage</span><span class="op">)</span><span class="op">)</span>
<span class="va">mean_unique_Ab_variants_per_clonal_lineage</span> </code></pre></div>
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">std_unique_Ab_variants_per_clonal_lineage</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/Round.html" class="external-link">round</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/sd.html" class="external-link">sd</a></span><span class="op">(</span><span class="va">unique_Ab_variants_per_clonal_lineage</span><span class="op">)</span><span class="op">)</span>
<span class="va">std_unique_Ab_variants_per_clonal_lineage</span> </code></pre></div>
<p>Each clonal lineage has approximate on average 4 B cells and 3 clonal variants and considering standard deviation 11 B cells and 5 clonal variants.</p>
<p>From the iput list of clonal lineages, we can identify the clonal lineage, which contains the maximum number of cells:</p>
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">pos</span><span class="op">&lt;-</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="va">bcells_per_clonal_lineage</span> <span class="op">==</span> <span class="fu"><a href="https://rdrr.io/r/base/Extremes.html" class="external-link">max</a></span><span class="op">(</span><span class="va">bcells_per_clonal_lineage</span><span class="op">[</span><span class="va">bcells_per_clonal_lineage</span><span class="op">&gt;</span><span class="fl">0</span><span class="op">]</span><span class="op">)</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/utils/head.html" class="external-link">head</a></span><span class="op">(</span><span class="va">new</span><span class="op">[[</span><span class="va">pos</span><span class="op">]</span><span class="op">]</span>,<span class="fl">3</span><span class="op">)</span></code></pre></div>
<p>And the clonal lineage, which contains the maximum number of unique antibody variants:</p>
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">pos</span><span class="op">&lt;-</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="va">unique_Ab_variants_per_clonal_lineage</span> <span class="op">==</span> <span class="fu"><a href="https://rdrr.io/r/base/Extremes.html" class="external-link">max</a></span><span class="op">(</span><span class="va">unique_Ab_variants_per_clonal_lineage</span><span class="op">[</span><span class="va">unique_Ab_variants_per_clonal_lineage</span><span class="op">&gt;</span><span class="fl">0</span><span class="op">]</span><span class="op">)</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/utils/head.html" class="external-link">head</a></span><span class="op">(</span><span class="va">new</span><span class="op">[[</span><span class="va">pos</span><span class="op">]</span><span class="op">]</span>,<span class="fl">3</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">p_total_lineages</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/gridExtra/man/arrangeGrob.html" class="external-link">arrangeGrob</a></span><span class="op">(</span><span class="va">p_total_lineages</span>, top <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/grid.text.html" class="external-link">textGrob</a></span><span class="op">(</span><span class="st">"A"</span>, x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">0</span>, <span class="st">"npc"</span><span class="op">)</span>,y<span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">1</span>, <span class="st">"npc"</span><span class="op">)</span>, just<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">"left"</span>,<span class="st">"top"</span><span class="op">)</span>,                                 gp<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/grid/gpar.html" class="external-link">gpar</a></span><span class="op">(</span>col<span class="op">=</span><span class="st">"black"</span>, fontsize<span class="op">=</span><span class="fl">12</span>, fontfamily<span class="op">=</span><span class="st">"Times"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>

<span class="va">p_cells_all</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/gridExtra/man/arrangeGrob.html" class="external-link">arrangeGrob</a></span><span class="op">(</span><span class="va">p_cells_all</span>, top <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/grid.text.html" class="external-link">textGrob</a></span><span class="op">(</span><span class="st">"B"</span>, x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">0</span>, <span class="st">"npc"</span><span class="op">)</span>, y <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">1</span>, <span class="st">"npc"</span><span class="op">)</span>, just<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">"left"</span>,<span class="st">"top"</span><span class="op">)</span>,
gp<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/grid/gpar.html" class="external-link">gpar</a></span><span class="op">(</span>col<span class="op">=</span><span class="st">"black"</span>, fontsize<span class="op">=</span><span class="fl">12</span>, fontfamily<span class="op">=</span><span class="st">"Times"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>

<span class="va">p_variants_all</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/gridExtra/man/arrangeGrob.html" class="external-link">arrangeGrob</a></span><span class="op">(</span><span class="va">p_variants_all</span>, top <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/grid.text.html" class="external-link">textGrob</a></span><span class="op">(</span><span class="st">"C"</span>, x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">0</span>, <span class="st">"npc"</span><span class="op">)</span>,y  <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">1</span>, <span class="st">"npc"</span><span class="op">)</span>, just<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">"left"</span>,<span class="st">"top"</span><span class="op">)</span>,
gp<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/grid/gpar.html" class="external-link">gpar</a></span><span class="op">(</span>col<span class="op">=</span><span class="st">"black"</span>, fontsize<span class="op">=</span><span class="fl">12</span>, fontfamily<span class="op">=</span><span class="st">"Times"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>

<span class="va">p_mean_cells_variants</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/gridExtra/man/arrangeGrob.html" class="external-link">arrangeGrob</a></span><span class="op">(</span><span class="va">p_mean_cells_variants</span>, top <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/grid.text.html" class="external-link">textGrob</a></span><span class="op">(</span><span class="st">"D"</span>, x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">0</span>, <span class="st">"npc"</span><span class="op">)</span>, y <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">1</span>, <span class="st">"npc"</span><span class="op">)</span>, just<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">"left"</span>,<span class="st">"top"</span><span class="op">)</span>,gp<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/grid/gpar.html" class="external-link">gpar</a></span><span class="op">(</span>col<span class="op">=</span><span class="st">"black"</span>,fontsize<span class="op">=</span><span class="fl">12</span>, fontfamily<span class="op">=</span><span class="st">"Times"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/pkg/gridExtra/man/arrangeGrob.html" class="external-link">grid.arrange</a></span><span class="op">(</span><span class="va">p_total_lineages</span>,<span class="va">p_cells_all</span>,
            <span class="va">p_variants_all</span>,<span class="va">p_mean_cells_variants</span>,
            ncol<span class="op">=</span><span class="fl">2</span><span class="op">)</span></code></pre></div>
</div>
<div id="sub-repertoire-analysis" class="section level2">
<h2 class="hasAnchor">
<a href="#sub-repertoire-analysis" class="anchor" aria-hidden="true"></a>4. Sub-repertoire analysis</h2>
<p>To determine whether the evolution of IgG, IgA and IgM clonal lineages underwent distinct selection processes, we classified B cell lineages by majority isotype, defined as the isotype per clonal lineage with the highest number of distinct cell barcodes.</p>
<p>The clonal lineages can be split into 5 subrepertoires. Each subrepertoire is dominated by the following isotypes: IgG, IgA, IgM and other types.</p>
<ul>
<li>In case, there is an equal number of IgA and IgG isotypes in a clonal lineage, a separate category is created</li>
<li>In case there exists a tie in the number of IgA and IgM isotypes in a clonal lineage, this lineage is considered as IgA majority isotype</li>
<li>In case there exists a tie in the number of IgG and IgM isotypes in a clonal lineage, this lineage is considered as IgG majority isotype</li>
</ul>
<p>SubRepertoiresByCells function assigns clonal lineages into sub-repertoires by isotype based on number of B cells.</p>
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">repert</span><span class="op">&lt;-</span> <span class="fu"><a href="../reference/AbForests_SubRepertoiresByCells.html">AbForests_SubRepertoiresByCells</a></span><span class="op">(</span><span class="va">new</span><span class="op">)</span></code></pre></div>
<p>The isotype distinction that we assumed is based on the immunological background of the different isotypes. In particular, IgG isotype is the most abundant antibody in the serum and together with IgA isotype are expressed via class switching after antigen challenge. IgM isotype is expressed on naive cells, is present early in the B cell response and is highly reactive to various antigens, without assistance from T cells.</p>
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">total_lineages_per_isotype</span><span class="op">&lt;-</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="fu"><a href="https://rdrr.io/r/base/lapply.html" class="external-link">lapply</a></span><span class="op">(</span><span class="va">repert</span>, <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/base/length.html" class="external-link">length</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>
<span class="va">total_lineages_per_isotype</span></code></pre></div>
<p>This sub-categorization resulted in 1140 IgG majority clonal lineages, 163 IgA majority clonal lineages and 330 IgM majority clonal lineages.</p>
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">df_clon_lineages_isotype</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>Strategies<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">"IgG"</span>,<span class="st">"IgA"</span>,<span class="st">"IgM"</span><span class="op">)</span>,Freq<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/unname.html" class="external-link">unname</a></span><span class="op">(</span><span class="va">total_lineages_per_isotype</span><span class="op">[</span><span class="fl">1</span><span class="op">:</span><span class="fl">3</span><span class="op">]</span><span class="op">)</span>,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">"green1"</span>,<span class="st">"red"</span>,<span class="st">"purple"</span><span class="op">)</span><span class="op">)</span>
<span class="va">df_clon_lineages_isotype</span><span class="op">$</span><span class="va">colors</span><span class="op">&lt;-</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">df_clon_lineages_isotype</span><span class="op">$</span><span class="va">colors</span><span class="op">)</span>

<span class="va">p_clon_lineages_isotype</span><span class="op">&lt;-</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="va">df_clon_lineages_isotype</span>, <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes_.html" class="external-link">aes_string</a></span><span class="op">(</span>x <span class="op">=</span> <span class="st">'Strategies'</span>, y <span class="op">=</span> <span class="st">'Freq'</span>, fill<span class="op">=</span><span class="st">'colors'</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">ylab</a></span><span class="op">(</span><span class="st">"# of clonal lineages \n before filetering"</span><span class="op">)</span><span class="op">+</span> 
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_bar.html" class="external-link">geom_bar</a></span><span class="op">(</span>width<span class="op">=</span><span class="fl">0.6</span>,stat<span class="op">=</span><span class="st">"identity"</span>, position<span class="op">=</span><span class="st">"dodge"</span>,colour <span class="op">=</span> <span class="st">"black"</span>,show.legend <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span><span class="op">+</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><span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_discrete.html" class="external-link">scale_x_discrete</a></span><span class="op">(</span>expand <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/expansion.html" class="external-link">expansion</a></span><span class="op">(</span>add<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.6</span>,<span class="fl">0.5</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_continuous.html" class="external-link">scale_y_continuous</a></span><span class="op">(</span>expand <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</span>,<span class="fl">0</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span>  
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html" class="external-link">theme</a></span><span class="op">(</span>aspect.ratio <span class="op">=</span> <span class="fl">1</span>,axis.title.x<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.title.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">rel</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span>, angle <span class="op">=</span> <span class="fl">90</span><span class="op">)</span>,
        axis.text <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fl">8</span><span class="op">)</span>,axis.line <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_line</a></span><span class="op">(</span>colour <span class="op">=</span> <span class="st">"black"</span><span class="op">)</span>,
        panel.grid.major <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        panel.grid.minor <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.text.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.8</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        axis.text.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.8</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        panel.background <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,legend.title<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size<span class="op">=</span><span class="fl">8</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span><span class="op">)</span><span class="op">+</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="fu"><a href="https://rdrr.io/r/base/levels.html" class="external-link">levels</a></span><span class="op">(</span><span class="va">df_clon_lineages_isotype</span><span class="op">$</span><span class="va">colors</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">list6</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_ConvertStructure.html">AbForests_ConvertStructure</a></span><span class="op">(</span><span class="va">repert</span>,<span class="st">"isotype"</span>,<span class="cn">NULL</span><span class="op">)</span>
<span class="va">rev_rep</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_RemoveNets.html">AbForests_RemoveNets</a></span><span class="op">(</span><span class="va">list6</span>,<span class="st">"isotype"</span>,<span class="va">custom_mat</span>,<span class="va">tie_flag</span>,<span class="va">weight</span>,<span class="cn">NULL</span>,<span class="fl">6</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span><span class="op">)</span>
<span class="va">remained_lineages_per_isotype</span><span class="op">&lt;-</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="fu"><a href="https://rdrr.io/r/base/lapply.html" class="external-link">lapply</a></span><span class="op">(</span><span class="va">rev_rep</span>, <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/base/length.html" class="external-link">length</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>
<span class="va">remained_lineages_per_isotype</span></code></pre></div>
<p>After eliminating the lineages with less than 6 unique cells, only 222, 23 and 30 clonal lineages remained in each of IgG, IgA and IgM sub-repertoires.</p>
<p>Prior to filtering, ConvertStructure function converts input data to the approriate format when the user desires to alter input data. Specifically, the function recovers the isotype/transcriptional cluster information and the full-length antibody sequences.</p>
<p>The filtering of networks with less than 6 unique cells leads to the elimination of those small networks which are less informative and convey a limited potential diversity in the structure of the network. On the other hand, the comparison of multiple identical sized networks consisting of few nodes, allows to extract identical properties among those networks such as path lengths. A valid threshold value in the filtering is often less clear to determine, but increasing the lower bound on the number of unique sequences within a clone increases exponentially the number of distinct possible graph topologies and therefore the likelihood of recognizing meaningful patterns in the graphs.</p>
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">df_clon_lineages_isotype_after</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>Strategies<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">"IgG"</span>,<span class="st">"IgA"</span>,<span class="st">"IgM"</span><span class="op">)</span>, Freq<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/unname.html" class="external-link">unname</a></span><span class="op">(</span><span class="va">remained_lineages_per_isotype</span><span class="op">[</span><span class="fl">1</span><span class="op">:</span><span class="fl">3</span><span class="op">]</span><span class="op">)</span>,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">"green1"</span>,<span class="st">"red"</span>,<span class="st">"purple"</span><span class="op">)</span><span class="op">)</span>
<span class="va">df_clon_lineages_isotype_after</span><span class="op">$</span><span class="va">colors</span> <span class="op">&lt;-</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">df_clon_lineages_isotype_after</span><span class="op">$</span><span class="va">colors</span><span class="op">)</span>

<span class="va">p_clon_lineages_isotype_after</span><span class="op">&lt;-</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="va">df_clon_lineages_isotype_after</span>, <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes_.html" class="external-link">aes_string</a></span><span class="op">(</span>x <span class="op">=</span> <span class="st">'Strategies'</span>, y <span class="op">=</span> <span class="st">'Freq'</span>,fill<span class="op">=</span><span class="st">'colors'</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">ylab</a></span><span class="op">(</span><span class="st">"# of clonal lineages \n after filtering"</span><span class="op">)</span><span class="op">+</span> 
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_bar.html" class="external-link">geom_bar</a></span><span class="op">(</span>width<span class="op">=</span><span class="fl">0.6</span>,stat<span class="op">=</span><span class="st">"identity"</span>, position<span class="op">=</span><span class="st">"dodge"</span>,colour <span class="op">=</span> <span class="st">"black"</span>,show.legend <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span><span class="op">+</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><span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_discrete.html" class="external-link">scale_x_discrete</a></span><span class="op">(</span>expand <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/expansion.html" class="external-link">expansion</a></span><span class="op">(</span>add<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.6</span>,<span class="fl">0.5</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_continuous.html" class="external-link">scale_y_continuous</a></span><span class="op">(</span>expand <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</span>,<span class="fl">0</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> 
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html" class="external-link">theme</a></span><span class="op">(</span>aspect.ratio<span class="op">=</span><span class="fl">1</span>, axis.title.x<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.title.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">rel</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span>, angle <span class="op">=</span> <span class="fl">90</span><span class="op">)</span>,
        axis.text <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fl">8</span><span class="op">)</span>,axis.line <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_line</a></span><span class="op">(</span>colour <span class="op">=</span> <span class="st">"black"</span><span class="op">)</span>,
        panel.grid.major <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        panel.grid.minor <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.text.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.8</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        axis.text.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.8</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        panel.background <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,legend.title<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size<span class="op">=</span><span class="fl">8</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span><span class="op">)</span><span class="op">+</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="fu"><a href="https://rdrr.io/r/base/levels.html" class="external-link">levels</a></span><span class="op">(</span><span class="va">df_clon_lineages_isotype_after</span><span class="op">$</span><span class="va">colors</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">percent_remained</span><span class="op">&lt;-</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="fu"><a href="https://rdrr.io/r/base/mapply.html" class="external-link">mapply</a></span><span class="op">(</span><span class="st">"/"</span>,<span class="va">remained_lineages_per_isotype</span><span class="op">[</span><span class="fl">1</span><span class="op">:</span><span class="fl">3</span><span class="op">]</span>,<span class="va">total_lineages_per_isotype</span><span class="op">[</span><span class="fl">1</span><span class="op">:</span><span class="fl">3</span><span class="op">]</span>,SIMPLIFY <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span><span class="op">)</span>

<span class="va">df_percent_remained</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>Strategies<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">"IgG"</span>,<span class="st">"IgA"</span>,<span class="st">"IgM"</span><span class="op">)</span>,Freq<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="fu"><a href="https://rdrr.io/r/base/unname.html" class="external-link">unname</a></span><span class="op">(</span><span class="va">percent_remained</span><span class="op">)</span><span class="op">)</span>,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">"green1"</span>,<span class="st">"red"</span>,<span class="st">"purple"</span><span class="op">)</span><span class="op">)</span>

<span class="va">df_percent_remained</span><span class="op">[</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html" class="external-link">lapply</a></span><span class="op">(</span><span class="va">df_percent_remained</span>, <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="kw">if</span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/numeric.html" class="external-link">is.numeric</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span> <span class="va">x</span><span class="op">*</span><span class="fl">100</span> <span class="kw">else</span> <span class="va">x</span><span class="op">)</span>
<span class="va">df_percent_remained</span><span class="op">$</span><span class="va">colors</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html" class="external-link">factor</a></span><span class="op">(</span><span class="va">df_percent_remained</span><span class="op">$</span><span class="va">colors</span>, levels <span class="op">=</span> <span class="va">df_percent_remained</span><span class="op">$</span><span class="va">colors</span><span class="op">)</span>
<span class="va">p_rem</span><span class="op">&lt;-</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="va">df_percent_remained</span>, <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">Strategies</span>, y <span class="op">=</span> <span class="va">Freq</span>, fill<span class="op">=</span> <span class="va">colors</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">ylab</a></span><span class="op">(</span><span class="st">"% of clonal lineages \n after filtering"</span><span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_bar.html" class="external-link">geom_bar</a></span><span class="op">(</span>width<span class="op">=</span><span class="fl">0.5</span>,stat<span class="op">=</span><span class="st">"identity"</span>, position<span class="op">=</span><span class="st">"dodge"</span>,colour <span class="op">=</span> <span class="st">"black"</span>,show.legend <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span><span class="op">+</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><span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_discrete.html" class="external-link">scale_x_discrete</a></span><span class="op">(</span>expand <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/expansion.html" class="external-link">expansion</a></span><span class="op">(</span>add<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.6</span>,<span class="fl">0.5</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_continuous.html" class="external-link">scale_y_continuous</a></span><span class="op">(</span>expand <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</span>,<span class="fl">0</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> 
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html" class="external-link">theme</a></span><span class="op">(</span>aspect.ratio<span class="op">=</span><span class="fl">1</span>,axis.line <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_line</a></span><span class="op">(</span>colour <span class="op">=</span> <span class="st">"black"</span><span class="op">)</span>,
        axis.title.x<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        panel.grid.major <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        panel.grid.minor <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,
        axis.title.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">rel</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span>, angle <span class="op">=</span> <span class="fl">90</span><span class="op">)</span>,
        axis.text.y <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.8</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        axis.text <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size <span class="op">=</span> <span class="fl">8</span><span class="op">)</span>,
        axis.text.x <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>angle <span class="op">=</span> <span class="fl">0</span>, vjust <span class="op">=</span> <span class="fl">0.5</span>,colour <span class="op">=</span> <span class="st">"black"</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span>,
        panel.background <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_blank</a></span><span class="op">(</span><span class="op">)</span>,legend.title<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html" class="external-link">element_text</a></span><span class="op">(</span>size<span class="op">=</span><span class="fl">8</span>,face<span class="op">=</span><span class="st">"bold"</span><span class="op">)</span><span class="op">)</span> <span class="op">+</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="fu"><a href="https://rdrr.io/r/base/levels.html" class="external-link">levels</a></span><span class="op">(</span><span class="va">df_percent_remained</span><span class="op">$</span><span class="va">colors</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<div id="sub-repertoire-statistics" class="section level3">
<h3 class="hasAnchor">
<a href="#sub-repertoire-statistics" class="anchor" aria-hidden="true"></a>Sub-repertoire Statistics</h3>
<p>The subrepertoires statistics are summarized below.</p>
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">p_clon_lineages_isotype</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/gridExtra/man/arrangeGrob.html" class="external-link">arrangeGrob</a></span><span class="op">(</span><span class="va">p_clon_lineages_isotype</span>, top <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/grid.text.html" class="external-link">textGrob</a></span><span class="op">(</span><span class="st">"A"</span>, x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">0</span>, <span class="st">"npc"</span><span class="op">)</span>, y <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">1</span>, <span class="st">"npc"</span><span class="op">)</span>, just<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">"left"</span>,<span class="st">"top"</span><span class="op">)</span>,gp<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/grid/gpar.html" class="external-link">gpar</a></span><span class="op">(</span>col<span class="op">=</span><span class="st">"black"</span>, fontsize<span class="op">=</span><span class="fl">12</span>, fontfamily<span class="op">=</span><span class="st">"Times"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>

<span class="va">p_clon_lineages_isotype_after</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/gridExtra/man/arrangeGrob.html" class="external-link">arrangeGrob</a></span><span class="op">(</span><span class="va">p_clon_lineages_isotype_after</span>, top <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/grid.text.html" class="external-link">textGrob</a></span><span class="op">(</span><span class="st">"B"</span>, x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">0</span>, <span class="st">"npc"</span><span class="op">)</span>, y <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">1</span>, <span class="st">"npc"</span><span class="op">)</span>, just<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">"left"</span>,<span class="st">"top"</span><span class="op">)</span>, gp<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/grid/gpar.html" class="external-link">gpar</a></span><span class="op">(</span>col<span class="op">=</span><span class="st">"black"</span>,fontsize<span class="op">=</span><span class="fl">12</span>, fontfamily<span class="op">=</span><span class="st">"Times"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>

<span class="va">p_rem</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/gridExtra/man/arrangeGrob.html" class="external-link">arrangeGrob</a></span><span class="op">(</span><span class="va">p_rem</span>, top <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/grid.text.html" class="external-link">textGrob</a></span><span class="op">(</span><span class="st">"C"</span>, x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">0</span>, <span class="st">"npc"</span><span class="op">)</span>
, y <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/grid/unit.html" class="external-link">unit</a></span><span class="op">(</span><span class="fl">1</span>, <span class="st">"npc"</span><span class="op">)</span>, just<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">"left"</span>,<span class="st">"top"</span><span class="op">)</span>,  gp<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/grid/gpar.html" class="external-link">gpar</a></span><span class="op">(</span>col<span class="op">=</span><span class="st">"black"</span>,    fontsize<span class="op">=</span><span class="fl">12</span>, fontfamily<span class="op">=</span><span class="st">"Times"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/pkg/gridExtra/man/arrangeGrob.html" class="external-link">grid.arrange</a></span><span class="op">(</span><span class="va">p_clon_lineages_isotype</span>,
            <span class="va">p_clon_lineages_isotype_after</span>,<span class="va">p_rem</span>, ncol<span class="op">=</span><span class="fl">2</span><span class="op">)</span></code></pre></div>
<p>Consequently, the categorization of most clonal lineages as IgG majority and the subsequent filtering of networks with less than 6 unique cells, elevated the number of clonal variants in each network only in the IgG and IgA lineages. We were therefore able to demonstrate that class-switched B cells clones underwent further diversification of their unique BCR sequences.</p>
</div>
</div>
<div id="network-inference" class="section level2">
<h2 class="hasAnchor">
<a href="#network-inference" class="anchor" aria-hidden="true"></a>5. Network inference</h2>
<p>Within a single repertoire, there exists a multitude of co-evolving clonal lineages, each of which consists of B cells descending from an independent V(D)J recombination event and can therefore be modeled into a single network. Each network represents the evolutionary trajectory following somatic hypermutation relative to an unmutated, reference germline. Vertices refer to unique appended full-length variable heavy and variable light chain (<span class="math inline">\(V_H\)</span> + <span class="math inline">\(V_L\)</span>) antibody sequences, which can be either internal or terminal nodes in the network, thereby diverging from the traditional B cell phylogenies. Edges connect clonal variants with the smallest separation similarity, computed by the edit distance under default parameters. The reconstruction of networks is based on 2 node and edge selection algorithms , which maintain the principles of Directed Acyclic Graphs (DAGs), therefore eliminating potential bidirectional cycles.</p>
<div id="naive-algorithm" class="section level3">
<h3 class="hasAnchor">
<a href="#naive-algorithm" class="anchor" aria-hidden="true"></a>Naive Algorithm</h3>
<p>The default graph construction algorithm initially collapses unique antibody sequences, while preserving pivotal information on properties of the networks such as the clonal expansion of clonal variants, defined as the amount of cells corresponding to each unique antibody, the distribution of isotypes and the length of their antibody sequences. A symmetric distance matrix is then calculated, depicting the number of mutations between all unique antibody sequences and reference germline, within one clonal family. The default method to compute the distance matrix is the Levenshtein distance (Levenshtein, 1966), which counts the number of per letter transformations between strings to quantify their dissimilarity. Edge weights are extracted from the distance matrix apart from the special case of the unmutated germline. Weights of outgoing edges of germline nodes are either set to 1 (weight=FALSE) or to the difference between the corresponding distance from the matrix and the absolute value of the difference between the sequence lengths of germline and corresponding connected nodes (weight=TRUE).</p>
<p>Starting from the germline node, the closest sequences, according to distance matrix calculations, are assigned to the set of already examined nodes in the graph. For each element in the set of current nodes and for all combinations with the remaining nodes, edges with the minimum distance are sequentially added in the graph. This procedure is repeated until all nodes have been examined. Ties between distances are resolved randomly under default parameters, but additionally can be resolved using other immune repertoire features.</p>
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">graphs_IGHG</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="cn">NULL</span>,<span class="cn">FALSE</span>,<span class="va">rev_rep</span><span class="op">$</span><span class="va">list_IGHG</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"isotype"</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="cn">NULL</span><span class="op">)</span></code></pre></div>
<p>The AntibodyForest function apart from the construction of networks, provides essential information on the structure and properties of networks. Such information is summarized below.</p>
<ul>
<li><p>graphs_IGHG<span class="math inline">\([[1][[1]]\)</span> -&gt; network: an igraph object, containing the first network in tree format</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[2]]\)</span> -&gt; legend: contains the legend parameters of the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[3]]\)</span> -&gt; count.rand: contains the number of randomly considered nodes for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[4]]\)</span> -&gt; adj.matrix: contains the adjacency matrix for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[5]]\)</span> -&gt; distance.matrix: contains the distance matrix for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[6]]\)</span> -&gt; cells.per.network: contains the number of cells for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[7]]\)</span> -&gt; variants.per.network: contains the number of variants for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[8]]\)</span> -&gt; variant.sequences: contains the sequences of the variants for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[9]]\)</span> -&gt; cells.per.variant: contains the number of cells per variant (clonal frequency) for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[10]]\)</span> -&gt; cell.indicies.per.variant: the indices of cells per variant for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[11]]\)</span> -&gt; new.variant.names: contains the names of variants for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[12]]\)</span> -&gt; germline.index: contains the index of germline sequence for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[13]]\)</span> -&gt; isotype.per.variant: contains the isotypes corresponding to each variant for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[14]]\)</span> -&gt; transcriptome.cluster.per.variant: contains the transcriptional clusters corresponding to each variant for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[15]]\)</span> -&gt; isotype.per.cell: contains the isotype corresponding to each cell for the first network</p></li>
<li><p>graphs_IGHG<span class="math inline">\([[1]][[16]]\)</span> -&gt; transcriptome.cluster.per.cell: contains the transcriptional cluster corresponding to each cell for the first network</p></li>
</ul>
<p>Example networks are provided, highlighting the complexity of the LCVM dataset. Nodes are both labeled and scaled by the clonal frequency. The scaling of nodes by their relative clonal expansion assists in pinpointing identical antibody sequences produced by multiple B cells.</p>
<ol style="list-style-type: lower-alpha">
<li>This is an example network from the IgG-sub-repertoire that contains highly clonally expanded variants.</li>
</ol>
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.0001</span><span class="op">*</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">17</span><span class="op">+</span><span class="op">(</span><span class="fl">0.8</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">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">network</span><span class="op">)</span><span class="op">$</span><span class="va">size</span><span class="op">)</span>,layout<span class="op">=</span><span class="fl">0.05</span><span class="op">*</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">network</span><span class="op">$</span><span class="va">layout</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty <span class="op">=</span> <span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">11</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
<ol start="2" style="list-style-type: lower-alpha">
<li>This is an example network from the IgG-sub-repertoire that contains multiple dictinct isotypes.</li>
</ol>
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.0001</span><span class="op">*</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">17</span><span class="op">+</span><span class="op">(</span><span class="fl">0.8</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">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">network</span><span class="op">)</span><span class="op">$</span><span class="va">size</span><span class="op">)</span>,layout<span class="op">=</span><span class="fl">0.05</span><span class="op">*</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">network</span><span class="op">$</span><span class="va">layout</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty <span class="op">=</span> <span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_IGHG</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
<ol start="3" style="list-style-type: lower-alpha">
<li>This is an example network from the IgM-sub-repertoire that contains highly clonally expanded variants.</li>
</ol>
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">graphs_IGHM</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="cn">NULL</span>,<span class="cn">FALSE</span>,<span class="va">rev_rep</span><span class="op">$</span><span class="va">list_IGHM</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"isotype"</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="cn">NULL</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb42"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.0001</span><span class="op">*</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">17</span><span class="op">+</span><span class="op">(</span><span class="fl">0.8</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">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">network</span><span class="op">)</span><span class="op">$</span><span class="va">size</span><span class="op">)</span>,layout<span class="op">=</span><span class="fl">0.05</span><span class="op">*</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">network</span><span class="op">$</span><span class="va">layout</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty <span class="op">=</span> <span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_IGHM</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
<p>The package provides additional scaling and labeling options of nodes.</p>
<p>Relating the size of nodes with centrality metrics highlights the importance of certain nodes in the network. The measurement of node importance is of great practical and theoretical significance in identifying how individual nodes influence network structure and functionality, thereby describing the robustness of the network.</p>
<p>Therefore, the size of vertices can also depend on vertex betweenness (computed by counting the number of shortest paths going through a vertex (Freeman, 1979)) and vertex closeness (measured by the number of shortest paths going through each edge (Freeman, 1979)).</p>
<p>Node labeling can be also based on the traversal order of nodes specified by the utilized algorithm. This option facilitates the the detection of modifications in the topology of networks.</p>
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#Scaling of nodes by vertex betweenness and labeling based on traversal order of nodes in the naive algorithm </span>
<span class="va">graphs_IGHM_new</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="cn">NULL</span>,<span class="cn">FALSE</span>,<span class="va">rev_rep</span><span class="op">$</span><span class="va">list_IGHM</span>,<span class="va">custom_mat</span>,clonal_frequency<span class="op">=</span><span class="cn">FALSE</span>,scaleByClonalFreq<span class="op">=</span><span class="cn">FALSE</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,scaleBybetweenness<span class="op">=</span><span class="cn">TRUE</span>,scaleByclocloseness_metr<span class="op">=</span><span class="cn">FALSE</span>,<span class="st">"isotype"</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="cn">NULL</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.0001</span><span class="op">*</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">17</span><span class="op">+</span><span class="op">(</span><span class="fl">0.8</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">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">network</span><span class="op">)</span><span class="op">$</span><span class="va">size</span><span class="op">)</span>,layout<span class="op">=</span><span class="fl">0.05</span><span class="op">*</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">network</span><span class="op">$</span><span class="va">layout</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty <span class="op">=</span> <span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_IGHM_new</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
</div>
<div id="two-step-algorithm" class="section level3">
<h3 class="hasAnchor">
<a href="#two-step-algorithm" class="anchor" aria-hidden="true"></a>Two-step Algorithm</h3>
<p>The two-step algorithm relies on the same concept, but completes the network construction in a multi-level fashion. Resolving ties in the distance matrix is handled in a second step. Edges rendering nodes with multiple parents are eliminated, forcing each antibody variant to descend from a single parent. Consequently, AbNetForests supports various customizable options that enable the user to select whether mutational load, clonal expansion, random selection or no selection at all dictates graph topology. In case of subsequent ties, a random node is selected.</p>
<ol style="list-style-type: decimal">
<li>“rand” option allows the random selection of one child node</li>
<li>“full” option allows keeping all children nodes</li>
<li>“close_to_germ” and “far_from_germ” options allow the pruning of farthest and closest nodes relative to the germline, respectively, based on the number of intermediate nodes in the path.</li>
<li>“close_path_to_germ” and “far_path_from_germ” options allow the pruning of farthest and closest nodes relative to the germline, respectively, based on the weighted or unweighted edge path length.</li>
<li>“most_expanded” and “least_expanded” options allow the pruning of nodes with the lowest B cell count and the highest B cell count, respectively.</li>
</ol>
<p>Tie resolving options 3 and 4 are utilized to incorporate information regarding deep (a single variant continues to linearly produce new progeny) versus broad (a single variant produces multiple direct progeny) selection, while option 5 resolves ties by assuming that either the most expanded or least expanded clones contribute to new variants. Closeness of a node to germline node, as described in tie case 3, means identifying the minimum number of edges in the path between the node and germline, whereas in tie case 4 the minimum weighted path length between the node and germline.</p>
<p>Therefore, using the 2-step algorithm and preserving the option to resolve ties randomly influnces the topology of networks</p>
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">graphs_IGHG_2</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="cn">NULL</span>,<span class="cn">FALSE</span>,<span class="va">rev_rep</span><span class="op">$</span><span class="va">list_IGHG</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"isotype"</span>,<span class="va">random.seed</span>,alg_opt<span class="op">=</span><span class="st">"two-step"</span>,<span class="cn">NULL</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb46"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.0001</span><span class="op">*</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">17</span><span class="op">+</span><span class="op">(</span><span class="fl">0.8</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">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">network</span><span class="op">)</span><span class="op">$</span><span class="va">size</span><span class="op">)</span>,layout<span class="op">=</span><span class="fl">0.05</span><span class="op">*</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">network</span><span class="op">$</span><span class="va">layout</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty <span class="op">=</span> <span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_IGHG_2</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
<p>The graph topology can also be altered under different tie resolving cases. For example, changing the option to resolve ties by removing the farthest node(s) from germline (“close_to_germ”) influnces the topology of networks:</p>
<div class="sourceCode" id="cb47"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">graphs_IGHG_close_germ</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="cn">NULL</span>,<span class="cn">FALSE</span>,<span class="va">rev_rep</span><span class="op">$</span><span class="va">list_IGHG</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,tie_flag<span class="op">=</span><span class="st">"close_to_germ"</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"isotype"</span>,<span class="va">random.seed</span>,alg_opt<span class="op">=</span><span class="st">"two-step"</span>,<span class="cn">NULL</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb48"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.0001</span><span class="op">*</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">17</span><span class="op">+</span><span class="op">(</span><span class="fl">0.8</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">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">network</span><span class="op">)</span><span class="op">$</span><span class="va">size</span><span class="op">)</span>,layout<span class="op">=</span><span class="fl">0.05</span><span class="op">*</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">network</span><span class="op">$</span><span class="va">layout</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty <span class="op">=</span> <span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_IGHG_close_germ</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
<p>A user may does not want to add all these biases, thus the package can generate networks without resolving ties. These networks are not directed acyclic any more as they contain bi-directional cycles.</p>
<div class="sourceCode" id="cb49"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">graphs_IGHG_full</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="cn">NULL</span>,<span class="cn">FALSE</span>,<span class="va">rev_rep</span><span class="op">$</span><span class="va">list_IGHG</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,tie_flag<span class="op">=</span><span class="st">"full"</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"isotype"</span>,<span class="va">random.seed</span>,alg_opt<span class="op">=</span><span class="st">"two-step"</span>,<span class="cn">NULL</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb50"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.0001</span><span class="op">*</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">17</span><span class="op">+</span><span class="op">(</span><span class="fl">0.8</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">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">network</span><span class="op">)</span><span class="op">$</span><span class="va">size</span><span class="op">)</span>,layout<span class="op">=</span><span class="fl">0.05</span><span class="op">*</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">network</span><span class="op">$</span><span class="va">layout</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty <span class="op">=</span> <span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_IGHG_full</span><span class="op">[</span><span class="fl">104</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
</div>
</div>
<div id="calculation-of-network-metrics" class="section level2">
<h2 class="hasAnchor">
<a href="#calculation-of-network-metrics" class="anchor" aria-hidden="true"></a>6. Calculation of network metrics</h2>
<p>Following the construction of the mutational networks, AbNetForests calculates and visualizes summary statistics, which provides the opportunity for both qualitative and quantitative comparison of the evolutionary relationships among antibodies. The tool extracts the topologies of individual networks within the repertoire and links them with clonal expansion, distance from the reference germline, isotype distribution and transcriptional phenotype. Specifically, the following metrics are computed for all networks:</p>
<ol style="list-style-type: decimal">
<li>weighted/unweighted longest path(s) from germline. Longest path is defined as the path with the maximum length between all shortest paths from the germline node to all other nodes. Shortest path is a path with the minimal number of edges. In case of unweighted graphs, the breadth-first search algorithm is used, while for weighted graphs Dijkstra’s algorithm is utilized</li>
<li>length of weighted/ unweighted longest shortest path from germline</li>
<li>average/standard deviation/minimum/maximum number of daughter cells. These metrics are computed with the aid of the most fundamental graph property, the vertex degree, which is defined as the number of the adjacent edges of the node</li>
<li>weighted vertex degree or strength. It is calculated by summing up the edge weights of the adjacent edges for each vertex (Barrat et al., 2004)</li>
<li>average number of isotypes and/or clusters. For each network, the occurrences of distinct isotypes or clusters are counted and divided by the number of nodes</li>
<li>informative data.frame for isotypes and/or clusters, which contains the type of isotypes/clusters for each pair of nodes in the graph (Parent-Child relationship in the graph)</li>
<li>vertex betweenness centrality</li>
<li>edge betweenness centrality. It is measured by the number of shortest paths going through each edge (Freeman, 1979)</li>
<li>closeness centrality of vertices</li>
<li>global/average clustering coefficient. To compute clustering coefficients, transitivity is measured by specifying the probability of adjacent vertices of a vertex to be connected. Global transitivity is the ratio of triangles and connected triples in the graph, while local transitivity follows the same definition but centered on the vertex level (for directed graphs, the direction of the edges is ignored)</li>
<li>mean clonal expansion. It is calculated as the mean value of clonal frequencies of all vertices in the network</li>
<li>ratios of number of edges from germline to each node divided by the respective clonal frequency of each node</li>
<li>mean ratio of the number of edges from germline to each node divided byclonal frequency (mean ratio of values in metric 12).</li>
<li>mean number of edges from germline for all nodes in the network</li>
<li>ratios of total path length from germline to each node divided by the respective clonal frequency of each node</li>
<li>mean ratio: total path length from germline to each node divided by the respective clonal frequency of each node (mean ratio of values in metric 15)</li>
<li>mean total path length from germline for all nodes in the network</li>
</ol>
<p>The metrics for the IgG subrepertoire are summarized below</p>
<div class="sourceCode" id="cb51"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">metrics_igg</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_ForestMetrics.html">AbForests_ForestMetrics</a></span><span class="op">(</span><span class="va">graphs_IGHG</span>,<span class="va">DAG</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="st">"isotype"</span><span class="op">)</span>

<span class="va">metrics_igg</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">`Mean Total path length from germline`</span></code></pre></div>
<p>Another example metric is the distribution of distinct isotypes versus their frequency</p>
<div class="sourceCode" id="cb52"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">metrics_igg</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">`Plot: Distribution of isotypes`</span></code></pre></div>
</div>
<div id="comparison-of-networks" class="section level2">
<h2 class="hasAnchor">
<a href="#comparison-of-networks" class="anchor" aria-hidden="true"></a>7. Comparison of networks</h2>
<p>We can also compare the repertoires of distinct B cells. In this case, we compare the IgG and IgM subreperoires using the CompareForests function</p>
<div class="sourceCode" id="cb53"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">output</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_CompareForests.html">AbForests_CompareForests</a></span><span class="op">(</span><span class="va">graphs_IGHG</span>,<span class="va">graphs_IGHM</span>,<span class="va">DAG</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="st">"isotype"</span><span class="op">)</span></code></pre></div>
<p>CompareForests function has 3 outputs</p>
<ul>
<li>combined_df, a data.frame that summarizes metrics for both repertoires. In particular, each row represents a single network and networks of both repertoires are combined row-wise. It has the following columns:</li>
</ul>
<ol style="list-style-type: decimal">
<li>Weighted.Longest.path.from.germline</li>
<li>Length.of.weighted.longest.shortest.path.from.germline</li>
<li>Unweighted.Longest.path.from.germline</li>
<li>Length.of.unweighted.longest.shortest.path.from.germline</li>
<li>Average.number.of.daughter.cells</li>
<li>Std.number.of.daughter.cells</li>
<li>Min.number.of.daughter.cells</li>
<li>Max.number.of.daughter.cells</li>
<li>Weighted.vertex.degree</li>
<li>Average.number.of.clusters/isotypes</li>
<li>Isotypes/Clusters.info</li>
<li>vertex.betweenness.centrality</li>
<li>edge.betweenness.centrality</li>
<li>closeness.centrality.of.vertices</li>
<li>global.clustering.coefficient</li>
<li>average.clustering.coefficient</li>
<li>Mean.clonal.expansion</li>
</ol>
<p>If the labeling or scaling of nodes in graph is based on clonal frequency (arguments: clonal_frequency==TRUE or scaleByClonalFreq==TRUE), then combined_df contains also:</p>
<ol start="18" style="list-style-type: decimal">
<li>Ratio.Number.of.edges.from.germline.to.each.node.with.clonal.frequency</li>
<li>Mean.Ratio.Number.of.edges.from.germline.to.each.node.with.clonal.frequency</li>
<li>Mean.number.of.edges.from.germline</li>
<li>Ratio.Total.path.length.from.germline.to.each.node.with.clonal.frequency</li>
<li>Mean.Ratio.Total.path.length.from.germline.to.each.node.with.clonal.frequency</li>
<li>Mean.Total.path.length.from.germline</li>
<li>Repertoire.id</li>
<li>Number.of.sequences</li>
</ol>
<ul>
<li>isotype_info_rep1, a data.frame that summarizes the isotype/cluster info for the IgG sub-repertoire</li>
<li>isotype_info_rep2, a data.frame that summarizes the isotype/cluster info for the IgM sub-repertoire</li>
</ul>
</div>
<div id="custom-node-coloring" class="section level2">
<h2 class="hasAnchor">
<a href="#custom-node-coloring" class="anchor" aria-hidden="true"></a>8. Custom node coloring</h2>
<p>For visualization purposes only, AbNetForests can color network nodes not only based on isotype or transcriptional cluster information, but also based on any data column. This is achieved by allowing the user to specify the name of the column of interest. The possibility of custom coloring is supported for both possible input formats either as a list of dfs or a list of csv files.</p>
<p>For the lcmv dataset, if we want to color nodes based on VDJ_jgene, then</p>
<div class="sourceCode" id="cb54"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">graphs_custom</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="va">new</span>,<span class="cn">FALSE</span>,<span class="cn">NULL</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"VDJ_jgene"</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="cn">NULL</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb55"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.0001</span><span class="op">*</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">17</span><span class="op">+</span><span class="op">(</span><span class="fl">0.8</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">graphs_custom</span><span class="op">[</span><span class="fl">14</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">network</span><span class="op">)</span><span class="op">$</span><span class="va">size</span><span class="op">)</span>,layout<span class="op">=</span><span class="fl">0.05</span><span class="op">*</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">network</span><span class="op">$</span><span class="va">layout</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty <span class="op">=</span> <span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_custom</span><span class="op">[</span><span class="fl">14</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
<p>For the csv files, we can color based on LCvgene</p>
<div class="sourceCode" id="cb56"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">graphs_csv</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="va">files</span>,<span class="cn">TRUE</span>,<span class="cn">NULL</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"LCvgene"</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="fl">0</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb57"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.0001</span><span class="op">*</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">17</span><span class="op">+</span><span class="op">(</span><span class="fl">0.8</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">graphs_csv</span><span class="op">[</span><span class="fl">1</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">network</span><span class="op">)</span><span class="op">$</span><span class="va">size</span><span class="op">)</span>,layout<span class="op">=</span><span class="fl">0.05</span><span class="op">*</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">network</span><span class="op">$</span><span class="va">layout</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty <span class="op">=</span> <span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_csv</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.7</span><span class="op">)</span></code></pre></div>
</div>
<div id="other-package-functionality" class="section level2">
<h2 class="hasAnchor">
<a href="#other-package-functionality" class="anchor" aria-hidden="true"></a>9. Other package functionality</h2>
<p>In case the user wants to perform changes in the input data, for a list of csvs as input, similar to the provided data, the CsvToDf function is first used to transform the input list to a list of data.frames, with the appropriate format.</p>
<p>In addition, there is the option to split a single cell immune repertoire into sub-repertoires by isotype based on the number of unique sequences instead of the number of B cells, using the SubRepertoiresByUniqueSeq function.</p>
<div class="sourceCode" id="cb58"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">repert</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_SubRepertoiresByUniqueSeq.html">AbForests_SubRepertoiresByUniqueSeq</a></span><span class="op">(</span><span class="va">new</span>,<span class="st">"isotype"</span>,<span class="va">custom_mat</span>,<span class="va">tie_flag</span>,<span class="va">weight</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="fl">0</span><span class="op">)</span></code></pre></div>
<p>We can also filter those networks with less than N unique sequences apart from the elimination of networks with less than C unique cells.</p>
<p>In PlotGraphs function, parameter topdf=FALSE would enable the user to print the network in the console (This parameter option is not advised for large input lists).</p>
<p>The previously additional functionality of the package is summarized below, taking into account the transcriptional cluster information and removing the networks with less than 4 unique BCR sequences.</p>
<div class="sourceCode" id="cb59"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">list_scv</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_CsvToDf.html">AbForests_CsvToDf</a></span><span class="op">(</span><span class="va">files</span><span class="op">)</span> 
<span class="va">list6</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_ConvertStructure.html">AbForests_ConvertStructure</a></span><span class="op">(</span><span class="va">list_scv</span>,<span class="st">"cluster"</span>,<span class="fl">0</span><span class="op">)</span>
<span class="va">rev_rep</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_RemoveNets.html">AbForests_RemoveNets</a></span><span class="op">(</span><span class="va">list6</span>,<span class="st">"cluster"</span>,<span class="va">custom_mat</span>,<span class="va">tie_flag</span>,<span class="va">weight</span>,<span class="fl">4</span>,<span class="cn">NULL</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span><span class="op">)</span>
<span class="va">graphs_csv_less_4</span><span class="op">&lt;-</span><span class="fu"><a href="../reference/AbForests_AntibodyForest.html">AbForests_AntibodyForest</a></span><span class="op">(</span><span class="cn">NULL</span>,<span class="cn">FALSE</span>,<span class="va">rev_rep</span>,<span class="va">custom_mat</span>,<span class="va">clonal_frequency</span>,<span class="va">scaleByClonalFreq</span>,<span class="va">weight</span>,<span class="va">tie_flag</span>,<span class="va">scaleBybetweenness</span>,<span class="va">scaleByclocloseness_metr</span>,<span class="st">"cluster"</span>,<span class="va">random.seed</span>,<span class="va">alg_opt</span>,<span class="fl">0</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb60"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">igraph</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/igraph/man/plot.igraph.html" class="external-link">plot.igraph</a></span><span class="op">(</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">network</span>,vertex.label.cex<span class="op">=</span><span class="fl">1</span><span class="op">+</span><span class="op">(</span><span class="fl">0.0001</span><span class="op">*</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">cells.per.variant</span><span class="op">)</span>,vertex.size<span class="op">=</span><span class="fl">17</span><span class="op">+</span><span class="op">(</span><span class="fl">0.8</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">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">network</span><span class="op">)</span><span class="op">$</span><span class="va">size</span><span class="op">)</span>,layout<span class="op">=</span><span class="fl">0.05</span><span class="op">*</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">network</span><span class="op">$</span><span class="va">layout</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>,bty <span class="op">=</span> <span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>,legend<span class="op">=</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">3</span><span class="op">]</span><span class="op">]</span>,fill<span class="op">=</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">4</span><span class="op">]</span><span class="op">]</span>,border<span class="op">=</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">5</span><span class="op">]</span><span class="op">]</span>,inset<span class="op">=</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span>,xpd<span class="op">=</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">7</span><span class="op">]</span><span class="op">]</span>,title<span class="op">=</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">$</span><span class="va">title</span>,cex<span class="op">=</span><span class="va">graphs_csv_less_4</span><span class="op">[</span><span class="fl">1</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">legend</span><span class="op">[[</span><span class="fl">10</span><span class="op">]</span><span class="op">]</span><span class="op">*</span><span class="fl">0.26</span><span class="op">)</span></code></pre></div>
</div>
<div id="custom-distance-matrix" class="section level2">
<h2 class="hasAnchor">
<a href="#custom-distance-matrix" class="anchor" aria-hidden="true"></a>10. Custom distance matrix</h2>
<p>AbNetForests allows the investigation of other mutational models, more appropriate for antibodies, apart from the previously considered one, receiving as input a custom distance matrix per each network. The user is responsible for providing a distance matrix with the appropriate dimensions.</p>
</div>
<div id="converting-phylogenetic-tree-to-custom-distance-matrix" class="section level2">
<h2 class="hasAnchor">
<a href="#converting-phylogenetic-tree-to-custom-distance-matrix" class="anchor" aria-hidden="true"></a>11. Converting phylogenetic tree to custom distance matrix</h2>
<p>Finally, there is the option to convert a previously existing phylogenetic tree to a corresonding distance matrix, utilizing the cophenetic distance.</p>
<p>Given an example phylogenetic tree in Newick format, we can extract the distance matrix</p>
<div class="sourceCode" id="cb61"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/AbForests_PlyloToMatrix.html">AbForests_PlyloToMatrix</a></span><span class="op">(</span><span class="st">"example.tree"</span><span class="op">)</span></code></pre></div>
</div>
<div id="references" class="section level2">
<h2 class="hasAnchor">
<a href="#references" class="anchor" aria-hidden="true"></a>10. References</h2>
<ul>
<li><p>“Platypus: an open-access software for integrating lymphocyte single-cell immune repertoires with transcriptomes” Yermanos, Alexander; Agrafiotis, Andreas; Kuhn, Raphael; Robbiani, Damiano; Yates, Josephine; Papadopoulou, Chrysa; Han, Jiami; Sandu, Ioana; Weber, Cédric; Bieberich, Florian; Vazquez-Lombardi, Rodrigo; Neumeier, Daniel ; Oxenius, Annette; Reddy, Sai(2021). <a href="https://doi.org/10.1093/nargab/lqab023" class="external-link uri">https://doi.org/10.1093/nargab/lqab023</a></p></li>
<li><p>"Single-cell sequencing reveals clonally expanded plasma cells during chronic viral infection produce virus-specific and cross-reactive antibodies.Neumeier Daniel, Pedrioli Alessandro, Genovese Alessandro, Sandu Ioana, Ehling Roy, Hong Kai-Lin, Papadopoulou Chrysa, Agrafiotis Andreas, Kuhn Raphael, Robbiani Damiano, Han Jiami, Hauri Laura, Csepregi Lucia, Greiff Victor, ,Merkler Doron, Reddy Sai, Oxenius Annette, Yermanos Alexander (2021). bioRxiv doi: <a href="https://doi.org/10.1101/2021.01.29.428852" class="external-link uri">https://doi.org/10.1101/2021.01.29.428852</a></p></li>
<li><p>Levenshtein, V. (1966) Binary Codes capable of correcting deletions, insertions, and reversals. Solviet Physics Doklady 10 (8): 707-710</p></li>
<li><p>Freeman, L.C. (1979). Centrality in Social Networks I: Conceptual Clarification. Social Networks, 1, 215-239.</p></li>
<li><p>Barrat Alain, Barthelemy Marc, Pastor-Satorras Romualdo, Vespignani Alessandro. (2004). The architecture of complex weighted networks. Proc. Natl. Acad. Sci. USA 101, 3747.</p></li>
</ul>
</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 external-link">pkgdown</a> 1.6.1.9001.</p>
</div>

      </footer>
</div>

  


  

  </body>
</html>
