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

Switch to unified view

a b/docs/spotanalysis.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>Cell/Spot Analysis</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">Cell/Spot Analysis</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="xenium-data-analysis" class="section level1">
462
<h1>Xenium Data Analysis</h1>
463
<p>VoltRon is an end-to-end spatial omic analysis package which also
464
supports investigating spatial points in single cell resolution. VoltRon
465
includes essential built-in functions capable of
466
<strong>filtering</strong>, <strong>processing</strong> and
467
<strong>clustering</strong> as well as <strong>visualizing</strong>
468
spatial datasets with a goal of cell type discovery and annotation.</p>
469
<p>In this use case, we analyse readouts of the experiments conducted on
470
example tissue sections analysed by the <a
471
href="https://www.10xgenomics.com/platforms/xenium">Xenium In Situ</a>
472
platform. Two tissue sections of 5 <span
473
class="math inline">\(\mu\)</span>m tickness are derived from a single
474
formalin-fixed, paraffin-embedded (FFPE) breast cancer tissue block.
475
More information on the spatial datasets and the study can be also be
476
found on the <a
477
href="https://www.biorxiv.org/content/10.1101/2022.10.06.510405v1">BioArxiv
478
preprint</a>.</p>
479
<p>You can import these readouts from the <a
480
href="https://www.10xgenomics.com/products/xenium-in-situ/preview-dataset-human-breast">10x
481
Genomics website</a> (specifically, import <strong>In Situ Replicate
482
1/2</strong>). Alternatively, you can <strong>download a zipped
483
collection of Xenium readouts</strong> from <a
484
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/SpatialDataAlignment/Xenium_vs_Visium/10X_Xenium_Visium.zip">here</a>.</p>
485
<p><br></p>
486
<div id="building-voltron-objects" class="section level2">
487
<h2>Building VoltRon objects</h2>
488
<p>VoltRon includes built-in functions for converting readouts of Xenium
489
experiments into VoltRon objects. The <strong>importXenium</strong>
490
function locates all readout documents under the output folder of the
491
Xenium experiment, and forms a VoltRon object. We will import both
492
Xenium replicates separately, and merge them after some image
493
manipulation.</p>
494
<pre class="r watch-out"><code>library(VoltRon)
495
Xen_R1 &lt;- importXenium(&quot;Xenium_R1/outs&quot;, sample_name = &quot;XeniumR1&quot;, import_molecules = TRUE)
496
Xen_R2 &lt;- importXenium(&quot;Xenium_R2/outs&quot;, sample_name = &quot;XeniumR2&quot;, import_molecules = TRUE)</code></pre>
497
<p>Before moving on to the downstream analysis of the imaging-based
498
data, we can inspect both Xenium images. We use the
499
<strong>vrImages</strong> function to call and visualize reference
500
images of all VoltRon objects. Observe that the DAPI image of the second
501
Xenium replicate is dim, hence we might need to increase the
502
brightness.</p>
503
<pre class="r watch-out"><code>vrImages(Xen_R1)
504
vrImages(Xen_R2)</code></pre>
505
<table>
506
<tbody>
507
<tr style="vertical-align: center">
508
<td style="width:50%; vertical-align: center">
509
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/xeniumr1.png" class="center">
510
</td>
511
<td style="width:50%; vertical-align: center">
512
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/xeniumr2.png" class="center">
513
</td>
514
</tr>
515
</tbody>
516
</table>
517
<p><br></p>
518
<p>We can adjust the brightness of the second Xenium replicate using the
519
<strong>modulateImage</strong> function where we can change the
520
brightness and saturation of the reference image of this VoltRon object.
521
This functionality is optional for VoltRon objects and should be used
522
when images require further adjustments.</p>
523
<pre class="r watch-out"><code>Xen_R2 &lt;- modulateImage(Xen_R2, brightness = 800)
524
vrImages(Xen_R2)</code></pre>
525
<p><img width="40%" height="40%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/xeniumr2_new.png" class="center"></p>
526
<p><br></p>
527
<p>Once both VoltRon objects are created and images are well-tuned, we
528
can merge these two into a single VoltRon object.</p>
529
<pre class="r watch-out"><code>Xen_list &lt;- list(Xen_R1, Xen_R2)
530
Xen_data &lt;- merge(Xen_list[[1]], Xen_list[-1])</code></pre>
531
<pre><code>VoltRon Object 
532
XeniumR1: 
533
  Layers: Section1 
534
XeniumR2: 
535
  Layers: Section1 
