<!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>AIRR compatibility • 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="AIRR compatibility">
<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.3.3</span>
      </span>
    </div>

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

      

      </header><div class="row">
  <div class="col-md-9 contents">
    <div class="page-header toc-ignore">
      <h1 data-toc-skip>AIRR compatibility</h1>
                        <h4 data-toc-skip class="author">Victor Kreiner,
Alexander Yermanos</h4>
            
            <h4 data-toc-skip class="date">2022-04-02</h4>
      
      <small class="dont-index">Source: <a href="https://github.com/alexyermanos/Platypus/tree/mastervignettes/airr_compatibility.Rmd" class="external-link"><code>vignettes/airr_compatibility.Rmd</code></a></small>
      <div class="hidden name"><code>airr_compatibility.Rmd</code></div>

    </div>

    
    
<div class="section level2">
<h2 id="introduction">1. Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
</h2>
<p>The Adaptive Immune Receptor Repertoire Community (AIRR) is a large
collaborative effort to estabilish community standards and tools for
AIRR-seq (VDJ in Platypus) generation, analyzing and sharing. An example
of sharing are several databases for AIRR-seq such as
<a href="http://ireceptor.irmacs.sfu.ca/" class="external-link">link iReceptor</a> and
<a href="https://vdjbase.org/" class="external-link">link VDJBase</a>. All these repositories
use a standard format for AIRR data. Recently 10x’s Cellranger was also
updated to output AIRR_rearrangements.tsv, a file complying with this
standard format.</p>
<p>Notably, the format has a key limitation for single-cell application,
as it allows for a single productive rearrangement per table row
(i.e. one receptor chain contig). Every single cell in e.g. a 10x
dataset is therefore described by 1 or more rows, depening on the number
of recovered contigs. On contrary, the Platypus VGM format puts each
cell in a single line and doubles columns identified by either “VDJ_…”
for beta or heavy chains or “VJ_…” for alpha or light chains.</p>
<p>To allow interoperability between AIRR standards and Platypus, two
compatbility functions are available: 1. PlatypusDB_VGM_to_AIRR() 2.
PlatypusDB_AIRR_to_VGM()</p>
<p>Here we show the capabilities of these by use cases.</p>
<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">Platypus</span><span class="op">)</span></code></pre></div>
</div>
<div class="section level2">
<h2 id="i-am-interested-in-a-dataset-on-platypusdb-and-would-like-to-recover-airr-compatible-output">2. “I am interested in a dataset on PlatypusDB and would like to
recover AIRR-compatible output”<a class="anchor" aria-label="anchor" href="#i-am-interested-in-a-dataset-on-platypusdb-and-would-like-to-recover-airr-compatible-output"></a>
</h2>
<p>For showcasing, we download data from T cells in the CNS of aged
mice. Analysis of this dataset is showcased in the Platypus Quickstart
vignette.</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#downloading raw VDJ data</span>
<span class="va">yermanos2021a_raw</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/PlatypusDB_fetch.html">PlatypusDB_fetch</a></span><span class="op">(</span>PlatypusDB.links <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"yermanos2021a/ALL/VDJ"</span><span class="op">)</span>,load.to.list <span class="op">=</span> <span class="cn">T</span>, load.to.enviroment <span class="op">=</span> <span class="cn">F</span><span class="op">)</span> 

