<!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>General Helpers &amp; Utilities • scCustomize</title>
<!-- 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/flatly/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="General Helpers &amp; Utilities">
<meta property="og:description" content="scCustomize">
<!-- 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">scCustomize</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">2.1.2</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
<li>
  <a href="../index.html">Getting Started</a>
</li>
<li>
  <a href="../articles/Installation.html">Install</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
    Vignettes
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
<li class="dropdown-header">Plotting Vignettes</li>
    <li>
      <a href="../articles/Gene_Expression_Plotting.html">Plotting #1: General Analysis Plots</a>
    </li>
    <li>
      <a href="../articles/QC_Plots.html">Plotting #2: QC Plots</a>
    </li>
    <li>
      <a href="../articles/Sequencing_QC_Plots.html">Plotting #3: Sequencing QC Plots/Analysis</a>
    </li>
    <li>
      <a href="../articles/Iterative_Plotting.html">Plotting #4: Iterative Plotting Functions</a>
    </li>
    <li>
      <a href="../articles/Color_Palettes.html">Customized Color Palettes &amp; Themes</a>
    </li>
    <li class="divider">
    </li>
<li class="dropdown-header">Helpers &amp; Utilities</li>
    <li>
      <a href="../articles/Helpers_and_Utilities.html">General Helpers &amp; Utilities</a>
    </li>
    <li>
      <a href="../articles/Read_and_Write_Functions.html">Read &amp; Write Data Functions</a>
    </li>
    <li>
      <a href="../articles/Object_Conversion.html">Object/Assay Format Conversion</a>
    </li>
    <li>
      <a href="../articles/Markers_and_Cluster_Annotation.html">Marker Identification &amp; Cluster Annotation Helpers</a>
    </li>
    <li>
      <a href="../articles/Statistics.html">Statistics Functions</a>
    </li>
    <li>
      <a href="../articles/Update_Gene_Symbols.html">Updating Gene Symbols</a>
    </li>
    <li>
      <a href="../articles/Misc_Functions.html">Misc Functions</a>
    </li>
    <li class="divider">
    </li>
<li class="dropdown-header">Other Package Interactivity/Functions</li>
    <li>
      <a href="../articles/LIGER_Functions.html">LIGER Plotting &amp; Functionality</a>
    </li>
    <li>
      <a href="../articles/Cell_Bender_Functions.html">Cell Bender Functionality &amp; Plotting</a>
    </li>
  </ul>
</li>
<li>
  <a href="../news/index.html">News/Changelog</a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li>
  <a href="../articles/FAQ.html">FAQ</a>
</li>
      </ul>
<ul class="nav navbar-nav navbar-right">
<li>
  <a href="https://github.com/samuel-marsh/scCustomize/" class="external-link">
    <span class="fab fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
</div>
<!--/.nav-collapse -->
  </div>
<!--/.container -->
</div>
<!--/.navbar -->

      

      </header><script src="Helpers_and_Utilities_files/kePrint-0.0.1/kePrint.js"></script><link href="Helpers_and_Utilities_files/lightable-0.0.1/lightable.css" rel="stylesheet">
<div class="row">
  <div class="col-md-9 contents">
    <div class="page-header toc-ignore">
      <h1 data-toc-skip>General Helpers &amp; Utilities</h1>
            
            <h4 data-toc-skip class="date">Compiled: February 28,
2024</h4>
      
      <small class="dont-index">Source: <a href="https://github.com/samuel-marsh/scCustomize/blob/HEAD/vignettes/articles/Helpers_and_Utilities.Rmd" class="external-link"><code>vignettes/articles/Helpers_and_Utilities.Rmd</code></a></small>
      <div class="hidden name"><code>Helpers_and_Utilities.Rmd</code></div>

    </div>

    
    