536
Assays: Xenium(Main) </code></pre>
537
<p><br></p>
538
</div>
539
<div id="spatial-visualization" class="section level2">
540
<h2>Spatial Visualization</h2>
541
<p>With <strong>vrSpatialPlot</strong>, we can visualize Xenium
542
experiments in both cellular and subcellular context. Since we have not
543
yet started analyzing raw counts of cells, we can first visualize some
544
transcripts of interest. We first visualize mRNAs of ACTA2, a marker for
545
smooth muscle cell actin, and TCF7, an early exhausted t cell marker. We
546
can interactively select a subset of interest within the tissue section
547
and visualize the localization of these transcripts. Here we subset a
548
ductal carcinoma niche, and visualize visualize mRNAs of
549
<strong>(i)</strong> ACTA2, a marker for smooth muscle cell actin, and
550
<strong>(ii)</strong> TCF7, an early exhausted t cell marker.</p>
551
<pre class="r watch-out"><code>Xen_R1_subsetinfo &lt;- subset(Xen_R1, interactive = TRUE)
552
Xen_R1_subset &lt;- Xen_R1_subsetinfo$subsets[[1]]
553
vrSpatialPlot(Xen_R1_subset, assay = &quot;Xenium_mol&quot;, group.by = &quot;gene&quot;,
554
              group.id = c(&quot;ACTA2&quot;, &quot;KRT15&quot;, &quot;TACSTD2&quot;, &quot;CEACAM6&quot;), pt.size = 0.2, legend.pt.size = 5)</code></pre>
555
<p><img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_transcripts_visualize.png" class="center"></p>
556
<p>We can also visualize count data of cells in the Xenium replicates.
557
The behaviour of <strong>vrSpatialFeaturePlot</strong> (and most
558
plotting functions in VoltRon) depend on the number of assays associated
559
with the assay type (e.g. Xenium is both cell and subcellular type).
560
Here, we have two assays, and we visualize two features, hence the
561
resulting plot would include four panels. Prior to spatial
562
visualization, we can normalize the counts to correct for count depth of
563
cells by <strong>(i)</strong> dividing counts with total counts in each
564
cell, <strong>(ii)</strong> multiply with some constant (default:
565
10000), and followed by <strong>(iii)</strong> log transformation of the
566
counts.</p>
567
<pre class="r watch-out"><code>Xen_data &lt;- normalizeData(Xen_data, sizefactor = 1000)
568
vrSpatialFeaturePlot(Xen_data, features = c(&quot;ACTA2&quot;, &quot;TCF7&quot;), alpha = 1, pt.size = 0.7)</code></pre>
569
<p><img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_spatialfeature_xenium.png" class="center"></p>
570
</div>
571
<div id="processing-and-embedding" class="section level2">
572
<h2>Processing and Embedding</h2>
573
<p>Some number of cells in both Xenium replicates might have extremely
574
low counts. Although cells are detected at these locations, the low
575
total counts of cells would make it challenging for phenotyping and
576
clustering these cells. Hence, we remove such cells from the VoltRon
577
objects.</p>
578
<pre class="r watch-out"><code>Xen_data &lt;- subset(Xen_data, Count &gt; 5)</code></pre>
579
<p>VoltRon is capable of reducing dimensionality of datasets using both
580
PCA and UMAP which we gonna use to build profile-specific neighborhood
581
graphs and partition the data into cell types.</p>
582
<pre class="r watch-out"><code>Xen_data &lt;- getPCA(Xen_data, dims = 20)
583
Xen_data &lt;- getUMAP(Xen_data, dims = 1:20)</code></pre>
584
<p>We can also visualize the normalized expression of these features on
585
embedding spaces (e.g. UMAP) using
586
<strong>vrEmbeddingFeaturePlot</strong> function.</p>
587
<pre class="r watch-out"><code>vrEmbeddingFeaturePlot(Xen_data, features = c(&quot;LRRC15&quot;, &quot;TCF7&quot;), embedding = &quot;umap&quot;, 
588
                       pt.size = 0.4)</code></pre>
589
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_featureplot_xenium.png" class="center"></p>
590
<p><br></p>
591
</div>
592
<div id="clustering" class="section level2">
593
<h2>Clustering</h2>
594
<p>Next, we build neighborhood graphs with the <strong>shared nearest
595
neighbors (SNN)</strong> of cells which are constructed from
596
dimensionally reduced gene expression profiles. The function
597
<strong>getProfileNeighbors</strong> also has an option of building
598
<strong>k-nearest neighbors (kNN)</strong> graphs.</p>
599
<pre class="r watch-out"><code>Xen_data &lt;- getProfileNeighbors(Xen_data, dims = 1:20, method = &quot;SNN&quot;)
600
vrGraphNames(Xen_data)</code></pre>
601
<pre><code>[1] &quot;SNN&quot;</code></pre>
602
<p>We can later conduct a clustering of cells using the <strong>leiden’s
603
method</strong> from the igraph package, which is utilized with the
604
<strong>getClusters</strong> function.</p>
605
<pre class="r watch-out"><code>Xen_data &lt;- getClusters(Xen_data, resolution = 1.0, label = &quot;Clusters&quot;, graph = &quot;SNN&quot;)</code></pre>
606
<p>Now we can label each cell with the associated clustering index and
607
take a look at the clustering accuracy on the embedding space, and we
608
can also visualize these clusters on a spatial context.</p>
609
<pre class="r watch-out"><code>vrEmbeddingPlot(Xen_data, group.by = &quot;Clusters&quot;, embedding = &quot;umap&quot;, 
610
                pt.size = 0.4, label = TRUE)</code></pre>
