<!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>Trajectory and Pseudotime Analysis • SeuratExtend</title>
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" 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="Trajectory and Pseudotime Analysis">
<meta property="og:description" content="SeuratExtend">
<!-- 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">SeuratExtend</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">1.0.0</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
<li>
  <a href="../reference/index.html">Reference</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>
      <a href="../articles/Visualization.html">Enhanced Visualization</a>
    </li>
    <li>
      <a href="../articles/GSEA.html">Geneset Enrichment Analysis (GSEA) </a>
    </li>
    <li>
      <a href="../articles/Trajectory.html">Trajectory and Pseudotime Analysis </a>
    </li>
    <li>
      <a href="../articles/SCENIC.html">SCENIC for Gene Regulatory Networks Analysis </a>
    </li>
    <li>
      <a href="../articles/Utilities.html">Utility Tools and Functions</a>
    </li>
  </ul>
</li>
<li>
  <a href="../articles/FAQ.html">FAQ</a>
</li>
      </ul>
<ul class="nav navbar-nav navbar-right"></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>Trajectory and Pseudotime Analysis</h1>
                        <h4 data-toc-skip class="author">Yichao Hua</h4>
            
            <h4 data-toc-skip class="date">2024-07-11</h4>
      
      
      <div class="hidden name"><code>Trajectory.Rmd</code></div>

    </div>

    
    
