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

Switch to unified view

a b/docs/ondisk.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>ondisk</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">ondisk</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="import-visiumhd-data" class="section level2">
462
<h2>Import VisiumHD Data</h2>
463
<p>We first have to download some packages that are necessary to import
464
datasets from <code>.parquet</code> and <code>.h5</code> files provided
465
by the VisiumHD readouts.</p>
466
<pre class="r watch-out"><code>install.packages(&quot;arrow&quot;)
467
BiocManager::install(&quot;rhdf5&quot;)
468
library(arrow)
469
library(rhdf5)</code></pre>
470
<p>We use the <strong>importVisiumHD</strong> function to start
471
analyzing the data. The data has 393401 spots which we will use
472
OnDisk-backed methods to efficiently manipulate, analyze and visualize
473
these spots.</p>
474
<p>The VisiumHD readouts provide multiple bin sizes which are aggregated
475
versions of the original 2<span class="math inline">\(\mu\)</span>m
476
<span class="math inline">\(x\)</span> 2<span
477
class="math inline">\(\mu\)</span>m capture spots. The default bin sizes
478
are <strong>(i)</strong> 2<span class="math inline">\(\mu\)</span>m
479
<span class="math inline">\(x\)</span> 2<span
480
class="math inline">\(\mu\)</span>m, <strong>(ii)</strong> 8<span
481
class="math inline">\(\mu\)</span>m <span
482
class="math inline">\(x\)</span> 8<span
483
class="math inline">\(\mu\)</span>m and <strong>(iii)</strong> 16<span
484
class="math inline">\(\mu\)</span>m <span
485
class="math inline">\(x\)</span> 16<span
486
class="math inline">\(\mu\)</span>m.</p>
487
<pre class="r watch-out"><code>hddata &lt;- importVisiumHD(dir.path = &quot;VisiumHD/outs/&quot;, 
488
                         bin.size = &quot;8&quot;, 
489
                         resolution_level = &quot;hires&quot;)</code></pre>