611
<p><img width="60%" height="60%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_embedplot_xenium.png" class="center"></p>
612
<pre class="r watch-out"><code>vrSpatialPlot(Xen_data, group.by = &quot;Clusters&quot;, pt.size = 0.18, background.color = &quot;black&quot;)</code></pre>
613
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_spatial_xenium.png" class="center"></p>
614
<p><br></p>
615
</div>
616
<div id="annotation" class="section level2">
617
<h2>Annotation</h2>
618
<p>We can annotate each of these clusters according to their positive
619
markers across 313 features. One can use the
620
<strong>FindAllMarkers</strong> from the <a
621
href="https://satijalab.org/seurat/">Seurat</a> package to pinpoint
622
these markers by first utilizing the <strong>as.Seurat</strong> function
623
first on the Xenium assays of the VoltRon object.</p>
624
<p>For more information on conversion to other packages, please visit
625
the <a href="conversion.html">Converting VoltRon Objects</a>.</p>
626
<p>Let us create a new metadata feature from the
627
<strong>Clusters</strong> column, called <strong>CellType</strong>, we
628
can insert this new metadata column directly to the object.</p>
629
<pre class="r watch-out"><code>clusters &lt;- factor(Xen_data$Clusters, levels = sort(unique(Xen_data$Clusters)))
630
levels(clusters) &lt;- c(&quot;DCIS_1&quot;, 
631
                      &quot;DCIS_2&quot;, 
632
                      &quot;CD4_TCells&quot;,
633
                      &quot;Adipocytes&quot;,
634
                      &quot;PLD4+_LILRA4+_CD4+_Cells&quot;,
635
                      &quot;ACTA2_myoepithelial&quot;,
636
                      &quot;IT_2&quot;,
637
                      &quot;Macrophages&quot;,
638
                      &quot;MastCells&quot;,
639
                      &quot;Bcells&quot;,
640
                      &quot;StromalCells&quot;,
641
                      &quot;CD8_TCells&quot;,
642
                      &quot;CD8_TCells&quot;,
643
                      &quot;EndothelialCells&quot;,
644
                      &quot;StromalCells&quot;,
645
                      &quot;MyelomaCells&quot;,
646
                      &quot;IT_1&quot;,
647
                      &quot;IT_2&quot;,
648
                      &quot;ACTA2_myoepithelial&quot;,
649
                      &quot;DCIS_2&quot;,
650
                      &quot;IT_3&quot;,
651
                      &quot;KRT15_myoepithelial&quot;)
652
Xen_data$CellType &lt;- as.character(clusters)</code></pre>
653
<p><strong>vrSpatialPlot</strong> function can visualize multiple types
654
of metadata columns, and users can change the location of the legends as
655
well.</p>
656
<pre class="r watch-out"><code>vrSpatialPlot(Xen_data, group.by = &quot;CellType&quot;, pt.size = 0.13, background.color = &quot;black&quot;, 
657
              legend.loc = &quot;top&quot;, n.tile = 500)</code></pre>
