Diff of /docs/registration.html [000000] .. [413088]

Switch to unified view

a b/docs/registration.html
1
<!DOCTYPE html>
2
3
<html>
4
5
<head>
6
7
<meta charset="utf-8" />
8
<meta name="generator" content="pandoc" />
9
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
10
11
12
13
14
<title>Image Registration</title>
15
16
<script src="site_libs/header-attrs-2.29/header-attrs.js"></script>
17
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
18
<meta name="viewport" content="width=device-width, initial-scale=1" />
19
<link href="site_libs/bootstrap-3.3.5/css/flatly.min.css" rel="stylesheet" />
20
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
21
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
22
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
23
<style>h1 {font-size: 34px;}
24
       h1.title {font-size: 38px;}
25
       h2 {font-size: 30px;}
26
       h3 {font-size: 24px;}
27
       h4 {font-size: 18px;}
28
       h5 {font-size: 16px;}
29
       h6 {font-size: 12px;}
30
       code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
31
       pre:not([class]) { background-color: white }</style>
32
<script src="site_libs/jqueryui-1.13.2/jquery-ui.min.js"></script>
33
<link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
34
<script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script>
35
<script src="site_libs/navigation-1.1/tabsets.js"></script>
36
<link href="site_libs/highlightjs-9.12.0/textmate.css" rel="stylesheet" />
37
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
38
<link href="site_libs/font-awesome-6.5.2/css/all.min.css" rel="stylesheet" />
39
<link href="site_libs/font-awesome-6.5.2/css/v4-shims.min.css" rel="stylesheet" />
40
41
<style type="text/css">
42
  code{white-space: pre-wrap;}
43
  span.smallcaps{font-variant: small-caps;}
44
  span.underline{text-decoration: underline;}
45
  div.column{display: inline-block; vertical-align: top; width: 50%;}
46
  div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
47
  ul.task-list{list-style: none;}
48
    </style>
49
50
<style type="text/css">code{white-space: pre;}</style>
51
<script type="text/javascript">
52
if (window.hljs) {
53
  hljs.configure({languages: []});
54
  hljs.initHighlightingOnLoad();
55
  if (document.readyState && document.readyState === "complete") {
56
    window.setTimeout(function() { hljs.initHighlighting(); }, 0);
57
  }
58
}
59
</script>
60
61
62
63
64
65
66
67
68
69
<style type = "text/css">
70
.main-container {
71
  max-width: 940px;
72
  margin-left: auto;
73
  margin-right: auto;
74
}
75
img {
76
  max-width:100%;
77
}
78
.tabbed-pane {
79
  padding-top: 12px;
80
}
81
.html-widget {
82
  margin-bottom: 20px;
83
}
84
button.code-folding-btn:focus {
85
  outline: none;
86
}
87
summary {
88
  display: list-item;
89
}
90
details > summary > p:only-child {
91
  display: inline;
92
}
93
pre code {
94
  padding: 0;
95
}
96
</style>
97
98
99
<style type="text/css">
100
.dropdown-submenu {
101
  position: relative;
102
}
103
.dropdown-submenu>.dropdown-menu {
104
  top: 0;
105
  left: 100%;
106
  margin-top: -6px;
107
  margin-left: -1px;
108
  border-radius: 0 6px 6px 6px;
109
}
110
.dropdown-submenu:hover>.dropdown-menu {
111
  display: block;
112
}
113
.dropdown-submenu>a:after {
114
  display: block;
115
  content: " ";
116
  float: right;
117
  width: 0;
118
  height: 0;
119
  border-color: transparent;
120
  border-style: solid;
121
  border-width: 5px 0 5px 5px;
122
  border-left-color: #cccccc;
123
  margin-top: 5px;
124
  margin-right: -10px;
125
}
126
.dropdown-submenu:hover>a:after {
127
  border-left-color: #adb5bd;
128
}
129
.dropdown-submenu.pull-left {
130
  float: none;
131
}
132
.dropdown-submenu.pull-left>.dropdown-menu {
133
  left: -100%;
134
  margin-left: 10px;
135
  border-radius: 6px 0 6px 6px;
136
}
137
</style>
138
139
<script type="text/javascript">
140
// manage active state of menu based on current page
141
$(document).ready(function () {
142
  // active menu anchor
143
  href = window.location.pathname
144
  href = href.substr(href.lastIndexOf('/') + 1)
145
  if (href === "")
146
    href = "index.html";
147
  var menuAnchor = $('a[href="' + href + '"]');
148
149
  // mark the anchor link active (and if it's in a dropdown, also mark that active)
150
  var dropdown = menuAnchor.closest('li.dropdown');
151
  if (window.bootstrap) { // Bootstrap 4+
152
    menuAnchor.addClass('active');
153
    dropdown.find('> .dropdown-toggle').addClass('active');
154
  } else { // Bootstrap 3
155
    menuAnchor.parent().addClass('active');
156
    dropdown.addClass('active');
157
  }
158
159
  // Navbar adjustments
160
  var navHeight = $(".navbar").first().height() + 15;
161
  var style = document.createElement('style');
162
  var pt = "padding-top: " + navHeight + "px; ";
163
  var mt = "margin-top: -" + navHeight + "px; ";
164
  var css = "";
165
  // offset scroll position for anchor links (for fixed navbar)
166
  for (var i = 1; i <= 6; i++) {
167
    css += ".section h" + i + "{ " + pt + mt + "}\n";
168
  }
169
  style.innerHTML = "body {" + pt + "padding-bottom: 40px; }\n" + css;
170
  document.head.appendChild(style);
171
});
172
</script>
173
174
<!-- tabsets -->
175
176
<style type="text/css">
177
.tabset-dropdown > .nav-tabs {
178
  display: inline-table;
179
  max-height: 500px;
180
  min-height: 44px;
181
  overflow-y: auto;
182
  border: 1px solid #ddd;
183
  border-radius: 4px;
184
}
185
186
.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before {
187
  content: "\e259";
188
  font-family: 'Glyphicons Halflings';
189
  display: inline-block;
190
  padding: 10px;
191
  border-right: 1px solid #ddd;
192
}
193
194
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
195
  content: "\e258";
196
  font-family: 'Glyphicons Halflings';
197
  border: none;