<span class="co">#Cellranger AIRR compatible output can be found here:</span>
<span class="fu"><a href="https://rdrr.io/r/base/names.html" class="external-link">names</a></span><span class="op">(</span><span class="va">yermanos2021a_raw</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span><span class="op">[[</span><span class="fl">6</span><span class="op">]</span><span class="op">]</span><span class="op">)</span></code></pre></div>
<pre><code><span class="co">##  [1] "cell_id"            "clone_id"           "sequence_id"       </span>
<span class="co">##  [4] "sequence"           "sequence_aa"        "productive"        </span>
<span class="co">##  [7] "rev_comp"           "v_call"             "v_cigar"           </span>
<span class="co">## [10] "d_call"             "d_cigar"            "j_call"            </span>
<span class="co">## [13] "j_cigar"            "c_call"             "c_cigar"           </span>
<span class="co">## [16] "sequence_alignment" "germline_alignment" "junction"          </span>
<span class="co">## [19] "junction_aa"        "junction_length"    "junction_aa_length"</span>
<span class="co">## [22] "v_sequence_start"   "v_sequence_end"     "d_sequence_start"  </span>
<span class="co">## [25] "d_sequence_end"     "j_sequence_start"   "j_sequence_end"    </span>
<span class="co">## [28] "c_sequence_start"   "c_sequence_end"     "consensus_count"   </span>
<span class="co">## [31] "duplicate_count"    "is_cell"</span></code></pre>
<p>Another way to get these file outside of R is to download RAW VDJ
.zip files from PlatypusDB. Check these for all datasets
<a href="https://alexyermanos.github.io/Platypus/PlatypusDB_index.html" class="external-link">here</a>.</p>
</div>
<div class="section level2">
<h2 id="i-want-to-export-airr-compatibile-data-from-a-platypus-vgm-object">3. “I want to export AIRR-compatibile data from a Platypus VGM
object”<a class="anchor" aria-label="anchor" href="#i-want-to-export-airr-compatibile-data-from-a-platypus-vgm-object"></a>
</h2>
<p>For this the PlatypusDB_AIRR_to_VGM function is provided. It returns
AIRR compatibile tables by enriching and aggregating
airr_rearrangements.tsv files from cellranger and an input VGM</p>
<p>As the Platypus VGM does not store alignment CIGAR strings, the
Cellranger output airr_rearrangements is neccessary to fill these
columns in the final dataframe.</p>
<p>! Additional columns: While the AIRR standards specify the minimal
required columns, there is no limit to extending this format. The
VGM_to_AIRR function thereby also exports all other columns including
additional clonotyping, groupings and most importantly any present GEX
metadata.</p>
</div>
<div class="section level2">
<h2 id="use-loaded-airr_rearrangement-from-platypudb">3.1. Use loaded airr_rearrangement from PlatypuDB<a class="anchor" aria-label="anchor" href="#use-loaded-airr_rearrangement-from-platypudb"></a>
</h2>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#Downloading a VGM</span>
<span class="fu"><a href="../reference/PlatypusDB_fetch.html">PlatypusDB_fetch</a></span><span class="op">(</span>PlatypusDB.links <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"yermanos2021a//ALL"</span><span class="op">)</span>,load.to.enviroment <span class="op">=</span> <span class="cn">T</span><span class="op">)</span> </code></pre></div>
<pre><code><span class="co">## 2022-04-02 10:08:08: Starting download of yermanos2021a__VDJmatrix.RData...</span></code></pre>
<pre><code><span class="co">## 2022-04-02 10:08:08: Starting download of yermanos2021a__GEXmatrix.RData...</span></code></pre>
<pre><code><span class="co">## [1] "yermanos2021a__VDJGEXmatrix"</span></code></pre>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#Return basic AIRR table</span>
<span class="va">AIRR_out</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/PlatypusDB_VGM_to_AIRR.html">PlatypusDB_VGM_to_AIRR</a></span><span class="op">(</span><span class="va">yermanos2021a__VDJGEXmatrix</span>, 
                                   airr.rearrangements <span class="op">=</span> <span class="va">yermanos2021a_raw</span>, airr.integrate <span class="op">=</span> <span class="cn">T</span><span class="op">)</span></code></pre></div>
<pre><code><span class="co">## Order of samples in VGM is (Barcode prefix: entry in sample_id column): s1: s1 / s2: s2 / s3: s3 / s4: s4</span></code></pre>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#export</span>
<span class="fu">utils</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/utils/write.table.html" class="external-link">write.table</a></span><span class="op">(</span><span class="va">AIRR_out</span>, <span class="st">"yermanos2021a_AIRR_integrated.tsv"</span><span class="op">)</span></code></pre></div>
</div>
<div class="section level2">
<h2 id="use-local-airr_rearrangement-from-disk">3.2. Use local airr_rearrangement from disk<a class="anchor" aria-label="anchor" href="#use-local-airr_rearrangement-from-disk"></a>
</h2>
<p>This is the case when working on a local dataset. The VGM_to_AIRR
function takes file paths to airr_rearrangement.tsv files in cellranger
output directories</p>
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#Return basic AIRR table</span>
<span class="va">AIRR_out</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/PlatypusDB_VGM_to_AIRR.html">PlatypusDB_VGM_to_AIRR</a></span><span class="op">(</span><span class="va">yermanos2021a__VDJGEXmatrix</span>, 
                                   airr.rearrangements <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span>
 <span class="st">"C:/Users/PlatypusDB/yermanos2021a__VDJ_RAW/Aged.CNS.pool.3m.Tcell.S1/airr_rearrangement.tsv"</span>,