658
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_spatial_xenium_annotated.png" class="center"></p>
659
<p><br></p>
660
</div>
661
</div>
662
<div id="visium-data-analysis" class="section level1">
663
<h1>Visium Data Analysis</h1>
664
<p>Spot-based spatial transcriptomic assays capture spatially-resolved
665
gene expression profiles that are somewhat closer to single cell
666
resolution. However, each spot still include a few number of cells that
667
are likely from a combination of cell types within the tissue of origin.
668
VoltRon analyzes spot level spatial data sets and even allows selecting
669
a highly variable subset of features to cluster spots into meaningful
670
groups of in situ spots for detecting niches of interests</p>
671
<div id="import-st-data" class="section level2">
672
<h2>Import ST Data</h2>
673
<p>For this tutorial we will analyze spot-based transcriptomic assays
674
from Mouse Brain generated by the <a
675
href="https://www.10xgenomics.com/products/spatial-gene-expression">Visium</a>
676
instrument.</p>
677
<p>You can find and download readouts of all four Visium sections <a
678
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Cellanalysis/Visium/MouseBrainSerialSections.zip">here</a>.
679
The <strong>Mouse Brain Serial Section 1</strong> datasets can be
680
downloaded from <a
681
href="https://www.10xgenomics.com/resources/datasets?menu%5Bproducts.name%5D=Spatial%20Gene%20Expression&amp;query=&amp;page=1&amp;configure%5BhitsPerPage%5D=50&amp;configure%5BmaxValuesPerFacet%5D=1000">here</a>
682
(specifically, please filter for <strong>Species=Mouse</strong>,
683
<strong>AnatomicalEntity=brain</strong>, <strong>Chemistry=v1</strong>
684
and <strong>PipelineVersion=v1.1.0</strong>).</p>
685
<p>We will now import each of four samples separately and merge them
686
into one VoltRon object. There are four sections in total given two
687
serial anterior and serial posterior sections, hence we have <strong>two
688
tissue blocks each having two layers</strong>.</p>
689
<pre class="r watch-out"><code>library(VoltRon)
690
Ant_Sec1 &lt;- importVisium(&quot;Sagittal_Anterior/Section1/&quot;, sample_name = &quot;Anterior1&quot;)
691
Pos_Sec1 &lt;- importVisium(&quot;Sagittal_Posterior/Section1/&quot;, sample_name = &quot;Posterior1&quot;)
692
693
# merge datasets
694
MBrain_Sec &lt;- merge(Ant_Sec1, Pos_Sec1, samples = c(&quot;Anterior&quot;, &quot;Posterior&quot;))
695
MBrain_Sec</code></pre>
696
<pre><code>VoltRon Object 
697
Anterior: 
698
  Layers: Section1 
699
Posterior: 
700
  Layers: Section1
