Skip to content

Commit

Permalink
Built site for gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrunqin committed Dec 20, 2024
1 parent c54ad2c commit 1354c4f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .nojekyll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4bd82853
c890d009
2 changes: 1 addition & 1 deletion 03a-cell_annotation.html
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ <h1 class="title">
</div>
</div>
<div class="callout-body-container callout-body">
<p><strong>Imperfect clustering can stem from many issues: the 3 most common are outlined below:</strong></p>
<p><strong>Three common issues which cause imperfect clustering have been outlined below:</strong></p>
<ol type="1">
<li>
<strong>Imperfect segmentation</strong> - excessive lateral marker spill over can severely impact downstream clustering, as cell type specific markers leak into nearby cells. This should largely be diagnosed in the segmentation step and will need to be fixed by optimizing the upstream segmentation algorithm.</li>
Expand Down
52 changes: 10 additions & 42 deletions 04a-cell_localisation.html
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ <h1 class="title">
</div>
<section id="quantifying-cell-type-co-localisation-with-spicyr" class="level2" data-number="8.1"><h2 data-number="8.1" class="anchored" data-anchor-id="quantifying-cell-type-co-localisation-with-spicyr">
<span class="header-section-number">8.1</span> Quantifying cell type co-localisation with spicyR</h2>
<p><a href="https://www.bioconductor.org/packages/release/bioc/html/spicyR.html">spicyR</a> provides a metric to quantify the degree of localisation or dispersion between two cell types. It then tests for changes in the co-localisation metric across different disease states or groups. Here, we will use the Keren 2018 dataset to demonstrate the use of <code>spicyR</code> The data is stored as a <code>SpatialExperiment</code> object within the <code>SpatialDatasets</code> package and contains single-cell spatial data from 41 images for three types of breast cancer tumours (cold, compartmentalised, and mixed).</p>
<p><a href="https://www.bioconductor.org/packages/release/bioc/html/spicyR.html">spicyR</a> provides a metric to quantify the degree of localisation or dispersion between two cell types. It then tests for changes in the co-localisation metric across different disease states or groups.</p>
<p><img src="images/spicyR_fig1.jpeg" align="center" style="height: 300px; border: 0px"></p>
<p>Here, we will use the Keren 2018 dataset to demonstrate the use of <code>spicyR</code>. The data is stored as a <code>SpatialExperiment</code> object within the <code>SpatialDatasets</code> package and contains single-cell spatial data from 41 images for three types of breast cancer tumours (cold, compartmentalised, and mixed).</p>
<div class="cell">
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">kerenSPE</span> <span class="op">&lt;-</span> <span class="fu">SpatialDatasets</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/SpatialDatasets/man/SpatialDatasets.html">spe_Keren_2018</a></span><span class="op">(</span><span class="op">)</span></span>
<span></span>
Expand Down Expand Up @@ -719,7 +721,7 @@ <h1 class="title">
<p>In the example below, we examine the degree of co-localisation between <code>Keratin_Tumour__Neutrophils</code> in one image using the <code>getPairwise</code> function, which returns the L-function values for each cell type pair. We set the radius over which the L-function should be calculated (<code>Rs = 100</code>) and specify <code>sigma = NULL</code>. The calculated L-function is positive, indicating attraction between the two cell types.</p>
<div class="cell">
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co"># filter SPE object to obtain image 24 data</span></span>
<span><span class="va">kerenSubset</span> <span class="op">=</span> <span class="va">kerenSPE</span><span class="op">[</span>, <span class="fu">colData</span><span class="op">(</span><span class="va">kerenSPE</span><span class="op">)</span><span class="op">$</span><span class="va">imageID</span> <span class="op">==</span> <span class="st">"24"</span><span class="op">]</span></span>
<span><span class="va">kerenSubset</span> <span class="op">=</span> <span class="va">kerenSPE</span><span class="op">[</span>, <span class="fu">colData</span><span class="op">(</span><span class="va">kerenSPE</span><span class="op">)</span><span class="op">$</span><span class="va">imageID</span> <span class="op">==</span> <span class="st">"1"</span><span class="op">]</span></span>
<span></span>
<span><span class="va">pairwiseAssoc</span> <span class="op">=</span> <span class="fu"><a href="https://sydneybiox.github.io/spicyR/reference/getPairwise.html">getPairwise</a></span><span class="op">(</span><span class="va">kerenSubset</span>, </span>
<span> sigma <span class="op">=</span> <span class="cn">NULL</span>, </span>
Expand All @@ -728,59 +730,25 @@ <h1 class="title">
<span></span>
<span><span class="va">pairwiseAssoc</span><span class="op">[[</span><span class="st">"Keratin_Tumour__Neutrophils"</span><span class="op">]</span><span class="op">]</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 10.88892</code></pre>
<pre><code>[1] -5.837485</code></pre>
</div>
</div>
<p>When we specify <code>sigma = 20</code> and re-calculate the L-function, it indicates that there is no relationship between <code>Keratin_Tumour</code> and <code>Neutrophils</code>, i.e., there is no major attraction or dispersion, as it now takes into account tissue inhomogeneity.</p>
<div class="cell">
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">pairwiseAssoc</span> <span class="op">=</span> <span class="fu"><a href="https://sydneybiox.github.io/spicyR/reference/getPairwise.html">getPairwise</a></span><span class="op">(</span><span class="va">kerenSubset</span>, </span>
<span> sigma <span class="op">=</span> <span class="fl">20</span>, </span>
<span> Rs <span class="op">=</span> <span class="fl">100</span><span class="op">)</span> <span class="op">|&gt;</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/as.data.frame.html">as.data.frame</a></span><span class="op">(</span><span class="op">)</span></span>
<span> Rs <span class="op">=</span> <span class="fl">100</span><span class="op">)</span> <span class="op">|&gt;</span> <span class="fu"><a href="https://rdrr.io/r/base/as.data.frame.html">as.data.frame</a></span><span class="op">(</span><span class="op">)</span></span>
<span></span>
<span><span class="va">pairwiseAssoc</span><span class="op">[[</span><span class="st">"Keratin_Tumour__Neutrophils"</span><span class="op">]</span><span class="op">]</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 0.9024836</code></pre>
<pre><code>[1] 1.962962</code></pre>
</div>
</div>
<p>To understand why this might be happening, we can take a closer look at the relationship between <code>Keratin_Tumour</code> and <code>Neutrophils</code>. The <code>plotImage</code> function allows us to plot any two cell types for a specific image. Below, we plot image 24 for the <code>Keratin_Tumour__Neutrophils</code> relationship by specifying <code>from = Keratin_Tumour</code> and <code>to</code> = <code>Neutrophils</code>.</p>
<div class="cell">
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co"># obtain colData for image 24</span></span>
<span><span class="va">cData</span> <span class="op">=</span> <span class="fu">colData</span><span class="op">(</span><span class="va">kerenSPE</span><span class="op">)</span> <span class="op">|&gt;</span> <span class="fu"><a href="https://rdrr.io/r/base/as.data.frame.html">as.data.frame</a></span><span class="op">(</span><span class="op">)</span> <span class="op">|&gt;</span> </span>
<span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="va">imageID</span> <span class="op">==</span> <span class="st">"24"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># obtain cells present in image 24</span></span>
<span><span class="va">coords</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/pkg/SpatialExperiment/man/SpatialExperiment-methods.html">spatialCoords</a></span><span class="op">(</span><span class="va">kerenSPE</span><span class="op">)</span> <span class="op">|&gt;</span> <span class="fu"><a href="https://rdrr.io/r/base/as.data.frame.html">as.data.frame</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="va">coords</span><span class="op">$</span><span class="va">cellID</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/colnames.html">rownames</a></span><span class="op">(</span><span class="va">coords</span><span class="op">)</span></span>
<span><span class="va">coords</span> <span class="op">=</span> <span class="va">coords</span> <span class="op">|&gt;</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="va">cellID</span> <span class="op"><a href="https://rdrr.io/r/base/match.html">%in%</a></span> <span class="va">cData</span><span class="op">$</span><span class="va">CellID</span><span class="op">)</span></span>
<span></span>
<span><span class="va">cData</span><span class="op">$</span><span class="va">X</span> <span class="op">=</span> <span class="va">coords</span><span class="op">$</span><span class="va">x</span></span>
<span><span class="va">cData</span><span class="op">$</span><span class="va">Y</span> <span class="op">=</span> <span class="va">coords</span><span class="op">$</span><span class="va">y</span></span>
<span></span>
<span><span class="va">cData</span> <span class="op">=</span> <span class="va">cData</span> <span class="op">|&gt;</span> </span>
<span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>cellTypeNew <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span><span class="op">(</span><span class="va">cellType</span> <span class="op"><a href="https://rdrr.io/r/base/match.html">%in%</a></span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Keratin_Tumour"</span>, <span class="st">"Neutrophils"</span><span class="op">)</span>, </span>
<span> <span class="va">cellType</span>, <span class="st">"Other"</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span> <span class="va">pal</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/setNames.html">setNames</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"#d6b11c"</span>, <span class="st">"#850f07"</span><span class="op">)</span>, </span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Keratin_Tumour"</span>, <span class="st">"Neutrophils"</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot</a></span><span class="op">(</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_density_2d.html">stat_density_2d</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">cData</span>, <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">X</span>, y <span class="op">=</span> <span class="va">Y</span>, fill <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes_eval.html">after_stat</a></span><span class="op">(</span><span class="va">density</span><span class="op">)</span><span class="op">)</span>, </span>
<span> geom <span class="op">=</span> <span class="st">"raster"</span>, </span>
<span> contour <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_point.html">geom_point</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">cData</span> <span class="op">|&gt;</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="va">cellType</span> <span class="op">!=</span> <span class="st">"Other"</span><span class="op">)</span>,</span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">X</span>, y <span class="op">=</span> <span class="va">Y</span>, colour <span class="op">=</span> <span class="va">cellTypeNew</span><span class="op">)</span>, size <span class="op">=</span> <span class="fl">1</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_manual.html">scale_color_manual</a></span><span class="op">(</span>values <span class="op">=</span> <span class="va">pal</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_brewer.html">scale_fill_distiller</a></span><span class="op">(</span>palette <span class="op">=</span> <span class="st">"Blues"</span>, direction <span class="op">=</span> <span class="fl">1</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggtheme.html">theme_classic</a></span><span class="op">(</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html">labs</a></span><span class="op">(</span>title <span class="op">=</span> <span class="st">"image ID: 24"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure"><p><img src="04a-cell_localisation_files/figure-html/04a-plotCellTypes-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu">plotImage</span><span class="op">(</span><span class="va">kerenSPE</span>, imageToPlot <span class="op">=</span> <span class="st">"24"</span>, from <span class="op">=</span> <span class="st">"Keratin_Tumour"</span>, to <span class="op">=</span> <span class="st">"Neutrophils"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Plotting image 24 shows that the supposed co-localisation occurs due to the dense cluster of cells near the top of the image.</p>
<p>Plotting image 24 shows that the supposed co-localisation occurs due to the dense cluster of cells near the bottom of the image.</p>
</section></section><section id="sessioninfo" class="level2" data-number="8.2"><h2 data-number="8.2" class="anchored" data-anchor-id="sessioninfo">
<span class="header-section-number">8.2</span> sessionInfo</h2>
<div class="cell">
Expand Down
1 change: 1 addition & 0 deletions 04b-cell_localisation_parent.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ <h1 class="title">
</section><section id="kontextual-context-aware-cell-localisation" class="level2" data-number="9.2"><h2 data-number="9.2" class="anchored" data-anchor-id="kontextual-context-aware-cell-localisation">
<span class="header-section-number">9.2</span> Kontextual: Context aware cell localisation</h2>
<p><code>Kontextual</code> is a method for performing inference on cell localisation which explicitly defines the contexts in which spatial relationships between cells can be identified and interpreted. These contexts may represent landmarks, spatial domains, or groups of functionally similar cells which are consistent across regions. By modelling spatial relationships between cells relative to these contexts, <code>Kontextual</code> produces robust spatial quantifications that are not confounded by biases such as the choice of region to image and the tissue structure present in the images. The <code>Kontextual</code> function is available in the <a href="https://www.bioconductor.org/packages/release/bioc/html/Statial.html">Statial</a> package.</p>
<p><img src="images/kontextual_fig1.png" align="center" style="height: 300px; border: 0px"></p>
<p>In this example we demonstrate how cell type hierarchies can be used as a means to derive appropriate “contexts” for the evaluation of cell localisation. We then demonstrate the types of conclusions which <code>Kontextual</code> enables.</p>
<section id="using-cell-type-hierarchies-to-define-a-context" class="level3" data-number="9.2.1"><h3 data-number="9.2.1" class="anchored" data-anchor-id="using-cell-type-hierarchies-to-define-a-context">
<span class="header-section-number">9.2.1</span> Using cell type hierarchies to define a “context”</h3>
Expand Down
Loading

0 comments on commit 1354c4f

Please sign in to comment.