198
}
199
200
.tabset-dropdown > .nav-tabs > li.active {
201
  display: block;
202
}
203
204
.tabset-dropdown > .nav-tabs > li > a,
205
.tabset-dropdown > .nav-tabs > li > a:focus,
206
.tabset-dropdown > .nav-tabs > li > a:hover {
207
  border: none;
208
  display: inline-block;
209
  border-radius: 4px;
210
  background-color: transparent;
211
}
212
213
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
214
  display: block;
215
  float: none;
216
}
217
218
.tabset-dropdown > .nav-tabs > li {
219
  display: none;
220
}
221
</style>
222
223
<!-- code folding -->
224
225
226
227
<style type="text/css">
228
229
#TOC {
230
  margin: 25px 0px 20px 0px;
231
}
232
@media (max-width: 768px) {
233
#TOC {
234
  position: relative;
235
  width: 100%;
236
}
237
}
238
239
@media print {
240
.toc-content {
241
  /* see https://github.com/w3c/csswg-drafts/issues/4434 */
242
  float: right;
243
}
244
}
245
246
.toc-content {
247
  padding-left: 30px;
248
  padding-right: 40px;
249
}
250
251
div.main-container {
252
  max-width: 1200px;
253
}
254
255
div.tocify {
256
  width: 20%;
257
  max-width: 260px;
258
  max-height: 85%;
259
}
260
261
@media (min-width: 768px) and (max-width: 991px) {
262
  div.tocify {
263
    width: 25%;
264
  }
265
}
266
267
@media (max-width: 767px) {
268
  div.tocify {
269
    width: 100%;
270
    max-width: none;
271
  }
272
}
273
274
.tocify ul, .tocify li {
275
  line-height: 20px;
276
}
277
278
.tocify-subheader .tocify-item {
279
  font-size: 0.90em;
280
}
281
282
.tocify .list-group-item {
283
  border-radius: 0px;
284
}
285
286
.tocify-subheader {
287
  display: inline;
288
}
289
.tocify-subheader .tocify-item {
290
  font-size: 0.95em;
291
}
292
293
</style>
294
295
296
297
</head>
298
299
<body>
300
301
302
<div class="container-fluid main-container">
303
304
305
<!-- setup 3col/9col grid for toc_float and main content  -->
306
<div class="row">
307
<div class="col-xs-12 col-sm-4 col-md-3">
308
<div id="TOC" class="tocify">
309
</div>
310
</div>
311
312
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
313
314
315
316
317
<div class="navbar navbar-default  navbar-fixed-top" role="navigation">
318
  <div class="container">
319
    <div class="navbar-header">
320
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-bs-toggle="collapse" data-target="#navbar" data-bs-target="#navbar">
321
        <span class="icon-bar"></span>
322
        <span class="icon-bar"></span>
323
        <span class="icon-bar"></span>
324
      </button>
325
      <a class="navbar-brand" href="index.html">VoltRon</a>
326
    </div>
327
    <div id="navbar" class="navbar-collapse collapse">
328
      <ul class="nav navbar-nav">
329
        <li>
330
  <a href="tutorials.html">Explore</a>
331
</li>
332
<li class="dropdown">
333
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
334
    Vignette
335
     
336
    <span class="caret"></span>
337
  </a>
338
  <ul class="dropdown-menu" role="menu">
339
    <li class="dropdown-submenu">
340
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">Spatial Data Integration</a>
341
      <ul class="dropdown-menu" role="menu">
342
        <li>
343
          <a href="registration.html">Spatial Data Alignment</a>
344
        </li>
345
        <li>
346
          <a href="multiomic.html">Multi-omic Integration</a>
347
        </li>
348
        <li>
349
          <a href="nicheclustering.html">Niche Clustering</a>
350
        </li>
351
      </ul>
352
    </li>
353
    <li class="dropdown-submenu">
354
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">Downstream Analysis</a>
355
      <ul class="dropdown-menu" role="menu">
356
        <li>
357
          <a href="roianalysis.html">ROI Analysis</a>
358
        </li>
359
        <li>
360
          <a href="spotanalysis.html">Cell/Spot Analysis</a>
361
        </li>
362
        <li>
363
          <a href="moleculeanalysis.html">Molecule Analysis</a>
364
        </li>
365
        <li>
366
          <a href="pixelanalysis.html">Pixels (Image Only) Analysis</a>
367
        </li>
368
      </ul>
369
    </li>
370
    <li class="dropdown-submenu">
371
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">Utilities</a>
372
      <ul class="dropdown-menu" role="menu">
373
        <li>
374
          <a href="interactive.html">Interactive Utilities</a>
375
        </li>
376
        <li>
377
          <a href="importingdata.html">Importing Spatial Data</a>
378
        </li>
379
        <li>
380
          <a href="voltronobjects.html">Working with VoltRon Objects</a>
381
        </li>
382
        <li>
383
          <a href="conversion.html">Converting VoltRon Objects</a>
384
        </li>
385
        <li>
386
          <a href="ondisk.html">OnDisk-based Analysis Utilities</a>
387
        </li>
388
      </ul>
389
    </li>
390
  </ul>
391
</li>
392
      </ul>
393
      <ul class="nav navbar-nav navbar-right">
394
        <li class="dropdown">
395
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
396
    <span class="fa fa-envelope-o"></span>
397
     
398
    Contact
399
     
400
    <span class="caret"></span>
401
  </a>
402
  <ul class="dropdown-menu" role="menu">
403
    <li>
404
      <a href="https://bioinformatics.mdc-berlin.de">Altuna Lab/BIMSB Bioinfo</a>
405
    </li>
406
    <li>
407
      <a href="https://www.mdc-berlin.de/landthaler">Landthaler Lab/BIMSB</a>
408
    </li>
409
  </ul>
410
</li>
411
<li class="dropdown">
412
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
413
    <span class="fa fa-github"></span>
414
     
415
    GitHub
416
     
417
    <span class="caret"></span>
418
  </a>
419
  <ul class="dropdown-menu" role="menu">
420
    <li>
421
      <a href="https://github.com/BIMSBbioinfo/VoltRon">VoltRon</a>
422
    </li>
423
    <li>
424
      <a href="https://github.com/BIMSBbioinfo">BIMSB Bioinfo</a>
425
    </li>
426
  </ul>
427
</li>
428
      </ul>
429
    </div><!--/.nav-collapse -->
430
  </div><!--/.container -->