490
<p><br></p>
491
</div>
492
<div id="savingloading-voltron-objects" class="section level2">
493
<h2>Saving/Loading VoltRon Objects</h2>
494
<p>We use <strong>BPCells</strong> and <strong>ImageArray</strong>
495
packages to accelerate operations of feature matrices and images. Here
496
<strong>BPCells</strong> allows users access and operate on large
497
feature matrices or clustering/spatial analysis, while
498
<strong>ImageArray</strong> provides <a
499
href="https://en.wikipedia.org/wiki/Pyramid_(image_processing)">pyramids
500
images</a> to allow fast access to large microscopy images. You can
501
download these package from GitHub using <strong>devtools</strong>.</p>
502
<pre class="r watch-out"><code>devtools::install_github(&quot;bnprks/BPCells/r&quot;)
503
devtools::install_github(&quot;BIMSBbioinfo/ImageArray&quot;)
504
library(BPCells)
505
library(ImageArray)</code></pre>
506
<p>We can now save the VoltRon object to disk, large matrices and images
507
will be written to either <strong>hdf5</strong> or <strong>zarr</strong>
508
files depending on the <strong>format</strong> arguement, and the rest
509
of the R object would be written to an <code>.rds</code> file, both
510
under the designated <strong>output</strong>.</p>
511
<pre class="r watch-out"><code>hddata &lt;- saveVoltRon(hddata, format = &quot;HDF5VoltRon&quot;, output = &quot;data/VisiumHD&quot;)</code></pre>
512
<p>If you want you can load the VoltRon object from the same path as you
513
have saved.</p>
514
<pre class="r watch-out"><code>hddata &lt;- loadVoltRon(&quot;data/VisiumHD/&quot;)</code></pre>
515
<p><br></p>
516
</div>
517
<div id="cellspot-analysis" class="section level2">
518
<h2>Cell/Spot Analysis</h2>
519
<p>The <strong>BPCells</strong> package provides fast methods to achieve
520
operations common to single cell analysis such as filtering,
521
normalization and dimensionality reduction. Here we have an example of
522
single-cell like clustering of VisiumHD bins which is efficiently
523
clustered.</p>
524
<pre class="r watch-out"><code>spatialpoints &lt;- vrSpatialPoints(hddata)[as.vector(Metadata(hddata)$Count &gt; 10)]
525
hddata &lt;- subset(hddata, spatialpoints = spatialpoints)
526
hddata &lt;- normalizeData(hddata, sizefactor = 10000)
527
hddata &lt;- getFeatures(hddata, n = 3000)
528
selected_features &lt;- getVariableFeatures(hddata)
529
hddata &lt;- getPCA(hddata, features = selected_features, dims = 30)
530
hddata &lt;- getUMAP(hddata, dims = 1:30)</code></pre>
531
<p>We can now visualized genes over embedding or spatial plots.</p>
532
<pre class="r watch-out"><code>vrEmbeddingFeaturePlot(hddata, features = &quot;Nrgn&quot;, embedding = &quot;umap&quot;)
533
vrSpatialFeaturePlot(hddata, features = &quot;Nrgn&quot;)</code></pre>
534
<table>
535
<tbody>
536
<tr style="vertical-align: center">
537
<td style="width:50%; vertical-align: center">
538
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/ondisk_embeddingfeature.png" class="center">
539
</td>
540
<td style="width:55%; vertical-align: center">
541
<img src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/ondisk_spatialfeature.png" class="center">
542
</td>
543
</tr>
544
</tbody>
545
</table>
546
<p><br></p>
547
</div>
548
<div id="spatial-data-alignment" class="section level2">
549
<h2>Spatial Data Alignment</h2>
550
<p>The image registration workflow in the <a
551
href="registration.html">Spatial Data Alignment</a> tutorial can also be
552
conducted using disk-backed methods of the VoltRon package.</p>
553
<pre class="r watch-out"><code>library(VoltRon)
554
Xen_R1 &lt;- importXenium(&quot;Xenium_R1/outs&quot;, sample_name = &quot;XeniumR1&quot;, resolution_level = 3)
555
Xen_R1_image &lt;- importImageData(&quot;Xenium_FFPE_Human_Breast_Cancer_Rep1_he_image.tif&quot;,
556
                                sample_name = &quot;XeniumR1image&quot;,
557
                                image_name = &quot;H&amp;E&quot;)</code></pre>
558
<p><br></p>
559
<p>We can save both Xenium and H&amp;E (image) datasets to disk before
560
using the mini Shiny app for registration</p>
561
<pre class="r watch-out"><code>Xen_R1_disk &lt;- saveVoltRon(Xen_R1, 
562
                           format = &quot;HDF5VoltRon&quot;, 
563
                           output = &quot;data/Xen_R1_h5&quot;, replace = TRUE)
564
Xen_R1_image_disk &lt;- saveVoltRon(Xen_R1_image,
565
                                 format = &quot;HDF5VoltRon&quot;, 
566
                                 output = &quot;data/Xen_R1_image_h5&quot;, replace = TRUE)</code></pre>