<span class="st">"C:/Users/PlatypusDB/yermanos2021a__VDJ_RAW/Aged.CNS.pool.12m.Tcell.S2/airr_rearrangement.tsv"</span>,
<span class="st">"C:/Users/PlatypusDB/yermanos2021a__VDJ_RAW/Aged.CNS.pool.18m.Tcell.S3/airr_rearrangement.tsv"</span>,
<span class="st">"C:/Users/PlatypusDB/yermanos2021a__VDJ_RAW/Aged.CNS.single.18m.Tcell.S4/airr_rearrangement.tsv"</span><span class="op">)</span>,
                                   airr.integrate <span class="op">=</span> <span class="cn">T</span><span class="op">)</span></code></pre></div>
<pre><code><span class="co">## Order of samples in VGM is (Barcode prefix: entry in sample_id column): s1: s1 / s2: s2 / s3: s3 / s4: s4</span></code></pre>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#export</span>
<span class="fu">utils</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/utils/write.table.html" class="external-link">write.table</a></span><span class="op">(</span><span class="va">AIRR_out</span>, <span class="st">"yermanos2021a_AIRR_integrated.tsv"</span><span class="op">)</span></code></pre></div>
</div>
<div class="section level2">
<h2 id="append-platypus-vgm-columns-to-airr-output">3.3. Append Platypus VGM columns to AIRR output<a class="anchor" aria-label="anchor" href="#append-platypus-vgm-columns-to-airr-output"></a>
</h2>
<p>VDJ and GEX.features.to.append default to “none”. They accept
character vectors of column names to append to the AIRR output and, in
case of GEX.features.to.append, also Gene names, which are passed onto
Seurat::FetchData() In the example below, we set both to “all”</p>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#Return basic AIRR table</span>
<span class="va">AIRR_out</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/PlatypusDB_VGM_to_AIRR.html">PlatypusDB_VGM_to_AIRR</a></span><span class="op">(</span><span class="va">yermanos2021a__VDJGEXmatrix</span>, 
                                   airr.rearrangements <span class="op">=</span> <span class="va">yermanos2021a_raw</span>,
                                   airr.integrate <span class="op">=</span> <span class="cn">T</span>,
                                   VDJ.features.to.append <span class="op">=</span> <span class="st">"all"</span>,
                                   GEX.features.to.append <span class="op">=</span> <span class="st">"all"</span><span class="op">)</span></code></pre></div>