701
Assays: Visium(Main) </code></pre>
702
<p>VoltRon maps metadata features on the spatial images, multiple
703
features can be provided for all assays/layers associated with the main
704
assay (Visium).</p>
705
<pre class="r watch-out"><code>vrSpatialFeaturePlot(MBrain_Sec, features = &quot;Count&quot;, crop = TRUE, alpha = 1, ncol = 2)</code></pre>
706
<p><img width="80%" height="80%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_visium_firstplot.png" class="center"></p>
707
<p><br></p>
708
</div>
709
<div id="feature-selection" class="section level2">
710
<h2>Feature Selection</h2>
711
<p>VoltRon captures the nearly full transcriptome of the Visium data
712
which then can be filtered from a list of features ranked by their
713
variance and importance. We use the <strong>variance stabilization
714
transformation (vst)</strong> on each individual assay using the
715
<strong>getFeatures</strong> function and combine these ranked list to
716
capture features important for all assay of the Visium data later with
717
<strong>getVariableFeatures</strong> function.</p>
718
<pre class="r watch-out"><code>head(vrFeatures(MBrain_Sec))</code></pre>
719
<pre><code>[1] &quot;Xkr4&quot;    &quot;Gm1992&quot;  &quot;Gm19938&quot; &quot;Gm37381&quot; &quot;Rp1&quot;     &quot;Sox17&quot;  </code></pre>
720
<pre class="r watch-out"><code>length(vrFeatures(MBrain_Sec))</code></pre>
721
<pre><code>[1] 33502</code></pre>
722
<pre class="r watch-out"><code>MBrain_Sec &lt;- normalizeData(MBrain_Sec)
723
MBrain_Sec &lt;- getFeatures(MBrain_Sec, n = 3000)
724
head(vrFeatureData(MBrain_Sec))</code></pre>
725
<pre><code>                mean          var    adj_var  rank
726
Xkr4    0.0248608534 0.0249941807 0.02800216 14114
727
Gm1992  0.0000000000 0.0000000000 0.00000000     0
728
Gm19938 0.0285714286 0.0322197476 0.03224908 13889
729
Gm37381 0.0000000000 0.0000000000 0.00000000     0
730
Rp1     0.0003710575 0.0003710575 0.00000000     0
731
Sox17   0.1907235622 0.2219629135 0.23715920 10304</code></pre>
732
<pre class="r watch-out"><code>selected_features &lt;- getVariableFeatures(MBrain_Sec)
733
head(selected_features, 20)</code></pre>
734
<pre><code>[1] &quot;Bc1&quot;     &quot;mt-Co1&quot;  &quot;mt-Co3&quot;  &quot;mt-Atp6&quot; &quot;mt-Co2&quot;  &quot;mt-Cytb&quot; &quot;mt-Nd4&quot;  &quot;mt-Nd1&quot;  &quot;mt-Nd2&quot;  
735
[2] &quot;Fth1&quot;    &quot;Hbb-bs&quot;  &quot;Cst3&quot;    &quot;Gapdh&quot;   &quot;Tmsb4x&quot;  &quot;Mbp&quot;     &quot;Rplp1&quot;   &quot;Ttr&quot;     &quot;Ppia&quot;    
736
[3] &quot;Ckb&quot;     &quot;mt-Nd3&quot; </code></pre>
737
</div>
738
<div id="embedding" class="section level2">
739
<h2>Embedding</h2>
740
<p>Now we can learn and visualize PCA and UMAP embeddings on this
741
smaller number of selected features</p>
742
<pre class="r watch-out"><code>MBrain_Sec &lt;- getPCA(MBrain_Sec, features = selected_features, dims = 30)
743
MBrain_Sec &lt;- getUMAP(MBrain_Sec, dims = 1:30)
744
vrEmbeddingPlot(MBrain_Sec, embedding = &quot;umap&quot;)</code></pre>
745
<p><img width="65%" height="65%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_visium_umap.png" class="center"></p>
746
<p><br></p>
747
</div>
748
<div id="clustering-1" class="section level2">
749
<h2>Clustering</h2>
750
<pre class="r watch-out"><code>MBrain_Sec &lt;- getProfileNeighbors(MBrain_Sec, dims = 1:30, k = 10, method = &quot;SNN&quot;)
751
vrGraphNames(MBrain_Sec)</code></pre>
752
<pre><code>[1] &quot;SNN&quot;</code></pre>
753
<pre class="r watch-out"><code>MBrain_Sec &lt;- getClusters(MBrain_Sec, resolution = 0.5, label = &quot;Clusters&quot;, graph = &quot;SNN&quot;)
754
vrEmbeddingPlot(MBrain_Sec, embedding = &quot;umap&quot;, group.by = &quot;Clusters&quot;)</code></pre>
755
<p><img width="65%" height="65%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_visium_umap_clusters.png" class="center"></p>
756
<p><br></p>
757
<pre class="r watch-out"><code>vrSpatialPlot(MBrain_Sec, group.by = &quot;Clusters&quot;)</code></pre>
758
<p><img width="65%" height="65%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_visium_spatial_clusters1.png" class="center"></p>
759
<p><br></p>
760
</div>
761
</div>
762
<div id="melc-data-analysis" class="section level1">
763
<h1>MELC Data Analysis</h1>
764
<p>VoltRon also provides support for imaging based proteomics assays. In
765
this next use case, we analyze cells characterized by
766
<strong>multi-epitope ligand cartography (MELC)</strong> with a panel of
767
44 parameters. We use the already segmented cells on which expression of
768
<strong>43 protein features</strong> (excluding DAPI) were mapped to
769
these cells.</p>
770
<p>We use the segmented cells over microscopy images collected from
771
<strong>control</strong> and <strong>COVID-19</strong> lung tissues of
772
donors categorized based on disease durations (<strong>control</strong>,
773
<strong>acute</strong>, <strong>chronic</strong> and
774
<strong>prolonged</strong>). Each image is associated with one of few
775
field of views (FOVs) from a single tissue section of a donor. See <a
776
href="https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE190732">GSE190732</a>
777
for more information. You can download the <strong>IFdata.csv</strong>
778
file and the folder with the <strong>DAPI</strong> images <a
779
href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Cellanalysis/MELC/GSE190732.zip">here</a>.</p>
780
<p>We import the <strong>protein intensities</strong>,
781
<strong>metadata</strong> and <strong>coordinates</strong> associated
782
with segmented cells across FOVs of samples.</p>
783
<pre class="r watch-out"><code>library(VoltRon)
784
IFdata &lt;- read.csv(&quot;IFdata.csv&quot;)
785
data &lt;- IFdata[,c(2:43)]
786
metadata &lt;- IFdata[,c(&quot;disease_state&quot;, &quot;object_id&quot;, &quot;cluster&quot;, &quot;Clusters&quot;,
787
                      &quot;SourceID&quot;, &quot;Sample&quot;, &quot;FOV&quot;, &quot;Section&quot;)]