567
<p><br></p>
568
<p>These disk-based datasets can then be loaded from the disk
569
easily.</p>
570
<pre class="r watch-out"><code>Xen_R1_disk &lt;- loadVoltRon(&quot;../data/OnDisk/Xen_R1_h5/&quot;)
571
Xen_R1_image_disk &lt;- loadVoltRon(&quot;../data/OnDisk/Xen_R1_image_h5/&quot;)</code></pre>
572
<p><br></p>
573
<p>VoltRon stores large images as pyramids to increase interactive
574
visualization efficiency. This storage strategy allows shiny apps to
575
zoom in to tissue niches in a speedy fashion. VoltRon incorporates
576
<code>Image_Array</code> objects (<a
577
href="https://github.com/BIMSBbioinfo/ImageArray"
578
class="uri">https://github.com/BIMSBbioinfo/ImageArray</a>) to define
579
these pyramids.</p>
580
<pre class="r watch-out"><code>vrImages(Xen_R1_image_disk, as.raster = TRUE)</code></pre>
581
<pre><code>Image_Array Object 
582
Series 1 of size (3,27587,20511) 
583
Series 2 of size (3,13794,10256) 
584
Series 3 of size (3,6897,5128) 
585
Series 4 of size (3,3449,2564) 
586
Series 5 of size (3,1725,1282) 
587
Series 6 of size (3,863,641) 
588
Series 7 of size (3,432,321) </code></pre>
589
<p><br></p>
590
<p>We can now visualize and align the Xenium and H&amp;E objects.</p>
591
<pre class="r watch-out"><code># Align spatial data
592
xen_reg &lt;- registerSpatialData(object_list = list(Xen_R1_disk, Xen_R1_image_disk))</code></pre>
593
<div>
594
<p><video width="100%" height="100%" controls autoplay>
595
<source src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/video_temp.mov" type="video/mp4">
596
Your browser does not support the video tag. </video></p>
597
</div>
598
<p><br></p>
599
<pre class="r watch-out"><code># transfer aligned H&amp;E to Xenium data
600
Xenium_reg &lt;- xen_reg$registered_spat[[2]]
601
vrImages(Xen_R1_disk[[&quot;Assay1&quot;]], name = &quot;main&quot;, channel = &quot;H&amp;E&quot;) &lt;- vrImages(Xenium_reg, name = &quot;H&amp;E_reg&quot;)
602
603
# visualize
604
vrImages(Xen_R1_disk, channel = &quot;H&amp;E&quot;, scale.perc = 10)</code></pre>
605
<p><br></p>
606
<p><img width="92%" height="92%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/ondisk_alignedHE.png" class="center"></p>
607
</div>
608
609
610
611
</div>
612
</div>
613
614
</div>
615
616
<script>
617
618
// add bootstrap table styles to pandoc tables
619
function bootstrapStylePandocTables() {
620
  $('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
621
}
622
$(document).ready(function () {
623
  bootstrapStylePandocTables();
624
});
625
626
627
</script>
628
629
<!-- tabsets -->
630
631
<script>
632
$(document).ready(function () {
633
  window.buildTabsets("TOC");
634
});
635
636
$(document).ready(function () {
637
  $('.tabset-dropdown > .nav-tabs > li').click(function () {
638
    $(this).parent().toggleClass('nav-tabs-open');
639
  });
640
});
641
</script>
642
643
<!-- code folding -->
644
645
<script>
646
$(document).ready(function ()  {
647
648
    // temporarily add toc-ignore selector to headers for the consistency with Pandoc
649
    $('.unlisted.unnumbered').addClass('toc-ignore')
650
651
    // move toc-ignore selectors from section div to header
652
    $('div.section.toc-ignore')
653
        .removeClass('toc-ignore')
654
        .children('h1,h2,h3,h4,h5').addClass('toc-ignore');
655
656
    // establish options
657
    var options = {
658
      selectors: "h1,h2,h3",
659
      theme: "bootstrap3",
660
      context: '.toc-content',
661
      hashGenerator: function (text) {
662
        return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
663
      },
664
      ignoreSelector: ".toc-ignore",
665
      scrollTo: 0
666
    };
667
    options.showAndHide = false;
668
    options.smoothScroll = false;
669
670
    // tocify
671
    var toc = $("#TOC").tocify(options).data("toc-tocify");
672
});
673
</script>
674
675
<!-- dynamically load mathjax for compatibility with self-contained -->
676
<script>
677
  (function () {
678
    var script = document.createElement("script");
679
    script.type = "text/javascript";
680
    script.src  = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
681
    document.getElementsByTagName("head")[0].appendChild(script);
682
  })();
683
</script>
684
685
</body>
686
</html>