<pre><code><span class="co">## Order of samples in VGM is (Barcode prefix: entry in sample_id column): s1: s1 / s2: s2 / s3: s3 / s4: s4</span></code></pre>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/names.html" class="external-link">names</a></span><span class="op">(</span><span class="va">AIRR_out</span><span class="op">)</span></code></pre></div>
<pre><code><span class="co">##  [1] "barcode"             "cell_id"             "clone_id"           </span>
<span class="co">##  [4] "sequence_id"         "sequence"            "sequence_aa"        </span>
<span class="co">##  [7] "productive"          "rev_comp"            "v_call"             </span>
<span class="co">## [10] "v_cigar"             "d_call"              "d_cigar"            </span>
<span class="co">## [13] "j_call"              "j_cigar"             "c_call"             </span>
<span class="co">## [16] "c_cigar"             "sequence_alignment"  "germline_alignment" </span>
<span class="co">## [19] "junction"            "junction_aa"         "junction_length"    </span>
<span class="co">## [22] "junction_aa_length"  "v_sequence_start"    "v_sequence_end"     </span>
<span class="co">## [25] "d_sequence_start"    "d_sequence_end"      "j_sequence_start"   </span>
<span class="co">## [28] "j_sequence_end"      "c_sequence_start"    "c_sequence_end"     </span>
<span class="co">## [31] "consensus_count"     "duplicate_count"     "is_cell"            </span>
<span class="co">## [34] "sample_id"           "celltype"            "VDJ_chain_contig"   </span>
<span class="co">## [37] "VJ_chain_contig"     "orig_barcode"        "FB_assignment"      </span>
<span class="co">## [40] "group_id"            "clonotype_id_10x"    "celltype.1"         </span>
<span class="co">## [43] "clonotype_frequency" "specifity"           "affinity"           </span>
<span class="co">## [46] "GEX_available"       "orig.ident"          "orig_barcode_GEX"   </span>
<span class="co">## [49] "seurat_clusters"     "PC_1"                "PC_2"               </span>
<span class="co">## [52] "UMAP_1"              "UMAP_2"              "tSNE_1"             </span>
<span class="co">## [55] "tSNE_2"              "batch_id"            "clonotype_id"       </span>
<span class="co">## [58] "nCount_RNA"          "nFeature_RNA"        "percent.mt"         </span>
<span class="co">## [61] "RNA_snn_res.0.5"</span></code></pre>
<p>GEX and VDJ columns have been added to the AIRR output. Given the
AIRR data structure entries on a cell level are duplicated in two rows
(if that cell contained 2 V(D)J chains).</p>
<p>To give an example:</p>
VGM FORMAT
<table class="table">
<tr>
<th>
barcode
</th>
<td>
VDJ_chain_contig
</td>
<td>
VJ_chain_contig
</td>
<td>
seurat_clusters
</td>
</tr>
<tr>
<th>
Cell-1
</th>
<th>
Contig-1
</th>
<th>
Contig-4
</th>
<th>
2
</th>
</tr>
<tr>
<th>
Cell-2
</th>
<th>
Contig-2
</th>
<th>
Contig-5
</th>
<th>
1
</th>
</tr>
<tr>
<th>
Cell-3
</th>
<th>
Contig-3
</th>
<th>
Contig-6
</th>
<th>
5
</th>
</tr>
</table>
AIRR FORMAT
<table class="table">
<tr>
<th>
barcode
</th>
<td>
sequence_id
</td>
<td>
seurat_clusters
</td>
</tr>
<tr>
<th>
Cell-1
</th>
<th>
Contig-1
</th>
<th>
2
</th>
</tr>
<tr>
<th>
Cell-2
</th>
<th>
Contig-2
</th>
<th>
1
</th>
</tr>
<tr>
<th>
Cell-3
</th>
<th>
Contig-3
</th>
<th>
5
</th>
</tr>
<tr>
<th>
Cell-1
</th>
<th>
Contig-4
</th>
<th>
2
</th>
</tr>
<tr>
<th>
Cell-2
</th>
<th>
Contig-5
</th>
<th>
1
</th>
</tr>
<tr>
<th>
Cell-3
</th>
<th>
Contig-6
</th>
<th>
5
</th>
</tr>
</table>
</div>
<div class="section level2">
<h2 id="append-gene-expression-values-to-airr-output">3.4. Append Gene expression values to AIRR output<a class="anchor" aria-label="anchor" href="#append-gene-expression-values-to-airr-output"></a>
</h2>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#Return basic AIRR table</span>
<span class="va">AIRR_out</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/PlatypusDB_VGM_to_AIRR.html">PlatypusDB_VGM_to_AIRR</a></span><span class="op">(</span><span class="va">yermanos2021a__VDJGEXmatrix</span>, 
                                   airr.rearrangements <span class="op">=</span> <span class="va">yermanos2021a_raw</span>,
                                   airr.integrate <span class="op">=</span> <span class="cn">T</span>,
                                   GEX.features.to.append <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">"CD3E"</span>,<span class="st">"CD8A"</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<pre><code><span class="co">## Order of samples in VGM is (Barcode prefix: entry in sample_id column): s1: s1 / s2: s2 / s3: s3 / s4: s4</span></code></pre>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/names.html" class="external-link">names</a></span><span class="op">(</span><span class="va">AIRR_out</span><span class="op">)</span></code></pre></div>