788
coordinates &lt;- as.matrix(IFdata[,c(&quot;posX&quot;,&quot;posY&quot;)], rownames.force = TRUE)</code></pre>
789
<p><br></p>
790
<div id="importing-melc-data" class="section level2">
791
<h2>Importing MELC data</h2>
792
<p>Before analyzing MELC assays across FOVs, we should <strong>build a
793
VoltRon object</strong> for each individual FOV/Section by using the
794
<strong>formVoltron</strong> function. We then merge these sections to
795
respective tissue blocks by defining their samples of origins. We can
796
also define <strong>assay names</strong>, <strong>assay types</strong>
797
and <strong>sample (i.e. block) names</strong> of these objects.</p>
798
<pre class="r watch-out"><code>library(dplyr)
799
library(magick)
800
vr_list &lt;- list()
801
sample_metadata &lt;- metadata %&gt;% select(Sample, FOV, Section) %&gt;% distinct()
802
for(i in 1:nrow(sample_metadata)){
803
  vrassay &lt;- sample_metadata[i,]
804
  cells &lt;- rownames(metadata)[metadata$Section == vrassay$Section]
805
  image &lt;- image_read(paste0(&quot;DAPI/&quot;, vrassay$Sample, &quot;/DAPI_&quot;, vrassay$FOV, &quot;.tif&quot;))
806
  vr_list[[vrassay$Section]] &lt;- formVoltRon(data = t(data[cells,]), 
807
                                            metadata = metadata[cells,],
808
                                            image = image, 
809
                                            coords = coordinates[cells,],
810
                                            main.assay = &quot;MELC&quot;, 
811
                                            assay.type = &quot;cell&quot;,
812
                                            sample_name = vrassay$Section)
813
}</code></pre>
814
<p>Before moving forward with merging FOVs, we should <strong>flip
815
coordinates</strong> of cells and perhaps also then
816
<strong>resize</strong> these images. The main reason for this
817
coordinate flipping is that the y-axis of most digital images are of the
818
opposite direction to the commonly used coordinate spaces.</p>
819
<pre class="r watch-out"><code>for(i in 1:nrow(sample_metadata)){
820
  vrassay &lt;- sample_metadata[i,]
821
  vr_list[[vrassay$Section]] &lt;- flipCoordinates(vr_list[[vrassay$Section]])
822
  vr_list[[vrassay$Section]] &lt;- resizeImage(vr_list[[vrassay$Section]], size = 600)
823
}</code></pre>
824
<p>Finally, we merge these assays into one VoltRon object. The
825
<strong>samples</strong> arguement in the merge function determines
826
which assays are layers of a single tissue sample/block.</p>
827
<pre class="r watch-out"><code>vr_merged &lt;- merge(vr_list[[1]], vr_list[-1], samples = sample_metadata$Sample)
828
vr_merged </code></pre>
829
<pre><code>VoltRon Object 
830
control_case_3: 
831
  Layers: Section1 Section2 
832
control_case_2: 
833
  Layers: Section1 Section2 
834
control_case_1: 
835
  Layers: Section1 Section2 Section3 
836
acute_case_3: 
837
  Layers: Section1 Section2 
838
acute_case_1: 
839
  Layers: Section1 Section2 
840
... 
841
There are 13 samples in total 
842
Assays: MELC(Main) </code></pre>
843
<p><br></p>
844
<p>The prolonged case 4 has two fields of views (FOVs). By subsetting on
845
the sample of a prolonged case, we can visualize only these two
846
sections, and visualize the protein expression of CD31 and
847
Pancytokeratin which are markers of endothelial and epithelial
848
cells.</p>
849
<pre class="r watch-out"><code>vr_subset &lt;- subset(vr_merged, samples = &quot;prolonged_case_4&quot;)
850
g1 &lt;- vrSpatialFeaturePlot(vr_subset, features = c(&quot;CD31&quot;, &quot;Pancytokeratin&quot;), alpha = 1, 
851
                           pt.size = 0.7, background.color = &quot;black&quot;)</code></pre>
852
<p><img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_spatialfeature.png" class="center"></p>
853
<p><br></p>
854
</div>
855
<div id="dimensionality-reduction" class="section level2">
856
<h2>Dimensionality Reduction</h2>
857
<p>We can utilize dimensional reduction of the available protein markers
858
using the getPCA and getUMAP functions, but now with relatively lower
859
numbers of principal components which are enough to capture the
860
information across 44 features.</p>
861
<pre class="r watch-out"><code>vr_merged &lt;- getPCA(vr_merged, dims = 10)
862
vr_merged &lt;- getUMAP(vr_merged, dims = 1:10)
863
vrEmbeddingFeaturePlot(vr_merged, features = c(&quot;CD31&quot;, &quot;Pancytokeratin&quot;), embedding = &quot;umap&quot;)</code></pre>
864
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_embedding.png" class="center"></p>
865
<p><br></p>
866
</div>
867
<div id="clustering-2" class="section level2">
868
<h2>Clustering</h2>
869
<p>Now we can visualize the clusters across these sections and perhaps
870
also check for clusters that may reside in only specific disease
871
conditions.</p>
872
<pre class="r watch-out"><code># SNN graph and clusters
873
vr_merged &lt;- getProfileNeighbors(vr_merged, dims = 1:10, k = 10, method = &quot;SNN&quot;)
874
vrGraphNames(vr_merged)</code></pre>
875
<pre><code>[1] &quot;SNN&quot;</code></pre>
876
<pre class="r watch-out"><code>vr_merged &lt;- getClusters(vr_merged, resolution = 0.8, label = &quot;MELC_Clusters&quot;, graph = &quot;SNN&quot;)
877
878
# install patchwork package
879
if (!requireNamespace(&quot;patchwork&quot;, quietly = TRUE))
880
  install.packages(&quot;patchwork&quot;)