<hr>
<style>
p.caption {
  font-size: 0.9em;
}
</style>
<div class="section level2">
<h2 id="general-helperutility-functions">General Helper/Utility Functions<a class="anchor" aria-label="anchor" href="#general-helperutility-functions"></a>
</h2>
<p>scCustomize has several helper functions to simplify/streamline
common tasks in scRNA-seq analysis. Let’s load packages and raw data
object for this tutorial.</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Load Packages</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://ggplot2.tidyverse.org" class="external-link">ggplot2</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://magrittr.tidyverse.org" class="external-link">magrittr</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://patchwork.data-imaginist.com" class="external-link">patchwork</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://satijalab.org/seurat" class="external-link">Seurat</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/samuel-marsh/scCustomize" class="external-link">scCustomize</a></span><span class="op">)</span></span>
<span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu">pbmc3k.SeuratData</span><span class="fu">::</span><span class="va"><a href="https://rdrr.io/pkg/pbmc3k.SeuratData/man/pbmc3k.html" class="external-link">pbmc3k</a></span></span></code></pre></div>
<p>We’ll add some random meta data variables to pbmc data form use in
this vignette</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">pbmc</span><span class="op">$</span><span class="va">sample_id</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/sample.html" class="external-link">sample</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="st">"sample1"</span>, <span class="st">"sample2"</span>, <span class="st">"sample3"</span>, <span class="st">"sample4"</span>, <span class="st">"sample5"</span>, <span class="st">"sample6"</span><span class="op">)</span>, size <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/nrow.html" class="external-link">ncol</a></span><span class="op">(</span><span class="va">pbmc</span><span class="op">)</span>,</span>
<span>    replace <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="va">pbmc</span><span class="op">$</span><span class="va">batch</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/sample.html" class="external-link">sample</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="st">"Batch1"</span>, <span class="st">"Batch2"</span><span class="op">)</span>, size <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/nrow.html" class="external-link">ncol</a></span><span class="op">(</span><span class="va">pbmc</span><span class="op">)</span>, replace <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<div class="section level3">
<h3 id="add-mitochondrial-ribosomal-percentages">Add Mitochondrial &amp; Ribosomal Percentages<a class="anchor" aria-label="anchor" href="#add-mitochondrial-ribosomal-percentages"></a>
</h3>
<p>As discussed in <a href="https://samuel-marsh.github.io/scCustomize/articles/QC_Plots.html">QC
Plotting vignette</a> one the first steps after creating object if often
to calculate and add mitochondrial and ribosomal count percentages per
cell/nucleus.</p>
<div class="section level4">
<h4 id="add_mito_ribo">
<code>Add_Mito_Ribo()</code><a class="anchor" aria-label="anchor" href="#add_mito_ribo"></a>
</h4>
<p>scCustomize contains easy wrapper function to automatically add both
Mitochondrial and Ribosomal percentages to meta.data slot. If you are
using mouse, human, marmoset, zebrafish, rat, drosophila, or rhesus
macaque data all you need to do is specify the <code>species</code>
parameter.</p>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># These defaults can be run just by providing accepted species name</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Mito_Ribo.html">Add_Mito_Ribo</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, species <span class="op">=</span> <span class="st">"human"</span><span class="op">)</span></span></code></pre></div>
<p>To view list of accepted values for default species names simply set
<code>list_species_names = TRUE</code>.</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/Add_Mito_Ribo.html">Add_Mito_Ribo</a></span><span class="op">(</span>list_species_names <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<table class="table table table-bordered table-condensed table-responsive table-striped" style="margin-left: auto; margin-right: auto;">
<thead><tr>
<th style="text-align:left;">
</th>
<th style="text-align:left;">
Mouse_Options
</th>
<th style="text-align:left;">
Human_Options
</th>
<th style="text-align:left;">
Marmoset_Options
</th>
<th style="text-align:left;">
Zebrafish_Options
</th>
<th style="text-align:left;">
Rat_Options
</th>
<th style="text-align:left;">
Drosophila_Options
</th>
<th style="text-align:left;">
Macaque_Options
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
1
</td>
<td style="text-align:left;">
Mouse
</td>
<td style="text-align:left;">
Human
</td>
<td style="text-align:left;">
Marmoset
</td>
<td style="text-align:left;">
Zebrafish
</td>
<td style="text-align:left;">
Rat
</td>
<td style="text-align:left;">
Drosophila
</td>
<td style="text-align:left;">
Macaque
</td>
</tr>
<tr>
<td style="text-align:left;">
2
</td>
<td style="text-align:left;">
mouse
</td>
<td style="text-align:left;">
human
</td>
<td style="text-align:left;">
marmoset
</td>
<td style="text-align:left;">
zebrafish
</td>
<td style="text-align:left;">
rat
</td>
<td style="text-align:left;">
drosophila
</td>
<td style="text-align:left;">
macaque
</td>
</tr>
<tr>
<td style="text-align:left;">
3
</td>
<td style="text-align:left;">
Ms
</td>
<td style="text-align:left;">
Hu
</td>
<td style="text-align:left;">
CJ
</td>
<td style="text-align:left;">
DR
</td>
<td style="text-align:left;">
RN
</td>
<td style="text-align:left;">
DM
</td>
<td style="text-align:left;">
Rhesus
</td>
</tr>
<tr>
<td style="text-align:left;">
4
</td>
<td style="text-align:left;">
ms
</td>
<td style="text-align:left;">
hu
</td>
<td style="text-align:left;">
Cj
</td>
<td style="text-align:left;">
Dr
</td>
<td style="text-align:left;">
Rn
</td>
<td style="text-align:left;">
Dm
</td>
<td style="text-align:left;">
macaca
</td>
</tr>
<tr>
<td style="text-align:left;">
5
</td>
<td style="text-align:left;">
Mm
</td>
<td style="text-align:left;">
Hs
</td>
<td style="text-align:left;">
cj
</td>
<td style="text-align:left;">
dr
</td>
<td style="text-align:left;">
rn
</td>
<td style="text-align:left;">
dm
</td>
<td style="text-align:left;">
mmulatta
</td>
</tr>
<tr>
<td style="text-align:left;">
6
</td>
<td style="text-align:left;">
mm
</td>
<td style="text-align:left;">
hs
</td>
<td style="text-align:left;">
NA
</td>
<td style="text-align:left;">
NA
</td>
<td style="text-align:left;">
NA
</td>
<td style="text-align:left;">
NA
</td>
<td style="text-align:left;">
NA
</td>
</tr>
</tbody>
</table>
<div class="section level5">
<h5 id="non-default-species">Non-default species<a class="anchor" aria-label="anchor" href="#non-default-species"></a>
</h5>
<p>However custom prefixes can be used for
non-human/mouse/marmoset/rat/zebrafish/drosophila/macaque species with
different annotations. Simply specify <code>species = other</code> and
supply feature lists or regex patterns for your species of interest.
<em>NOTE: If desired please submit issue on GitHub for additional
default species. Please include regex pattern or list of genes for both
mitochondrial and ribosomal genes and I will add additional built-in
defaults to the function.</em></p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Using gene name patterns</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Mito_Ribo.html">Add_Mito_Ribo</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, species <span class="op">=</span> <span class="st">"other"</span>, mito_pattern <span class="op">=</span> <span class="st">"regexp_pattern"</span>, ribo_pattern <span class="op">=</span> <span class="st">"regexp_pattern"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Using feature name lists</span></span>
<span><span class="va">mito_gene_list</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"gene1"</span>, <span class="st">"gene2"</span>, <span class="st">"etc"</span><span class="op">)</span></span>
<span><span class="va">ribo_gene_list</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"gene1"</span>, <span class="st">"gene2"</span>, <span class="st">"etc"</span><span class="op">)</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Mito_Ribo.html">Add_Mito_Ribo</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, species <span class="op">=</span> <span class="st">"other"</span>, mito_features <span class="op">=</span> <span class="va">mito_gene_list</span>, ribo_features <span class="op">=</span> <span class="va">ribo_gene_list</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Using combination of gene lists and gene name patterns</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Mito_Ribo.html">Add_Mito_Ribo</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, species <span class="op">=</span> <span class="st">"Human"</span>, mito_features <span class="op">=</span> <span class="va">mito_gene_list</span>, ribo_pattern <span class="op">=</span> <span class="st">"regexp_pattern"</span><span class="op">)</span></span></code></pre></div>
</div>
</div>
<div class="section level4">
<h4 id="warning-messages">Warning Messages<a class="anchor" aria-label="anchor" href="#warning-messages"></a>
</h4>
<p>The added benefit of <code>Add_Mito_Ribo</code> is that it will
return informative warnings if no Mitochondrial or Ribosomal features
are found using the current species, features, or pattern
specification.</p>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># For demonstration purposes we can set `species = mouse` for this object of human cells</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Mito_Ribo.html">Add_Mito_Ribo</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, species <span class="op">=</span> <span class="st">"mouse"</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## <span style="color: #BBBB00; font-weight: bold;">Error</span><span style="font-weight: bold;"> in `Add_Mito_Ribo()`:</span></span></span>
<span><span class="co">## <span style="color: #BBBB00;">!</span> No Mito or Ribo features found in object using patterns/feature list</span></span>
<span><span class="co">##   provided.</span></span>
<span><span class="co">## <span style="color: #00BBBB;">ℹ</span> Please check pattern/feature list and/or gene names in object.</span></span></code></pre>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Or if providing custom patterns/lists and features not found</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Mito_Ribo.html">Add_Mito_Ribo</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, species <span class="op">=</span> <span class="st">"other"</span>, mito_pattern <span class="op">=</span> <span class="st">"^MT-"</span>, ribo_pattern <span class="op">=</span> <span class="st">"BAD_PATTERN"</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Warning: No Ribo features found in object using pattern/feature list provided.</span></span>
<span><span class="co">## <span style="color: #00BBBB;">ℹ</span> No column will be added to meta.data.</span></span></code></pre>
<p><code>Add_Mito_Ribo</code> will also return warnings if columns are
already present in <code>@meta.data</code> slot and prompt you to
provide override if you want to run the function.</p>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Mito_Ribo.html">Add_Mito_Ribo</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, species <span class="op">=</span> <span class="st">"human"</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## <span style="color: #BBBB00; font-weight: bold;">Error</span><span style="font-weight: bold;"> in `Add_Mito_Ribo()`:</span></span></span>
<span><span class="co">## <span style="color: #BBBB00;">!</span> Columns with <span style="color: #0000BB;">"percent_mito"</span> and/or <span style="color: #0000BB;">"percent_ribo"</span> already present in</span></span>
<span><span class="co">##   meta.data slot.</span></span>
<span><span class="co">## <span style="color: #00BBBB;">ℹ</span> *To run function and overwrite columns set parameter `overwrite = TRUE` or</span></span>
<span><span class="co">##   change respective `mito_name`, `ribo_name`, and/or `mito_ribo_name`*</span></span></code></pre>
</div>
<div class="section level4">
<h4 id="liger-objects-add_mito_ribo">LIGER Objects: <code>Add_Mito_Ribo()</code><a class="anchor" aria-label="anchor" href="#liger-objects-add_mito_ribo"></a>
</h4>
<p>scCustomize <code>Add_Mito_Ribo</code> also works seemlessly with
LIGER objects.</p>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">liger_obj</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Mito_Ribo.html">Add_Mito_Ribo</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">liger_obj</span>, species <span class="op">=</span> <span class="st">"human"</span><span class="op">)</span></span></code></pre></div>
</div>
</div>
<div class="section level3">
<h3 id="add-cell-complexitynovelty-qc-metrics">Add Cell Complexity/Novelty QC Metrics<a class="anchor" aria-label="anchor" href="#add-cell-complexitynovelty-qc-metrics"></a>
</h3>
<p>In addition to metrics like number of features and UMIs it can often
be helpful to analyze the complexity of expression within a single cell.
scCustomize provides functions to add two of these metrics to meta
data.</p>
<div class="section level4">
<h4 id="cell-complexity-log10nfeature-log10ncount">Cell Complexity (log10(nFeature) / log10(nCount))<a class="anchor" aria-label="anchor" href="#cell-complexity-log10nfeature-log10ncount"></a>
</h4>
<p>scCustomize contains easy shortcut function to add a measure of cell
complexity/novelty that can sometimes be useful to filter low quality
cells. The metric is calculated by calculating the result of
log10(nFeature) / log10(nCount).</p>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># These defaults can be run just by providing accepted species name</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Cell_Complexity.html">Add_Cell_Complexity</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span><span class="op">)</span></span></code></pre></div>
<p><em>NOTE: The function also works seemlessly with LIGER
objects.</em></p>
</div>
<div class="section level4">
<h4 id="add-top-percent-expression-qc-metric">Add Top Percent Expression QC Metric<a class="anchor" aria-label="anchor" href="#add-top-percent-expression-qc-metric"></a>
</h4>
<p>Additionally, (or alternatively), scCustomize contains another metric
of complexity which is the top percent expression. The user supplies an
integer value for <code>num_top_genes</code> (default is 50) which
species the number of genes and the function returns percentage of
counts occupied by top XX genes in each cell.</p>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># These defaults can be run just by providing accepted species name</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Top_Gene_Pct_Seurat.html">Add_Top_Gene_Pct_Seurat</a></span><span class="op">(</span>seurat_object <span class="op">=</span> <span class="va">pbmc</span>, num_top_genes <span class="op">=</span> <span class="fl">50</span><span class="op">)</span></span></code></pre></div>
</div>
</div>
<div class="section level3">
<h3 id="add-all-cell-qc-metrics-with-single-function">Add All Cell QC Metrics with Single Function<a class="anchor" aria-label="anchor" href="#add-all-cell-qc-metrics-with-single-function"></a>
</h3>
<p>To simplify the process of adding cell QC metrics scCustomize
contains a wrapper function which can be customized to add all or some
of the available QC metrics. The default parameters of the function
<code>Add_Cell_QC_Metrics</code> will add:</p>
<ul>
<li>Mitochondrial and Ribosomal Percentages (default and custom
species).</li>
<li>Cell Complexity (log10(nFeature) / log10(nCount).</li>
<li>Top XX Gene Percentage.</li>
<li>Percentage of counts for IEG (human and mouse only).</li>
<li>OXPHOS, APOP, and DNA Repair pathways (supported species only).</li>
<li>Cell Cycle Scoring (Human only).</li>
</ul>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Cell_QC_Metrics.html">Add_Cell_QC_Metrics</a></span><span class="op">(</span>seurat_object <span class="op">=</span> <span class="va">pbmc</span>, species <span class="op">=</span> <span class="st">"human"</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="meta-data">Meta Data<a class="anchor" aria-label="anchor" href="#meta-data"></a>
</h3>
<p>scCustomize contains a set of functions to aid in use of meta data
both within and outside of objects.</p>
<div class="section level4">
<h4 id="extract-all-meta-data-cell-level-from-object">Extract all meta data (cell-level) from object<a class="anchor" aria-label="anchor" href="#extract-all-meta-data-cell-level-from-object"></a>
</h4>
<p><code><a href="../reference/Fetch_Meta.html">Fetch_Meta()</a></code> functions as simple getter function to
obtain meta data from object and return data.frame.</p>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">meta_data</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Fetch_Meta.html">Fetch_Meta</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span><span class="op">)</span></span>
<span></span>
<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">meta_data</span>, <span class="fl">10</span><span class="op">)</span></span></code></pre></div>
<table class="table table table-bordered table-condensed table-responsive table-striped" style="margin-left: auto; margin-right: auto;">
<thead><tr>
<th style="text-align:left;">
</th>
<th style="text-align:left;">
orig.ident
</th>
<th style="text-align:right;">
nCount_RNA
</th>
<th style="text-align:right;">
nFeature_RNA
</th>
<th style="text-align:left;">
seurat_annotations
</th>
<th style="text-align:left;">
sample_id
</th>
<th style="text-align:left;">
batch
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
AAACATACAACCAC
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:right;">
2419
</td>
<td style="text-align:right;">
779
</td>
<td style="text-align:left;">
Memory CD4 T
</td>
<td style="text-align:left;">
sample3
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
AAACATTGAGCTAC
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:right;">
4903
</td>
<td style="text-align:right;">
1352
</td>
<td style="text-align:left;">
B
</td>
<td style="text-align:left;">
sample5
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
AAACATTGATCAGC
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:right;">
3147
</td>
<td style="text-align:right;">
1129
</td>
<td style="text-align:left;">
Memory CD4 T
</td>
<td style="text-align:left;">
sample4
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
AAACCGTGCTTCCG
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:right;">
2639
</td>
<td style="text-align:right;">
960
</td>
<td style="text-align:left;">
CD14+ Mono
</td>
<td style="text-align:left;">
sample1
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
AAACCGTGTATGCG
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:right;">
980
</td>
<td style="text-align:right;">
521
</td>
<td style="text-align:left;">
NK
</td>
<td style="text-align:left;">
sample4
</td>
<td style="text-align:left;">
Batch1
</td>
</tr>
<tr>
<td style="text-align:left;">
AAACGCACTGGTAC
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:right;">
2163
</td>
<td style="text-align:right;">
781
</td>
<td style="text-align:left;">
Memory CD4 T
</td>
<td style="text-align:left;">
sample6
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
AAACGCTGACCAGT
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:right;">
2175
</td>
<td style="text-align:right;">
782
</td>
<td style="text-align:left;">
CD8 T
</td>
<td style="text-align:left;">
sample3
</td>
<td style="text-align:left;">
Batch1
</td>
</tr>
<tr>
<td style="text-align:left;">
AAACGCTGGTTCTT
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:right;">
2260
</td>
<td style="text-align:right;">
790
</td>
<td style="text-align:left;">
CD8 T
</td>
<td style="text-align:left;">
sample4
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
AAACGCTGTAGCCA
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:right;">
1275
</td>
<td style="text-align:right;">
532
</td>
<td style="text-align:left;">
Naive CD4 T
</td>
<td style="text-align:left;">
sample6
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
AAACGCTGTTTCTG
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:right;">
1103
</td>
<td style="text-align:right;">
550
</td>
<td style="text-align:left;">
FCGR3A+ Mono
</td>
<td style="text-align:left;">
sample3
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
</tbody>
</table>
</div>
<div class="section level4">
<h4 id="extract-sample-level-meta-data-from-object">Extract sample-level meta data from object<a class="anchor" aria-label="anchor" href="#extract-sample-level-meta-data-from-object"></a>
</h4>
<p>While cell-level meta data is helpful in some situations often all
that is required is sample-level meta data. This can easily be extracted
and filtered using <code><a href="../reference/Extract_Sample_Meta.html">Extract_Sample_Meta()</a></code>.</p>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">sample_meta</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Extract_Sample_Meta.html">Extract_Sample_Meta</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, sample_name <span class="op">=</span> <span class="st">"sample_id"</span><span class="op">)</span></span></code></pre></div>
<table class="table table table-bordered table-condensed table-responsive table-striped" style="margin-left: auto; margin-right: auto;">
<thead><tr>
<th style="text-align:left;">
</th>
<th style="text-align:left;">
orig.ident
</th>
<th style="text-align:left;">
seurat_annotations
</th>
<th style="text-align:left;">
sample_id
</th>
<th style="text-align:left;">
batch
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
1
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:left;">
CD14+ Mono
</td>
<td style="text-align:left;">
sample1
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
2
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:left;">
NA
</td>
<td style="text-align:left;">
sample2
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
3
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:left;">
Memory CD4 T
</td>
<td style="text-align:left;">
sample3
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
4
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:left;">
Memory CD4 T
</td>
<td style="text-align:left;">
sample4
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
5
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:left;">
B
</td>
<td style="text-align:left;">
sample5
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
6
</td>
<td style="text-align:left;">
pbmc3k
</td>
<td style="text-align:left;">
Memory CD4 T
</td>
<td style="text-align:left;">
sample6
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
</tbody>
</table>
<div class="section level5">
<h5 id="remove-columns-that-are-not-relevant-on-sample-level">Remove columns that are not relevant on sample level<a class="anchor" aria-label="anchor" href="#remove-columns-that-are-not-relevant-on-sample-level"></a>
</h5>
<p>As you can see by default <code>Extract_Sample_Meta</code> removes a
default set of columns (see documentation) which do not provide
meaningful sample-level information (e.g., nFeature_RNA). However, you
may want to remove other columns too. This can be achieved using either
positive or negative selection using <code>variables_include</code> or
<code>variables_exclude</code> parameters.</p>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">sample_meta</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Extract_Sample_Meta.html">Extract_Sample_Meta</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, sample_name <span class="op">=</span> <span class="st">"sample_id"</span>, variables_exclude <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">"nFeature_RNA"</span>,</span>
<span>    <span class="st">"nCount_RNA"</span>, <span class="st">"seurat_annotations"</span>, <span class="st">"orig.ident"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<table class="table table table-bordered table-condensed table-responsive table-striped" style="margin-left: auto; margin-right: auto;">
<thead><tr>
<th style="text-align:left;">
</th>
<th style="text-align:left;">
sample_id
</th>
<th style="text-align:left;">
batch
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
1
</td>
<td style="text-align:left;">
sample1
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
2
</td>
<td style="text-align:left;">
sample2
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
3
</td>
<td style="text-align:left;">
sample3
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
4
</td>
<td style="text-align:left;">
sample4
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
5
</td>
<td style="text-align:left;">
sample5
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
<tr>
<td style="text-align:left;">
6
</td>
<td style="text-align:left;">
sample6
</td>
<td style="text-align:left;">
Batch2
</td>
</tr>
</tbody>
</table>
</div>
<div class="section level5">
<h5 id="merge-with-sample-level-summary-statistic-data">Merge with sample-level summary statistic data<a class="anchor" aria-label="anchor" href="#merge-with-sample-level-summary-statistic-data"></a>
</h5>
<p>While some original number columns are not valid at sample-level it
can be valuable to get summary information for those variables. This can
be achieved by merging outputs with <code>Median_Stats</code>
function.</p>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">sample_meta</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Extract_Sample_Meta.html">Extract_Sample_Meta</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, sample_name <span class="op">=</span> <span class="st">"sample_id"</span>, variables_exclude <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">"nFeature_RNA"</span>,</span>
<span>    <span class="st">"nCount_RNA"</span>, <span class="st">"seurat_annotations"</span>, <span class="st">"orig.ident"</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="va">sample_median</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Median_Stats.html">Median_Stats</a></span><span class="op">(</span>seurat_object <span class="op">=</span> <span class="va">pbmc</span>, group_by_var <span class="op">=</span> <span class="st">"sample_id"</span><span class="op">)</span></span>
<span></span>
<span><span class="va">sample_merged</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html" class="external-link">right_join</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">sample_meta</span>, y <span class="op">=</span> <span class="va">sample_median</span><span class="op">)</span></span></code></pre></div>
<table class="table table table-bordered table-condensed table-responsive table-striped" style="margin-left: auto; margin-right: auto;">
<thead><tr>
<th style="text-align:left;">
</th>
<th style="text-align:left;">
sample_id
</th>
<th style="text-align:left;">
batch
</th>
<th style="text-align:right;">
Median_nCount_RNA
</th>
<th style="text-align:right;">
Median_nFeature_RNA
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
1
</td>
<td style="text-align:left;">
sample1
</td>
<td style="text-align:left;">
Batch2
</td>
<td style="text-align:right;">
2237.0
</td>
<td style="text-align:right;">
830.0
</td>
</tr>
<tr>
<td style="text-align:left;">
2
</td>
<td style="text-align:left;">
sample2
</td>
<td style="text-align:left;">
Batch2
</td>
<td style="text-align:right;">
2223.0
</td>
<td style="text-align:right;">
810.0
</td>
</tr>
<tr>
<td style="text-align:left;">
3
</td>
<td style="text-align:left;">
sample3
</td>
<td style="text-align:left;">
Batch2
</td>
<td style="text-align:right;">
2197.0
</td>
<td style="text-align:right;">
816.0
</td>
</tr>
<tr>
<td style="text-align:left;">
4
</td>
<td style="text-align:left;">
sample4
</td>
<td style="text-align:left;">
Batch2
</td>
<td style="text-align:right;">
2234.5
</td>
<td style="text-align:right;">
815.5
</td>
</tr>
<tr>
<td style="text-align:left;">
5
</td>
<td style="text-align:left;">
sample5
</td>
<td style="text-align:left;">
Batch2
</td>
<td style="text-align:right;">
2110.0
</td>
<td style="text-align:right;">
797.5
</td>
</tr>
<tr>
<td style="text-align:left;">
6
</td>
<td style="text-align:left;">
sample6
</td>
<td style="text-align:left;">
Batch2
</td>
<td style="text-align:right;">
2168.0
</td>
<td style="text-align:right;">
820.0
</td>
</tr>
<tr>
<td style="text-align:left;">
7
</td>
<td style="text-align:left;">
Totals (All Cells)
</td>
<td style="text-align:left;">
NA
</td>
<td style="text-align:right;">
2196.0
</td>
<td style="text-align:right;">
816.0
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section level4">
<h4 id="add-sample-level-meta-data-to-object">Add sample-level meta data to object<a class="anchor" aria-label="anchor" href="#add-sample-level-meta-data-to-object"></a>
</h4>
<p>scCustomize provides easy function to add sample-level meta data to
object without the need to first convert it to cell-level meta data.
This makes adding meta data from summary or supplemental tables to cell
level object data very easy.</p>
<p>In order to add meta data you will need to specify:</p>
<ul>
<li>Seurat Object with <code>@meta.data</code> column that matches
sample-level meta data (often “orig.ident”).<br>
</li>
<li>Sample-level meta data/file. Can be either a data.frame or tibble in
environment or a path to file to read.<br>
</li>
<li>Joining parameters. Define the column names the specify matching
information in Seurat object and sample-level meta data.</li>
</ul>
<p>This is example command:</p>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">obj</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Add_Sample_Meta.html">Add_Sample_Meta</a></span><span class="op">(</span>seurat_object <span class="op">=</span> <span class="va">obj</span>, meta_data <span class="op">=</span> <span class="va">sample_meta</span>, join_by_seurat <span class="op">=</span> <span class="st">"orig.ident"</span>,</span>
<span>    join_by_meta <span class="op">=</span> <span class="st">"sample_id"</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="add-feature-meta-data">Add feature meta data<a class="anchor" aria-label="anchor" href="#add-feature-meta-data"></a>
</h4>
<p>Starting in Seurat V5 each assay now possess it’s own meta.data slot
which is feature-level meta data. During course of normal analysis this
is where information on variable features is stored. However, we can
also use it to store alternate feature names, in most cases this is
Ensembl IDs matching the symbols used in object creation/analysis.</p>
<p>scCustomize provides the function <code><a href="../reference/Add_Alt_Feature_ID.html">Add_Alt_Feature_ID()</a></code>
to automatically match and add these features using the same files used
in object creation. Users only need to supply either path to the
features.tsv.gz file or the hdf5 file produced from Cell Ranger
output.</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" tabindex="-1"></a><span class="co"># Using features.tsv.gz file</span></span>
<span id="cb21-2"><a href="#cb21-2" tabindex="-1"></a>obj <span class="ot">&lt;-</span> <span class="fu">Add_Alt_Feature_ID</span>(<span class="at">seurat_object =</span> obj,</span>
<span id="cb21-3"><a href="#cb21-3" tabindex="-1"></a><span class="at">features_tsv =</span> <span class="st">"sample01/outs/filtered_feature_bc_matrix/features.tsv.gz"</span>, <span class="at">assay =</span> <span class="st">"RNA"</span>)</span>
<span id="cb21-4"><a href="#cb21-4" tabindex="-1"></a></span>
<span id="cb21-5"><a href="#cb21-5" tabindex="-1"></a><span class="co"># Using hdf5 file</span></span>
<span id="cb21-6"><a href="#cb21-6" tabindex="-1"></a>obj <span class="ot">&lt;-</span> <span class="fu">Add_Alt_Feature_ID</span>(<span class="at">seurat_object =</span> obj,</span>
<span id="cb21-7"><a href="#cb21-7" tabindex="-1"></a><span class="at">hdf5_file =</span> <span class="st">"sample01/outs/outs/filtered_feature_bc_matrix.h5"", assay = "</span>RNA<span class="st">")</span></span></code></pre></div>
<p><em>NOTE:</em> If using features.tsv.gz file the file from either
filtered or raw outputs can be used as they are identical.</p>
<p><em>NOTE:</em> If using hdf5 file the file from either
filtered_feature_bc or raw_feature_bc can be used as the features slot
is identical. Though it is faster to load filtered_feature_bc file due
to droplet filtering.</p>
</div>
</div>
<div class="section level3">
<h3 id="check-for-featuresgenes">Check for Features/Genes<a class="anchor" aria-label="anchor" href="#check-for-featuresgenes"></a>
</h3>
<p>scCustomize also makes forward-facing a number of utilities that are
used internally in functions but may also have utility on their own.</p>
<div class="section level4">
<h4 id="gene_present-to-check-for-features-">
<code>Gene_Present()</code> to check for features.<a class="anchor" aria-label="anchor" href="#gene_present-to-check-for-features-"></a>
</h4>
<p><code>Gene_Present</code> is fairly basic function to check if
feature exists in data. It can be used with Seurat or LIGER objects as
well as generic data formats (Matrix, data.frame, tibble).</p>
<p>In addition to some warning messages <code>Gene_Present</code>
returns a list with 3 entries when run:</p>
<ul>
<li>found_features: features found in the data.<br>
</li>
<li>bad_features: features not found in the data.<br>
</li>
<li>wrong_case_found_features: features found but in different case than
present in input gene list.
<ul>
<li><em>If <code>bad_features</code> &gt; 0 then
<code>Gene_Present</code> will convert
<code>the gene list</code>bad_features` to all upper case and to
sentence case and check against all possible features to see if wrong
case was provided.</em></li>
</ul>
</li>
</ul>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Example gene list with all examples (found genes, wrong case (lower) and misspelled (CD8A</span></span>
<span><span class="co"># forgetting to un-shift when typing 8))</span></span>
<span><span class="va">gene_input_list</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"CD14"</span>, <span class="st">"CD3E"</span>, <span class="st">"Cd4"</span>, <span class="st">"CD*A"</span><span class="op">)</span></span>
<span></span>
<span><span class="va">genes_present</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Gene_Present.html">Gene_Present</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">pbmc</span>, gene_list <span class="op">=</span> <span class="va">gene_input_list</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Warning: `Gene_Present()` was deprecated in scCustomize 2.1.0.</span></span>
<span><span class="co">## <span style="color: #00BBBB;">ℹ</span> Please use `Feature_Present()` instead.</span></span>
<span><span class="co">## <span style="color: #00BBBB;">ℹ</span> Please adjust code now to prepare for full deprecation.</span></span>
<span><span class="co">## <span style="color: #555555;">This warning is displayed once every 8 hours.</span></span></span>
<span><span class="co">## <span style="color: #555555;">Call `lifecycle::last_lifecycle_warnings()` to see where this warning was</span></span></span>
<span><span class="co">## <span style="color: #555555;">generated.</span></span></span></code></pre>
<pre><code><span><span class="co">## Warning: The following features were omitted as they were not found:</span></span>
<span><span class="co">## <span style="color: #00BBBB;">ℹ</span> <span style="color: #00BB00;">Cd4 and CD*A</span></span></span></code></pre>
<pre><code><span><span class="co">## Warning: NOTE: However, the following features were found: <span style="color: #00BB00;">CD4</span></span></span>
<span><span class="co">## <span style="color: #00BBBB;">ℹ</span> Please check intended case of features provided.</span></span></code></pre>
<p>Now let’s look at the output:</p>
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">genes_present</span></span></code></pre></div>
<pre><code><span><span class="co">## $found_features</span></span>
<span><span class="co">## [1] "CD14" "CD3E"</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $bad_features</span></span>
<span><span class="co">## [1] "Cd4"  "CD*A"</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $wrong_case_found_features</span></span>
<span><span class="co">## [1] "CD4"</span></span></code></pre>
</div>
<div class="section level4">
<h4 id="turn-warningsmessages-off-">Turn warnings/messages off.<a class="anchor" aria-label="anchor" href="#turn-warningsmessages-off-"></a>
</h4>
<p>By default <code>Gene_Present</code> has 3 sets of warnings/messages
it prints to console when it finds issues. If using the function
yourself on its own or wrapped inside your own function and you prefer
no messages each of these can be toggled using optional parameters.</p>
<ul>
<li>
<code>case_check_msg</code> prints and list of features if alternate
case features are found in data.<br>
</li>
<li>
<code>omit_warn</code> prints warning and list of all features not
found in data.<br>
</li>
<li>
<code>print_msg</code> prints message if all features in
<code>gene_list</code> are found in data.</li>
</ul>
</div>
<div class="section level4">
<h4 id="check-for-updated-gene-symbols">Check for updated gene symbols<a class="anchor" aria-label="anchor" href="#check-for-updated-gene-symbols"></a>
</h4>
<p>In order to keep run times down and support offer greater support for
offline use <code>Gene_Present</code> does not include a check for
updated gene symbols. If you’re dataset is from human cells/donors you
can simply supply the not found features from <code>Gene_Present</code>
to Seurat’s <code>UpdateSymbolList</code> function.</p>
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">gene_input_list</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"CD14"</span>, <span class="st">"CD3E"</span>, <span class="st">"Cd4"</span>, <span class="st">"CD*A"</span>, <span class="st">"SEPT1"</span><span class="op">)</span></span>
<span></span>
<span><span class="va">genes_present</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Gene_Present.html">Gene_Present</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">pbmc</span>, gene_list <span class="op">=</span> <span class="va">gene_input_list</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Warning: The following features were omitted as they were not found:</span></span>
<span><span class="co">## <span style="color: #00BBBB;">ℹ</span> <span style="color: #00BB00;">Cd4 and CD*A</span></span></span></code></pre>
<pre><code><span><span class="co">## Warning: NOTE: However, the following features were found: <span style="color: #00BB00;">CD4</span></span></span>
<span><span class="co">## <span style="color: #00BBBB;">ℹ</span> Please check intended case of features provided.</span></span></code></pre>
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">check_symbols</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://satijalab.org/seurat/reference/UpdateSymbolList.html" class="external-link">UpdateSymbolList</a></span><span class="op">(</span>symbols <span class="op">=</span> <span class="va">genes_present</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span>, verbose <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Warning: No updated symbols found</span></span></code></pre>
</div>
</div>
<div class="section level3">
<h3 id="merging-splitting-dataobjects">Merging &amp; Splitting Data/Objects<a class="anchor" aria-label="anchor" href="#merging-splitting-dataobjects"></a>
</h3>
<div class="section level4">
<h4 id="merging-raw-data">Merging raw data<a class="anchor" aria-label="anchor" href="#merging-raw-data"></a>
</h4>
<p>It can often be advantageous to merge raw data before creating
analysis objects vs creating lots of objects and merging them all later.
scCustomize features a modified version of the internal LIGER function
<code>MergeSparseDataAll()</code>.</p>
<p><code><a href="../reference/Merge_Sparse_Data_All.html">Merge_Sparse_Data_All()</a></code> will combine a list of sparse
matrices and return single sparse matrix. Additionally, by specifying
the <code>add_cell_ids</code> parameter you can specify a prefix to be
added to the barcodes from each entry in the list (using “_” as
delimiter).</p>
<p>This function can be especially useful when combined with any of the
scCustomize’s <code>Read_</code> data functions which automatically
return named lists of matrices and the ability to specify sample
<code>orig.ident</code> when creating Seurat objects. See <a href="https://samuel-marsh.github.io/scCustomize/articles/Read_and_Write_Functions.html">Read
&amp; Write Vignette</a> for more info on the data import functions.</p>
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Read in data</span></span>
<span><span class="va">GEO_10X</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Read10X_GEO.html">Read10X_GEO</a></span><span class="op">(</span>data_dir <span class="op">=</span> <span class="st">"assets/GSE152183_RAW_Marsh/"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Merge data and add sample prefix</span></span>
<span><span class="va">GEO_10X_merged</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Merge_Sparse_Data_All.html">Merge_Sparse_Data_All</a></span><span class="op">(</span>matrix_list <span class="op">=</span> <span class="va">GEO_10X</span>, add_cell_ids <span class="op">=</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">GEO_10X</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Create Seurat Object and specify orig.ident location</span></span>
<span><span class="va">GEO_10X_Seurat</span> <span class="op">&lt;-</span> <span class="fu">Seurat</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/SeuratObject/man/CreateSeuratObject.html" class="external-link">CreateSeuratObject</a></span><span class="op">(</span>counts <span class="op">=</span> <span class="va">GEO_10X_merged</span>, names.field <span class="op">=</span> <span class="fl">1</span>, names.delim <span class="op">=</span> <span class="st">"_"</span>,</span>
<span>    min.features <span class="op">=</span> <span class="fl">200</span>, min.cells <span class="op">=</span> <span class="fl">5</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="merging-list-of-seurat-objects">Merging List of Seurat Objects<a class="anchor" aria-label="anchor" href="#merging-list-of-seurat-objects"></a>
</h4>
<p>Sometimes it can be advantageous to create a list of multiple Seurat
Objects in order to run similar pipeline on all objects in loop.</p>
<p>To facilitate ease in merging such lists into single object
scCustomize contains simple wrapper <code>Merge_Seurat_List</code> that
uses <code><a href="https://purrr.tidyverse.org/reference/reduce.html" class="external-link">purrr::reduce()</a></code> to merge all objects in list into
single combined object</p>
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">list_of_objects</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="va">obj1</span>, <span class="va">obj2</span>, <span class="va">obj2</span>, <span class="va">...</span>, <span class="va">obj10</span><span class="op">)</span></span>
<span></span>
<span><span class="va">merged_seurat</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Merge_Seurat_List.html">Merge_Seurat_List</a></span><span class="op">(</span>list_seurat <span class="op">=</span> <span class="va">list_of_objects</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Can also add sample specific ids to each object during the merge</span></span>
<span><span class="va">cell_ids</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"sample1"</span>, <span class="st">"sample2"</span>, <span class="st">"sample3"</span>, <span class="va">...</span>, <span class="st">"sample10"</span><span class="op">)</span></span>
<span></span>
<span><span class="va">merged_seurat</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Merge_Seurat_List.html">Merge_Seurat_List</a></span><span class="op">(</span>list_seurat <span class="op">=</span> <span class="va">list_of_objects</span>, add.cell.ids <span class="op">=</span> <span class="va">cell_ids</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="splitting-seurat-v5-layers">Splitting Seurat V5 Layers<a class="anchor" aria-label="anchor" href="#splitting-seurat-v5-layers"></a>
</h4>
<p>Seurat V5 objects now have the ability to split within the object
into layers. However, I find that the syntax to do this is not the most
intuitive and can be simplified with a new simple wrapper function:
<code><a href="../reference/Split_Layers.html">Split_Layers()</a></code></p>
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Split_Layers.html">Split_Layers</a></span><span class="op">(</span>seurat_object <span class="op">=</span> <span class="va">pbmc</span>, split.by <span class="op">=</span> <span class="st">"sample_id"</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## <span style="color: #00BBBB;">•</span> Splitting layers within assay: <span style="color: #00BB00;">RNA</span> into <span style="color: #00BB00;">6 parts</span> by <span style="color: #0000BB;">"sample_id"</span></span></span>
<span><span class="co">## <span style="color: #00BBBB;">ℹ</span> <span style="color: #00BB00;">RNA</span> is not Assay5, converting to Assay5 before splitting.</span></span></code></pre>
<p><code><a href="../reference/Split_Layers.html">Split_Layers()</a></code> defaults to “RNA” assay but can be used
for any assay present in object (users should check whether splitting
assay other than “RNA” is valid before proceeding).</p>
</div>
</div>
<div class="section level3">
<h3 id="storing-misc-information-in-seurat-objects">Storing Misc Information in Seurat Objects<a class="anchor" aria-label="anchor" href="#storing-misc-information-in-seurat-objects"></a>
</h3>
<p>Seurat objects contain an extra empty slot that can be used to store
any extra information desired.<br>
scCustomize contains two functions <code>Store_Misc_Info_Seurat</code>
and a wrapper around that function <code>Store_Palette_Seurat</code> to
make this process easy.</p>
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Data can be vectors or data.frames</span></span>
<span><span class="va">misc_info</span> <span class="op">&lt;-</span> <span class="st">"misc_vector_dataframe_list_etc"</span></span>
<span></span>
<span><span class="co"># Add data to the @misc slot in Seurat Object</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Store_Misc_Info_Seurat.html">Store_Misc_Info_Seurat</a></span><span class="op">(</span>seurat_object <span class="op">=</span> <span class="va">pbmc</span>, data_to_store <span class="op">=</span> <span class="va">misc_info</span>, data_name <span class="op">=</span> <span class="st">"misc_info_name"</span><span class="op">)</span></span></code></pre></div>
<div class="section level4">
<h4 id="storing-lists">Storing Lists<a class="anchor" aria-label="anchor" href="#storing-lists"></a>
</h4>
<p>If you are storing a list in the <code>@misc</code> slot there is
additional parameter that dictates whether to store the information as a
list or whether to store each entry in the list separately.</p>
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Create list</span></span>
<span><span class="va">misc_info</span> <span class="op">&lt;-</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">"misc_item1"</span>, <span class="st">"misc_item2"</span>, <span class="va">etc</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Store the list directly</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Store_Misc_Info_Seurat.html">Store_Misc_Info_Seurat</a></span><span class="op">(</span>seurat_object <span class="op">=</span> <span class="va">pbmc</span>, data_to_store <span class="op">=</span> <span class="va">misc_info</span>, data_name <span class="op">=</span> <span class="st">"misc_info_name"</span>,</span>
<span>    list_as_list <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Store each entry in list as separate entity in `@misc` slot</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Store_Misc_Info_Seurat.html">Store_Misc_Info_Seurat</a></span><span class="op">(</span>seurat_object <span class="op">=</span> <span class="va">pbmc</span>, data_to_store <span class="op">=</span> <span class="va">misc_info</span>, data_name <span class="op">=</span> <span class="st">"misc_info_name"</span>,</span>
<span>    list_as_list <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="storing-color-palettes">Storing Color Palettes<a class="anchor" aria-label="anchor" href="#storing-color-palettes"></a>
</h4>
<p>One of the most common times I use this function is to store color
palettes associated with clustering or subclustering.<br>
To make it easier to remember function call in this situation
scCustomize contains a wrapper function
<code>Store_Palette_Seurat</code>.</p>
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Data can be vectors or data.frames</span></span>
<span><span class="va">annotated_color_palette</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"color1"</span>, <span class="st">"color2"</span>, <span class="st">"color3"</span>, <span class="st">"etc"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Add data to the @misc slot in Seurat Object</span></span>
<span><span class="va">pbmc</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Store_Palette_Seurat.html">Store_Palette_Seurat</a></span><span class="op">(</span>seurat_object <span class="op">=</span> <span class="va">pbmc</span>, palette <span class="op">=</span> <span class="va">annotated_color_palette</span>, palette_name <span class="op">=</span> <span class="st">"Round01_Color_Pal"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Then you can easily call that palette (with tab completion) when plotting without ever</span></span>
<span><span class="co"># needing to reload the palette in current environment</span></span>
<span><span class="fu"><a href="https://satijalab.org/seurat/reference/DimPlot.html" class="external-link">DimPlot</a></span><span class="op">(</span>object <span class="op">=</span> <span class="va">pbmc</span>, cols <span class="op">=</span> <span class="va">pbmc</span><span class="op">@</span><span class="va">misc</span><span class="op">$</span><span class="va">Round01_Color_Pal</span><span class="op">)</span></span></code></pre></div>
</div>
</div>
<div class="section level3">
<h3 id="modify-cell-barcodes-in-raw-data">Modify Cell Barcodes in Raw Data<a class="anchor" aria-label="anchor" href="#modify-cell-barcodes-in-raw-data"></a>
</h3>
<p>Sometimes, especially with public data, you may want to modify the
cell barcode names before creating analysis object.</p>
<p>scCustomize contains a selection of functions to simplify this
process:</p>
<div class="section level4">
<h4 id="replace-suffixes">Replace Suffixes<a class="anchor" aria-label="anchor" href="#replace-suffixes"></a>
</h4>
<p><code>Replace_Suffix</code> can be used on single matrix/data.frame
or list of matrices/data.frames to modify to remove suffixes</p>
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># For single object</span></span>
<span><span class="va">data_mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Replace_Suffix.html">Replace_Suffix</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">raw_data</span>, current_suffix <span class="op">=</span> <span class="st">"-1"</span>, new_suffix <span class="op">=</span> <span class="st">"-2"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># For list of objects containing same suffix</span></span>
<span><span class="va">raw_data_list</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="va">raw_data1</span>, <span class="va">raw_data2</span>, <span class="va">raw_data3</span>, <span class="va">...</span>, <span class="va">raw_data10</span><span class="op">)</span></span>
<span></span>
<span><span class="va">new_suffixes</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"-1"</span>, <span class="st">"-2"</span>, <span class="st">"-3"</span>, <span class="va">...</span>, <span class="st">"-10"</span><span class="op">)</span></span>
<span></span>
<span><span class="va">data_mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Replace_Suffix.html">Replace_Suffix</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">raw_data_list</span>, current_suffix <span class="op">=</span> <span class="st">"-1"</span>, new_suffix <span class="op">=</span> <span class="va">new_suffixes</span><span class="op">)</span></span>
<span></span>
<span></span>
<span><span class="co"># For list of objects containing different suffixes</span></span>
<span><span class="va">raw_data_list</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="va">raw_data1</span>, <span class="va">raw_data2</span>, <span class="va">raw_data3</span>, <span class="va">...</span>, <span class="va">raw_data10</span><span class="op">)</span></span>
<span></span>
<span><span class="va">old_suffixes</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"-A"</span>, <span class="st">"-B"</span>, <span class="st">"-C"</span>, <span class="va">...</span>, <span class="st">"-J"</span><span class="op">)</span></span>
<span><span class="va">new_suffixes</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"-1"</span>, <span class="st">"-2"</span>, <span class="st">"-3"</span>, <span class="va">...</span>, <span class="st">"-10"</span><span class="op">)</span></span>
<span></span>
<span><span class="va">data_mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Replace_Suffix.html">Replace_Suffix</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">raw_data_list</span>, current_suffix <span class="op">=</span> <span class="va">old_suffixes</span>, new_suffix <span class="op">=</span> <span class="va">new_suffixes</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="strip-suffixes">Strip Suffixes<a class="anchor" aria-label="anchor" href="#strip-suffixes"></a>
</h4>
<p><code>Replace_Suffix</code> can also be used to strip suffixes from
data</p>
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># For single object</span></span>
<span><span class="va">data_mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Replace_Suffix.html">Replace_Suffix</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">raw_data</span>, current_suffix <span class="op">=</span> <span class="st">"-1"</span>, new_suffix <span class="op">=</span> <span class="st">""</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="change-prefixsuffix-delimiters">Change Prefix/Suffix Delimiters<a class="anchor" aria-label="anchor" href="#change-prefixsuffix-delimiters"></a>
</h4>
<p>scCustomize has 3 functions to facilitate changing the type of
delimiters present in cell barcodes.</p>
<ul>
<li>
<code><a href="../reference/Change_Delim_Prefix.html">Change_Delim_Prefix()</a></code> Change just the suffix
delimiter.</li>
<li>
<code><a href="../reference/Change_Delim_Suffix.html">Change_Delim_Suffix()</a></code> Change just the prefix
delimiter.</li>
<li>
<code><a href="../reference/Change_Delim_All.html">Change_Delim_All()</a></code> Change all delimiters.</li>
</ul>
<p>These functions all take identical inputs and can be applied to
either single matrix/data.frames or lists of matrices/data.frames.</p>
<div class="sourceCode" id="cb42"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">data_mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Change_Delim_Prefix.html">Change_Delim_Prefix</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">raw_data</span>, current_delim <span class="op">=</span> <span class="st">"."</span>, new_delim <span class="op">=</span> <span class="st">"_"</span><span class="op">)</span></span>
<span></span>
<span><span class="va">data_mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Change_Delim_Suffix.html">Change_Delim_Suffix</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">raw_data</span>, current_delim <span class="op">=</span> <span class="st">"."</span>, new_delim <span class="op">=</span> <span class="st">"_"</span><span class="op">)</span></span>
<span></span>
<span><span class="va">data_mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Change_Delim_All.html">Change_Delim_All</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">raw_data</span>, current_delim <span class="op">=</span> <span class="st">"."</span>, new_delim <span class="op">=</span> <span class="st">"_"</span><span class="op">)</span></span></code></pre></div>
</div>
</div>
</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 Samuel Marsh.</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.7.</p>
</div>

      </footer>
</div>

  


  

  </body>
</html>