<pre><code><span class="co">##  [1] "barcode"            "cell_id"            "clone_id"          </span>
<span class="co">##  [4] "sequence_id"        "sequence"           "sequence_aa"       </span>
<span class="co">##  [7] "productive"         "rev_comp"           "v_call"            </span>
<span class="co">## [10] "v_cigar"            "d_call"             "d_cigar"           </span>
<span class="co">## [13] "j_call"             "j_cigar"            "c_call"            </span>
<span class="co">## [16] "c_cigar"            "sequence_alignment" "germline_alignment"</span>
<span class="co">## [19] "junction"           "junction_aa"        "junction_length"   </span>
<span class="co">## [22] "junction_aa_length" "v_sequence_start"   "v_sequence_end"    </span>
<span class="co">## [25] "d_sequence_start"   "d_sequence_end"     "j_sequence_start"  </span>
<span class="co">## [28] "j_sequence_end"     "c_sequence_start"   "c_sequence_end"    </span>
<span class="co">## [31] "consensus_count"    "duplicate_count"    "is_cell"           </span>
<span class="co">## [34] "sample_id"          "celltype"           "VDJ_chain_contig"  </span>
<span class="co">## [37] "VJ_chain_contig"    "CD3E"               "CD8A"</span></code></pre>
</div>
<div class="section level2">
<h2 id="i-want-to-import-an-airr-table-as-a-platypus-vgm">4. “I want to import an AIRR table as a Platypus VGM”<a class="anchor" aria-label="anchor" href="#i-want-to-import-an-airr-table-as-a-platypus-vgm"></a>
</h2>
<p>For demo purposes we use a small TRB dataset from <a href="https://doi.org/10.1038/s41421-020-0168-9" class="external-link">a study of human immune
repertoires during COVID-19 infection</a>. (Wen W, Su W, Tang H et
al. Cell Discovery 2020)</p>
<p>Data of Study ID PRCJCA002413 and Sample ID “ERS3” and “ERS5” were
downloaded from IReceptor</p>
<p>The function AIRR_to_VGM offers some parameters of the
VDJ_GEX_matrix, including the re-alignment and trimming of receptor
sequences</p>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">Wen2020_VGM</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/PlatypusDB_AIRR_to_VGM.html">PlatypusDB_AIRR_to_VGM</a></span><span class="op">(</span>AIRR.input <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="st">"C:/Users/PlatypusDB/wen2020/ERS3/airr-covid-19.tsv"</span>,
                                                        <span class="st">"C:/Users/PlatypusDB/wen2020/ERS5/airr-covid-19.tsv"</span><span class="op">)</span>,
                                      VDJ.combine <span class="op">=</span> <span class="cn">T</span>,
                                      verbose <span class="op">=</span> <span class="cn">T</span>,
                                      filter.overlapping.barcodes.VDJ <span class="op">=</span> <span class="cn">T</span>,
                                      trim.and.align <span class="op">=</span> <span class="cn">T</span><span class="op">)</span></code></pre></div>
<pre><code><span class="co">## </span>
<span class="co">##  Loading in data     [1] "2022-04-02 10:08:54 CEST"</span>
<span class="co">## </span>
<span class="co">##  Local paths input detected. Loading in tables</span>
<span class="co">##  TRUST4 input format detected for sample 1. Appending extra columns for complete_vdj and consensus_count to output VGM</span>
<span class="co">##  TRUST4 input format detected for sample 2. Appending extra columns for complete_vdj and consensus_count to output VGM</span>
<span class="co">##  AIRR tables loaded     [1] "2022-04-02 10:08:55 CEST"</span>
<span class="co">## </span>
<span class="co">##  Got VDJ stats    [1] "2022-04-02 10:08:55 CEST"</span>
<span class="co">## </span>
<span class="co">##  For sample 1: 1106 cell assigned barcodes in VDJ</span>
<span class="co">##  For sample 2: 1046 cell assigned barcodes in VDJ</span>
<span class="co">##  Removed a total of 2 cells with non unique barcodes</span>
<span class="co">##  Starting VDJ barcode iteration 1 of 2...    [1] "2022-04-02 10:08:55 CEST"</span>
<span class="co">## </span>
<span class="co">##  Filtered out  0 cells with 0 chains</span>
<span class="co">##       Done with 1 of 2     [1] "2022-04-02 10:09:00 CEST"</span>
<span class="co">## </span>
<span class="co">##  Starting VDJ barcode iteration 2 of 2...    [1] "2022-04-02 10:09:00 CEST"</span>
<span class="co">## </span>
<span class="co">##  Filtered out  0 cells with 0 chains</span>
<span class="co">##       Done with 2 of 2     [1] "2022-04-02 10:09:04 CEST"</span>
<span class="co">## </span>
<span class="co">##  Done     [1] "2022-04-02 10:09:04 CEST"</span></code></pre>
<p>This VGM can now be used by Platypus functions:</p>
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">Wen2020_VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/VDJ_clonotype_v3.html">VDJ_clonotype_v3</a></span><span class="op">(</span><span class="va">Wen2020_VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, 
                                     clone.strategy <span class="op">=</span> <span class="st">"cdr3.aa"</span>,
                                     global.clonotype <span class="op">=</span> <span class="cn">F</span>,
                                     hierarchical <span class="op">=</span> <span class="st">"none"</span>, 
                                     VDJ.VJ.1chain <span class="op">=</span> <span class="cn">F</span><span class="op">)</span></code></pre></div>
