<!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>Read &amp; Write Data Functions • 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="Read &amp; Write Data Functions">
<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><div class="row">
  <div class="col-md-9 contents">
    <div class="page-header toc-ignore">
      <h1 data-toc-skip>Read &amp; Write Data Functions</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/Read_and_Write_Functions.Rmd" class="external-link"><code>vignettes/articles/Read_and_Write_Functions.Rmd</code></a></small>
      <div class="hidden name"><code>Read_and_Write_Functions.Rmd</code></div>

    </div>

    
    
<hr>
<style>
p.caption {
  font-size: 0.9em;
}
</style>
<div class="section level2">
<h2 id="import-data-functions">Import Data Functions<a class="anchor" aria-label="anchor" href="#import-data-functions"></a>
</h2>
<p>Seurat and other packages provide excellent tools for importing data
however when importing large numbers of samples or samples with
non-standard names this process can be cumbersome. scCustomize provides
number of functions to simplify the process of importing many data sets
at the same time and speed up the process using parallelization.</p>
<p>For this tutorial, I will be utilizing several publicly available
data sets from NCBI GEO.</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><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://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></code></pre></div>
<div class="section level3">
<h3 id="import-single-data-file">Import Single Data File<a class="anchor" aria-label="anchor" href="#import-single-data-file"></a>
</h3>
<p>While most single cell packages have support for 10X and other
commercial formats sometimes additional functions are required.</p>
<div class="section level4">
<h4 id="import-cellbender-h5-file">Import CellBender h5 File<a class="anchor" aria-label="anchor" href="#import-cellbender-h5-file"></a>
</h4>
<p>CellBender is tool for the removal of ambient RNA (<a href="https://github.com/broadinstitute/CellBender" class="external-link">GitHub</a>, <a href="https://doi.org/10.1101/791699" class="external-link">Preprint</a>). Starting with
CellBender v3 the output file is styled like Cell Ranger h5 files it
also contains some additional information. This causes
<code><a href="https://satijalab.org/seurat/reference/Read10X_h5.html" class="external-link">Seurat::Read10X_h5()</a></code> to to fail when trying to import
data.</p>
<p>scCustomize has new function to read both new and old CellBender
output files.</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">cell_bender_mat</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Read_CellBender_h5_Mat.html">Read_CellBender_h5_Mat</a></span><span class="op">(</span>file_name <span class="op">=</span> <span class="st">"PATH/SampleA_out_filtered.h5"</span><span class="op">)</span></span></code></pre></div>
</div>
</div>
<div class="section level3">
<h3 id="import-multiple-data-files-from-single-directory">Import Multiple Data Files from Single Directory<a class="anchor" aria-label="anchor" href="#import-multiple-data-files-from-single-directory"></a>
</h3>
<p>Often when downloading files from NCBI GEO or other repos all of the
files are contained in single directory and contain non-standard file
names. However, functions like <code><a href="https://satijalab.org/seurat/reference/Read10X.html" class="external-link">Seurat::Read10X()</a></code> expect
non-prefixed files (i.e. Cell Ranger outputs).</p>
<p>scCustomize has three functions to deal with these situations without
need for renaming files.</p>
<div class="section level4">
<h4 id="import-10x-genomics-or-10x-styled-single-directory-with-file-prefixes">Import 10X Genomics (or 10X-styled) single directory with file
prefixes<a class="anchor" aria-label="anchor" href="#import-10x-genomics-or-10x-styled-single-directory-with-file-prefixes"></a>
</h4>
<p>The function <code>Read10X_GEO</code> can be used to iteratively read
all sets of 10X style files within single directory.</p>
<p>For this example I will be utilizing data from Marsh et al., 2022 (<a href="https://doi.org/10.1038/s41593-022-01022-8" class="external-link"><em>Nature
Neuroscience</em></a>), which were downloaded from <a href="https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE152183" class="external-link">NCBI
GEO GSE152183</a></p>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/list.files.html" class="external-link">list.files</a></span><span class="op">(</span><span class="st">"assets/GSE152183_RAW_Marsh/"</span><span class="op">)</span></span>
<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></code></pre></div>
<div class="section level5">
<h5 id="read10x_geo-additional-parameters">
<code>Read10X_GEO</code> Additional Parameters<a class="anchor" aria-label="anchor" href="#read10x_geo-additional-parameters"></a>
</h5>
<p><code>Read10X_GEO</code> also contains several additional optional
parameters to streamline the import process.</p>
<ul>
<li>
<code>parallel</code> and <code>num_cores</code> parameters enable
use of multiple cores to speed up data import.</li>
<li>
<code>sample_list</code> By default <code>Read10X_GEO</code> will
import all sets of files found within single directory. However, if only
a subset of files is desired a vector of sample prefixes can be supplied
to <code>sample_list</code>.</li>
<li>
<code>sample_names</code> By default <code>Read10X_GEO</code> names
each entry in the returned list (see below) using the file name prefix.
If different names are desired they can be supplied to
<code>sample_names</code>.</li>
<li>Several other parameters from <code><a href="https://satijalab.org/seurat/reference/Read10X.html" class="external-link">Seurat::Read10X()</a></code>. See
<code><a href="../reference/Read10X_GEO.html">?Read10X_GEO</a></code> for more details.</li>
</ul>
</div>
<div class="section level5">
<h5 id="read10x_geo-import-format">
<code>Read10X_GEO</code> Import Format<a class="anchor" aria-label="anchor" href="#read10x_geo-import-format"></a>
</h5>
<p><code>Read10X_GEO</code> will return list of matrices (single
modality data) or list of list of matrices (multi-modal data).</p>
<center>
<img src="../reference/figures/assets/Read10X_GEO.png" width="49%"><img src="../reference/figures/assets/multimodal.png" width="49%"><em>Example outputs for GEX only (list of matrices) or multimodal (list
of list of matrices) 10X-Style files downloaded from NCBI GEO</em>
</center>
</div>
</div>
<div class="section level4">
<h4 id="import-10x-genomics-h5-formatted-files-single-directory-with-file-prefixes">Import 10X Genomics H5 Formatted Files single directory with file
prefixes<a class="anchor" aria-label="anchor" href="#import-10x-genomics-h5-formatted-files-single-directory-with-file-prefixes"></a>
</h4>
<p>There is equivalent function for reading in 10X H5 formatted files
<code>Read10X_h5_GEO</code>.<br><em>NOTE: If files have shared aspect to file name specify this using
<code>shared_suffix</code> parameter to avoid that being incorporated
into names to list entries in returned list.</em></p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">GEO_10X</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Read10X_h5_GEO.html">Read10X_h5_GEO</a></span><span class="op">(</span>data_dir <span class="op">=</span> <span class="st">"/path/to/data/"</span>, shared_suffix <span class="op">=</span> <span class="st">"filtered_feature_bc_matrix"</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="import-cellbender-h5-files-from-single-directory">Import CellBender H5 Files from single directory<a class="anchor" aria-label="anchor" href="#import-cellbender-h5-files-from-single-directory"></a>
</h4>
<p>Importing CellBender h5 files from single directory can be done using
<code><a href="../reference/Read_CellBender_h5_Multi_File.html">Read_CellBender_h5_Multi_File()</a></code>, which functions very
similar to <code>Read10X_h5_GEO</code>. Here is example directory/file
setup:</p>
<pre><code>Parent_Directory
├── Exp_Name
│   └── Cell_Bender_Results
│       └── SampleA_CB_out_filtered.h5
│       └── SampleB_CB_out_filtered.h5
│       └── SampleC_CB_out_filtered.h5</code></pre>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">Multi_CB</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Read_CellBender_h5_Multi_File.html">Read_CellBender_h5_Multi_File</a></span><span class="op">(</span>data_dir <span class="op">=</span> <span class="st">"Exp_Name/Cell_Bender_Results/"</span>, custom_name <span class="op">=</span> <span class="st">"_CB_out_filtered.h5"</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="import-delimited-matrices-single-directory-with-file-prefixes">Import delimited matrices single directory with file prefixes<a class="anchor" aria-label="anchor" href="#import-delimited-matrices-single-directory-with-file-prefixes"></a>
</h4>
<p>Often data is uploaded to NCBI GEO or other repositories with single
file (.csv, .tsv, .txt, etc) containing all of the information.</p>
<p>For this example I will be utilizing data from Hammond et al., 2019
(<a href="https://doi.org/10.1016/j.immuni.2018.11.004" class="external-link"><em>Immunity</em></a>),
which were downloaded from <a href="https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE121654" class="external-link">NCBI
GEO GSE121654</a>.</p>
<p><code>Read_GEO_Delim</code> uses fread function for automatic
detection of file delimiter and fast read times and then converts
objects to sparse matrices to save memory</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Read in and use file names to name the list (default)</span></span>
<span><span class="va">GEO_Single</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Read_GEO_Delim.html">Read_GEO_Delim</a></span><span class="op">(</span>data_dir <span class="op">=</span> <span class="st">"assets/GSE121654_RAW_Hammond/GSE121654_RAW_Hammond/"</span>, file_suffix <span class="op">=</span> <span class="st">".dge.txt.gz"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Read in and use new sample names to name the list</span></span>
<span><span class="va">GEO_Single</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Read_GEO_Delim.html">Read_GEO_Delim</a></span><span class="op">(</span>data_dir <span class="op">=</span> <span class="st">"assets/GSE121654_RAW_Hammond/GSE121654_RAW_Hammond/"</span>, file_suffix <span class="op">=</span> <span class="st">".dge.txt.gz"</span>,</span>
<span>    sample_names <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">"sample01"</span>, <span class="st">"sample02"</span>, <span class="st">"sample03"</span>, <span class="st">"sample04"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<center>
<img src="../reference/figures/assets/delim_default.png" width="49%"><img src="../reference/figures/assets/renamed.png" width="49%"><em>Example outputs with default naming based on file name or providing
<code>sample_names</code> parameter.</em>
</center>
<div class="section level5">
<h5 id="read_geo_delim-additional-parameters">
<code>Read_GEO_Delim</code> additional parameters<a class="anchor" aria-label="anchor" href="#read_geo_delim-additional-parameters"></a>
</h5>
<p>See <a href="https://samuel-marsh.github.io/scCustomize/reference/Read_GEO_Delim.html">manual
entry</a> for more info.</p>
</div>
</div>
</div>
<div class="section level3">
<h3 id="import-multiple-files-from-multiple-directories">Import Multiple Files from Multiple Directories<a class="anchor" aria-label="anchor" href="#import-multiple-files-from-multiple-directories"></a>
</h3>
<p>In addition to those functions for single directories, scCustomize
contains functions for when files are contained in multiple
sub-directories within shared parent directory.<br><em>NOTE: These functions all assume that each sub-directory contains
one sample and that sub-directory structure is identical between all
samples.</em></p>
<div class="section level4">
<h4 id="import-10x-genomics-tsv-mtx">Import 10X Genomics (tsv, mtx)<a class="anchor" aria-label="anchor" href="#import-10x-genomics-tsv-mtx"></a>
</h4>
<p>Take an abbreviated example directory found below styled as output
from Cell Ranger <code>count</code></p>
<pre><code>Parent_Directory
├── sample_01
│   └── outs
│       └── filtered_feature_bc_matrix
│           └── feature.tsv.gz
│           └── barcodes.tsv.gz
│           └── matrix.mtx.gz
└── sample_02
    └── outs
        └── filtered_feature_bc_matrix
            └── feature.tsv.gz
            └── barcodes.tsv.gz
            └── matrix.mtx.gz</code></pre>
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># In this case we can use default_10X = TRUE to tell function where to find the matrix files</span></span>
<span><span class="va">multi_10x</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Read10X_Multi_Directory.html">Read10X_Multi_Directory</a></span><span class="op">(</span>base_path <span class="op">=</span> <span class="st">"Parent_Directory/"</span>, default_10X <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<div class="section level5">
<h5 id="path-inside-sub-directories">Path Inside Sub-Directories<a class="anchor" aria-label="anchor" href="#path-inside-sub-directories"></a>
</h5>
<p>In order to properly import the data
<code>Read10X_Multi_Directory</code> needs to know how to navigate the
sub-directory structure.</p>
<ul>
<li>The parameter <code>default_10X</code> tells the function that the
directory structure matches the standardized output from Cell Ranger
(see above).</li>
<li>However, it can also accept any unique sub-directory structure using
the <code>secondary_path</code> parameter as long as structure is the
same for all samples (see below).</li>
</ul>
<p>For instance:</p>
<pre><code>Parent_Directory
├── sample_01
│   └── gex_matrices
│       └── feature.tsv.gz
│       └── barcodes.tsv.gz
│       └── matrix.mtx.gz
└── sample_02
    └── gex_matrices
        └── feature.tsv.gz
        └── barcodes.tsv.gz
        └── matrix.mtx.gz</code></pre>
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># In this case we can use default_10X = FALSE to tell function where to find the matrix files</span></span>
<span><span class="va">multi_10x</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Read10X_Multi_Directory.html">Read10X_Multi_Directory</a></span><span class="op">(</span>base_path <span class="op">=</span> <span class="st">"Parent_Directory"</span>, default_10X <span class="op">=</span> <span class="cn">FALSE</span>, secondary_path <span class="op">=</span> <span class="st">"gex_matrices"</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level5">
<h5 id="optional-parameters">Optional Parameters<a class="anchor" aria-label="anchor" href="#optional-parameters"></a>
</h5>
<p><code>Read10X_Multi_Directory</code> also contains several additional
parameters.</p>
<ul>
<li>
<code>parallel</code> and <code>num_cores</code> to use multiple
core processing.</li>
<li>
<code>sample_list</code> By default
<code>Read10X_Multi_Directory</code> will read in all sub-directories
present in parent directory. However a subset can be specified by
passing a vector of sample directory names.</li>
<li>
<code>sample_names</code> As with other functions by default
<code>Read10X_Multi_Directory</code> will use the sub-directory names
within parent directory to name the output list entries. Alternate names
for the list entries can be provided here if desired. These names will
also be used to add cell prefixes if <code>merge = TRUE</code> (see
below).<br>
</li>
<li>
<code>merge</code> logical (default FALSE). Whether to combine all
samples into single sparse matrix and using <code>sample_names</code> to
provide sample prefixes.</li>
</ul>
</div>
</div>
<div class="section level4">
<h4 id="import-10x-genomics-h5-outputs">Import 10X Genomics (H5 Outputs)<a class="anchor" aria-label="anchor" href="#import-10x-genomics-h5-outputs"></a>
</h4>
<p>scCustomize contains function:
<code>Read10X_h5_Multi_Directory</code> can be used to read 10X Genomics
H5 files similarly to <code>Read10X_Multi_Directory</code></p>
</div>
<div class="section level4">
<h4 id="import-cellbender-h5-outputs">Import CellBender h5 Outputs<a class="anchor" aria-label="anchor" href="#import-cellbender-h5-outputs"></a>
</h4>
<p>scCustomize also contains function
<code><a href="../reference/Read_CellBender_h5_Multi_Directory.html">Read_CellBender_h5_Multi_Directory()</a></code> which can be used to
read CellBender outputs in multiple sub-directories similar to
<code>Read10X_h5_Multi_Directory</code> using the same type of
parameters as <code>Read_CellBender_h5_Multi_File</code></p>
</div>
</div>
<div class="section level3">
<h3 id="merging-sparse-matrices">Merging Sparse Matrices<a class="anchor" aria-label="anchor" href="#merging-sparse-matrices"></a>
</h3>
<p>Rather than creating and merging Seurat objects it can sometimes be
advantageous to simply combine the sparse matrices before creating
Seurat object.</p>
<div class="section level4">
<h4 id="basic-use">Basic Use<a class="anchor" aria-label="anchor" href="#basic-use"></a>
</h4>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">GEO_Single</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">mat1</span>, <span class="va">mat2</span>, <span class="va">mat3</span><span class="op">)</span></span>
<span></span>
<span><span class="va">GEO_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_Single</span><span class="op">)</span></span></code></pre></div>
<center>
<img src="../reference/figures/assets/geo_merged.png" width="98%"><em>Progress bar outputs in <code>Merge_Sparse_Data_All</code> function
through scCustomize.</em>
</center>
</div>
<div class="section level4">
<h4 id="multimodal-data">Multimodal Data<a class="anchor" aria-label="anchor" href="#multimodal-data"></a>
</h4>
<p>If you have multimodal data (each entry in list contains sub-list
with matrices) then you can use
<code><a href="../reference/Merge_Sparse_Multimodal_All.html">Merge_Sparse_Multimodal_All()</a></code>. This function will return a
list with each entry representing a merged matrix for single
modality.</p>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">GEO_Merged_Multimodal</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Merge_Sparse_Multimodal_All.html">Merge_Sparse_Multimodal_All</a></span><span class="op">(</span>matrix_list <span class="op">=</span> <span class="va">GEO_Multimodal</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="add-barcode-prefixsuffix">Add Barcode Prefix/Suffix<a class="anchor" aria-label="anchor" href="#add-barcode-prefixsuffix"></a>
</h4>
<p><code>Merge_Sparse_Data_All</code> contains a number of optional
parameters to control modification to the cell barcodes.<br><em>NOTE: If any of the barcodes in the input matrix list overlap and no
prefixes/suffixes are provided the function will error.</em></p>
<ul>
<li>Users can provide a vector of either prefixes or suffixes
to<code>add_cell_ids</code> to ensure barcodes are unique (and make the
import to Seurat smoother with samples already labeled).<br>
</li>
<li>By default ids are added as barcode prefixes but can be added as
suffixes by setting <code>prefix = FALSE</code>.<br>
</li>
<li>The prefix/suffix delimiter is “_” by default but can be changed
using <code>cell_id_delimiter</code> parameter.</li>
</ul>
</div>
</div>
<div class="section level3">
<h3 id="merge-list-of-seurat-objects">Merge List of Seurat Objects<a class="anchor" aria-label="anchor" href="#merge-list-of-seurat-objects"></a>
</h3>
<p>To easily merge many Seurat objects contained in a list scCustomize
contains simple function.</p>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Merge a list of compatible Seurat objects of any length and add cell prefixes if desired</span></span>
<span><span class="va">Seurat_Merged</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="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">"cell"</span>, <span class="st">"prefixes"</span>,</span>
<span>    <span class="st">"to"</span>, <span class="st">"add"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="write-10x-genomics-formatted-h5-file-from-non-h5-input">Write 10X Genomics Formatted H5 file from non-H5 input<a class="anchor" aria-label="anchor" href="#write-10x-genomics-formatted-h5-file-from-non-h5-input"></a>
</h3>
<p><code>Create_10X_H5</code> provides convenient wrapper around
<code>write10xCounts()</code> from DropletUtils package. Output can then
be easily read in using <code><a href="https://satijalab.org/seurat/reference/Read10X_h5.html" class="external-link">Seurat::Read10X_h5()</a></code> or LIGER’s
<code><a href="https://rdrr.io/pkg/rliger/man/createLiger.html" class="external-link">createLiger()</a></code> (which assumes H5 file is formatted as if
from Cell Ranger).</p>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Provide file path and specify type of files as either cell ranger triplicate files, matrix,</span></span>
<span><span class="co"># or data.frame</span></span>
<span><span class="fu"><a href="../reference/Create_10X_H5.html">Create_10X_H5</a></span><span class="op">(</span>raw_data_file_path <span class="op">=</span> <span class="st">"/path/matrix.mtx"</span>, source_type <span class="op">=</span> <span class="st">"Matrix"</span>, save_file_path <span class="op">=</span> <span class="st">"/path/"</span>,</span>
<span>    save_name <span class="op">=</span> <span class="st">"name"</span><span class="op">)</span></span></code></pre></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>