881
library(patchwork)
882
883
# visualize conditions and clusters
884
vr_merged$Condition &lt;- gsub(&quot;_[0-9]$&quot;, &quot;&quot;, vr_merged$Sample)
885
g1 &lt;- vrEmbeddingPlot(vr_merged, group.by = c(&quot;Condition&quot;), embedding = &quot;umap&quot;)
886
g2 &lt;- vrEmbeddingPlot(vr_merged, group.by = c(&quot;MELC_Clusters&quot;), embedding = &quot;umap&quot;, 
887
                      label = TRUE)
888
g1 | g2</code></pre>
889
<p><img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_embeddingclusters.png" class="center"></p>
890
<p><br></p>
891
</div>
892
<div id="visualization-of-markers" class="section level2">
893
<h2>Visualization of Markers</h2>
894
<p>VoltRon provides both violin plots (<strong>vrViolinPlot</strong>)
895
and heatmaps (<strong>vrHeatmapPlot</strong>) to further investigate the
896
enrichment of markers across newly clustered datasets.
897
<strong>Note:</strong> the vrHeatmapPlot function would require you to
898
have the <strong>ComplexHeatmap</strong> package in your namespace.</p>
899
<pre class="r watch-out"><code># install patchwork package
900
if (!requireNamespace(&quot;ComplexHeatmap&quot;, quietly = TRUE))
901
  BiocManager::install(&quot;ComplexHeatmap&quot;)
902
library(ComplexHeatmap)
903
904
# Visualize Markers
905
vrHeatmapPlot(vr_merged, features = vrFeatures(vr_merged), 
906
              group.by = &quot;MELC_Clusters&quot;, show_row_names = TRUE)</code></pre>
907
<p><img width="80%" height="80%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_heatmapclusters.png" class="center"></p>
908
<p><br></p>
909
<pre class="r watch-out"><code>vrViolinPlot(vr_merged, features = c(&quot;CD3&quot;, &quot;SMA&quot;, &quot;Pancytokeratin&quot;, &quot;CCR2&quot;), 
910
             group.by = &quot;MELC_Clusters&quot;, ncol = 2)</code></pre>