<div class="section level2">
<h2 id="table-of-contents">Table of Contents<a class="anchor" aria-label="anchor" href="#table-of-contents"></a>
</h2>
<ol style="list-style-type: decimal">
<li><a href="#analyzing-single-cell-trajectories-with-scvelo">scVelo
Tutorial for Trajectory Analysis</a></li>
<li><a href="#palantir-tutorial-for-trajectory-and-pseudotime-analysis">Palantir
Tutorial for Trajectory and Pseudotime Analysis</a></li>
<li><a href="#magic-for-denoising-and-smoothing-gene-expression">MAGIC
for Denoising and Smoothing Gene Expression</a></li>
<li><a href="#cellrank-tutorial-for-trajectory-analysis">CellRank
Tutorial for Trajectory Analysis</a></li>
<li><a href="#gene-expression-dynamics-along-differentiation-trajectories">Gene
Expression Dynamics Along Differentiation Trajectories</a></li>
<li><a href="#slingshot-tutorial-for-pseudotime-analysis">Slingshot
Tutorial for Pseudotime Analysis</a></li>
<li><a href="#integration-of-seurat-with-python-tools">Integration of
Seurat with Python Tools</a></li>
</ol>
</div>
<div class="section level2">
<h2 id="analyzing-single-cell-trajectories-with-scvelo">Analyzing Single-Cell Trajectories with scVelo<a class="anchor" aria-label="anchor" href="#analyzing-single-cell-trajectories-with-scvelo"></a>
</h2>
<p><code>scVelo</code> is a widely used tool for trajectory analysis
that leverages spliced and unspliced RNA information, as calculated by
Velocyto, to predict the direction of cell differentiation. For more
information, see <a href="https://scvelo.readthedocs.io/en/stable/" class="external-link">scVelo’s
documentation</a>. <code>SeuratExtend</code> includes a series of
functions that allow you to easily run everything in R. In this
tutorial, we use an example dataset (<code>pbmc10k_10X</code>)
downloaded from the <a href="https://www.10xgenomics.com/datasets" class="external-link">10X
Genomics website</a>, focusing on a small subset of myeloid cells for
simplicity.</p>
<div class="section level3">
<h3 id="downloading-example-data">Downloading Example Data<a class="anchor" aria-label="anchor" href="#downloading-example-data"></a>
</h3>
<p>First, we need to download the example data, including a small Seurat
object and a corresponding small loom file generated by Velocyto. These
files are stored on Zenodo:</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://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">SeuratExtend</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Download the example Seurat Object</span></span>
<span><span class="va">mye_small</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/readRDS.html" class="external-link">readRDS</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/connections.html" class="external-link">url</a></span><span class="op">(</span><span class="st">"https://zenodo.org/records/10944066/files/pbmc10k_mye_small_velocyto.rds"</span>, <span class="st">"rb"</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Download the example velocyto loom file to tmp folder</span></span>
<span><span class="va">loom_path</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/file.path.html" class="external-link">file.path</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/tempfile.html" class="external-link">tempdir</a></span><span class="op">(</span><span class="op">)</span>, <span class="st">"pbmc10k_mye_small.loom"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/utils/download.file.html" class="external-link">download.file</a></span><span class="op">(</span><span class="st">"https://zenodo.org/records/10944066/files/pbmc10k_mye_small.loom"</span>, <span class="va">loom_path</span><span class="op">)</span></span></code></pre></div>
<p><strong>Note:</strong> To save disk space, the data downloaded for
this tutorial is stored in the temporary folder and will be
automatically deleted after the R session is closed. If you wish to
permanently retain the tutorial files, please manually change the
storage location to your working directory.</p>
</div>
<div class="section level3">
<h3 id="preparing-data-for-scvelo">Preparing Data for scVelo<a class="anchor" aria-label="anchor" href="#preparing-data-for-scvelo"></a>
</h3>
<p><code>scVelo</code> requires an <code>AnnData</code> object from
Python’s <code>Scanpy</code> library for its analyses.
<code>SeuratExtend</code> makes this process seamless by integrating a
Seurat object and a velocyto loom file into a new <code>AnnData</code>
object, serving as a bridge between R and Python.</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Set up the path for saving the AnnData object in the HDF5 (h5ad) format</span></span>
<span><span class="va">adata_path</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/file.path.html" class="external-link">file.path</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/tempfile.html" class="external-link">tempdir</a></span><span class="op">(</span><span class="op">)</span>, <span class="st">"mye_small.h5ad"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Integrate Seurat Object and velocyto loom information into one AnnData object.</span></span>
<span><span class="co"># This object will be stored at the specified path.</span></span>
<span><span class="fu"><a href="../reference/scVelo.SeuratToAnndata.html">scVelo.SeuratToAnndata</a></span><span class="op">(</span></span>
<span>  <span class="va">mye_small</span>, <span class="co"># The downloaded example Seurat object</span></span>
<span>  filename <span class="op">=</span> <span class="va">adata_path</span>, <span class="co"># Path where the AnnData object will be saved</span></span>
<span>  velocyto.loompath <span class="op">=</span> <span class="va">loom_path</span>, <span class="co"># Path to the loom file</span></span>
<span>  prefix <span class="op">=</span> <span class="st">"sample1_"</span>, <span class="co"># Prefix for cell IDs in the Seurat object</span></span>
<span>  postfix <span class="op">=</span> <span class="st">"-1"</span> <span class="co"># Postfix for cell IDs in the Seurat object</span></span>
<span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Running scvelo 0.3.0 (python 3.10.12) on 2024-07-11 10:13.</span></span>
<span><span class="co">## Filtered out 10891 genes that are detected 20 counts (shared).</span></span>
<span><span class="co">## Normalized count data: X, spliced, unspliced.</span></span>
<span><span class="co">## Extracted 2000 highly variable genes.</span></span>
<span><span class="co">## Logarithmized X.</span></span>
<span><span class="co">## computing neighbors</span></span>
<span><span class="co">##     finished (0:00:04) --&gt; added </span></span>
<span><span class="co">##     'distances' and 'connectivities', weighted adjacency matrices (adata.obsp)</span></span>
<span><span class="co">## computing moments based on connectivities</span></span>
<span><span class="co">##     finished (0:00:00) --&gt; added </span></span>
<span><span class="co">##     'Ms' and 'Mu', moments of un/spliced abundances (adata.layers)</span></span>
<span><span class="co">## computing velocities</span></span>
<span><span class="co">##     finished (0:00:00) --&gt; added </span></span>
<span><span class="co">##     'velocity', velocity vectors for each individual cell (adata.layers)</span></span>
<span><span class="co">## computing velocity graph (using 1/28 cores)</span></span>
<span><span class="co">## WARNING: Unable to create progress bar. Consider installing `tqdm` as `pip install tqdm` and `ipywidgets` as `pip install ipywidgets`,</span></span>
<span><span class="co">## or disable the progress bar using `show_progress_bar=False`.</span></span>
<span><span class="co">##     finished (0:00:01) --&gt; added </span></span>
<span><span class="co">##     'velocity_graph', sparse matrix with cosine correlations (adata.uns)</span></span></code></pre>
<p><strong>Note</strong>: If this is your first time running
Python-related functions (<code>scVelo</code>, <code>Palantir</code>,
etc.) in <code>SeuratExtend</code>, it will prompt you to install a
conda environment named “seuratextend”. This environment automatically
installs all required Python packages, supporting Windows, Mac, or Linux
platforms. More details on managing the <code>Anndata</code> object and
Python dependencies are provided here: <a href="#python">Integration of
Seurat with Python Tools</a>.</p>
</div>
<div class="section level3">
<h3 id="generating-scvelo-plots">Generating scVelo Plots<a class="anchor" aria-label="anchor" href="#generating-scvelo-plots"></a>
</h3>
<p>Now, you’re ready to generate scVelo plots. The default dimension
reduction method is typically UMAP, colored by cluster.</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/scVelo.SeuratToAnndata.html">scVelo.Plot</a></span><span class="op">(</span>color <span class="op">=</span> <span class="st">"cluster"</span>, save <span class="op">=</span> <span class="st">"umap1.png"</span>, figsize <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">5</span>,<span class="fl">4</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<p><img src="figures/scvelo_umap1.png"><code>SeuratExtend</code>
supports most commonly used parameters for scVelo plots. You can
customize the plot style, dimensionality reduction method, color
palette, displayed clusters, and more. For more detailed information on
customization and advanced features, refer to the function documentation
or the <a href="https://scvelo.readthedocs.io/en/stable/scvelo.pl.velocity_embedding_stream.html?highlight=stream" class="external-link">official
scVelo documentation</a>.</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/scVelo.SeuratToAnndata.html">scVelo.Plot</a></span><span class="op">(</span></span>
<span>  style <span class="op">=</span> <span class="st">"scatter"</span>,</span>
<span>  color <span class="op">=</span> <span class="st">"cluster"</span>,</span>
<span>  groups <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">"DC"</span>, <span class="st">"Mono CD14"</span><span class="op">)</span>,</span>
<span>  palette <span class="op">=</span> <span class="fu"><a href="../reference/color_pro.html">color_pro</a></span><span class="op">(</span><span class="fl">3</span>, <span class="st">"light"</span><span class="op">)</span>,</span>
<span>  xlim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">0</span>, <span class="fl">5</span><span class="op">)</span>, ylim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">0</span>, <span class="fl">10</span><span class="op">)</span>,</span>
<span>  save <span class="op">=</span> <span class="st">"umap2_specified_area.png"</span>,</span>
<span>  figsize <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">5</span>,<span class="fl">4</span><span class="op">)</span></span>
<span><span class="op">)</span></span></code></pre></div>
<p><img src="figures/scvelo_umap2_specified_area.png"></p>
</div>
</div>
<div class="section level2">
<h2 id="palantir-tutorial-for-trajectory-and-pseudotime-analysis">Palantir Tutorial for Trajectory and Pseudotime Analysis<a class="anchor" aria-label="anchor" href="#palantir-tutorial-for-trajectory-and-pseudotime-analysis"></a>
</h2>
<div class="section level3">
<h3 id="introduction">Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
</h3>
<p><a href="https://github.com/dpeerlab/Palantir" class="external-link">Palantir</a> is a
Python tool designed for aligning cells along differentiation
trajectories, determining cell fate, and calculating pseudotime.
<code>SeuratExtend</code> enables these functionalities within R,
storing the results in a Seurat object for streamlined analysis.</p>
</div>
<div class="section level3">
<h3 id="downloading-example-data-1">Downloading Example Data<a class="anchor" aria-label="anchor" href="#downloading-example-data-1"></a>
</h3>
<p>We will use a subset of myeloid cells from the
<code>pbmc10k_10X</code> dataset available on the <a href="https://www.10xgenomics.com/datasets" class="external-link">10X Genomics website</a>. If
you have already loaded the Seurat object, you can skip this step.</p>
<div class="sourceCode" id="cb6"><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://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">SeuratExtend</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Download the example Seurat Object</span></span>
<span><span class="va">mye_small</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/readRDS.html" class="external-link">readRDS</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/connections.html" class="external-link">url</a></span><span class="op">(</span><span class="st">"https://zenodo.org/records/10944066/files/pbmc10k_mye_small_velocyto.rds"</span>, <span class="st">"rb"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="running-diffusion-map">Running Diffusion Map<a class="anchor" aria-label="anchor" href="#running-diffusion-map"></a>
</h3>
<p>Palantir aligns cells along differentiation trajectories by first
calculating the diffusion map. This is done in Python via
<code>reticulate</code>, based on pre-calculated dimension reductions in
Seurat (e.g., PCA, harmony). The diffusion map (<code>dm</code>) and
multiscale space (<code>ms</code>) embeddings are then added back to the
Seurat object.</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">mye_small</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Palantir-Methods.html">Palantir.RunDM</a></span><span class="op">(</span><span class="va">mye_small</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Determing nearest neighbor graph...</span></span></code></pre>
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># View the new dimensional reductions "dm" and "ms" in the Seurat Object:</span></span>
<span><span class="va">mye_small</span><span class="op">@</span><span class="va">reductions</span></span></code></pre></div>
<pre><code><span><span class="co">## $pca</span></span>
<span><span class="co">## A dimensional reduction object with key PC_ </span></span>
<span><span class="co">##  Number of dimensions: 50 </span></span>
<span><span class="co">##  Number of cells: 1000 </span></span>
<span><span class="co">##  Projected dimensional reduction calculated:  FALSE </span></span>
<span><span class="co">##  Jackstraw run: FALSE </span></span>
<span><span class="co">##  Computed using assay: RNA </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $umap</span></span>
<span><span class="co">## A dimensional reduction object with key UMAP_ </span></span>
<span><span class="co">##  Number of dimensions: 2 </span></span>
<span><span class="co">##  Number of cells: 1000 </span></span>
<span><span class="co">##  Projected dimensional reduction calculated:  FALSE </span></span>
<span><span class="co">##  Jackstraw run: FALSE </span></span>
<span><span class="co">##  Computed using assay: RNA </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $dm</span></span>
<span><span class="co">## A dimensional reduction object with key DM_ </span></span>
<span><span class="co">##  Number of dimensions: 50 </span></span>
<span><span class="co">##  Number of cells: 1000 </span></span>
<span><span class="co">##  Projected dimensional reduction calculated:  FALSE </span></span>
<span><span class="co">##  Jackstraw run: FALSE </span></span>
<span><span class="co">##  Computed using assay: RNA </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## $ms</span></span>
<span><span class="co">## A dimensional reduction object with key MS_ </span></span>
<span><span class="co">##  Number of dimensions: 2 </span></span>
<span><span class="co">##  Number of cells: 1000 </span></span>
<span><span class="co">##  Projected dimensional reduction calculated:  FALSE </span></span>
<span><span class="co">##  Jackstraw run: FALSE </span></span>
<span><span class="co">##  Computed using assay: RNA</span></span></code></pre>
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># View the first 2 ms dimensions:</span></span>
<span><span class="fu"><a href="../reference/DimPlot2.html">DimPlot2</a></span><span class="op">(</span><span class="va">mye_small</span>, reduction <span class="op">=</span> <span class="st">"ms"</span>, group.by <span class="op">=</span> <span class="st">"cluster"</span>, label <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<p><img src="Trajectory_files/figure-html/run-diffusion-map-1.png" width="700"></p>
<div class="section level4">
<h4 id="umap-based-on-ms">UMAP Based on “ms”<a class="anchor" aria-label="anchor" href="#umap-based-on-ms"></a>
</h4>
<p>In this simple example, the multiscale space (‘ms’) reduction has
only 2 dimensions, which makes additional dimension reduction
unnecessary for visualization. However, in more complex datasets, ‘ms’
reductions often yield more dimensions, necessitating further reduction
for effective visualization.</p>
<p>For such cases, one can create a new differentiation trajectory space
by running UMAP based on the “ms” reduction. This approach allows for a
more comprehensible display in a two-dimensional plot, especially when
dealing with a higher-dimensional ‘ms’ space. The following code,
although not run in this tutorial, illustrates how to implement UMAP on
‘ms’ with hypothetical ten dimensions and visualize the result:</p>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Assuming 'ms' has 10 dimensions:</span></span>
<span><span class="co"># mye_small &lt;- RunUMAP(mye_small, reduction = "ms", dims = 1:10)</span></span>
<span><span class="co"># DimPlot2(mye_small, group.by = "cluster", label = TRUE, reduction = "umap")</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="optional-incorporating-newly-calculated-dimension-reductions-into-anndata">(Optional) Incorporating Newly Calculated Dimension Reductions into
AnnData<a class="anchor" aria-label="anchor" href="#optional-incorporating-newly-calculated-dimension-reductions-into-anndata"></a>
</h4>
<p>If you’ve previously followed the scVelo tutorial, an
<code>adata</code> object should already exist in your Python
environment. If you wish to incorporate the dimension reductions
calculated by Palantir (such as ‘ms’) into this <code>adata</code> and
use it for visualization, you can do so with the following commands:</p>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Add the 'ms' dimension reduction to the existing AnnData object</span></span>
<span><span class="fu"><a href="../reference/adata.Load.html">adata.AddDR</a></span><span class="op">(</span><span class="va">mye_small</span>, dr <span class="op">=</span> <span class="st">"ms"</span>, scv.graph <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Generate a plot using the newly added 'ms' dimension reduction</span></span>
<span><span class="fu"><a href="../reference/scVelo.SeuratToAnndata.html">scVelo.Plot</a></span><span class="op">(</span>basis <span class="op">=</span> <span class="st">"ms"</span>, color <span class="op">=</span> <span class="st">"cluster"</span>, save <span class="op">=</span> <span class="st">"umap3_ms.png"</span>, figsize <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">5</span>,<span class="fl">4</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<p><img src="figures/scvelo_umap3_ms.png"></p>
</div>
</div>
<div class="section level3">
<h3 id="determining-cell-fates-and-calculating-pseudotime">Determining Cell Fates and Calculating Pseudotime<a class="anchor" aria-label="anchor" href="#determining-cell-fates-and-calculating-pseudotime"></a>
</h3>
<p>To predict cell fates and calculate pseudotime, You can manually
select “start cells” using the <code>CellSelector</code> function.</p>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">p</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://satijalab.org/seurat/reference/DimPlot.html" class="external-link">DimPlot</a></span><span class="op">(</span><span class="va">mye_small</span>, reduction <span class="op">=</span> <span class="st">"ms"</span>, group.by <span class="op">=</span> <span class="st">"cluster"</span><span class="op">)</span></span>
<span><span class="va">cells</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://satijalab.org/seurat/reference/CellSelector.html" class="external-link">CellSelector</a></span><span class="op">(</span><span class="va">p</span><span class="op">)</span></span></code></pre></div>
<p>Then, calculate pseudotime. Results are stored in
<code>SeuratObj@misc$Palantir$Pseudotime</code>.</p>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">mye_small</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Palantir-Methods.html">Palantir.Pseudotime</a></span><span class="op">(</span><span class="va">mye_small</span>, start_cell <span class="op">=</span> <span class="st">"sample1_GAGAGGTAGCAGTACG-1"</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Sampling and flocking waypoints...</span></span>
<span><span class="co">## Time for determining waypoints: 0.0010946273803710937 minutes</span></span>
<span><span class="co">## Determining pseudotime...</span></span>
<span><span class="co">## Shortest path distances using 30-nearest neighbor graph...</span></span>
<span><span class="co">## Time for shortest paths: 0.10573399464289347 minutes</span></span>
<span><span class="co">## Iteratively refining the pseudotime...</span></span>
<span><span class="co">## Correlation at iteration 1: 1.0000</span></span>
<span><span class="co">## Entropy and branch probabilities...</span></span>
<span><span class="co">## Markov chain construction...</span></span>
<span><span class="co">## Identification of terminal states...</span></span>
<span><span class="co">## Computing fundamental matrix and absorption probabilities...</span></span>
<span><span class="co">## Project results to all cells...</span></span></code></pre>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">ps</span> <span class="op">&lt;-</span> <span class="va">mye_small</span><span class="op">@</span><span class="va">misc</span><span class="op">$</span><span class="va">Palantir</span><span class="op">$</span><span class="va">Pseudotime</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">ps</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">##                            Pseudotime   Entropy sample1_AAACCCAAGGCCCAAA.1</span></span>
<span><span class="co">## sample1_GAGTCATGTACCCGCA-1  0.0369992 0.6087369                  0.7024933</span></span>
<span><span class="co">## sample1_TGGAGGAGTGTATACC-1  0.1307173 0.6093996                  0.7017203</span></span>
<span><span class="co">## sample1_CCCGGAAGTTGGCTAT-1  0.1137811 0.6082388                  0.7030721</span></span>
<span><span class="co">## sample1_CTGAGGCAGTCAGGGT-1  0.2990304 0.4924385                  0.8056717</span></span>
<span><span class="co">## sample1_GCCAACGTCCCGTGTT-1  0.1455877 0.6137009                  0.6966202</span></span>
<span><span class="co">## sample1_TCAAGCAGTGTGGTCC-1  0.0759786 0.6087872                  0.7024348</span></span>
<span><span class="co">##                            sample1_CCTCTAGGTGAACGGT.1</span></span>
<span><span class="co">## sample1_GAGTCATGTACCCGCA-1                  0.2975067</span></span>
<span><span class="co">## sample1_TGGAGGAGTGTATACC-1                  0.2982797</span></span>
<span><span class="co">## sample1_CCCGGAAGTTGGCTAT-1                  0.2969279</span></span>
<span><span class="co">## sample1_CTGAGGCAGTCAGGGT-1                  0.1943283</span></span>
<span><span class="co">## sample1_GCCAACGTCCCGTGTT-1                  0.3033798</span></span>
<span><span class="co">## sample1_TCAAGCAGTGTGGTCC-1                  0.2975652</span></span></code></pre>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Visualize cell fate on UMAP</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/colnames.html" class="external-link">colnames</a></span><span class="op">(</span><span class="va">ps</span><span class="op">)</span><span class="op">[</span><span class="fl">3</span><span class="op">:</span><span class="fl">4</span><span class="op">]</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">"fate1"</span>, <span class="st">"fate2"</span><span class="op">)</span></span>
<span><span class="va">mye_small</span><span class="op">@</span><span class="va">meta.data</span><span class="op">[</span>,<span class="fu"><a href="https://rdrr.io/r/base/colnames.html" class="external-link">colnames</a></span><span class="op">(</span><span class="va">ps</span><span class="op">)</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="va">ps</span></span>
<span><span class="fu"><a href="../reference/DimPlot2.html">DimPlot2</a></span><span class="op">(</span><span class="va">mye_small</span>, features <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/colnames.html" class="external-link">colnames</a></span><span class="op">(</span><span class="va">ps</span><span class="op">)</span>, reduction <span class="op">=</span> <span class="st">"ms"</span>, </span>
<span>         cols <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span>Entropy <span class="op">=</span> <span class="st">"D"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Loading required package: viridis</span></span></code></pre>
<pre><code><span><span class="co">## Loading required package: viridisLite</span></span></code></pre>
<p><img src="Trajectory_files/figure-html/calculate-pseudotime-1.png" width="700"></p>
</div>
</div>
<div class="section level2">
<h2 id="magic-for-denoising-and-smoothing-gene-expression">MAGIC for Denoising and Smoothing Gene Expression<a class="anchor" aria-label="anchor" href="#magic-for-denoising-and-smoothing-gene-expression"></a>
</h2>
<p>Another related tool, <a href="https://github.com/KrishnaswamyLab/MAGIC" class="external-link">MAGIC (Markov
Affinity-based Graph Imputation of Cells)</a>, denoises and smooths gene
expression in scRNA-seq data. Here’s how to run it and observe the
differences in gene expression:</p>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">mye_small</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Palantir-Magic.html">Palantir.Magic</a></span><span class="op">(</span><span class="va">mye_small</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Determing nearest neighbor graph...</span></span></code></pre>
<pre><code><span><span class="co">## Warning: Layer counts isn't present in the assay object; returning NULL</span></span></code></pre>
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Creates a new assay "magic" in the Seurat object</span></span>
<span><span class="va">mye_small</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://satijalab.org/seurat/reference/NormalizeData.html" class="external-link">NormalizeData</a></span><span class="op">(</span><span class="va">mye_small</span><span class="op">)</span></span>
<span><span class="fu"><a href="../reference/DimPlot2.html">DimPlot2</a></span><span class="op">(</span><span class="va">mye_small</span>, features <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">"CD14"</span>, <span class="st">"magic_CD14"</span>, <span class="st">"FLT3"</span>, <span class="st">"magic_FLT3"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<p><img src="Trajectory_files/figure-html/run-magic-1.png" width="700"></p>
</div>
<div class="section level2">
<h2 id="cellrank-tutorial-for-trajectory-analysis">CellRank Tutorial for Trajectory Analysis<a class="anchor" aria-label="anchor" href="#cellrank-tutorial-for-trajectory-analysis"></a>
</h2>
<div class="section level3">
<h3 id="introduction-1">Introduction<a class="anchor" aria-label="anchor" href="#introduction-1"></a>
</h3>
<p>While <a href="https://scvelo.readthedocs.io/" class="external-link">scVelo</a> is a
powerful tool for predicting differentiation potential, it may sometimes
produce arrows pointing opposite the known differentiation trajectory,
which is inconsistent with biological knowledge. For more details and
examples, visit the <a href="https://cellrank.readthedocs.io/en/latest/notebooks/tutorials/kernels/300_pseudotime.html" class="external-link">CellRank
documentation</a>. In such cases, CellRank offers an alternative by
utilizing pre-calculated pseudotime to create trajectory plots.
<strong>However, it’s crucial to ensure that the pseudotime calculation
aligns with validated biological knowledge to avoid misuse of the
algorithm.</strong></p>
<p>This tutorial assumes you have already completed the tutorials for
velocyto and Palantir. We will use CellRank to build trajectory plots,
continuing from where those tutorials left off.</p>
</div>
<div class="section level3">
<h3 id="adding-pseudotime-to-the-adata-object">Adding Pseudotime to the <code>adata</code> Object<a class="anchor" aria-label="anchor" href="#adding-pseudotime-to-the-adata-object"></a>
</h3>
<p>First, we add the Pseudotime calculated by Palantir to the
<code>adata</code> object. This information is saved in the
<code>meta.data</code> of the Seurat Object. We transfer the relevant
column from Seurat to <code>adata</code>:</p>
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/adata.Load.html">adata.AddMetadata</a></span><span class="op">(</span><span class="va">mye_small</span>, col <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/colnames.html" class="external-link">colnames</a></span><span class="op">(</span><span class="va">ps</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="running-cellrank-kernel">Running CellRank Kernel<a class="anchor" aria-label="anchor" href="#running-cellrank-kernel"></a>
</h3>
<p>Next, we run the CellRank Kernel to compute the trajectory plots
using the previously added Pseudotime information.</p>
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/Cellrank-Methods.html">Cellrank.Compute</a></span><span class="op">(</span>time_key <span class="op">=</span> <span class="st">"Pseudotime"</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="generating-the-plots">Generating the Plots<a class="anchor" aria-label="anchor" href="#generating-the-plots"></a>
</h3>
<p>The process for generating plots with CellRank is similar to that
used with <code>scVelo.Plot</code>:</p>
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Generate a plot using the 'ms' dimension reduction</span></span>
<span><span class="fu"><a href="../reference/Cellrank-Methods.html">Cellrank.Plot</a></span><span class="op">(</span>color <span class="op">=</span> <span class="st">"cluster"</span>, basis <span class="op">=</span> <span class="st">"ms"</span>, save <span class="op">=</span> <span class="st">"umap3_ms_cellrank.png"</span><span class="op">)</span></span></code></pre></div>
<p><img src="figures/scvelo_umap3_ms_cellrank.png"></p>
</div>
</div>
<div class="section level2">
<h2 id="gene-expression-dynamics-along-differentiation-trajectories">Gene Expression Dynamics Along Differentiation Trajectories]<a class="anchor" aria-label="anchor" href="#gene-expression-dynamics-along-differentiation-trajectories"></a>
</h2>
<p>Visualizing smoothed gene expression along a trajectory offers
insightful perspectives on cellular differentiation and development.
<code>SeuratExtend</code> introduces two methods for such visualization,
leveraging the pseudotime calculated by tools like
<code>Palantir</code>.</p>
<div class="section level3">
<h3 id="gene-trend-curves-with-palantir">Gene Trend Curves with Palantir<a class="anchor" aria-label="anchor" href="#gene-trend-curves-with-palantir"></a>
</h3>
<p>Assuming you have already executed <code>Palantir.Pseudotime</code>
as shown in a previous tutorial, you can create gene trend curves as
follows:</p>
<div class="sourceCode" id="cb29"><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">SeuratExtend</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Basic gene trend curve visualization</span></span>
<span><span class="fu"><a href="../reference/GeneTrendCurve-Methods.html">GeneTrendCurve.Palantir</a></span><span class="op">(</span><span class="va">mye_small</span>, features <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">"CD14"</span>, <span class="st">"FCGR3A"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<p><img src="Trajectory_files/figure-html/gene-trend-curve-initial-1.png" width="700"></p>
<div class="section level4">
<h4 id="customizing-gene-trend-curves">Customizing Gene Trend Curves<a class="anchor" aria-label="anchor" href="#customizing-gene-trend-curves"></a>
</h4>
<p>You can customize the plots, for instance, by adding points, removing
confidence intervals, and renaming cell fates:</p>
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Accessing pseudotime and adjusting fate names</span></span>
<span><span class="va">ps</span> <span class="op">&lt;-</span> <span class="va">mye_small</span><span class="op">@</span><span class="va">misc</span><span class="op">$</span><span class="va">Palantir</span><span class="op">$</span><span class="va">Pseudotime</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">ps</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">##                            Pseudotime   Entropy sample1_AAACCCAAGGCCCAAA.1</span></span>
<span><span class="co">## sample1_GAGTCATGTACCCGCA-1  0.0369992 0.6087369                  0.7024933</span></span>
<span><span class="co">## sample1_TGGAGGAGTGTATACC-1  0.1307173 0.6093996                  0.7017203</span></span>
<span><span class="co">## sample1_CCCGGAAGTTGGCTAT-1  0.1137811 0.6082388                  0.7030721</span></span>
<span><span class="co">## sample1_CTGAGGCAGTCAGGGT-1  0.2990304 0.4924385                  0.8056717</span></span>
<span><span class="co">## sample1_GCCAACGTCCCGTGTT-1  0.1455877 0.6137009                  0.6966202</span></span>
<span><span class="co">## sample1_TCAAGCAGTGTGGTCC-1  0.0759786 0.6087872                  0.7024348</span></span>
<span><span class="co">##                            sample1_CCTCTAGGTGAACGGT.1</span></span>
<span><span class="co">## sample1_GAGTCATGTACCCGCA-1                  0.2975067</span></span>
<span><span class="co">## sample1_TGGAGGAGTGTATACC-1                  0.2982797</span></span>
<span><span class="co">## sample1_CCCGGAAGTTGGCTAT-1                  0.2969279</span></span>
<span><span class="co">## sample1_CTGAGGCAGTCAGGGT-1                  0.1943283</span></span>
<span><span class="co">## sample1_GCCAACGTCCCGTGTT-1                  0.3033798</span></span>
<span><span class="co">## sample1_TCAAGCAGTGTGGTCC-1                  0.2975652</span></span></code></pre>
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/colnames.html" class="external-link">colnames</a></span><span class="op">(</span><span class="va">ps</span><span class="op">)</span><span class="op">[</span><span class="fl">3</span><span class="op">:</span><span class="fl">4</span><span class="op">]</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">"fate1"</span>, <span class="st">"fate2"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Customized gene trend curve visualization</span></span>
<span><span class="fu"><a href="../reference/GeneTrendCurve-Methods.html">GeneTrendCurve.Palantir</a></span><span class="op">(</span></span>
<span>  <span class="va">mye_small</span>, </span>
<span>  pseudotime.data <span class="op">=</span> <span class="va">ps</span>, </span>
<span>  features <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">"CD14"</span>, <span class="st">"FCGR3A"</span><span class="op">)</span>,</span>
<span>  point <span class="op">=</span> <span class="cn">TRUE</span>, </span>
<span>  se <span class="op">=</span> <span class="cn">FALSE</span></span>
<span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'</span></span></code></pre>
<p><img src="Trajectory_files/figure-html/gene-trend-curve-custom-1.png" width="700"></p>
</div>
</div>
<div class="section level3">
<h3 id="gene-trend-heatmaps-with-palantir">Gene Trend Heatmaps with Palantir<a class="anchor" aria-label="anchor" href="#gene-trend-heatmaps-with-palantir"></a>
</h3>
<p>Another powerful method for visualizing gene expression dynamics is
through heatmaps, which can illustrate how gene expression changes
across pseudotime and for specific lineages:</p>
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Creating a gene trend heatmap</span></span>
<span><span class="fu"><a href="../reference/GeneTrendHeatmap-Methods.html">GeneTrendHeatmap.Palantir</a></span><span class="op">(</span></span>
<span>  <span class="va">mye_small</span>, </span>
<span>  features <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">"CD14"</span>, <span class="fu"><a href="https://mojaveazure.github.io/seurat-object/reference/VariableFeatures.html" class="external-link">VariableFeatures</a></span><span class="op">(</span><span class="va">mye_small</span><span class="op">)</span><span class="op">[</span><span class="fl">1</span><span class="op">:</span><span class="fl">10</span><span class="op">]</span><span class="op">)</span>, </span>
<span>  pseudotime.data <span class="op">=</span> <span class="va">ps</span>, </span>
<span>  magic <span class="op">=</span> <span class="cn">FALSE</span>, </span>
<span>  lineage <span class="op">=</span> <span class="st">"fate1"</span></span>
<span><span class="op">)</span></span></code></pre></div>
<p><img src="Trajectory_files/figure-html/gene-trend-heatmap-1.png" width="700"></p>
</div>
</div>
<div class="section level2">
<h2 id="slingshot-tutorial-for-pseudotime-analysis">Slingshot Tutorial for Pseudotime Analysis<a class="anchor" aria-label="anchor" href="#slingshot-tutorial-for-pseudotime-analysis"></a>
</h2>
<p>Apart from Palantir, <code>Slingshot</code> is another valuable tool
for calculating pseudotime, particularly useful for mapping cellular
trajectories in single-cell RNA sequencing data.</p>
<div class="section level3">
<h3 id="running-slingshot">Running Slingshot<a class="anchor" aria-label="anchor" href="#running-slingshot"></a>
</h3>
<p>To calculate pseudotime using Slingshot, we start by integrating it
with our Seurat object:</p>
<div class="sourceCode" id="cb35"><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">SeuratExtend</span><span class="op">)</span></span>
<span></span>
<span><span class="va">mye_small</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/RunSlingshot.html">RunSlingshot</a></span><span class="op">(</span><span class="va">mye_small</span>, group.by <span class="op">=</span> <span class="st">"cluster"</span>, start.clus <span class="op">=</span> <span class="st">"Mono CD14"</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="accessing-slingshot-output">Accessing Slingshot Output<a class="anchor" aria-label="anchor" href="#accessing-slingshot-output"></a>
</h3>
<p>The Slingshot output is stored within the Seurat object. Let’s
extract the pseudotime values and visualize them on the UMAP:</p>
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">sling</span> <span class="op">&lt;-</span> <span class="va">mye_small</span><span class="op">@</span><span class="va">misc</span><span class="op">$</span><span class="va">slingshot</span><span class="op">$</span><span class="va">PCA</span><span class="op">$</span><span class="va">SlingPseudotime</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">sling</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## DataFrame with 6 rows and 2 columns</span></span>
<span><span class="co">##                            slingPseudotime_1 slingPseudotime_2</span></span>
<span><span class="co">##                                    &lt;numeric&gt;         &lt;numeric&gt;</span></span>
<span><span class="co">## sample1_GAGTCATGTACCCGCA-1           12.3665           12.3423</span></span>
<span><span class="co">## sample1_TGGAGGAGTGTATACC-1           20.2568           20.3749</span></span>
<span><span class="co">## sample1_CCCGGAAGTTGGCTAT-1           19.6071           19.7093</span></span>
<span><span class="co">## sample1_CTGAGGCAGTCAGGGT-1           26.1367           28.3753</span></span>
<span><span class="co">## sample1_GCCAACGTCCCGTGTT-1           17.0883           17.5357</span></span>
<span><span class="co">## sample1_TCAAGCAGTGTGGTCC-1           16.5014           16.4016</span></span></code></pre>
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">mye_small</span><span class="op">@</span><span class="va">meta.data</span><span class="op">[</span>,<span class="fu"><a href="https://rdrr.io/r/base/colnames.html" class="external-link">colnames</a></span><span class="op">(</span><span class="va">sling</span><span class="op">)</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/as.data.frame.html" class="external-link">as.data.frame</a></span><span class="op">(</span><span class="va">sling</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="../reference/DimPlot2.html">DimPlot2</a></span><span class="op">(</span><span class="va">mye_small</span>, features <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/colnames.html" class="external-link">colnames</a></span><span class="op">(</span><span class="va">sling</span><span class="op">)</span>, cols <span class="op">=</span> <span class="st">"C"</span><span class="op">)</span></span></code></pre></div>
<p><img src="Trajectory_files/figure-html/access-slingshot-output-1.png" width="700"></p>
</div>
<div class="section level3">
<h3 id="gene-trend-curves-for-slingshot-pseudotime">Gene Trend Curves for Slingshot Pseudotime<a class="anchor" aria-label="anchor" href="#gene-trend-curves-for-slingshot-pseudotime"></a>
</h3>
<p>Similar to Palantir, Slingshot pseudotime allows for the creation of
gene trend curves, illustrating the dynamics of gene expression along
the computed trajectories:</p>
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/GeneTrendCurve-Methods.html">GeneTrendCurve.Slingshot</a></span><span class="op">(</span><span class="va">mye_small</span>, features <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">"CD14"</span>, <span class="st">"FCGR3A"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'</span></span></code></pre>
<p><img src="Trajectory_files/figure-html/gene-trend-curve-slingshot-1.png" width="700"></p>
</div>
<div class="section level3">
<h3 id="visualizing-gene-trends-with-heatmaps">Visualizing Gene Trends with Heatmaps<a class="anchor" aria-label="anchor" href="#visualizing-gene-trends-with-heatmaps"></a>
</h3>
<p>Additionally, Slingshot pseudotime can be used to generate heatmaps,
showcasing the progression of gene expression across different
lineages:</p>
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/GeneTrendHeatmap-Methods.html">GeneTrendHeatmap.Slingshot</a></span><span class="op">(</span></span>
<span>  <span class="va">mye_small</span>, </span>
<span>  features <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">"CD14"</span>, <span class="fu"><a href="https://mojaveazure.github.io/seurat-object/reference/VariableFeatures.html" class="external-link">VariableFeatures</a></span><span class="op">(</span><span class="va">mye_small</span><span class="op">)</span><span class="op">[</span><span class="fl">1</span><span class="op">:</span><span class="fl">10</span><span class="op">]</span><span class="op">)</span>, </span>
<span>  lineage <span class="op">=</span> <span class="st">"slingPseudotime_2"</span></span>
<span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## Using id as id variables</span></span></code></pre>
<p><img src="Trajectory_files/figure-html/gene-trend-heatmap-slingshot-1.png" width="700"></p>
</div>
</div>
<div class="section level2">
<h2 id="integration-of-seurat-with-python-tools">Integration of Seurat with Python Tools<a class="anchor" aria-label="anchor" href="#integration-of-seurat-with-python-tools"></a>
</h2>
<div class="section level3">
<h3 id="introduction-2">Introduction<a class="anchor" aria-label="anchor" href="#introduction-2"></a>
</h3>
<p><code>SeuratExtend</code> incorporates numerous functions that
utilize Python packages such as <code>Scanpy</code>,
<code>scVelo</code>, <code>Palantir</code>, and <code>CellRank</code>.
This integration facilitates a seamless workflow between
<code>Seurat</code> objects and <code>AnnData</code> formats, crucial
for leveraging the comprehensive analytical capabilities of both R and
Python ecosystems.</p>
<p>To understand the mechanisms behind these functions, it is important
to grasp the fundamentals of how <code>Seurat</code> and
<code>AnnData</code> communicate. Initially, <code>loom</code> files
serve as the intermediary; these h5 format files are widely used for
storing scRNA-seq data and are compatible with both R and Python. Tools
such as <code>velocyto</code> and <code>SCENIC</code> utilize loom
files, which can store gene expression and metadata but have
limitations, such as the inability to store dimensional reduction and
neighborhood graph information.</p>
<p>In <code>SeuratExtend</code>, the conversion from a
<code>Seurat</code> object to an <code>AnnData</code> object does not
occur directly. Instead, <code>loom</code> files act as a bridge—first
converting <code>Seurat</code> to <code>loom</code> and then from
<code>loom</code> to <code>AnnData.</code> The loss of dimensional
reduction information during this process is compensated by other
related functions within <code>SeuratExtend</code>.</p>
</div>
<div class="section level3">
<h3 id="creating-a-conda-environment-with-all-required-python-packages">Creating a Conda Environment with All Required Python Packages<a class="anchor" aria-label="anchor" href="#creating-a-conda-environment-with-all-required-python-packages"></a>
</h3>
<p>If it is your first time running functions related to
<code>scVelo</code>, <code>Palantir</code>, or <code>CellRank</code>,
you will be automatically prompted to install a Conda environment named
“seuratextend”. This environment includes all the Python packages
required by <code>SeuratExtend</code> and is managed through
<code>reticulate</code>. If you prefer to initiate this installation
step manually, you can easily do so by running:</p>
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/create_condaenv_seuratextend.html">create_condaenv_seuratextend</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
<p>This function automatically detects your operating system and sets up
the environment accordingly. It is currently supported and tested on
Windows, macOS, and Linux (Ubuntu 20.04) systems.</p>
</div>
<div class="section level3">
<h3 id="integrating-seurat-with-anndata">Integrating Seurat with AnnData<a class="anchor" aria-label="anchor" href="#integrating-seurat-with-anndata"></a>
</h3>
<p>In this section, we demonstrate the utility of functions designed to
bridge <code>Seurat</code> objects with Python’s <code>AnnData</code>
structures, using a small <code>pbmc</code> Seurat object as an example.
The process covers conversion to a <code>loom</code> file, importing
into <code>AnnData</code>, and appending additional metadata and
dimension reduction data.</p>
<div class="section level4">
<h4 id="converting-seurat-object-to-loom">Converting Seurat Object to Loom<a class="anchor" aria-label="anchor" href="#converting-seurat-object-to-loom"></a>
</h4>
<p>First, we convert a <code>Seurat</code> object to a <code>loom</code>
file which can then be used to create an <code>AnnData</code>
object:</p>
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Convert Seurat object to loom file and save it locally</span></span>
<span><span class="va">pbmc_loom_path</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/file.path.html" class="external-link">file.path</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/tempfile.html" class="external-link">tempdir</a></span><span class="op">(</span><span class="op">)</span>, <span class="st">"pbmc3k_small.loom"</span><span class="op">)</span></span>
<span><span class="fu"><a href="../reference/adata.Load.html">Seu2Loom</a></span><span class="op">(</span><span class="va">pbmc</span>, filename <span class="op">=</span> <span class="va">pbmc_loom_path</span>, add.normdata <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="importing-loom-file-into-anndata">Importing Loom File into AnnData<a class="anchor" aria-label="anchor" href="#importing-loom-file-into-anndata"></a>
</h4>
<p>Next, we import the <code>loom</code> file into an
<code>AnnData</code> object, which is handled by Python:</p>
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Load the loom file into an AnnData object</span></span>
<span><span class="fu"><a href="../reference/adata.Load.html">adata.LoadLoom</a></span><span class="op">(</span>loompath <span class="op">=</span> <span class="va">pbmc_loom_path</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="viewing-anndata-object">Viewing AnnData Object<a class="anchor" aria-label="anchor" href="#viewing-anndata-object"></a>
</h4>
<p>To view the newly created <code>AnnData</code> object, we use
<code>reticulate</code> to execute Python code:</p>
<div class="sourceCode" id="cb46"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Print the AnnData object details</span></span>
<span><span class="fu">py_run_string</span><span class="op">(</span><span class="st">"print(adata)"</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AnnData object with n_obs × n_vars = 500 × 12627</span></span>
<span><span class="co">##     obs: 'RNA_snn_res.0.5', 'cluster', 'nCount_RNA', 'nFeature_RNA', 'orig.ident', 'percent.mt', 'seurat_clusters'</span></span>
<span><span class="co">##     layers: 'counts'</span></span></code></pre>
</div>
<div class="section level4">
<h4 id="adding-dimension-reduction-data">Adding Dimension Reduction Data<a class="anchor" aria-label="anchor" href="#adding-dimension-reduction-data"></a>
</h4>
<p><code>AnnData</code> objects can store more than just gene expression
and metadata; here we add dimension reduction data from
<code>Seurat</code>:</p>
<div class="sourceCode" id="cb48"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Add dimension reduction data from Seurat to AnnData</span></span>
<span><span class="fu"><a href="../reference/adata.Load.html">adata.AddDR</a></span><span class="op">(</span><span class="va">pbmc</span><span class="op">)</span></span>
<span><span class="co"># Print the updated AnnData object</span></span>
<span><span class="fu">py_run_string</span><span class="op">(</span><span class="st">"print(adata)"</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AnnData object with n_obs × n_vars = 500 × 12627</span></span>
<span><span class="co">##     obs: 'RNA_snn_res.0.5', 'cluster', 'nCount_RNA', 'nFeature_RNA', 'orig.ident', 'percent.mt', 'seurat_clusters'</span></span>
<span><span class="co">##     obsm: 'X_pca', 'X_umap'</span></span>
<span><span class="co">##     layers: 'counts'</span></span></code></pre>
</div>
<div class="section level4">
<h4 id="direct-conversion-from-seurat-to-anndata">Direct Conversion from Seurat to AnnData<a class="anchor" aria-label="anchor" href="#direct-conversion-from-seurat-to-anndata"></a>
</h4>
<p>For a streamlined conversion that includes the steps of
<code><a href="../reference/adata.Load.html">Seu2Loom()</a></code>, <code><a href="../reference/adata.Load.html">adata.LoadLoom()</a></code> and
<code><a href="../reference/adata.Load.html">adata.AddDR()</a></code>, you can use a single function:</p>
<div class="sourceCode" id="cb50"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Directly convert Seurat object to AnnData object</span></span>
<span><span class="fu"><a href="../reference/adata.Load.html">Seu2Adata</a></span><span class="op">(</span><span class="va">pbmc</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="updating-anndata-with-new-metadata">Updating AnnData with New Metadata<a class="anchor" aria-label="anchor" href="#updating-anndata-with-new-metadata"></a>
</h4>
<p>If new metadata columns are added to the <code>Seurat</code> object,
they can also be incorporated into the <code>AnnData</code> object:</p>
<div class="sourceCode" id="cb51"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Add new metadata column to AnnData</span></span>
<span><span class="va">pbmc</span><span class="op">$</span><span class="va">cluster2</span> <span class="op">&lt;-</span> <span class="va">pbmc</span><span class="op">$</span><span class="va">cluster</span></span>
<span><span class="fu"><a href="../reference/adata.Load.html">adata.AddMetadata</a></span><span class="op">(</span><span class="va">pbmc</span>, col <span class="op">=</span> <span class="st">"cluster2"</span><span class="op">)</span></span>
<span><span class="co"># Print the updated AnnData object</span></span>
<span><span class="fu">py_run_string</span><span class="op">(</span><span class="st">"print(adata)"</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## AnnData object with n_obs × n_vars = 500 × 12627</span></span>
<span><span class="co">##     obs: 'RNA_snn_res.0.5', 'cluster', 'nCount_RNA', 'nFeature_RNA', 'orig.ident', 'percent.mt', 'seurat_clusters', 'cluster2'</span></span>
<span><span class="co">##     obsm: 'X_pca', 'X_umap'</span></span>
<span><span class="co">##     layers: 'counts'</span></span></code></pre>
</div>
<div class="section level4">
<h4 id="saving-and-loading-anndata">Saving and Loading AnnData<a class="anchor" aria-label="anchor" href="#saving-and-loading-anndata"></a>
</h4>
<p>You can save the <code>AnnData</code> object to a local file for
future use:</p>
<div class="sourceCode" id="cb53"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Save the AnnData object to a local file</span></span>
<span><span class="va">pbmc_adata_path</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/file.path.html" class="external-link">file.path</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/tempfile.html" class="external-link">tempdir</a></span><span class="op">(</span><span class="op">)</span>, <span class="st">"pbmc3k_small.h5ad"</span><span class="op">)</span></span>
<span><span class="fu"><a href="../reference/adata.Load.html">adata.Save</a></span><span class="op">(</span><span class="va">pbmc_adata_path</span><span class="op">)</span></span></code></pre></div>
<p>And load it back when needed:</p>
<div class="sourceCode" id="cb54"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Load an existing AnnData object from file</span></span>
<span><span class="fu"><a href="../reference/adata.Load.html">adata.Load</a></span><span class="op">(</span><span class="va">pbmc_adata_path</span><span class="op">)</span></span></code></pre></div>
<p>If you have completed the scVelo tutorial and saved the results, you
can load the <code>AnnData</code> object and directly generate
plots:</p>
<div class="sourceCode" id="cb55"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Load the scVelo tutorial results and generate a plot</span></span>
<span><span class="fu"><a href="../reference/adata.Load.html">adata.Load</a></span><span class="op">(</span><span class="va">adata_path</span><span class="op">)</span></span>
<span><span class="fu"><a href="../reference/scVelo.SeuratToAnndata.html">scVelo.Plot</a></span><span class="op">(</span>color <span class="op">=</span> <span class="st">"cluster"</span>, figsize <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">5</span>,<span class="fl">4</span><span class="op">)</span>, save <span class="op">=</span> <span class="st">"umap4_load_adata.png"</span><span class="op">)</span></span></code></pre></div>
<p><img src="figures/scvelo_umap4_load_adata.png"></p>
<div class="sourceCode" id="cb56"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/utils/sessionInfo.html" class="external-link">sessionInfo</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
<pre><code><span><span class="co">## R version 4.4.0 (2024-04-24)</span></span>
<span><span class="co">## Platform: x86_64-pc-linux-gnu</span></span>
<span><span class="co">## Running under: Ubuntu 20.04.6 LTS</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## Matrix products: default</span></span>
<span><span class="co">## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 </span></span>
<span><span class="co">## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## locale:</span></span>
<span><span class="co">##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              </span></span>
<span><span class="co">##  [3] LC_TIME=de_BE.UTF-8        LC_COLLATE=en_US.UTF-8    </span></span>
<span><span class="co">##  [5] LC_MONETARY=de_BE.UTF-8    LC_MESSAGES=en_US.UTF-8   </span></span>
<span><span class="co">##  [7] LC_PAPER=de_BE.UTF-8       LC_NAME=C                 </span></span>
<span><span class="co">##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            </span></span>
<span><span class="co">## [11] LC_MEASUREMENT=de_BE.UTF-8 LC_IDENTIFICATION=C       </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## time zone: Europe/Brussels</span></span>
<span><span class="co">## tzcode source: system (glibc)</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## attached base packages:</span></span>
<span><span class="co">## [1] stats4    tools     stats     graphics  grDevices utils     datasets </span></span>
<span><span class="co">## [8] methods   base     </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## other attached packages:</span></span>
<span><span class="co">##  [1] slingshot_2.12.0            TrajectoryUtils_1.12.0     </span></span>
<span><span class="co">##  [3] SingleCellExperiment_1.26.0 SummarizedExperiment_1.34.0</span></span>
<span><span class="co">##  [5] Biobase_2.64.0              GenomicRanges_1.56.0       </span></span>
<span><span class="co">##  [7] GenomeInfoDb_1.40.1         IRanges_2.38.0             </span></span>
<span><span class="co">##  [9] S4Vectors_0.42.0            BiocGenerics_0.50.0        </span></span>
<span><span class="co">## [11] MatrixGenerics_1.16.0       matrixStats_1.3.0          </span></span>
<span><span class="co">## [13] princurve_2.1.6             rlang_1.1.4                </span></span>
<span><span class="co">## [15] scales_1.3.0                dplyr_1.1.4                </span></span>
<span><span class="co">## [17] mgcv_1.9-1                  nlme_3.1-165               </span></span>
<span><span class="co">## [19] reshape2_1.4.4              viridis_0.6.5              </span></span>
<span><span class="co">## [21] viridisLite_0.4.2           cowplot_1.1.3              </span></span>
<span><span class="co">## [23] ggplot2_3.5.1               reticulate_1.37.0          </span></span>
<span><span class="co">## [25] glue_1.7.0                  hdf5r_1.3.10               </span></span>
<span><span class="co">## [27] SeuratExtend_1.0.0          SeuratExtendData_0.2.0     </span></span>
<span><span class="co">## [29] Seurat_5.1.0                SeuratObject_5.0.2         </span></span>
<span><span class="co">## [31] sp_2.1-4                   </span></span>
<span><span class="co">## </span></span>
<span><span class="co">## loaded via a namespace (and not attached):</span></span>
<span><span class="co">##   [1] RcppAnnoy_0.0.22          splines_4.4.0            </span></span>
<span><span class="co">##   [3] later_1.3.2               tibble_3.2.1             </span></span>
<span><span class="co">##   [5] polyclip_1.10-6           fastDummies_1.7.3        </span></span>
<span><span class="co">##   [7] lifecycle_1.0.4           globals_0.16.3           </span></span>
<span><span class="co">##   [9] lattice_0.22-6            MASS_7.3-60.2            </span></span>
<span><span class="co">##  [11] magrittr_2.0.3            plotly_4.10.4            </span></span>
<span><span class="co">##  [13] sass_0.4.9                rmarkdown_2.27           </span></span>
<span><span class="co">##  [15] jquerylib_0.1.4           yaml_2.3.8               </span></span>
<span><span class="co">##  [17] rlist_0.4.6.2             httpuv_1.6.15            </span></span>
<span><span class="co">##  [19] sctransform_0.4.1         spam_2.10-0              </span></span>
<span><span class="co">##  [21] spatstat.sparse_3.0-3     pbapply_1.7-2            </span></span>
<span><span class="co">##  [23] RColorBrewer_1.1-3        abind_1.4-5              </span></span>
<span><span class="co">##  [25] zlibbioc_1.50.0           Rtsne_0.17               </span></span>
<span><span class="co">##  [27] purrr_1.0.2               rappdirs_0.3.3           </span></span>
<span><span class="co">##  [29] GenomeInfoDbData_1.2.12   ggrepel_0.9.5            </span></span>
<span><span class="co">##  [31] irlba_2.3.5.1             listenv_0.9.1            </span></span>
<span><span class="co">##  [33] spatstat.utils_3.0-4      goftest_1.2-3            </span></span>
<span><span class="co">##  [35] RSpectra_0.16-1           spatstat.random_3.2-3    </span></span>
<span><span class="co">##  [37] fitdistrplus_1.1-11       parallelly_1.37.1        </span></span>
<span><span class="co">##  [39] DelayedMatrixStats_1.26.0 pkgdown_2.0.9            </span></span>
<span><span class="co">##  [41] leiden_0.4.3.1            codetools_0.2-20         </span></span>
<span><span class="co">##  [43] DelayedArray_0.30.1       tidyselect_1.2.1         </span></span>
<span><span class="co">##  [45] UCSC.utils_1.0.0          farver_2.1.2             </span></span>
<span><span class="co">##  [47] spatstat.explore_3.2-7    jsonlite_1.8.8           </span></span>
<span><span class="co">##  [49] progressr_0.14.0          ggridges_0.5.6           </span></span>
<span><span class="co">##  [51] survival_3.7-0            systemfonts_1.1.0        </span></span>
<span><span class="co">##  [53] ragg_1.3.2                ica_1.0-3                </span></span>
<span><span class="co">##  [55] Rcpp_1.0.12               gridExtra_2.3            </span></span>
<span><span class="co">##  [57] SparseArray_1.4.8         xfun_0.44                </span></span>
<span><span class="co">##  [59] withr_3.0.0               fastmap_1.2.0            </span></span>
<span><span class="co">##  [61] fansi_1.0.6               digest_0.6.35            </span></span>
<span><span class="co">##  [63] R6_2.5.1                  mime_0.12                </span></span>
<span><span class="co">##  [65] textshaping_0.4.0         colorspace_2.1-0         </span></span>
<span><span class="co">##  [67] scattermore_1.2           tensor_1.5               </span></span>
<span><span class="co">##  [69] spatstat.data_3.0-4       utf8_1.2.4               </span></span>
<span><span class="co">##  [71] tidyr_1.3.1               generics_0.1.3           </span></span>
<span><span class="co">##  [73] data.table_1.15.4         httr_1.4.7               </span></span>
<span><span class="co">##  [75] htmlwidgets_1.6.4         S4Arrays_1.4.1           </span></span>
<span><span class="co">##  [77] uwot_0.2.2                pkgconfig_2.0.3          </span></span>
<span><span class="co">##  [79] gtable_0.3.5              lmtest_0.9-40            </span></span>
<span><span class="co">##  [81] XVector_0.44.0            htmltools_0.5.8.1        </span></span>
<span><span class="co">##  [83] dotCall64_1.1-1           png_0.1-8                </span></span>
<span><span class="co">##  [85] knitr_1.47                rstudioapi_0.16.0        </span></span>
<span><span class="co">##  [87] cachem_1.1.0              zoo_1.8-12               </span></span>
<span><span class="co">##  [89] stringr_1.5.1             KernSmooth_2.23-24       </span></span>
<span><span class="co">##  [91] parallel_4.4.0            miniUI_0.1.1.1           </span></span>
<span><span class="co">##  [93] desc_1.4.3                pillar_1.9.0             </span></span>
<span><span class="co">##  [95] grid_4.4.0                vctrs_0.6.5              </span></span>
<span><span class="co">##  [97] RANN_2.6.1                promises_1.3.0           </span></span>
<span><span class="co">##  [99] xtable_1.8-4              cluster_2.1.6            </span></span>
<span><span class="co">## [101] evaluate_0.23             cli_3.6.2                </span></span>
<span><span class="co">## [103] compiler_4.4.0            crayon_1.5.2             </span></span>
<span><span class="co">## [105] future.apply_1.11.2       labeling_0.4.3           </span></span>
<span><span class="co">## [107] plyr_1.8.9                fs_1.6.4                 </span></span>
<span><span class="co">## [109] stringi_1.8.4             deldir_2.0-4             </span></span>
<span><span class="co">## [111] munsell_0.5.1             lazyeval_0.2.2           </span></span>
<span><span class="co">## [113] spatstat.geom_3.2-9       Matrix_1.7-0             </span></span>
<span><span class="co">## [115] RcppHNSW_0.6.0            patchwork_1.2.0          </span></span>
<span><span class="co">## [117] sparseMatrixStats_1.16.0  bit64_4.0.5              </span></span>
<span><span class="co">## [119] future_1.33.2             shiny_1.8.1.1            </span></span>
<span><span class="co">## [121] highr_0.11                ROCR_1.0-11              </span></span>
<span><span class="co">## [123] igraph_1.3.4              memoise_2.0.1            </span></span>
<span><span class="co">## [125] bslib_0.7.0               bit_4.0.5</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 Yichao Hua.</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.9.</p>
</div>

      </footer>
</div>

  


  

  </body>
</html>
