<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
  <head>
  <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>Convert AnnData/H5AD files to h5Seurat files — H5ADToH5Seurat • SeuratDisk</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="Convert AnnData/H5AD files to h5Seurat files — H5ADToH5Seurat" />
<meta property="og:description" content="Convert AnnData/H5AD files to h5Seurat files" />




<!-- 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-reference-topic">
      <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">SeuratDisk</a>
        <span class="version label label-danger" data-toggle="tooltip" data-placement="bottom" title="Unreleased version">0.0.0.9011</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../index.html">
    <span class="fas fa fas fa-home fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
    Articles
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
    <li>
      <a href="../articles/convert-anndata.html">Conversions: h5Seurat and AnnData</a>
    </li>
    <li>
      <a href="../articles/h5Seurat-load.html">Saving and Loading Data from an h5Seurat File</a>
    </li>
    <li>
      <a href="../articles/h5Seurat-spec.html">h5Seurat File Format Specification</a>
    </li>
  </ul>
</li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="https://github.com/mojaveazure/seurat-disk/">
    <span class="fab fa 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">
    <h1>Convert AnnData/H5AD files to h5Seurat files</h1>
    <small class="dont-index">Source: <a href='https://github.com/mojaveazure/seurat-disk/blob/master/R/Convert.R'><code>R/Convert.R</code></a></small>
    <div class="hidden name"><code>H5ADToH5Seurat.Rd</code></div>
    </div>

    <div class="ref-description">
    <p>Convert AnnData/H5AD files to h5Seurat files</p>
    </div>

    <pre class="usage"><span class='fu'>H5ADToH5Seurat</span>(<span class='no'>source</span>, <span class='no'>dest</span>, <span class='kw'>assay</span> <span class='kw'>=</span> <span class='st'>"RNA"</span>, <span class='kw'>overwrite</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</pre>

    <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
    <table class="ref-arguments">
    <colgroup><col class="name" /><col class="desc" /></colgroup>
    <tr>
      <th>source</th>
      <td><p>Source dataset</p></td>
    </tr>
    <tr>
      <th>dest</th>
      <td><p>Name of destination dataset</p></td>
    </tr>
    <tr>
      <th>assay</th>
      <td><p>Converting from <code><a href='h5Seurat-class.html'>h5Seurat</a></code>: name of assay to write
out; converting to <code><a href='h5Seurat-class.html'>h5Seurat</a></code>: name to store assay data as</p></td>
    </tr>
    <tr>
      <th>overwrite</th>
      <td><p>Overwrite existing <code>dest</code></p></td>
    </tr>
    <tr>
      <th>verbose</th>
      <td><p>Show progress updates</p></td>
    </tr>
    </table>

    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p>Returns a handle to <code>dest</code> as an <code><a href='h5Seurat-class.html'>h5Seurat</a></code> object</p>
    <h2 class="hasAnchor" id="anndata-h-ad-to-h-seurat"><a class="anchor" href="#anndata-h-ad-to-h-seurat"></a>AnnData/H5AD to h5Seurat</h2>

    

<p>The AnnData/H5AD to h5Seurat conversion will try to automatically fill in
datasets based on data presence. It works in the following manner:</p><h3>Expression data</h3>
<p>The expression matrices <code>counts</code>, <code>data</code>, and <code>scale.data</code>
 are filled by <code>/X</code> and <code>/raw/X</code> in the following manner:</p><ul>
<li><p><code>counts</code> will be filled with <code>/raw/X</code> if present;
  otherwise, it will be filled with <code>/X</code></p></li>
<li><p><code>data</code> will be filled with <code>/raw/X</code> if <code>/raw/X</code> is
  present and <code>/X</code> is dense; otherwise, it will be filled with <code>/X</code></p></li>
<li><p><code>scale.data</code> will be filled with <code>/X</code> if it dense;
  otherwise, it will be empty</p></li>
</ul><p>Feature names are taken from the feature-level metadata</p>
<h3>Feature-level metadata</h3>
<p>Feature-level metadata is added to the <code>meta.features</code> datasets in each
assay. Feature names are taken from the dataset specified by the
&#8220;_index&#8221; attribute, the &#8220;_index&#8221; dataset, or the &#8220;index&#8221;
dataset, in that order. Metadata is populated with <code>/raw/var</code> if
present, otherwise with <code>/var</code>; if both <code>/raw/var</code> and <code>/var</code>
are present, then <code>meta.features</code> will be populated with <code>/raw/var</code>
first, then <code>/var</code> will be added to it. For columns present in both
<code>/raw/var</code> and <code>/var</code>, the values in <code>/var</code> will be used
instead. <strong>Note</strong>: it is possible for <code>/var</code> to have fewer features
than <code>/raw/var</code>; if this is the case, then only the features present in
<code>/var</code> will be overwritten, with the metadata for features <em>not</em>
present in <code>/var</code> remaining as they were in <code>/raw/var</code> or empty</p>
<h3>Cell-level metadata</h3>
<p>Cell-level metadata is added to <code>meta.data</code>; the row names of the
metadata (as determined by the value of the &#8220;_index&#8221; attribute, the
&#8220;_index&#8221; dataset, or the &#8220;index&#8221; dataset, in that order) are
added to the &#8220;cell.names&#8221; dataset instead. If the
&#8220;__categories&#8221; dataset is present, each dataset within
&#8220;__categories&#8221; will be stored as a factor group. Cell-level metadata
will be added as an HDF5 group unless factors are <strong>not</strong> present and
<code>SeuratDisk.dtype.dataframe_as_group</code> is <code>FALSE</code></p>
<h3>Dimensional reduction information:</h3>
<p>Cell embeddings are taken from <code>/obsm</code>; dimensional reductions are
 named based on their names from <code>obsm</code> by removing the preceding
 &#8220;X_&#8221;.For example, if a dimensional reduction is named &#8220;X_pca&#8221;
 in <code>/obsm</code>, the resulting dimensional reduction information will be
 named &#8220;pca&#8221;. The key will be set to one of the following:</p><ul>
<li><p>&#8220;PC_&#8221; if &#8220;pca&#8221; is present in the dimensional reduction
  name (<code><a href='https://rdrr.io/r/base/grep.html'>grepl("pca", reduction.name, ignore.case = TRUE)</a></code>)</p></li>
<li><p>&#8220;tSNE_&#8221; if &#8220;tsne&#8221; is present in the dimensional
  reduction name (<code><a href='https://rdrr.io/r/base/grep.html'>grepl("tsne", reduction.name, ignore.case = TRUE)</a></code>)</p></li>
<li><p><code>reduction.name_</code> for all other reductions</p></li>
</ul><p>Remember that the preceding &#8220;X_&#8221; will be removed from the reduction
 name before converting to a key. Feature loadings are taken from
 <code>/varm</code> and placed in the associated dimensional reduction. The
 dimensional reduction is determine from the loadings name in <code>/varm</code>:</p><ul>
<li><p>&#8220;PCs&#8221; will be added to a dimensional reduction named
  &#8220;pca&#8221;</p></li>
<li><p>All other loadings in <code>/varm</code> will be added to a dimensional
  reduction named <code><a href='https://rdrr.io/r/base/chartr.html'>tolower(loading)</a></code> (eg. a loading named &#8220;ICA&#8221;
  will be added to a dimensional reduction named &#8220;ica&#8221;)</p></li>
</ul><p>If a dimensional reduction cannot be found according to the rules above, the
 loading will not be taken from the AnnData/H5AD file. Miscellaneous
 information will be taken from <code>/uns/reduction</code> where <code>reduction</code>
 is the name of the reduction in <code>/obsm</code> without the preceding
 &#8220;X_&#8221;; if no dimensional reduction information present, then
 miscellaneous information will not be taken from the AnnData/H5AD file.
 Standard deviations are taken from a dataset <code>/uns/reduction/variance</code>;
 the variances will be converted to standard deviations and added to the
 <code>stdev</code> dataset of a dimensional reduction</p>
<h3>Nearest-neighbor graph</h3>
<p>If a nearest neighbor graph is present in <code>/uns/neighbors/distances</code>,
 it will be added as a graph dataset in the h5Seurat file and associated with
 <code>assay</code>; if a value is present in <code>/uns/neighbors/params/method</code>,
 the name of the graph will be <code>assay_method</code>, otherwise, it will be
 <code>assay_anndata</code></p>
<h3>Layers</h3>
<p>TODO: add this</p>
<h3>Miscellaneous information</h3>
<p>All groups and datasets from <code>/uns</code> will be copied to <code>misc</code> in
 the h5Seurat file except for the following:</p><ul>
<li><p>Any group or dataset named the same as a dimensional reduction (eg.
  <code>/uns/pca</code>)</p></li>
<li><p><code>/uns/neighbors</code></p></li>
</ul>



  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
    <nav id="toc" data-toggle="toc" class="sticky-top">
      <h2 data-toc-skip>Contents</h2>
    </nav>
  </div>
</div>


      <footer>
      <div class="copyright">
  <p>Developed by Paul Hoffman.</p>
</div>

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

      </footer>
   </div>

  


  </body>
</html>