911
<p><img width="80%" height="80%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_violinclusters.png" class="center"></p>
912
<p><br></p>
913
</div>
914
<div id="neighborhood-analysis" class="section level2">
915
<h2>Neighborhood Analysis</h2>
916
<p>We use the <strong>vrNeighbourhoodEnrichment</strong> function to
917
detect cell type pairs that co occur within each others’ neighborhoods.
918
First, we establish <strong>spatial neighborhood graphs</strong> that
919
determine the neighbors of each cell on tissue sections.</p>
920
<p><a
921
href="https://en.wikipedia.org/wiki/Delaunay_triangulation">Delaunay
922
tesselations</a> or graphs are commonly used to determine neighbors of
923
spatial entities. The function <strong>getSpatialNeighbors</strong>
924
builds a delaunay graph of all assays of a certain type and detects
925
neighbors of cells in a VoltRon object.</p>
926
<pre class="r watch-out"><code>vr_merged &lt;- getSpatialNeighbors(vr_merged, method = &quot;delaunay&quot;)</code></pre>
927
<p>The graph <strong>delaunay</strong>, which we will use for
928
spatially-aware neightborhood analysis, is now the second graph
929
available in the VoltRon object along with <strong>SNN</strong>.</p>
930
<pre class="r watch-out"><code>vrGraphNames(vr_merged)</code></pre>
931
<pre><code>[1] &quot;SNN&quot;      &quot;delaunay&quot;</code></pre>
932
<p>Once neighbors are founds, we can apply a <strong>permutation
933
test</strong> that compares the number of cell type occurances with an
934
expected number of these occurances under multiple permutations of
935
labels in the tissue (fixed coordinates but cells are randomly
936
labelled). A similar approach is used to by several spatial analysis
937
frameworks and packages (<a
938
href="https://www.nature.com/articles/nmeth.4391">Schapiro et. al
939
2017</a>, <a
940
href="https://www.nature.com/articles/s41592-021-01358-2">Palla et. al
941
2022</a>).</p>
942
<p>Here, we will use the original cell type labels annotated by <a
943
href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC9922044/">Mothes et.
944
al 2023</a>.</p>
945
<pre class="r watch-out"><code>neighborhood_results &lt;- vrNeighbourhoodEnrichment(vr_merged, group.by = &quot;Clusters&quot;)</code></pre>
946
<p>The neighborhood analysis provides the results of:</p>
947
<ul>
948
<li>the <strong>association</strong> tests (whether cell types are
949
within each other’s neighborhood)</li>
950
<li>the <strong>segregation</strong> tests (whether cell types are
951
clustered separately)</li>
952
</ul>
953
<p>between all cell type pairs across each layers and assay.</p>
954
<p>The number of each cell in a pair in each section is reported to
955
assess the impact of the results of the test (i.e. low number of
956
abundance in one cell type may indicate low impact).</p>
957
<pre class="r watch-out"><code>head(neighborhood_results)</code></pre>
958
<div>
959
<pre><code style="font-size: 10px;">          from_value     to_value   p_assoc   p_segreg p_assoc_adj p_segreg_adj n_from n_to AssayID Assay    Layer         Sample
960
Assay1.1 CD163+ macs  CD163+ macs 0.0000000 1.00000000      0.0000   1.00000000     41   41  Assay1  MELC Section1 control_case_3
961
Assay1.2 CD163+ macs CD4+ T cells 0.9380000 0.03300000      0.9980   0.09762866     41   48  Assay1  MELC Section1 control_case_3
962
Assay1.3 CD163+ macs  CD8+ Tcells 0.8779011 0.04339051      0.9980   0.09762866     41   11  Assay1  MELC Section1 control_case_3
963
Assay1.4 CD163+ macs     NK cells 0.8190000 0.08700000      0.9980   0.15660000     41   15  Assay1  MELC Section1 control_case_3
964
Assay1.5 CD163+ macs   endothelia 0.1230000 0.85100000      0.5535   0.95737500     41  139  Assay1  MELC Section1 control_case_3
965
Assay1.6 CD163+ macs    epithelia 0.9320000 0.03600000      0.9980   0.09762866     41   39  Assay1  MELC Section1 control_case_3</code></pre>
966
</div>
967
<p><br></p>
968
<pre class="r watch-out"><code>vrNeighbourhoodEnrichmentPlot(neighborhood_results, assay = &quot;Assay1&quot;, type = &quot;assoc&quot;)</code></pre>
969
<p><img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_neighenrichment.png" class="center"></p>
970
</div>
971
</div>
972
973
974
975
</div>
976
</div>
977
978
</div>
979
980
<script>
981
982
// add bootstrap table styles to pandoc tables
983
function bootstrapStylePandocTables() {
984
  $('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
985
}
986
$(document).ready(function () {
987
  bootstrapStylePandocTables();
988
});
989
990
991
</script>
992
993
<!-- tabsets -->
994
995
<script>
996
$(document).ready(function () {
997
  window.buildTabsets("TOC");
998
});
999
1000
$(document).ready(function () {
1001
  $('.tabset-dropdown > .nav-tabs > li').click(function () {
1002
    $(this).parent().toggleClass('nav-tabs-open');
1003
  });
1004
});
1005
</script>
1006
1007
<!-- code folding -->
1008
1009
<script>
1010
$(document).ready(function ()  {
1011
1012
    // temporarily add toc-ignore selector to headers for the consistency with Pandoc
1013
    $('.unlisted.unnumbered').addClass('toc-ignore')
1014
1015
    // move toc-ignore selectors from section div to header
1016
    $('div.section.toc-ignore')
1017
        .removeClass('toc-ignore')
1018
        .children('h1,h2,h3,h4,h5').addClass('toc-ignore');
1019
1020
    // establish options
1021
    var options = {
1022
      selectors: "h1,h2,h3",
1023
      theme: "bootstrap3",
1024
      context: '.toc-content',
1025
      hashGenerator: function (text) {
1026
        return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
1027
      },
1028
      ignoreSelector: ".toc-ignore",
1029
      scrollTo: 0
1030
    };
1031
    options.showAndHide = false;
1032
    options.smoothScroll = false;
1033
1034
    // tocify
1035
    var toc = $("#TOC").tocify(options).data("toc-tocify");
1036
});
1037
</script>
1038
1039
<!-- dynamically load mathjax for compatibility with self-contained -->
1040
<script>
1041
  (function () {
1042
    var script = document.createElement("script");
1043
    script.type = "text/javascript";
1044
    script.src  = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
1045
    document.getElementsByTagName("head")[0].appendChild(script);
1046
  })();
1047
</script>
1048
1049
</body>
1050
</html>