431
</div><!--/.navbar -->
432
433
<div id="header">
434
435
436
437
<h1 class="title toc-ignore">Image Registration</h1>
438
439
</div>
440
441
442
<style>
443
.title{
444
  display: none;
445
}
446
body {
447
  text-align: justify
448
}
449
.center {
450
  display: block;
451
  margin-left: auto;
452
  margin-right: auto;
453
}
454
</style>
455
<style type="text/css">
456
.watch-out {
457
  color: black;
458
}
459
</style>
460
<p><br></p>
461
<div id="spatial-data-alignment" class="section level1">
462
<h1>Spatial Data Alignment</h1>
463
<p>Spatial genomic technologies often generate diverse images and
464
spatial readouts, even though the tissue slices are from adjacent
465
sections of a single tissue block. Hence, the alignment of images and
466
spatial coordinates across tissue sections are of utmost importance to
467
dissect the correct spatial closeness across these sections.</p>
468
<p>VoltRon allows users to <strong>align spatial omics datasets of these
469
serial sections</strong> for data transfer and 3 dimensional stack
470
alignment. The order of the tissue/sample slices should be provided by
471
the user. VoltRon provides a fully embedded <strong>shiny
472
application</strong> to either automatically or manually align images.
473
The automatic alignment is achieved with the <strong>OpenCV</strong>’s
474
C++ library fully embedded in the VoltRon package.</p>
475
<table>
476
<tbody>
477
<tr style="vertical-align: center">
478
<td style="width:43%; vertical-align: center">
479
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/manualregistration.png" class="center">
480
</td>
481
<td style="width:43%; vertical-align: center">
482
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/autoregistration.png" class="center">
483
</td>
484
</tr>
485
</tbody>
486
</table>
487
<p><br></p>
488
<div id="alignment-of-xenium-and-visium" class="section level2">
489
<h2>Alignment of Xenium and Visium</h2>
490
<p>In this use case, we will align <strong>immunofluorescence
491
(IF)</strong> and <strong>H&amp;E images</strong> of the <strong>Xenium
492
In Situ</strong> and <strong>Visium CytAssist</strong> platforms
493
readouts. Three tissue sections are derived from a single
494
formalin-fixed, paraffin-embedded (FFPE) breast cancer tissue block. A 5
495
<span class="math inline">\(\mu\)</span>m section was taken for Visium
496
CytAssist and two replicate 5 <span class="math inline">\(\mu\)</span>m
497
sections were taken for the Xenium replicates. More information on the
498
spatial datasets and the study can be also be found on the <a
499
href="https://www.biorxiv.org/content/10.1101/2022.10.06.510405v1">BioArxiv
500
preprint</a>.</p>
501
<p>You can download the Xenium and Visium readouts from the <a
502
href="https://www.10xgenomics.com/products/xenium-in-situ/preview-dataset-human-breast">10x
503
Genomics website</a> (specifically, import <strong>In Situ Replicate 1/2
504
and Visium Spatial</strong>). Alternatively, you can <strong>download a
505
zipped collection of three Visium and Xenium readouts</strong> from <a
506
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/SpatialDataAlignment/Xenium_vs_Visium/10X_Xenium_Visium.zip">here</a>.</p>
507
<p>VoltRon includes built-in functions for converting readouts from both
508
Xenium and Visium platforms into VoltRon objects. We will import both
509
Xenium replicates alongside with the Visium CytAssist data so that we
510
can register images of these assays and merge them into one VoltRon
511
object.</p>
512
<pre class="r watch-out"><code>library(VoltRon)
513
Xen_R1 &lt;- importXenium(&quot;Xenium_R1/outs&quot;, sample_name = &quot;XeniumR1&quot;)
514
Xen_R2 &lt;- importXenium(&quot;Xenium_R2/outs&quot;, sample_name = &quot;XeniumR2&quot;)
515
Vis &lt;- importVisium(&quot;Visium/&quot;, sample_name = &quot;VisiumR1&quot;)</code></pre>
516
<p>Before moving on to image alignment, we can inspect both Xenium and
517
Visium images. We use the <strong>vrImages</strong> function to call and
518
visualize reference images of all VoltRon objects.</p>
519
<pre class="r watch-out"><code>vrImages(Xen_R1)
520
vrImages(Xen_R2)
521
vrImages(Vis)</code></pre>
522
<table>
523
<tbody>
524
<tr style="vertical-align: center">
525
<td style="width:33%; vertical-align: center">
526
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/xeniumr1.png" class="center">
527
</td>
528
<td style="width:33%; vertical-align: center">
529
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/xeniumr2.png" class="center">
530
</td>
531
<td style="width:33%; vertical-align: center">
532
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/visium.png" class="center">
533
</td>
534
</tr>
535
</tbody>
536
</table>
537
<p><br></p>
538
<p>Although images of the first Xenium replicate and the Visium assay
539
are workable, we have to adjust the brightness of the second Xenium
540
replicate before image alignment. You can use
541
<strong>modulateImage</strong> function to change the brightness and`
542
saturation of the reference image of this VoltRon object. This
543
functionality is optional for VoltRon objects and should be used when
544
images require further adjustments.</p>
545
<pre class="r watch-out"><code>Xen_R2 &lt;- modulateImage(Xen_R2, brightness = 800)
546
vrImages(Xen_R2)</code></pre>
547
<p><img width="40%" height="40%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/xeniumr2_new.png" class="center"></p>
548
<p><br></p>
549
<div id="automated-image-alignment" class="section level3">
550
<h3>Automated Image Alignment</h3>
551
<p>In order to achieve data transfer and integration across these two
552
modalities, we need to first make sure that spatial coordinates of these
553
three datasets are perfectly aligned. To this end, we will make use of
554
the <strong>registerSpatialData</strong> function which calls a
555
<strong>shiny app</strong> embedded into VoltRon. The function takes a
556
single list as an input where the order of VoltRon objects in the list
557
should be the same as the <strong>order of serial sections</strong>.</p>
558
<p>We will make use of the <strong>registerSpatialData</strong> function
559
to <strong>automatically register two Xenium assays onto the Visium
560
assay</strong>. The Visium CytAssist image (or the <strong>image on the
561
center</strong> of the list) would be taken as the image of reference,
562
and hence all other images (or spatial datasets) are to be aligned to
563
the Visium data. Then, registerSpatialData will return a list of VoltRon
564
objects whose assays include both the original and registered versions
565
of spatial coordinates. The shiny app will provide <strong>two
566
images</strong> for this task:</p>
567
<ul>
568
<li>An image that shows the matched points across two images, and</li>
569
<li>A slideshow with of the reference and registered images that
570
demonstrates the alignment accuracy.</li>
571
</ul>
572
<p>We will select <strong>FLANN</strong> method for automated alignment
573
which incorporates the <strong>SIFT</strong> method for automated
574
keypoints selection and utilizes the <strong>Fast library for
575
Approximate Nearest Neighbors (FLANN) algorithm</strong> for matching
576
keypoints. <strong>NOTE:</strong> For better alignment performance,
577
users can incorporate image manipulation tools above each image and sync
578
images into the same orientation by rotating, flipping (horizontally and
579
vertically) and negating these images. We always negate DAPI images to
580
align them onto H&amp;E images.</p>
581
<pre class="r watch-out"><code>xen_reg &lt;- registerSpatialData(object_list = list(Xen_R1, Vis, Xen_R2))</code></pre>
582
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/XeniumVisiumRegistration_FLANN.gif" class="center"></p>
583
<p><br></p>
584
<p>You can save and use the same parameters later, and reproduce the
585
alignment without choosing parameters the second time.</p>
586
<pre class="r watch-out"><code>mapping_parameters &lt;- xen_reg$mapping_parameters
587
xen_reg &lt;- registerSpatialData(object_list = list(Xen_R1, Vis, Xen_R2), 
588
                               mapping_parameters = mapping_parameters)</code></pre>
589
<p>You can find a presaved set of parameters <a
590
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/SpatialDataAlignment/Xenium_vs_Visium/mapping_parameters.rds">here</a>.</p>
591
<pre class="r watch-out"><code>mapping_parameters &lt;- readRDS(&quot;mapping_parameters.rds&quot;)
592
xen_reg &lt;- registerSpatialData(object_list = list(Xen_R1, Vis, Xen_R2), 
593
                               mapping_parameters = mapping_parameters)</code></pre>
594
<p>If the pre-saved parameters are available, the registration can also
595
be performed without using the shiny app. By using <strong>interactive =
596
FALSE</strong>, we can register images and VoltRon objects directly.</p>
597
<pre class="r watch-out"><code>mapping_parameters &lt;- xen_reg$mapping_parameters
598
xen_reg &lt;- registerSpatialData(object_list = list(Xen_R1, Vis, Xen_R2), 
599
                               mapping_parameters = mapping_parameters, 
600
                               interactive = FALSE)</code></pre>
601
<p>In case there are only two images, <strong>the first image will be
602
taken as the image of reference</strong>. Hence, in order to align the
603
first Xenium Replicate to the Visium dataset, we can create a list of
604
two VoltRon objects as given below.</p>
605
<pre class="r watch-out"><code>xen_reg &lt;- registerSpatialData(object_list = list(Vis, Xen_R2))</code></pre>
606
<p><br></p>
607
</div>
608
<div id="manual-image-alignment" class="section level3">
609
<h3>Manual Image Alignment</h3>
610
<p>Given the diverse types of tissue sections and their complex
611
morphology, we need an alternative alignment strategy if automated
612
registration may fail. VoltRon allows <strong>manually choosing
613
keypoints (or landmarks)</strong> on images that are locations on the
614
tissue with structural/morphological similarity. Similar to the
615
automated mode, <strong>the image on the center</strong> will be taken
616
as reference and the users will be able to observe the quality of the
617
registration and remove/reselect keypoints as they see fit.</p>
618
<pre class="r watch-out"><code>xen_reg &lt;- registerSpatialData(object_list = list(Xen_R1, Vis, Xen_R2))</code></pre>
619
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/XeniumVisiumRegistration.gif" class="center"></p>
620
<p><br></p>
621
<p>You can save and use the same keypoints later, and reproduce the
622
manual alignment without choosing keypoints for the second time.</p>
623
<pre class="r watch-out"><code>mapping_parameters &lt;- xen_reg$mapping_parameters
624
xen_reg &lt;- registerSpatialData(object_list = list(Xen_R1, Vis, Xen_R2), 
625
                               mapping_parameters = mapping_parameters)</code></pre>
626
<p>You can find a presaved set of parameters with selected manual
627
keypoints <a
628
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/SpatialDataAlignment/Xenium_vs_Visium/mapping_parameters_manual.rds">here</a>.</p>
629
<pre class="r watch-out"><code>mapping_parameters &lt;- readRDS(&quot;mapping_parameters_manual.rds&quot;)
630
xen_reg &lt;- registerSpatialData(object_list = list(Xen_R1, Vis, Xen_R2), 
631
                               mapping_parameters = mapping_parameters)</code></pre>
632
<p>If the pre-saved keypoints are available with parameters, the
633
registration can also be performed without using the shiny app. By using
634
<strong>interactive = FALSE</strong>, we can register images and VoltRon
635
objects directly.</p>
636
<pre class="r watch-out"><code>mapping_parameters &lt;- xen_reg$mapping_parameters
637
xen_reg &lt;- registerSpatialData(object_list = list(Xen_R1, Vis, Xen_R2), 
638
                               mapping_parameters = mapping_parameters, 
639
                               interactive = FALSE)</code></pre>
640
<p>In case there are only two images, <strong>the first image will be
641
taken as the image of reference</strong>. Hence, in order to align the
642
first Xenium Replicate to the Visium dataset. We can create a list of
643
two VoltRon objects as given below.</p>
644
<pre class="r watch-out"><code>xen_reg &lt;- registerSpatialData(object_list = list(Vis, Xen_R2))</code></pre>
645
<p><br></p>
646
</div>
647
<div id="combine-voltron-object" class="section level3">
648
<h3>Combine VoltRon object</h3>
649
<p>Now that the VoltRon objects of Xenium and Visium datasets are
650
accurately aligned, we can combine these objects to create <strong>one
651
VoltRon object with three layers</strong>. Since all sections are
652
derived from the same tissue block, we want them to be associated with
653
the same sample, hence we define the sample name as well. VoltRon will
654
recognize that all layers are originated from the same sample/block, and
655
choose the majority assay as the main assay.</p>
656
<pre class="r watch-out"><code>merge_list &lt;- xen_reg$registered_spat
657
VRBlock &lt;- merge(merge_list[[1]], merge_list[-1], samples = &quot;10XBlock&quot;)
658
VRBlock</code></pre>
659
<pre><code>10XBlock: 
660
  Layers: Section1 Section2 Section3 
661
Assays: Xenium(Main) Visium
662
Features: RNA(Main) </code></pre>
663
<p>Here, we can quickly check the change in spatial coordinate systems
664
in the new tissue block. The <code>registerSpatialData</code> function
665
syncronizes the coordinate systems of all VoltRon objects in the list
666
before merging. Both Xenium sections have now two coordinate system
667
where the registered system <strong>main_reg</strong> is the default
668
one.</p>
669
<pre class="r watch-out"><code>vrSpatialNames(VRBlock, assay = &quot;all&quot;)</code></pre>
670
<pre><code>        Assay    Layer   Sample       Spatial     Main
671
Assay1 Xenium Section1 10XBlock main,main_reg main_reg
672
Assay2 Visium Section2 10XBlock          main     main
673
Assay3 Xenium Section3 10XBlock main,main_reg main_reg</code></pre>
674
<p><br></p>
675
</div>
676
<div id="datalabel-transfer-across-layers" class="section level3">
677
<h3>Data/Label Transfer Across Layers</h3>
678
<p>The combined VoltRon object of Visium and Xenium datasets can be used
679
to transfer information across layers and assays. This is accomplished
680
by aggregating and summarizing, for example, gene counts of cells from
681
the Xenium assay aligned to Visium spots. Either labels or cell types
682
can be summarized to generate:</p>
683
<ul>
684
<li>pseudo cell type abundance assays or</li>
685
<li>pseudo gene expression assays.</li>
686
</ul>
687
<p><br></p>
688
<div id="data-transfer-cells-spots" class="section level4">
689
<h4>Data Transfer (Cells-&gt;Spots)</h4>
690
<p>We must first determine the names of the assays where labels are
691
transfered <strong>from</strong> one <strong>to</strong> the other. For
692
the sake of this tutorial, we can select Assay1 of <strong>Xenium as the
693
source</strong> assay and the Assay2 of <strong>Visium as the
694
destination</strong> assay.</p>
695
<pre class="r watch-out"><code>SampleMetadata(VRBlock)</code></pre>
696
<pre><code>        Assay    Layer   Sample
697
Assay1 Xenium Section1 10XBlock
698
Assay2 Visium Section2 10XBlock
699
Assay3 Xenium Section3 10XBlock</code></pre>
700
<p>The <strong>transferData</strong> function detects the types of both
701
the <strong>source (from)</strong> and the <strong>destination
702
(to)</strong> assays and determines the how the data should be
703
transfered. We can first transfer data from the Xenium assay to the
704
Visium assay (hence <strong>Cells -&gt; Spots</strong>), the raw count
705
data of each cell in the source Xenium assay will be aggregated into
706
spots in a newly create pseudo Visium assay. The new assay with
707
aggregated counts will be named <strong>Visium_pseudo</strong>.</p>
708
<pre class="r watch-out"><code>VRBlock &lt;- transferData(VRBlock, from = &quot;Assay1&quot;, to = &quot;Assay2&quot;)</code></pre>
709
<p>VoltRon supports multiple feature type within each assay. Now, the
710
Visium assay includes two spot-type features:</p>
711
<ul>
712
<li>the original Visium spot feature counts,</li>
713
<li>a pseudo Visium feature count matrix with aggregated Xenium raw
714
counts.</li>
715
</ul>
716
<pre class="r watch-out"><code>vrMainAssay(VRBlock) &lt;- &quot;Visium&quot;
717
VRBlock</code></pre>
718
<pre><code>VoltRon Object 
719
10XBlock: 
720
  Layers: Section1 Section2 Section3 
721
Assays: Visium(Main) Xenium 
722
Features: RNA(Main) RNA_pseudo </code></pre>
723
<p>We can now visualize both the original and aggregated counts of a
724
gene, such as ERBB2 and ESR1 that marks ductal carcinoma in situ (DCIS)
725
regions, to validate the correlation of gene signatures across adjacent
726
tissue sections, and to validate the accuracy of the automated image
727
alignment. Here, PGR is also expressed at a small DCIS region found on
728
adipocyte niche of the tissue.</p>
729
<pre class="r watch-out"><code>library(patchwork)
730
vrMainFeatureType(VRBlock, assay = &quot;Visium&quot;) &lt;- &quot;RNA&quot;
731
g1 &lt;- vrSpatialFeaturePlot(VRBlock,  
732
                           features = c(&quot;ERBB2&quot;, &quot;ESR1&quot;, &quot;PGR&quot;), crop = FALSE, 
733
                           norm = FALSE, ncol = 3)
734
vrMainFeatureType(VRBlock, assay = &quot;Visium&quot;) &lt;- &quot;RNA_pseudo&quot;
735
g2 &lt;- vrSpatialFeaturePlot(VRBlock, 
736
                           features = c(&quot;ERBB2&quot;, &quot;ESR1&quot;, &quot;PGR&quot;), crop = FALSE, 
737
                           norm = FALSE, ncol = 3)
738
g1 / g2</code></pre>
739
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/registration_TACSTD2.png" class="center"></p>
740
</div>
741
<div id="data-transfer-spots-cells" class="section level4">
742
<h4>Data Transfer (Spots-&gt;Cells)</h4>
743
<p>A similar transfer can be achieved on the opposite direction. We can
744
select Assay2 of <strong>Visium as the source</strong> assay and Assay1
745
of <strong>Xenium as the destination</strong>, thus we can transfer
746
whole transcriptome counts of the Visium assays to Xenium to create new
747
feature sets for Xenium data with more features originally available in
748
the Xenium panel.</p>
749
<pre class="r watch-out"><code>vrMainFeatureType(VRBlock, assay = &quot;Visium&quot;) &lt;- &quot;RNA&quot;
750
VRBlock &lt;- transferData(VRBlock, from = &quot;Assay2&quot;, to = &quot;Assay1&quot;)</code></pre>
751
<p>We now set the main feature set of the Xenium assays.</p>
752
<pre class="r watch-out"><code>vrMainFeatureType(VRBlock, assay = &quot;Xenium&quot;) &lt;- &quot;RNA_pseudo&quot;
753
vrMainFeatureType(VRBlock, assay = &quot;all&quot;)</code></pre>
754
<pre><code>   Assay    Feature
755
1 Assay1 RNA_pseudo
756
2 Assay2        RNA
757
3 Assay3        RNA</code></pre>
758
<pre class="r watch-out"><code>library(patchwork)
759
g1 &lt;- vrSpatialFeaturePlot(VRBlock, 
760
                           assay = &quot;Assay1&quot;, features = c(&quot;ERBB2&quot;, &quot;ESR1&quot;, &quot;PGR&quot;), 
761
                           crop = TRUE, norm = FALSE, alpha = 1, n.tile = 300, ncol = 3)
762
g2 &lt;- vrSpatialFeaturePlot(VRBlock, 
763
                           assay = &quot;Assay2&quot;, features = c(&quot;ERBB2&quot;, &quot;ESR1&quot;, &quot;PGR&quot;), 
764
                           crop = TRUE, norm = FALSE, alpha = 1, ncol = 3)
765
g1 / g2</code></pre>
766
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/registration_spot2cell.png" class="center"></p>
767
</div>
768
<div id="label-transfer-cells-spots" class="section level4">
769
<h4>Label Transfer (Cells-&gt;Spots)</h4>
770
<p>The <strong>transferData</strong> function can also transfer
771
<strong>metadata features</strong> across layers and assays. In this
772
case, we will transfer cell type labels that were trained on the Xenium
773
sections onto the Visium sections. We will use the cluster labels
774
generated at the end of the Xenium analysis section of workflow from <a
775
href="spotanalysis.html">Cell/Spot Analysis</a>. You can download the
776
VoltRon object with clustered and annotated Xenium cells along with the
777
Visium assay from <a
778
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/SpatialDataAlignment/Xenium_vs_Visium/VRBlock_data_clustered.rds">here</a>.</p>
779
<pre class="r watch-out"><code>VRBlock &lt;- readRDS(&quot;VRBlock_data_clustered.rds&quot;)
780
vrSpatialPlot(VRBlock, assay = &quot;Xenium&quot;, group.by = &quot;CellType&quot;, pt.size = 0.4)</code></pre>
781
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_spatial_xenium_annotated.png" class="center"></p>
782
<p>Here, we can see that both Xenium layers are clustered and annotated
783
where we can use these cell annotations and transfer them to the Visium
784
assay to create an assay of <strong>estimated cell type
785
abundances</strong>. If the features argument is specified, and if its a
786
single metadata feature with, e.g. cell types, then the each spot at the
787
new pseudo Visium will be collection of abundances of the categories
788
within that metadata feature.</p>
789
<pre class="r watch-out"><code>VRBlock &lt;- transferData(VRBlock, from = &quot;Assay1&quot;, to = &quot;Assay2&quot;, features = &quot;CellType&quot;, 
790
                        new_assay_name = &quot;Visium_CellType&quot;)
791
VRBlock</code></pre>
792
<pre><code>VoltRon Object 
793
10XBlock: 
794
  Layers: Section1 Section2 Section3 
795
Assays: Visium(Main) Xenium 
796
Features: RNA_pseudo(Main) RNA Visium_CellType </code></pre>
797
<p>By visualizing the transferred labels on the Visium spots, we can see
798
abundance of some DCIS and invasive tumor subtypes.</p>
799
<pre class="r watch-out"><code>vrMainFeatureType(VRBlock) &lt;- &quot;Visium_CellType&quot;
800
vrSpatialFeaturePlot(VRBlock, assay = &quot;Visium&quot;,
801
                     features = c(&quot;IT_1&quot;,&quot;DCIS_2&quot;), 
802
                     crop = TRUE, alpha = 1, ncol = 3)</code></pre>
803
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/registration_CellType.png" class="center"></p>
804
<p><br></p>
805
</div>
806
<div id="label-transfer-rois-" class="section level4">
807
<h4>Label Transfer (ROIs-&gt;…)</h4>
808
<p>VoltRon allows users to annotate regions of interests (ROIs) in a
809
given assay and transfer the annotations to these ROIs across other
810
assays within the same tissue block. Let us annotate two specific tumor
811
regions in the Visium section. In the process, a new assay called
812
<strong>ROIAnnotation</strong> will be added to the VoltRon object.</p>
813
<pre class="r watch-out"><code>VRBlock &lt;- annotateSpatialData(VRBlock, assay = &quot;Visium&quot;, 
814
                               label = &quot;annotation&quot;, use.image.only = TRUE)</code></pre>
815
<p><img width="80%" height="80%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/registration_ROIAnnotation.png" class="center"></p>
816
<p><br></p>
817
<p>You can observe the changes in the object and check the assay ID of
818
this new ROI type assay using <code>SampleMetadata</code> function.</p>
819
<pre class="r watch-out"><code>VRBlock</code></pre>
820
<pre><code>VoltRon Object 
821
10XBlock: 
822
  Layers: Section1 Section2 Section3 
823
Assays: Xenium(Main) Visium ROIAnnotation 
824
Features: RNA(Main) </code></pre>
825
<pre class="r watch-out"><code>SampleMetadata(VRBlock)</code></pre>
826
<pre><code>               Assay    Layer   Sample
827
Assay1        Xenium Section1 10XBlock
828
Assay2        Visium Section2 10XBlock
829
Assay3        Xenium Section3 10XBlock
830
Assay4 ROIAnnotation Section2 10XBlock</code></pre>
831
<p>The metadata of the ROI assay will include the annotation of the ROIs
832
as well.</p>
833
<pre class="r watch-out"><code>Metadata(VRBlock, assay = &quot;ROIAnnotation&quot;)</code></pre>
834
<pre><code>                               Assay    Layer   Sample      annotation
835
InvasiveTumor_Assay4   ROIAnnotation Section2 10XBlock   InvasiveTumor
836
DuctalCarcinoma_Assay4 ROIAnnotation Section2 10XBlock DuctalCarcinoma</code></pre>
837
<p>Now we can transfer the ROI labels from the
838
<strong>annotation</strong> metadata column and define the same metadata
839
column in the remaining assays.</p>
840
<pre class="r watch-out"><code>VRBlock &lt;- transferData(object = VRBlock, from = &quot;Assay4&quot;, to = &quot;Assay1&quot;, 
841
                        features = &quot;annotation&quot;)
842
VRBlock &lt;- transferData(object = VRBlock, from = &quot;Assay4&quot;, to = &quot;Assay3&quot;, 
843
                        features = &quot;annotation&quot;)</code></pre>
844
<p>Let us observe the changes across all assays.</p>
845
<pre class="r watch-out"><code>vrSpatialPlot(VRBlock, group.by = &quot;annotation&quot;, assay = &quot;Xenium&quot;, crop = TRUE)
846
vrSpatialPlot(VRBlock, group.by = &quot;annotation&quot;, assay = &quot;Visium&quot;, crop = TRUE)</code></pre>
847
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/registration_ROI_xenium.png" class="center"></p>
848
<p><img width="50%" height="50%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/registration_ROI_visium.png" class="center"></p>
849
<p><br></p>
850
<p>You can also use the <strong>addSpatialLayer</strong> function to
851
overlay annotation segments to the spatial plot of the Xenium data.</p>
852
<pre class="r watch-out"><code>vrSpatialPlot(VRBlock_new2, group.by = &quot;CellType&quot;, assay = &quot;Assay1&quot;, crop = TRUE) |&gt;
853
  addSpatialLayer(VRBlock_new2, assay = &quot;ROIAnnotation&quot;, group.by = &quot;annotation&quot;, spatial = &quot;main&quot;, alpha = 0.4)</code></pre>
854
<p><img width="50%" height="50%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/registration_ROI_xenium_overlay.png" class="center"></p>
855
<p><br></p>
856
</div>
857
</div>
858
</div>
859
<div id="alignment-of-xenium-and-he" class="section level2">
860
<h2>Alignment of Xenium and H&amp;E</h2>
861
<p>In this use case, we will align <strong>immunofluorescence
862
(IF)</strong> of the <strong>Xenium In Situ</strong> platform to an
863
<strong>H&amp;E images</strong> generated from the same sections as the
864
Xenium. VoltRon provides built-in utilities to import images as spatial
865
datasets where <strong>tiles</strong> are the spatial points. We will
866
import both Xenium and H&amp;E images into two separate VoltRon objects
867
and overlay H&amp;E images.</p>
868
<p>You can download the Xenium readout and the H&amp;E image of the same
869
tissue section from the <a
870
href="https://www.10xgenomics.com/products/xenium-in-situ/preview-dataset-human-breast">10x
871
Genomics website</a> (specifically, import <strong>In Situ Replicate
872
1</strong> and <strong>Supplemental: Post-Xenium H&amp;E image
873
(TIFF)</strong>).</p>
874
<pre class="r watch-out"><code>library(VoltRon)
875
876
# import Xenium 
877
Xen_R1 &lt;- importXenium(&quot;Xenium_R1/outs&quot;, sample_name = &quot;XeniumR1&quot;)
878
879
# import H&amp;E image and build a VoltRon object
880
Xen_R1_image &lt;- importImageData(&quot;Xenium_FFPE_Human_Breast_Cancer_Rep1_he_image.tif&quot;,
881
                                sample_name = &quot;XeniumR1image&quot;, 
882
                                channel_names = &quot;H&amp;E&quot;)
883
Xen_R1_image</code></pre>
884
<pre><code>VoltRon Object 
885
XeniumR1image: 
886
  Layers: Section1 
887
Assays: ImageData(Main) </code></pre>
888
<p>Lets take a look at the image of the Xen_R1_image object</p>
889
<pre class="r watch-out"><code>vrImages(Xen_R1_image)</code></pre>
890
<p><img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/importdata_HE.png" class="center"></p>
891
<p><br></p>
892
<div id="automated-image-alignment-1" class="section level3">
893
<h3>Automated Image Alignment</h3>
894
<p>We can use the <strong>registerSpatialData</strong> function to
895
warp/align images across multiple VoltRon objects and define these
896
aligned images additional channels of existing coordinate systems of
897
assays in one of these VoltRon objects.</p>
898
<p>First we align the H&amp;E image to the DAPI image of the Xenium
899
replicate. Similar to the first use case, we need to negate the DAPI
900
image and change the alignment of the image to match it with the H&amp;E
901
image. We can also scale the resolution of the H&amp;E image to
902
9103.71x6768.63.</p>
903
<pre class="r watch-out"><code>xen_reg &lt;- registerSpatialData(object_list = list(Xen_R1, Xen_R1_image))</code></pre>
904
<p><img width="92%" height="92%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/registration_HE_function.png" class="center"></p>
905
<p><br></p>
906
<p>Now we create a new channel for the existing coordinate system of the
907
Xenium data. Here, the spatial key of the registered H&amp;E image will
908
be <strong>main_reg</strong>. We choose the destination of the
909
registered image which is the first Assay of the Xenium data
910
(i.e. <strong>Assay1</strong>). The original DAPI coordinate system, and
911
we give a name for the new image/channel which is
912
<strong>H&amp;E</strong>.</p>
913
<pre class="r watch-out"><code>Xen_R1_image_reg &lt;- xen_reg$registered_spat[[2]]
914
vrImages(Xen_R1[[&quot;Assay1&quot;]], channel = &quot;H&amp;E&quot;) &lt;- vrImages(Xenium_reg, name = &quot;main_reg&quot;, channel = &quot;H&amp;E&quot;)</code></pre>
915
<p>We can now observe the new channels (H&amp;E) available for the
916
Xenium assay using <strong>vrImageChannelNames</strong>.</p>
917
<pre class="r watch-out"><code>vrImageChannelNames(Xen_R1)</code></pre>
918
<pre><code>       Assay    Layer           Sample Spatial                                               Channels
919
Assay1 GeoMx Section1 prolonged case 4    main scanimage,DNA,PanCK,CD45,Alpha Smooth Muscle Actin,H&amp;E</code></pre>
920
<p>We can call the registered H&amp;E image of the Xenium data or later
921
put the aligned H&amp;E when calling <strong>vrSpatialPlot</strong> or
922
<strong>vrSpatialFeaturePlot</strong>.</p>
923
<pre class="r watch-out"><code>vrImages(Xen_R1, channel = &quot;H&amp;E&quot;, scale.perc = 5)</code></pre>
924
<p><img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/registration_HE.png" class="center"></p>
925
<p><br></p>
926
</div>
927
</div>
928
<div id="alignment-of-visium-and-visium" class="section level2">
929
<h2>Alignment of Visium and Visium</h2>
930
<p>In the next use case, we will align <strong>H&amp;E images</strong>
931
associated with Visium data generated from tissue block sections of
932
<strong>adult humans with postmortem dorsolateral prefrontal cortex
933
(DLPFC)</strong>. Two pairs of adjacent sections was obtained from the
934
tissue block of the third donor. Each pair are composed of two 10 <span
935
class="math inline">\(\mu\)</span>m serial tissue sections, and pairs
936
are located 300 <span class="math inline">\(\mu\)</span>m apart from
937
each other. Hence, we align each pair individually. The datasets can be
938
downloaded from <a
939
href="https://research.libd.org/spatialLIBD/">here</a>.</p>
940
<pre class="r watch-out"><code>library(VoltRon)
941
DLPFC_1 &lt;- importVisium(&quot;DLPFC/151673&quot;, sample_name = &quot;DLPFC_1&quot;)
942
DLPFC_2 &lt;- importVisium(&quot;DLPFC/151674&quot;, sample_name = &quot;DLPFC_2&quot;)
943
DLPFC_3 &lt;- importVisium(&quot;DLPFC/151675&quot;, sample_name = &quot;DLPFC_3&quot;)
944
DLPFC_4 &lt;- importVisium(&quot;DLPFC/151676&quot;, sample_name = &quot;DLPFC_4&quot;)</code></pre>
945
<p><br></p>
946
<div id="automated-image-alignment-2" class="section level3">
947
<h3>Automated Image Alignment</h3>
948
<p>We will again use the registerSpatialData function to
949
<strong>automatically register two Visium assays (two H&amp;E
950
images)</strong>. This time, we will use the
951
<strong>BRUTE-FORCE</strong> method for automated alignment which we
952
found to be more accurate compared to FLANN when aligning two H&amp;E
953
images. The shiny app also provides two tuning parameters that used by
954
the the BRUTE-FORCE workflow:</p>
955
<ul>
956
<li><strong># of Features</strong> option specifies the number of
957
maximum image features spotted within each image which later be used to
958
match to the other image.</li>
959
<li><strong>Match %</strong> specifies the percentage of these features
960
matching at max which in turn used to compute the
961
registration/transformation matrix.</li>
962
</ul>
963
<p>We will use <strong>1000 features</strong> for this alignment, set
964
<strong>Match %</strong> to 20% of the features to be matched across
965
images. The quality of the alignment will be determined by the fine
966
tuning of these parameters where users will immediately observe the
967
alignment quality looking at the slideshow.</p>
968
<pre class="r watch-out"><code>DLPFC_list &lt;- list(DLPFC_1, DLPFC_2)
969
reg1and2 &lt;- registerSpatialData(object_list = DLPFC_list)</code></pre>
970
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/VisiumDLFPCRegistration.gif" class="center"></p>
971
<p><br></p>
972
<p>We can now apply a similar alignment across the second pair of
973
VoltRon objects. We will use <strong>800 features</strong> for this
974
alignment, set <strong>Match %</strong> to 50% of the features to be
975
matched across images.</p>
976
<pre class="r watch-out"><code>DLPFC_list &lt;- list(DLPFC_3, DLPFC_4)
977
reg3and4 &lt;- registerSpatialData(object_list = DLPFC_list)</code></pre>
978
<p><br></p>
979
</div>
980
<div id="d-spot-clustering" class="section level3">
981
<h3>3D Spot Clustering</h3>
982
<p>We can now combine all sections into one VoltRon object. There are
983
two pairs of serial tissue sections, but both pairs (thus 4 sections)
984
are from the same tissue block. Hence, we can combine these two lists
985
into one list and merge VoltRon objects even though sections were
986
aligned separately.</p>
987
<pre class="r watch-out"><code>merge_list &lt;- c(reg1and2$registered_spat, reg3and4$registered_spat)
988
SRBlock &lt;- merge(merge_list[[1]], merge_list[-1], samples = &quot;DLPFC_Block&quot;)
989
SRBlock</code></pre>
990
<pre><code>VoltRon Object 
991
DLPFC_Block: 
992
  Layers: Section1 Section2 Section3 Section4 
993
Assays: Visium(Main) </code></pre>
994
<p><br></p>
995
<p>Aligning spots along the z dimension allows us to cluster these spots
996
using both the gene expression similarities and spatial adjacency (both
997
along the x-y direction and in the z direction). We first generate a
998
spatial neighborhood graph and use this graph along with the gene
999
expression neighborhood graph <strong>(under development)</strong>.</p>
1000
</div>
1001
</div>
1002
</div>
1003
1004
1005
1006
</div>
1007
</div>
1008
1009
</div>
1010
1011
<script>
1012
1013
// add bootstrap table styles to pandoc tables
1014
function bootstrapStylePandocTables() {
1015
  $('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
1016
}
1017
$(document).ready(function () {
1018
  bootstrapStylePandocTables();
1019
});
1020
1021
1022
</script>
1023
1024
<!-- tabsets -->
1025
1026
<script>
1027
$(document).ready(function () {
1028
  window.buildTabsets("TOC");
1029
});
1030
1031
$(document).ready(function () {
1032
  $('.tabset-dropdown > .nav-tabs > li').click(function () {
1033
    $(this).parent().toggleClass('nav-tabs-open');
1034
  });
1035
});
1036
</script>
1037
1038
<!-- code folding -->
1039
1040
<script>
1041
$(document).ready(function ()  {
1042
1043
    // temporarily add toc-ignore selector to headers for the consistency with Pandoc
1044
    $('.unlisted.unnumbered').addClass('toc-ignore')
1045
1046
    // move toc-ignore selectors from section div to header
1047
    $('div.section.toc-ignore')
1048
        .removeClass('toc-ignore')
1049
        .children('h1,h2,h3,h4,h5').addClass('toc-ignore');
1050
1051
    // establish options
1052
    var options = {
1053
      selectors: "h1,h2,h3,h4,h5",
1054
      theme: "bootstrap3",
1055
      context: '.toc-content',
1056
      hashGenerator: function (text) {
1057
        return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
1058
      },
1059
      ignoreSelector: ".toc-ignore",
1060
      scrollTo: 0
1061
    };
1062
    options.showAndHide = false;
1063
    options.smoothScroll = true;
1064
1065
    // tocify
1066
    var toc = $("#TOC").tocify(options).data("toc-tocify");
1067
});
1068
</script>
1069
1070
<!-- dynamically load mathjax for compatibility with self-contained -->
1071
<script>
1072
  (function () {
1073
    var script = document.createElement("script");
1074
    script.type = "text/javascript";
1075
    script.src  = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
1076
    document.getElementsByTagName("head")[0].appendChild(script);
1077
  })();
1078
</script>
1079
1080
</body>
1081
</html>