<pre><code><span class="co">## Clonotyping strategy: cdr3.aa</span></code></pre>
<pre><code><span class="co">## Processing sample 1 of 2</span></code></pre>
<pre><code><span class="co">## Processing sample 2 of 2</span></code></pre>
<pre><code><span class="co">## Backing up 10x default clonotyping in columns clonotype_id_10x and clonotype_frequency_10x before updating clonotype_id and clonotype_frequency columns</span></code></pre>
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#Setting hierarchical to "none" as this dataset does not contain paired VDJ and VJ sequences (bulk AIRR-seq) and not filtering out cells with less than 2 chains</span>

<span class="co">#One sample contains only TRB, the other only TRA sequences. For plotting we choose only sample 1 with TRBs</span>
<span class="va">expansion_plot</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/VDJ_clonal_expansion.html">VDJ_clonal_expansion</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/subset.html" class="external-link">subset</a></span><span class="op">(</span><span class="va">Wen2020_VGM</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span>, <span class="va">sample_id</span> <span class="op">==</span> <span class="st">"s1"</span><span class="op">)</span>,
                     group.by <span class="op">=</span> <span class="st">"none"</span>,
                     color.by <span class="op">=</span> <span class="st">"VDJ_cgene"</span><span class="op">)</span>

<span class="va">expansion_plot</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span></code></pre></div>
<pre><code><span class="co">## [[1]]</span></code></pre>
<p><img src="airr_compatibility_files/figure-html/unnamed-chunk-8-1.png" width="672">
## 5. Conclusion</p>
<p>With more and more tools using the AIRR data commons and standards,
we aim to keep the compatibility of the Platypus package and database as
easy as possible. This will open doors for data integration from various
sources as well as the usage of Platypus on datasets not processed by
Cellranger</p>
</div>
<div class="section level2">
<h2 id="session-information">6. Session information<a class="anchor" aria-label="anchor" href="#session-information"></a>
</h2>
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/utils/sessionInfo.html" class="external-link">sessionInfo</a></span><span class="op">(</span><span class="op">)</span></code></pre></div>
<pre><code><span class="co">## R version 4.0.5 (2021-03-31)</span>
<span class="co">## Platform: x86_64-w64-mingw32/x64 (64-bit)</span>
<span class="co">## Running under: Windows 10 x64 (build 19044)</span>
<span class="co">## </span>
<span class="co">## Matrix products: default</span>
<span class="co">## </span>
<span class="co">## locale:</span>
<span class="co">## [1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   </span>
<span class="co">## [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   </span>
<span class="co">## [5] LC_TIME=German_Germany.1252    </span>
<span class="co">## </span>
<span class="co">## attached base packages:</span>
<span class="co">## [1] stats     graphics  grDevices utils     datasets  methods   base     </span>
<span class="co">## </span>
<span class="co">## other attached packages:</span>
<span class="co">##  [1] Platypus_3.3.3     SeuratObject_4.0.4 Seurat_4.1.0       forcats_0.5.1     </span>
<span class="co">##  [5] stringr_1.4.0      purrr_0.3.4        readr_2.1.2        tidyr_1.1.3       </span>
<span class="co">##  [9] tibble_3.1.2       ggplot2_3.3.5      tidyverse_1.3.1    dplyr_1.0.7       </span>
<span class="co">## </span>
<span class="co">## loaded via a namespace (and not attached):</span>
<span class="co">##   [1] readxl_1.3.1          backports_1.4.1       systemfonts_1.0.4    </span>
<span class="co">##   [4] plyr_1.8.6            igraph_1.2.6          lazyeval_0.2.2       </span>
<span class="co">##   [7] splines_4.0.5         listenv_0.8.0         scattermore_0.7      </span>
<span class="co">##  [10] digest_0.6.27         htmltools_0.5.2       fansi_0.5.0          </span>
<span class="co">##  [13] magrittr_2.0.1        memoise_2.0.1         tensor_1.5           </span>
<span class="co">##  [16] cluster_2.1.2         ROCR_1.0-11           tzdb_0.2.0           </span>
<span class="co">##  [19] globals_0.14.0        modelr_0.1.8          matrixStats_0.59.0   </span>
<span class="co">##  [22] pkgdown_2.0.2         spatstat.sparse_2.0-0 colorspace_2.0-2     </span>
<span class="co">##  [25] rvest_1.0.2           ggrepel_0.9.1         textshaping_0.3.6    </span>
<span class="co">##  [28] haven_2.4.3           xfun_0.27             crayon_1.5.0         </span>
<span class="co">##  [31] jsonlite_1.7.2        spatstat.data_2.1-2   survival_3.2-11      </span>
<span class="co">##  [34] zoo_1.8-9             glue_1.4.2            polyclip_1.10-0      </span>
<span class="co">##  [37] gtable_0.3.0          leiden_0.3.9          future.apply_1.8.1   </span>
<span class="co">##  [40] abind_1.4-5           scales_1.1.1          DBI_1.1.2            </span>
<span class="co">##  [43] miniUI_0.1.1.1        Rcpp_1.0.7            viridisLite_0.4.0    </span>
<span class="co">##  [46] xtable_1.8-4          reticulate_1.20       spatstat.core_2.2-0  </span>
<span class="co">##  [49] htmlwidgets_1.5.4     httr_1.4.2            RColorBrewer_1.1-2   </span>
<span class="co">##  [52] ellipsis_0.3.2        ica_1.0-2             farver_2.1.0         </span>
<span class="co">##  [55] pkgconfig_2.0.3       uwot_0.1.10           sass_0.4.0           </span>
<span class="co">##  [58] dbplyr_2.1.1          deldir_0.2-10         utf8_1.2.1           </span>
<span class="co">##  [61] labeling_0.4.2        tidyselect_1.1.1      rlang_0.4.10         </span>
<span class="co">##  [64] reshape2_1.4.4        later_1.2.0           munsell_0.5.0        </span>
<span class="co">##  [67] cellranger_1.1.0      tools_4.0.5           cachem_1.0.6         </span>
<span class="co">##  [70] cli_3.1.1             generics_0.1.2        broom_0.7.12         </span>
<span class="co">##  [73] ggridges_0.5.3        evaluate_0.14         fastmap_1.1.0        </span>
<span class="co">##  [76] yaml_2.2.1            ragg_1.2.1            goftest_1.2-2        </span>
<span class="co">##  [79] knitr_1.37            fs_1.5.2              fitdistrplus_1.1-6   </span>
<span class="co">##  [82] RANN_2.6.1            pbapply_1.5-0         future_1.23.0        </span>
<span class="co">##  [85] nlme_3.1-152          mime_0.11             xml2_1.3.3           </span>
<span class="co">##  [88] compiler_4.0.5        rstudioapi_0.13       plotly_4.10.0        </span>
<span class="co">##  [91] png_0.1-7             spatstat.utils_2.2-0  reprex_2.0.1         </span>
<span class="co">##  [94] bslib_0.3.1           stringi_1.7.4         highr_0.9            </span>
<span class="co">##  [97] desc_1.4.0            lattice_0.20-44       Matrix_1.3-4         </span>
<span class="co">## [100] vctrs_0.3.8           pillar_1.7.0          lifecycle_1.0.1      </span>
<span class="co">## [103] spatstat.geom_2.2-0   lmtest_0.9-38         jquerylib_0.1.4      </span>
<span class="co">## [106] RcppAnnoy_0.0.18      data.table_1.14.0     cowplot_1.1.1        </span>
<span class="co">## [109] irlba_2.3.3           httpuv_1.6.1          patchwork_1.1.1      </span>
<span class="co">## [112] R6_2.5.1              promises_1.2.0.1      KernSmooth_2.23-20   </span>
<span class="co">## [115] gridExtra_2.3         parallelly_1.30.0     codetools_0.2-18     </span>
<span class="co">## [118] MASS_7.3-54           assertthat_0.2.1      rprojroot_2.0.2      </span>
<span class="co">## [121] withr_2.4.3           sctransform_0.3.3     mgcv_1.8-36          </span>
<span class="co">## [124] parallel_4.0.5        hms_1.1.1             grid_4.0.5           </span>
<span class="co">## [127] rpart_4.1-15          rmarkdown_2.11        Rtsne_0.15           </span>
<span class="co">## [130] shiny_1.7.1           lubridate_1.8.0</span></code></pre>
</div>
  </div>

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

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

</div>



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

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

      </footer>
</div>

  


  

  </body>
</html>
