<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>Multi-omics</title>
<script src="site_libs/header-attrs-2.29/header-attrs.js"></script>
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/flatly.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<style>h1 {font-size: 34px;}
h1.title {font-size: 38px;}
h2 {font-size: 30px;}
h3 {font-size: 24px;}
h4 {font-size: 18px;}
h5 {font-size: 16px;}
h6 {font-size: 12px;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<script src="site_libs/jqueryui-1.13.2/jquery-ui.min.js"></script>
<link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/textmate.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<link href="site_libs/font-awesome-6.5.2/css/all.min.css" rel="stylesheet" />
<link href="site_libs/font-awesome-6.5.2/css/v4-shims.min.css" rel="stylesheet" />
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">code{white-space: pre;}</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
details > summary > p:only-child {
display: inline;
}
pre code {
padding: 0;
}
</style>
<style type="text/css">
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #adb5bd;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
border-radius: 6px 0 6px 6px;
}
</style>
<script type="text/javascript">
// manage active state of menu based on current page
$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');
// mark the anchor link active (and if it's in a dropdown, also mark that active)
var dropdown = menuAnchor.closest('li.dropdown');
if (window.bootstrap) { // Bootstrap 4+
menuAnchor.addClass('active');
dropdown.find('> .dropdown-toggle').addClass('active');
} else { // Bootstrap 3
menuAnchor.parent().addClass('active');
dropdown.addClass('active');
}
// Navbar adjustments
var navHeight = $(".navbar").first().height() + 15;
var style = document.createElement('style');
var pt = "padding-top: " + navHeight + "px; ";
var mt = "margin-top: -" + navHeight + "px; ";
var css = "";
// offset scroll position for anchor links (for fixed navbar)
for (var i = 1; i <= 6; i++) {
css += ".section h" + i + "{ " + pt + mt + "}\n";
}
style.innerHTML = "body {" + pt + "padding-bottom: 40px; }\n" + css;
document.head.appendChild(style);
});
</script>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "\e259";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "\e258";
font-family: 'Glyphicons Halflings';
border: none;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
<style type="text/css">
#TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
position: relative;
width: 100%;
}
}
@media print {
.toc-content {
/* see https://github.com/w3c/csswg-drafts/issues/4434 */
float: right;
}
}
.toc-content {
padding-left: 30px;
padding-right: 40px;
}
div.main-container {
max-width: 1200px;
}
div.tocify {
width: 20%;
max-width: 260px;
max-height: 85%;
}
@media (min-width: 768px) and (max-width: 991px) {
div.tocify {
width: 25%;
}
}
@media (max-width: 767px) {
div.tocify {
width: 100%;
max-width: none;
}
}
.tocify ul, .tocify li {
line-height: 20px;
}
.tocify-subheader .tocify-item {
font-size: 0.90em;
}
.tocify .list-group-item {
border-radius: 0px;
}
.tocify-subheader {
display: inline;
}
.tocify-subheader .tocify-item {
font-size: 0.95em;
}
</style>
</head>
<body>
<div class="container-fluid main-container">
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-3">
<div id="TOC" class="tocify">
</div>
</div>
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
<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-bs-toggle="collapse" data-target="#navbar" data-bs-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">VoltRon</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="tutorials.html">Explore</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Vignette
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li class="dropdown-submenu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">Spatial Data Integration</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="registration.html">Spatial Data Alignment</a>
</li>
<li>
<a href="multiomic.html">Multi-omic Integration</a>
</li>
<li>
<a href="nicheclustering.html">Niche Clustering</a>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">Downstream Analysis</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="roianalysis.html">ROI Analysis</a>
</li>
<li>
<a href="spotanalysis.html">Cell/Spot Analysis</a>
</li>
<li>
<a href="moleculeanalysis.html">Molecule Analysis</a>
</li>
<li>
<a href="pixelanalysis.html">Pixels (Image Only) Analysis</a>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">Utilities</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="interactive.html">Interactive Utilities</a>
</li>
<li>
<a href="importingdata.html">Importing Spatial Data</a>
</li>
<li>
<a href="voltronobjects.html">Working with VoltRon Objects</a>
</li>
<li>
<a href="conversion.html">Converting VoltRon Objects</a>
</li>
<li>
<a href="ondisk.html">OnDisk-based Analysis Utilities</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<span class="fa fa-envelope-o"></span>
Contact
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="https://bioinformatics.mdc-berlin.de">Altuna Lab/BIMSB Bioinfo</a>
</li>
<li>
<a href="https://www.mdc-berlin.de/landthaler">Landthaler Lab/BIMSB</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<span class="fa fa-github"></span>
GitHub
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="https://github.com/BIMSBbioinfo/VoltRon">VoltRon</a>
</li>
<li>
<a href="https://github.com/BIMSBbioinfo">BIMSB Bioinfo</a>
</li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<div id="header">
<h1 class="title toc-ignore">Multi-omics</h1>
</div>
<style>
.title{
display: none;
}
body {
text-align: justify
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
table, th, td {
border-collapse: collapse;
align-self: center;
padding-right: 10px;
padding-left: 10px;
}
</style>
<style type="text/css">
.watch-out {
color: black;
}
</style>
<p><br></p>
<div id="label-transfer-via-registration" class="section level1">
<h1>Label Transfer via Registration</h1>
<p>VoltRon is capable of analyzing molecule-level subcellular datasets
independent of single cells, and specifically those that may also found
outside of these cells. To demonstrate how VoltRon investigates
extra-cellular molecules, we will make use of another Xenium in situ
dataset where custom Xenium probes designed to hybridize distinct open
reading frames of SARS-COV-2 virus molecules. These subcellular entities
which then can be detected both within and outside of cells which allows
to understand proliferation mechanics of the virus across the
tissue.</p>
<p>In this use case, we analyse readouts of <strong>eight tissue micro
array (TMA) tissue sections</strong> that were fitted into the scan area
of a slide loaded on a Xenium in situ instrument. These sections were
cut from <strong>control and COVID-19 lung tissues</strong> of donors
categorized based on disease durations (acute and prolonged). You can
download the standard Xenium output folder <a
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Multiomics/Xenium_SARSCOV2.zip">here</a>.</p>
<p>For more information on the TMA blocks, see <a
href="https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE190732">GSE190732</a>
for more information.</p>
<p><br></p>
<div id="single-cells-and-molecules" class="section level2">
<h2>Single Cells and Molecules</h2>
<p>Across these eight TMA section, we investigate a section of acute
case which is originated from a lung with extreme number of detected
open reading frames of virus molecules. For convenience, we load a
VoltRon object where cells are already annotated. You can also find the
RDS file <a
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Multiomics/acutecase1_annotated.rds">here</a>.</p>
<pre class="r watch-out"><code>vr2_merged_acute1 <- readRDS(file = "acutecase1_annotated.rds")</code></pre>
<p><br></p>
<p>Lets visualize both the UMAP and Spatial plot of the annotated
cells.</p>
<pre class="r watch-out"><code>vrEmbeddingPlot(vr2_merged_acute1, assay = "Xenium", embedding = "umap",
group.by = "CellType", label = TRUE)
vrSpatialPlot(vr2_merged_acute1, assay = "Xenium", group.by = "CellType",
plot.segments = TRUE)</code></pre>
<table>
<tbody>
<tr style="vertical-align: center">
<td style="width:45%; vertical-align: center">
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/molecule_vrembeddingplot.png" class="center">
</td>
<td style="width:55%; vertical-align: center">
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/molecule_visualize_celltype.png" class="center">
</td>
</tr>
</tbody>
</table>
<p><br></p>
<p>We incorporate two open reading frames (ORFs), named
<strong>S2_N</strong> and <strong>S2_orf1ab</strong>, which represent
unreplicated and replicated virus molecules, respectively. We can
visualize again tile the count of these virus expressions by
specifically selecting these two ORFs.</p>
<pre class="r watch-out"><code>vrSpatialPlot(vr2_merged_acute1, assay = "Xenium_mol", group.by = "gene",
group.ids = c("S2_N", "S2_orf1ab"), n.tile = 500)</code></pre>
<p><img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/molecule_visualize_virus.png" class="center"></p>
<p><br></p>
<p>We can even zoom into specific locations at the tissue to investigate
virus particles more closely by droping the <strong>n.tile</strong>
argument and calling interactive visualization.</p>
<pre class="r watch-out"><code>vrSpatialPlot(vr2_merged_acute1, assay = "Xenium_mol", group.by = "gene",
group.ids = c("S2_N", "S2_orf1ab"), interactive = TRUE, pt.size = 0.1)</code></pre>
<p><img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/molecules_visualize_virus_zoom.png" class="center"></p>
<p><br></p>
<p>In the following sections, we will integrate pathological images and
annotations with Xenium datasets to further understand the spatial
localization of virus ORF types over the tissue.</p>
<p><br></p>
</div>
<div id="hot-spot-analysis" class="section level2">
<h2>Hot Spot Analysis</h2>
<p>VoltRon platform allows users to find hot spots of several types of
spatial entities, for spots, cells, and even molecules. We first learn
spatial neighborhoods from molecules of interests, in this case, the
extracellular virus particles and their ORFs.</p>
<pre class="r watch-out"><code>vr2_merged_acute1</code></pre>
<pre><code>VoltRon Object
acute case 1:
Layers: Section1
Assays: Xenium(Main) Xenium_mol </code></pre>
<p>We switch to the molecule assay of the VoltRon object, and select
virus ORFs. We also look for other virus ORFs that are 50 pixel distance
from each virus molecule to pin point neighborhoods that are rich in
virus.</p>
<pre class="r watch-out"><code>vr2_merged_acute1 <- getSpatialNeighbors(vr2_merged_acute1, assay = "Xenium_mol",
group.by = "gene", group.ids = c("S2_N", "S2_orf1ab"),
method = "radius", radius = 50)</code></pre>
<p>We can now observe the new spatial neighborhood graph saved in the
VoltRon object with name <strong>radius</strong>.</p>
<pre class="r watch-out"><code>vrGraphNames(vr2_merged_acute1)</code></pre>
<pre><code>[1] "radius"</code></pre>
<p>We now select the feature type and graph name to run an hot spot
analysis which will label each molecule if their neighborhood are dense
in other virus molecules.</p>
<pre class="r watch-out"><code>vr2_merged_acute1 <- getHotSpotAnalysis(vr2_merged_acute1, assay = "Xenium_mol",
features = "gene", graph.type = "radius")
vrSpatialPlot(vr2_merged_acute1, assay = "Xenium_mol",
group.by = "gene_hotspot_flag", group.ids = c("cold", "hot"),
alpha = 1, background.color = "white")</code></pre>
<p><img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/molecule_visualize_virus_hotspot.png" class="center"></p>
</div>
<div id="automated-he-registration" class="section level2">
<h2>Automated H&E Registration</h2>
<p>VoltRon can analyze and also integrate information from distinct
spatial data types such as images, annotations (as regions of interests,
i.e. ROIs) and molecules independently. Using such advanced utilities,
we can make use of histological information and generate new metadata
level information for molecule datasets.</p>
<p>We will first import both histological images and manual annotations
using the <strong>importImageData</strong> function which accepts both
images to generate tile/pixel level datasets but also allows one to
import either a list of segments or <a
href="https://geojson.org/">GeoJSON</a> objects for create ROI-level
datasets as separate assays in a single VoltRon layer. The .geojson file
was generated using <a href="https://qupath.github.io/">QuPath</a> on
the same section H&E image of one Xenium section with the acute
COVID-19 case. We also have to flip the coordinates of ROI annotations
also for they were directly imported from QuPath which incorporates a
reverse coordinate system on the y-axis.</p>
<p>Once imported, the resulting VoltRon object will have two assays in a
single layer, one for tile dataset of the H&E image and the other
for ROI based annotations of again the same image. You can download the
H&E image from <a
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Multiomics/acutecase1_HE.jpg">here</a>,
and download the json file from <a
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Multiomics/acutecase1_membrane.geojson">here</a>.</p>
<pre class="r watch-out"><code># get image
imgdata <- importImageData("acutecase1_HE.jpg",
segments = "acutecase1_membrane.geojson",
sample_name = "acute case 1 (HE)")
imgdata <- flipCoordinates(imgdata, assay = "ROIAnnotation")
imgdata</code></pre>
<pre><code>VoltRon Object
acute case 1 (HE):
Layers: Section1
Assays: ImageData(Main) ROIAnnotation
Features: main(Main) </code></pre>
<p>By visualizing these annotations interactively, we can see that the
ROIs point to the hyaline membranes. Here, we likely find extra-cellular
SARS-COV-2 molecules mostly outside of any single cell.</p>
<pre class="r watch-out"><code>vrSpatialPlot(imgdata, assay = "ROIAnnotation", group.by = "Sample",
alpha = 0.7, interactive = TRUE)</code></pre>
<p><img width="60%" height="60%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/molecule_Covid_HE_zoom.png" class="center"></p>
<p><br></p>
<p>At a first glance, although the Xenium (DAPI) and H&E images are
associated with the same TMA core, they were captured in a different
perspective; that is, one image is almost the 90 degree rotated version
of the other. We will account for this rotation when we (automatically)
align the Xenium data with the H&E image.</p>
<pre class="r watch-out"><code>vr2_merged_acute1 <- modulateImage(vr2_merged_acute1, brightness = 300, channel = "DAPI")
vrImages(vr2_merged_acute1, assay = "Assay7", scale.perc = 20)
vrImages(imgdata, assay = "Assay1", scale.perc = 20)</code></pre>
<p><img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/multiomic_twoimages.png" class="center"></p>
<p><br></p>
<p>We now register the H&E image and annotations to the DAPI image
of Xenium section using the <strong>registerSpatialData</strong>
function. We select FLANN (with “Homography” method) automated
registration mode, negate the DAPI image of the Xenium slide, turn 90
degrees to the left and set the scale parameter of both images to
<strong>width = 1859</strong>. See <a href="registration.html">Spatial
Data Alignment</a> tutorial for more information.</p>
<pre class="r watch-out"><code>xen_reg <- registerSpatialData(object_list = list(vr2_merged_acute1, imgdata))</code></pre>
<p><img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/molecule_HE_registration.png" class="center"></p>
<p><br></p>
<p>Once registered, we can isolate the registered H&E data and use
it further analysis. We can transfer images and their channels across
assays of one or multiple VoltRon objects. Here, we save the registered
image of the H&E data as an additional channel of Xenium section of
the acuse case 1 sample with molecule data.</p>
<pre class="r watch-out"><code>imgdata_reg <- xen_reg$registered_spat[[2]]
vrImages(vr2_merged_acute1[["Assay7"]], name = "main", channel = "H&E") <-
vrImages(imgdata_reg, assay = "Assay1", name = "main_reg")
vrImages(vr2_merged_acute1[["Assay8"]], name = "main", channel = "H&E") <-
vrImages(imgdata_reg, assay = "Assay1", name = "main_reg")</code></pre>
<p>We can now observe the new channels available for the both molecule
and cell-level assays of Xenium data.</p>
<pre class="r watch-out"><code>vrImageChannelNames(vr2_merged_acute1)</code></pre>
<pre><code> Assay Layer Sample Spatial Channels
Assay7 Xenium Section1 acute case 1 main DAPI,H&E
Assay8 Xenium_mol Section1 acute case 1 main DAPI,H&E</code></pre>
<p><br></p>
<p>You can also add the VoltRon object of H&E data as an additional
assay of the Xenium section such that one layer includes cell,
molecules, ROI Annotations and images in the same time. Specifically, we
add the ROI annotation to the Xenium VoltRon object using the
<strong>addAssay</strong> function where we choose the destination
sample/block and the layer of the assay.</p>
<pre class="r watch-out"><code>vr2_merged_acute1 <- addAssay(vr2_merged_acute1,
assay = imgdata_reg[["Assay2"]],
metadata = Metadata(imgdata_reg, assay = "ROIAnnotation"),
assay_name = "ROIAnnotation",
sample = "acute case 1", layer = "Section1")
vr2_merged_acute1</code></pre>
<pre><code>VoltRon Object
acute case 1:
Layers: Section1
Assays: ROIAnnotation(Main) Xenium_mol Xenium </code></pre>
<p><br></p>
</div>
<div id="interactive-visualization" class="section level2">
<h2>Interactive Visualization</h2>
<p>Once the H&E image is registered and transfered to the Xenium
data, we can convert the VoltRon object into an Anndata object (h5ad
file) and use <a href="https://tissuumaps.github.io/">TissUUmaps</a>
tool for interactive visualization.</p>
<pre class="r watch-out"><code># convert VoltRon object to h5ad
as.AnnData(vr2_merged_acute1, assay = "Xenium", file = "vr2_merged_acute1.h5ad",
flip_coordinates = TRUE, name = "main", channel = "H&E")</code></pre>
<p>To run TissUUmaps please follow installation instructions <a
href="https://tissuumaps.github.io/installation/">here</a>, then you can
simply drag and drop both the h5ad file and png file to the
application.</p>
<p><img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/multiomic_interactivevisualization.png" class="center"></p>
<p><br></p>
</div>
<div id="label-transfer" class="section level2">
<h2>Label transfer</h2>
<p>Now we can transfer ROI annotations as additional metadata features
of the molecule assay. We will refer the new metadata column as “Region”
which will indicate if the molecule is within any annotated ROI in the
same layer.</p>
<pre class="r watch-out"><code>vrMainAssay(vr2_merged_acute1) <- "ROIAnnotation"
vr2_merged_acute1$Region <- vrSpatialPoints(vr2_merged_acute1)
# set the spatial coordinate system of ROI Annotations assay
vrMainSpatial(vr2_merged_acute1[["Assay9"]]) <- "main_reg"
# transfer ROI annotations to molecules
vr2_merged_acute1 <- transferData(object = vr2_merged_acute1, from = "Assay9", to = "Assay8",
features = "Region")
# Metadata of molecules
Metadata(vr2_merged_acute1, assay = "Xenium_mol")</code></pre>
<div>
<pre><code style="font-size: 11px;"> id assay_id overlaps_nucleus gene qv Assay Layer Sample Region
<char> <char> <int> <char> <num> <char> <char> <char> <char>
1: 281651070371256_cb791e Assay8 0 ENAH 40.00000 Xenium_mol Section1 acute case 1 undefined
2: 281651070371258_cb791e Assay8 1 CD274 40.00000 Xenium_mol Section1 acute case 1 undefined
3: 281651070372515_cb791e Assay8 0 CD163 40.00000 Xenium_mol Section1 acute case 1 undefined
4: 281651070374059_cb791e Assay8 1 CTSL 33.97290 Xenium_mol Section1 acute case 1 undefined
5: 281651070374411_cb791e Assay8 0 C1S 40.00000 Xenium_mol Section1 acute case 1 undefined
---
785787: 281874408669584_cb791e Assay8 0 SFRP2 40.00000 Xenium_mol Section1 acute case 1 undefined
785788: 281874408671410_cb791e Assay8 0 S2_N 40.00000 Xenium_mol Section1 acute case 1 undefined
785789: 281874408672438_cb791e Assay8 0 S100A8 40.00000 Xenium_mol Section1 acute case 1 undefined
785790: 281874408673446_cb791e Assay8 0 TIMP1 29.86642 Xenium_mol Section1 acute case 1 undefined
785791: 281874408673882_cb791e Assay8 0 S2_N 40.00000 Xenium_mol Section1 acute case 1 undefined</code></pre>
</div>
<p><br></p>
<p>This annotations can be accessed from the default molecule level
metadata of the VoltRon object.</p>
<pre class="r watch-out"><code>vrMainAssay(vr2_merged_acute1) <- "Xenium_mol"
head(table(vr2_merged_acute1$Region))</code></pre>
<pre><code> ROI1_Assay9 ROI10_Assay9 ROI100_Assay9 ROI101_Assay9 ROI102_Assay9 ROI103_Assay9
583 624 784 357 215 200 </code></pre>
<p><br></p>
<p>Now we will grab these annotations from molecule metadata and
calculate the ratio of N to orf1ab frequency of SARS-COV-2 particles
across all annotated molecules.</p>
<pre class="r watch-out"><code>library(dplyr)
s2_summary_hyaline <-
Metadata(vr2_merged_acute1, assay = "Xenium_mol") %>%
filter(gene %in% c("S2_N", "S2_orf1ab"),
Region != "undefined") %>%
summarise(S2_N = sum(gene == "S2_N"),
S2_orf1ab = sum(gene == "S2_orf1ab"),
ratio = sum(gene == "S2_N")/sum(gene == "S2_orf1ab")) %>%
as.matrix()
s2_summary_hyaline</code></pre>
<pre><code> S2_N S2_orf1ab ratio
[1,] 50977 33532 1.520249</code></pre>
<p><br></p>
</div>
<div id="manual-annotation" class="section level2">
<h2>Manual annotation</h2>
<p>To compare the proportion of <strong>S2_N</strong> and
<strong>S2_orf1ab</strong> molecules in hyaline membranes with tissue
sites of possible infection. We focus on another tissue niche where a
large accumulation of cells with high <strong>S2_N</strong> and
<strong>S2_orf1ab</strong> counts.</p>
<p>By visualizing and zooming on a spatial plot with annotated cells, we
can detect a site of cells with high infection which are also
accompanied by a group of T cells.</p>
<pre class="r watch-out"><code>vrSpatialPlot(vr2_merged_acute1, assay = "Xenium", group.by = "CellType",
group.ids = c("H.I. Cells", "T cells"), plot.segments = TRUE,
alpha = 0.6, spatial = "main", channel = "H&E", interactive = TRUE)</code></pre>
<p><img width="80%" height="80%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/molecule_spatialplot_infected.png" class="center"></p>
<p><br></p>
<p>Now we use the <strong>annotateSpatialData</strong> function to
create an additional annotation of Xenium molecules directly. By
selecting this region of infection we can directly annotate the
‘Xenium_mol’ assay and the metadata of molecules. We use the H&E
image as the background again, and generate a new molecule-level
metadata column called “Infected”.</p>
<pre class="r watch-out"><code>vr2_merged_acute1 <- annotateSpatialData(vr2_merged_acute1, assay = "Xenium_mol",
label = "Region", use.image = TRUE,
channel = "H&E", annotation_assay = "ROIAnnotation1")</code></pre>
<p><img width="80%" height="80%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/molecule_annotation_infected.png" class="center"></p>
<p><br></p>
</div>
<div id="visualize-annotations" class="section level2">
<h2>Visualize annotations</h2>
<p>Before visualizing the annotations and molecule localizations in the
same time, lets make some changes to the metadata. We basically wanna
change the annotation of all ROIs originated from the GeoJson file to
have the label <strong>Hyaline Membrane</strong>.</p>
<pre class="r watch-out"><code># update molecule metadata
vrMainAssay(vr2_merged_acute1_infected) <- "Xenium_mol"
vr2_merged_acute1_infected$Region <- gsub("ROI[0-9]+", "Hyaline Membrane",
vr2_merged_acute1_infected$Region)
# update ROI metadata
vrMainAssay(vr2_merged_acute1_infected) <- "ROIAnnotation"
vr2_merged_acute1_infected$Region <- gsub("ROI[0-9]+", "Hyaline Membrane",
vr2_merged_acute1_infected$Region)</code></pre>
<p>Now we can visualize two assays together. We use the
<strong>addSpatialLayer</strong> function to overlay molecule locations
with both the Hyaline Membrane and the infected region annotations.</p>
<pre class="r watch-out"><code>vrSpatialPlot(vr2_merged_acute1_infected, assay = "Xenium_mol", group.by = "gene",
group.ids = c("S2_N", "S2_orf1ab"), n.tile = 500) |>
addSpatialLayer(vr2_merged_acute1_infected, assay = "ROIAnnotation",
group.by = "Region", alpha = 0.3,
colors = list(`Hyaline Membrane` = "blue", `Infected` = "yellow"))</code></pre>
<p><img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/molecule_visualize_virus_overlay.png" class="center"></p>
</div>
<div id="comparison-of-annotations" class="section level2">
<h2>Comparison of annotations</h2>
<p>By using the newly annotated infection-associated virus molecules, we
can do a comparison of infected regions versus the hyaline
membranes.</p>
<pre class="r watch-out"><code>library(dplyr)
s2_summary_infected <-
Metadata(vr2_merged_acute1, assay = "Xenium_mol") %>%
filter(gene %in% c("S2_N", "S2_orf1ab"),
Region == "Infected") %>%
summarise(S2_N = sum(gene == "S2_N"),
S2_orf1ab = sum(gene == "S2_orf1ab"),
ratio = sum(gene == "S2_N")/sum(gene == "S2_orf1ab")) %>%
as.matrix()
s2_summary_infected</code></pre>
<pre><code> S2_N S2_orf1ab ratio
[1,] 6376 2372 2.688027</code></pre>
<p>Comparison of both the ratio between the infected region and the
hyaline membranes show a considerable difference of the population of
<strong>S2_N</strong> and <strong>S2_orf1ab</strong> molecules.</p>
<pre class="r watch-out"><code>S2_table <- matrix(c(s2_summary_hyaline[,1:2],
s2_summary_infected[,1:2]),
dimnames = list(Region = c("Hyaline", "Infected"),
S2 = c("N", "orf1ab")),
ncol = 2, byrow = TRUE)
S2_table</code></pre>
<pre><code> S2
Region N orf1ab
Hyaline 50977 33532
Infected 6376 2372</code></pre>
<p>A quick test of independance on this contingency table show a
significant difference of ratios across Hyaline and Infected
regions.</p>
<pre class="r watch-out"><code>fisher.test(S2_table, alternative = "two.sided")</code></pre>
<pre><code>
Fisher's Exact Test for Count Data
data: S2_table
p-value < 2.2e-16
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.5382305 0.5941683
sample estimates:
odds ratio
0.5655696 </code></pre>
</div>
</div>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open');
});
});
</script>
<!-- code folding -->
<script>
$(document).ready(function () {
// temporarily add toc-ignore selector to headers for the consistency with Pandoc
$('.unlisted.unnumbered').addClass('toc-ignore')
// move toc-ignore selectors from section div to header
$('div.section.toc-ignore')
.removeClass('toc-ignore')
.children('h1,h2,h3,h4,h5').addClass('toc-ignore');
// establish options
var options = {
selectors: "h1,h2,h3,h4",
theme: "bootstrap3",
context: '.toc-content',
hashGenerator: function (text) {
return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
},
ignoreSelector: ".toc-ignore",
scrollTo: 0
};
options.showAndHide = false;
options.smoothScroll = false;
// tocify
var toc = $("#TOC").tocify(options).data("toc-tocify");
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>