Diff of /docs/importingdata.Rmd [000000] .. [413088]

Switch to unified view

a b/docs/importingdata.Rmd
1
---
2
title: "Importing Spatial Data"
3
output: 
4
  html_document:
5
    toc: true
6
    toc_depth: 4
7
    toc_float:
8
      collapsed: false
9
      smooth_scroll: false
10
---
11
12
<style>
13
.title{
14
  display: none;
15
}
16
body {
17
  text-align: justify
18
}
19
.center {
20
  display: block;
21
  margin-left: auto;
22
  margin-right: auto;
23
}
24
table, th, td {
25
  border-collapse: collapse;
26
  align-self: center;
27
  padding-right: 10px;
28
  padding-left: 10px;
29
}
30
</style>
31
32
```{css, echo=FALSE}
33
.watch-out {
34
  color: black;
35
}
36
```
37
38
```{r setup, include=FALSE}
39
# use rmarkdown::render_site(envir = knitr::knit_global())
40
knitr::opts_chunk$set(highlight = TRUE, echo = TRUE)
41
```
42
43
<br>
44
45
# Importing Spatial Datasets
46
47
VoltRon is an end-to-end spatial omic analysis package that supports a large selection of spatial data resolutions. Currently, there exists a considerable amount of spatial omic technologies that generate datasets whose omic profiles are spatially resolved. 
48
49
VoltRon objects are compatible with readouts of almost all of these technologies where we provide a selection of built-in functions to help users constructing VoltRon objects with ease. In this tutorial, we will review these spatial omic instruments and the functions available within the VoltRon package to import their readouts. 
50
51
</br>
52
53
## Visium (10x Genomics)
54
55
</br>
56
57
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/visium_summary.png" class="center">
58
<p style="margin-left: 1.2cm; margin-top:0.2cm; font-size:80%;"> <em> Image Credit: The Visium Spatial Gene Expression Slide (https://www.10xgenomics.com/) </em> </p>
59
60
10x Genomics [Visium](https://www.10xgenomics.com/products/spatial-gene-expression) Spatial Gene Expression Platform incorporates in situ arrays (i.e. spots) to capture spatial localization of omic profiles where these spots are of 55 \mu m in diameter and constitute a grid that covers a significant portion of a tissue section placed on the slide of the instrument.
61
62
We will use the readouts of **Visium CytAssist** platform that was derived from a single tissue section of a breast cancer sample. More information on the Visium CytAssist data and the study can be also be found on the [BioArxiv preprint](https://www.biorxiv.org/content/10.1101/2022.10.06.510405v1). You can download the data from the [10x Genomics website](https://www.10xgenomics.com/products/xenium-in-situ/preview-dataset-human-breast) (specifically, import the **Visium Spatial** data). 
63
64
We use the **importVisium** function to import the Visium readouts and create a VoltRon object. Here, we point to the folder of all the files with **dir.path** argument and also determine the name of this sample (**sample_name**).
65
66
```{r eval = FALSE, class.source="watch-out"}
67
library(VoltRon)
68
BiocManager::install("rhdf5")
69
library(rhdf5)
70
Vis_R1 <- importVisium(dir.path = "Visium/", sample_name = "VisiumR1")
71
```
72
73
```
74
VoltRon Object 
75
VisiumR1: 
76
  Layers: Section1 
77
Assays: Visium(Main) 
78
```
79
80
</br>
81
82
While importing the readouts, we can also determine the name of the assay as well as the name of the image. The **SampleMetadata** function summarizes the entire collection of assays, layers (sections) and samples (tissue blocks) within the R object.
83
84
```{r eval = FALSE, class.source="watch-out"}
85
Vis_R1 <- importVisium(dir.path = "Visium/", sample_name = "VisiumR1", 
86
                       assay_name = "Visium_assay", image_name = "H&E_stain")
87
SampleMetadata(Vis_R1)
88
```
89
90
```
91
              Assay    Layer   Sample
92
Assay1 Visium_assay Section1 VisiumR1
93
```
94
95
</br>
96
97
The current VoltRon object has only one assay associated with a single layer and a tissue block, and the image of this assay is currently the "H&E_stain". 
98
99
```{r eval = FALSE, class.source="watch-out"}
100
vrImageNames(Vis_R1)
101
```
102
103
```
104
[1] "H&E_stain"
105
```
106
107
<br>
108
109
Although by default the **importVisium** function selects the low resolution image, you can select the higher resolution one using **resolution_level="hires"**
110
111
```{r eval = FALSE, class.source="watch-out"}
112
Vis_R1 <- importVisium(dir.path = "Visium/", sample_name = "VisiumR1", resolution_level="hires")
113
```
114
115
<br>
116
117
## VisiumHD (10x Genomics)
118
119
</br>
120
121
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/visiumhd_summary.png" class="center">
122
<p style="margin-left: 1.2cm; margin-top:0.2cm; font-size:80%;"> <em> https://www.10xgenomics.com/products/visium-hd-spatial-gene-expression </em> </p>
123
124
10x Genomics [VisiumHD](https://www.10xgenomics.com/products/visium-hd-spatial-gene-expression) Spatial Gene Expression Platform contains two 6.5 x 6.5 mm Capture Areas with a continuous lawn of oligonucleotides arrayed in millions of 2 x 2 µm barcoded squares without gaps, achieving single cell–scale spatial resolution. The data is output at 2 µm, as well as multiple bin sizes. The 8 x 8 µm bin is the recommended starting point for visualization and analysis.
125
126
We will use the readouts of **Visium CytAssist** platform that was derived from a single tissue section of a breast cancer sample. More information on the Visium CytAssist data and the study can be also be found on the [BioArxiv preprint](https://www.biorxiv.org/content/10.1101/2022.10.06.510405v1). You can download the data from the [10x Genomics website](https://www.10xgenomics.com/products/xenium-in-situ/preview-dataset-human-breast) (specifically, import the **Visium Spatial** data). 
127
128
We use the **importVisium** function to import the Visium readouts and create a VoltRon object. Here, we point to the folder of all the files with **dir.path** argument and also determine the name of this sample (**sample_name**). 
129
130
```{r eval = FALSE, class.source="watch-out"}
131
library(VoltRon)
132
install.packages("arrow")
133
BiocManager::install("rhdf5")
134
library(arrow)
135
library(rhdf5)
136
hddata <- importVisium(dir.path = "VisiumHD/outs/", 
137
                       sample_name = "VisiumHD")
138
```
139
140
<br>
141
142
The VisiumHD readouts provide multiple bin sizes which are aggregated versions of the original 2$\mu$m $x$ 2$\mu$m capture spots. The default bin sizes are **(i)** 2$\mu$m $x$ 2$\mu$m, **(ii)** 8$\mu$m $x$ 8$\mu$m and **(iii)** 16$\mu$m $x$ 16$\mu$m. Although by default the **importVisium** function selects the low resolution image, you can select the higher resolution one using **resolution_level="hires"**.
143
144
```{r eval = FALSE, class.source="watch-out"}
145
hddata <- importVisium(dir.path = "VisiumHD/outs/", 
146
                       bin.size = "16", 
147
                       resolution_level = "hires", 
148
                       sample_name = "VisiumHD")
149
```
150
151
<br>
152
153
## Xenium (10x Genomics)
154
155
</br>
156
157
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/xenium_summary.png" class="center">
158
<p style="margin-left: 1.2cm; margin-top:0.2cm; font-size:80%;"> <em> Image Credit: https://www.biorxiv.org/content/10.1101/2022.10.06.510405v2 </em> </p>
159
160
The 10x Genomics [Xenium In Situ](https://www.10xgenomics.com/platforms/xenium) provides spatial localization of both (i) transcripts from a few hundred number of genes as well as (ii) the single cells with transcriptomic profiles. 
161
162
We will use the readouts of a single Xenium platform replicate that was derived from a single tissue section of a breast cancer sample. More information on the Xenium data and the study can be also be found on the [BioArxiv preprint](https://www.biorxiv.org/content/10.1101/2022.10.06.510405v1). You can download the data from the [10x Genomics website](https://www.10xgenomics.com/products/xenium-in-situ/preview-dataset-human-breast) (specifically, import the **In Situ Replicate 1** data). 
163
164
We use the **importXenium** function to import the Xenium readouts and create a VoltRon object. Here, we point to the folder of all the files with **dir.path** argument and also determine the name of this sample (**sample_name**).
165
166
```{r eval = FALSE, class.source="watch-out"}
167
library(VoltRon)
168
BiocManager::install("rhdf5")
169
library(rhdf5)
170
Xen_R1 <- importXenium("Xenium_R1/outs", sample_name = "XeniumR1")
171
```
172
173
```
174
VoltRon Object 
175
XeniumR1: 
176
  Layers: Section1 
177
Assays: Xenium(Main) 
178
```
179
180
</br>
181
182
You can use the **import_molecules** argument to import positions and features of the transcripts along with the single cell profiles.
183
184
```{r eval = FALSE, class.source="watch-out"}
185
Xen_R1 <- importXenium("Xenium_R1/outs", sample_name = "XeniumR1", import_molecules = TRUE)
186
Xen_R1
187
```
188
189
```
190
VoltRon Object 
191
XeniumR1: 
192
  Layers: Section1 
193
Assays: Xenium(Main) Xenium_mol 
194
```
195
196
The **SampleMetadata** function summarizes the entire collection of assays, layers (sections) and samples (tissue blocks) within the R object. In this case, the function will generate two assays in a single layer where one is a "cell" assay and the other is a "molecule assay". 
197
198
```{r eval = FALSE, class.source="watch-out"}
199
SampleMetadata(Xen_R1)
200
```
201
202
```
203
            Assay    Layer   Sample
204
Assay1     Xenium Section1 XeniumR1
205
Assay2 Xenium_mol Section1 XeniumR1
206
```
207
208
</br>
209
210
The Xenium in situ platform provides multiple resolution of the same Xenium slide which can be parsed from the OME.TIFF image file of DAPI stained tissue section (e.g. morphology_mip.ome.tif). The **resolution_level** argument determines the resolution of the DAPI image generated from the OME.TIFF file. More information on resolution levels can be found [here](https://kb.10xgenomics.com/hc/en-us/articles/11636252598925-What-are-the-Xenium-image-scale-factors-). 
211
212
```{r eval = FALSE, class.source="watch-out"}
213
Xen_R1 <- importXenium("Xenium_R1/outs", sample_name = "XeniumR1", import_molecules = TRUE, 
214
                       resolution_level = 4, overwrite_resolution = TRUE)
215
vrImages(Xen_R1, assay = "Xenium")
216
```
217
218
```
219
# A tibble: 1 × 7
220
  format width height colorspace matte filesize density
221
  <chr>  <int>  <int> <chr>      <lgl>    <int> <chr>  
222
1 PNG     4427   3222 Gray       FALSE        0 72x72  
223
```
224
225
</br>
226
227
Users can also decide to ignore OME.TIFF file and images, hence only cells and molecules would be imported. 
228
229
```{r eval = FALSE, class.source="watch-out"}
230
Xen_R1 <- importXenium("Xenium_R1/outs", sample_name = "XeniumR1", import_molecules = TRUE, 
231
                       use_image = FALSE)
232
```
233
234
</br>
235
236
## GeoMx (NanoString)
237
238
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/geomx_summary.png" class="center">
239
<p style="margin-left: 1.2cm; margin-top:0.2cm; font-size:80%;"> <em> Image Credit: https://www.biochain.com/nanostring-geomx-digital-spatial-profiling/ </em> </p>
240
241
The [Nanostring's GeoMx Digital Spatial Profiler](https://nanostring.com/products/geomx-digital-spatial-profiler/geomx-dsp-overview/) is a high-plex spatial profiling technology which produces segmentation-based protein and RNA assays. The instrument allows users to select regions of interest (ROIs) from fluorescent microscopy images that capture the morphological context of the tissue. These are ROIs are then used to generate transcriptomic or proteomic profiles. 
242
243
We will import the ROI profiles generated from the GeoMx scan area where COVID-19 lung tissues were fitted into. See [GSE190732](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE190732) for more information on this study.
244
245
Here is the usage of **importGeoMx** function and necessary files for this example:
246
247
<table>
248
  <tr>
249
    <th>Argument</th>
250
    <th>Description</th>
251
    <th>Link</th>
252
  </tr>
253
  <tr>
254
    <td>dcc.path</td>
255
    <td>The path to DCC files directory</td>
256
    <td><a href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GeoMx/DCC-20230427.zip">DDC files</a></td>
257
  </tr>
258
  <tr>
259
    <td>pkc.file</td>
260
    <td>GeoMx™ DSP configuration file</td>
261
    <td><a href="https://nanostring.com/wp-content/uploads/Hs_R_NGS_WTA_v1.0.pkc_.zip">Human RNA Whole Transcriptomic Atlas for NGS</a></td>
262
  </tr>
263
  <tr>
264
    <td>summarySegment</td>
265
    <td>Segment summary table (.xls or .csv)</td>
266
    <td><a href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GeoMx/segmentSummary.csv"> ROI Metadata file </a></td>
267
  </tr>
268
  <tr>
269
    <td>image</td>
270
    <td>The Morphology Image of the scan area </td>
271
    <td><a href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GeoMx/Lu1A1B5umtrueexp.tif"> Image file </a></td>
272
  </tr>
273
  <tr>
274
    <td>ome.tiff</td>
275
    <td>The OME.TIFF Image of the scan area </td>
276
    <td><a href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GeoMx/Lu1A1B5umtrueexp.ome.tiff"> OME.TIFF file </a></td>
277
  </tr>
278
    <tr>
279
    <td></td>
280
    <td>The OME.TIFF Image XML file </td>
281
    <td><a href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GeoMx/Lu1A1B5umtrueexp.ome.tiff.xml" download target="_blank"> OME.TIFF (XML) file </a></td>
282
  </tr>
283
</table>
284
285
</br>
286
287
```{r eval = FALSE, class.source="watch-out"}
288
library(VoltRon)
289
GeoMxR1 <- importGeoMx(dcc.path = "DCC-20230427/", 
290
                       pkc.file = "Hs_R_NGS_WTA_v1.0.pkc",
291
                       summarySegment = "segmentSummary.csv",
292
                       image = "Lu1A1B5umtrueexp.tif",
293
                       ome.tiff = "Lu1A1B5umtrueexp.ome.tiff",
294
                       sample_name = "GeoMxR1")
295
```
296
297
The OME.TIFF file here provides the ROI coordinates within the embedded XML metadata. We can also incorporate the **RBioFormats** package to extract the XML metadata from the OME.TIFF file. 
298
299
```{r eval = FALSE, class.source="watch-out"}
300
# fix java parameters
301
options(java.parameters = "-Xmx4g")
302
library(RBioFormats)
303
304
# alternatively you can use RBioFormats to create an xml file
305
ome.tiff.xml <- RBioFormats::read.omexml("data/GeoMx/Lu1A1B5umtrueexp.ome.tiff")
306
write(ome.tiff.xml, file = "data/GeoMx/Lu1A1B5umtrueexp.ome.tiff.xml")
307
```
308
309
The **ome.tiff** argument also accepts the path to this XML file.
310
311
```{r eval = FALSE, class.source="watch-out"}
312
GeoMxR1 <- importGeoMx(dcc.path = "DCC-20230427/",
313
                       pkc.file = "Hs_R_NGS_WTA_v1.0.pkc",
314
                       summarySegment = "segmentSummary.csv",
315
                       image = "Lu1A1B5umtrueexp.tif",
316
                       ome.tiff = "Lu1A1B5umtrueexp.ome.tiff.xml",
317
                       sample_name = "GeoMxR1")
318
```
319
320
</br>
321
322
## CosMx (NanoString)
323
324
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cosmx_summary.png" class="center">
325
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cosmx_summary2.png" class="center">
326
<p style="margin-left: 1.2cm; margin-top:0.2cm; font-size:80%;"> <em> Image Credit: https://www.biorxiv.org/content/10.1101/2021.11.03.467020v1.full </em> </p>
327
328
The [Nanostring's CosMx Spatial Molecular Imaging](https://nanostring.com/products/cosmx-spatial-molecular-imager/cosmx-smi-single-cell-imaging-de/) platform is a high-plex spatial multiomics technology that captures the spatial localization of both (i) transcripts from thousands of genes as well as (ii) the single cells with transcriptomic and proteomic profiles.
329
330
We will use the readouts from two slides of a single CosMx experiment. You can download the data from the [Nanostring website](https://nanostring.com/products/cosmx-spatial-molecular-imager/ffpe-dataset/cosmx-smi-mouse-brain-ffpe-dataset/). 
331
332
We use the **importCosMx** function to import the CosMx readouts and create a VoltRon object. Here, we point to the folder of the [TileDB](https://tiledb.com/) array that stores feature matrix as well as the transcript metadata.
333
334
```{r eval = FALSE, class.source="watch-out"}
335
CosMxR1 <- importCosMx(tiledbURI = "MuBrainDataRelease/")
336
```
337
338
```
339
VoltRon Object 
340
Slide1: 
341
  Layers: Section1 
342
Slide2: 
343
  Layers: Section1 
344
Assays: CosMx(Main) 
345
```
346
347
You can use the **import_molecules** argument to import positions and features of the transcripts along with the single cell profiles.
348
349
```{r eval = FALSE, class.source="watch-out"}
350
CosMxR1 <- importCosMx(tiledbURI = "MuBrainDataRelease/", import_molecules = TRUE)
351
```
352
353
</br>
354
  
355
## STOmics (MGI)
356
357
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/stomics_summary.png" class="center">
358
<p style="margin-left: 1.2cm; margin-top:0.2cm; font-size:80%;"> <em> Image Credit: https://bgi-australia.com.au/stomics </em> </p>
359
360
Before importing the STOmics data to VoltRon, we first convert STOmics readouts to an h5ad file using the **stereopy** Python module. For more information, visit [https://stereopy.readthedocs.io/](https://stereopy.readthedocs.io/en/latest/Tutorials/Format_Conversion.html). See [here](https://stereopy.readthedocs.io/en/latest/content/00_Installation.html) for instructions on how to install **stereopy**.
361
362
```{python class.source="watch-out", eval = FALSE}
363
import stereo as st
364
import warnings
365
warnings.filterwarnings('ignore')
366
367
# read the GEF file
368
data_path = './SS200000135TL_D1.tissue.gef'
369
data = st.io.read_gef(file_path=data_path, bin_size=50)
370
data.tl.raw_checkpoint()
371
372
# remember to set flavor as scanpy
373
adata = st.io.stereo_to_anndata(data, flavor='scanpy', output='sample.h5ad')
374
```
375
376
<br>
377
378
We use the **importSTOmics** function to import the STOmics readouts and create a VoltRon object. Here, we point to the folder an h5ad file generated using the **stereo.io.stereo_to_anndata** method previously.
379
380
```{r eval = FALSE, class.source="watch-out"}
381
vrdata <- importSTOmics(h5ad.path = "sample.h5ad")
382
```
383
384
```
385
VoltRon Object 
386
Sample1: 
387
  Layers: Section1 
388
Assays: STOmics(Main) 
389
```
390
391
</br>
392
393
## GenePS (Spatial Genomics)
394
395
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/geneps_summary.png" class="center">
396
<p style="margin-left: 1.2cm; margin-top:0.2cm; font-size:80%;"> <em> Image Credit: https://spatialgenomics.com/applications/ </em> </p>
397
398
We use the **importGenePS** function to import the GenePS ([Spatial Genomics](https://spatialgenomics.com/product/)) readouts and create a VoltRon object. You can use the **import_molecules** argument to import positions and features of the transcripts along with the single cell profiles. The **resolution_level** argument determines the resolution of the DAPI image generated from the TIFF file. 
399
400
```{r eval = FALSE, class.source="watch-out"}
401
vrdata <- importGenePS(dir.path = "out/", import_molecules = TRUE, resolution_level = 7)
402
```
403
404
```
405
VoltRon Object 
406
Sample1: 
407
  Layers: Section1 
408
Assays: GenePS(Main) GenePS_mol
409
```
410
411
</br>
412
413
## PhenoCycler (Akoya)
414
415
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/phenocycler_summary.png" class="center">
416
<p style="margin-left: 1.2cm; margin-top:0.2cm; font-size:80%;"> <em> Image Credit: https://tep.cancer.illinois.edu/phenocycler-fusion-system/ </em> </p>
417
418
We use the **importPhenoCycler** function to import the PhenoCycler ([Akoya Biosciences](https://www.akoyabio.com/)) readouts and create a VoltRon object. The function supports multiple readouts types depending on how the readouts were generated, this is controlled by the **type** arguement. For more information on all arguements of the function, see **help(importPhenoCycler)**. 
419
420
We used the Human FFPE tonsil tissue example with 83000 cells which could be found [here](https://akoya.app.box.com/s/lqaz1eyefni57sfynveh03e9sdy4aeuk). You have to download the contents and **dir.path** arguement should be set to the location of the **Example-dataset-for-MAV** folder. 
421
422
```{r eval = FALSE, class.source="watch-out"}
423
vr_pheno <- importPhenoCycler(dir.path = "Example-dataset-for-MAV/", type = "processor", 
424
                              sample_name = "Tonsil18AB")
425
```
426
427
```
428
VoltRon Object 
429
Tonsil18AB: 
430
  Layers: Section1 
431
Assays: PhenoCycler(Main) 
432
```
433
434
</br>
435
436
## OpenST
437
438
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/openst_summary.jpg" class="center">
439
<p style="margin-left: 1.2cm; margin-top:0.2cm; font-size:80%;"> <em> Image Credit: https://www.cell.com/cell/fulltext/S0092-8674(24)00636-6 </em> </p>
440
441
We use the **importOpenST** function to import the OpenST [https://rajewsky-lab.github.io/openst/latest/](https://rajewsky-lab.github.io/openst/latest/) readouts and create a VoltRon object. The function will parse each section from the output h5ad file, define it as an independent assay in a single layer where these layers are ordered in a single tissue block.
442
443
We use the metastatic lymph node example that is deposited to NCBI/GEO ([GSE251926](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE251926)). Please use the **GSE251926_metastatic_lymph_node_3d.h5ad.gz** file and unzip it to use the importOpenST function below.
444
445
```{r eval = FALSE, class.source="watch-out"}
446
vr_openst <- importOpenST(h5ad.path = "GSE251926_metastatic_lymph_node_3d.h5ad", 
447
                          sample_name = "MLN_3D")
448
```
449
450
```
451
VoltRon Object 
452
MLN_3D: 
453
  Layers: Section1 Section2 Section3 Section4 Section5 Section6 Section7 Section8 Section9 Section10 Section11 Section12 Section13 Section14 Section15 Section16 Section17 Section18 Section19 
454
Assays: OpenST(Main) 
455
```
456
457
</br>
458
459
## DBIT-Seq
460
461
<img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/dbitseq_summary.jpg" class="center">
462
<p style="margin-left:3.4cm; margin-top:0.2cm; font-size:80%;"> <em> Image Credit: https://www.cell.com/cell/fulltext/S0092-8674(20)31390-8 </em> </p>
463
464
We use the **importDBITSeq** function to import the DBIT-Seq [https://www.cell.com/cell/fulltext/S0092-8674(20)31390-8](https://www.cell.com/cell/fulltext/S0092-8674(20)31390-8) readouts and create a VoltRon object. The default path to the rna count matrix is accompanied by the path to the protein count matrix, which is optional. The **size** parameter here determines the size of each square pixel on the DBIT-Seq slide (default is 10$\mu$m).
465
466
We use the example with developing eye field in a E10 mouse embryo using 10-μm microfluidic (sample id: 0719cL for RNA, and 0719aL for Protein) channels that is deposited to NCBI/GEO ([GSE137986](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE137986)). 
467
468
```{r eval = FALSE, class.source="watch-out"}
469
vr_dbit <- importDBITSeq(path.rna = "GSM4189615_0719cL.tsv", 
470
                         path.prot = "GSM4202309_0719aL.tsv", 
471
                         size = 10, sample_name = "E10_Eye_2", image_name = "main")
472
```
473
474
```
475
VoltRon Object 
476
E10_Eye_2: 
477
  Layers: Section1 
478
Assays: DBIT-Seq-RNA(Main) DBIT-Seq-Prot 
479
```
480
481
</br>
482
483
## ST data
484
485
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/stdata_summary.png" class="center">
486
<p style="margin-left: 1.2cm; margin-top:0.2cm; font-size:80%;"> <em> Image Credit: Ståhl, et. al (2016). Visualization and analysis of gene expression in tissue sections by spatial transcriptomics. Science, 353(6294), 78-82. </em> </p>
487
488
We demonstrate importing the original Spatial Transcriptomics (ST) datasets by formulating custom spot-level spatial transcriptomics datasets. We will use the **formVoltRon** function directly. We use the example provided by the [https://doi.org/10.5281/zenodo.4751624](https://doi.org/10.5281/zenodo.4751624). For more information you can also check the paper [here](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8516894/). 
489
490
We first import and manipulate count matrices and spot coordinates from the provided output files. Here we only demonstrate building a custom spot-level VoltRon object for the section "A1", however the remaining sections can be imported using the same method.
491
492
```{r eval = FALSE, class.source="watch-out"}
493
# count matrix
494
raw.data <- read.table("A1.tsv", header = TRUE, sep = "\t")
495
spatialentities <- raw.data$X
496
raw.data <- raw.data[,-1]
497
raw.data <- t(as.matrix(raw.data))
498
499
# coords 
500
coords <- read.table("A1_selection.tsv", header = TRUE, sep = "\t")
501
rownames(coords) <- paste(coords$x, coords$y, sep = "x")
502
coords <- coords[entities,]
503
coords <- coords[,c("pixel_x", "pixel_y")]
504
colnames(coords) <- c("x", "y")
505
```
506
507
The image can be imported using the **magick** package. 
508
509
```{r eval = FALSE, class.source="watch-out"}
510
library(magick)
511
img <- magick::image_read("HE/A1.jpg")
512
img_info <- magick::image_info(img)
513
```
514
515
Before we form the VoltRon object, we should define the parameters for spot-level datasets. Here, we provide 
516
517
* the radius of a spot in the physical space (i.e. **spot.radius**)
518
* the radius of a spot for visualization (i.e. **vis.spot.radius**)
519
* The distance to the nearest spot, to be used for spatial neighborhood calculation (i.e. **nearestpost.distance**)
520
521
The scaling parameter (scale_param) is required to overlay localization and distances of spots to the coordinate system of the imported image. Here, 
522
523
* the width of a ST slide is of 6200$\mu$m, 
524
* the diameter of a spot is 100$\mu$m (hence a radius of 50$\mu$m) and 
525
* the center-to-center distance between two spots is 200$\mu$m. 
526
* Each spot has at most 8 neighboring spots including vertically, horizontally and diagonally adjacent spots. 
527
528
```{r eval = FALSE, class.source="watch-out"}
529
scale_param <- img_info$width/6200
530
params <- list(
531
  spot.radius = 50*(scale_param),
532
  vis.spot.radius = 100*(scale_param),
533
  nearestpost.distance = (200*sqrt(2) + 50)*scale_param
534
)
535
```
536
537
Now we can combine all components into a VoltRon object. We should also flip the coordinates of spots vertically after creating the object.
538
539
```{r eval = FALSE, class.source="watch-out"}
540
# make voltron object
541
stdata <- formVoltRon(data = datax, image = img, coords = coords, assay.type = "spot", 
542
                      params = params, sample_name = "A1")
543
stdata <- flipCoordinates(stdata)
544
```
545
546
We can now visualize spots and the adjacency between these spots simultaneously.
547
548
```{r eval = FALSE, class.source="watch-out"}
549
stdata <- getSpatialNeighbors(stdata, method = "radius")
550
vrSpatialPlot(stdata, graph.name = "radius", crop = T)
551
```
552
553
<img width="75%" height="75%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/stdata_summary_plot.png" class="center">
554
555
<br>
556
557
## Custom VoltRon objects
558
559
VoltRon incorporates the **formVoltRon** function to assemble each component of a spatial omic assay into a VoltRon object. Here: 
560
561
* **the feature matrix**: the <em> pxn </em> feature to point matrix for raw counts and omic profiles 
562
* **metadata**: the metadata table
563
* **image**: An image or a list of images with names associated to channel 
564
* **coordinates**: xy-Coordinates of spatial points
565
* **segments**: the list of xy-Coordinates of each spatial point
566
567
can individually be prepared before executing formVoltRon. 
568
569
We will use a single image based proteomic assay to demonstrate building custom VoltRon objects. Specifically, we use cells characterized by **multi-epitope ligand cartography (MELC)** with a panel of 44 parameters. We use the already segmented cells on which expression of **43 protein features** (excluding DAPI) were mapped to these cells. 
570
571
VoltRon also provides support for imaging based proteomics assays. In this next use case, we analyze cells characterized by **multi-epitope ligand cartography (MELC)** with a panel of 44 parameters. We use the already segmented cells on which expression of **43 protein features** (excluding DAPI) were mapped to these cells. You can download the files below [here](https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ImportData/custom_vr_object.zip). 
572
573
```{r eval = FALSE, class.source="watch-out"}
574
library(magick)
575
576
# feature x cell matrix
577
intensity_data <- read.table("intensities.tsv", sep = "\t")
578
intensity_data <- as.matrix(intensity_data)
579
580
# metadata
581
metadata <- read.table("metadata.tsv", sep = "\t")
582
583
# coordinates
584
coordinates <- read.table("coordinates.tsv", sep = "\t")
585
coordinates <- as.matrix(coordinates)
586
587
# image
588
library(magick)
589
image <- image_read("DAPI.tif")
590
591
# create VoltRon object
592
vr_object<- formVoltRon(data = intensity_data,
593
                        metadata = metadata,
594
                        image = image,
595
                        coords = coordinates,
596
                        main.assay = "MELC",
597
                        assay.type = "cell",
598
                        sample_name = "control_case_3",
599
                        image_name = "DAPI")
600
vr_object
601
```
602
603
```
604
VoltRon Object 
605
control_case_3: 
606
  Layers: Section1 
607
Assays: MELC(Main) 
608
```
609
610
VoltRon can store multiple images (or channels) associated with a single coordinate system. 
611
612
```{r eval = FALSE, class.source="watch-out"}
613
library(magick)
614
image <- list(DAPI = image_read("DAPI.tif"),
615
              CD45 = image_read("CD45.tif"))
616
617
vr_object<- formVoltRon(data = intensity_data,
618
                        metadata = metadata,
619
                        image = image,
620
                        coords = coordinates,
621
                        main.assay = "MELC",
622
                        assay.type = "cell",
623
                        sample_name = "control_case_3",
624
                        image_name = "MELC")
625
```
626
627
These channels then can be interrogated and used as background images for spatial plots and spatial feature plots as well.
628
629
```{r eval = FALSE, class.source="watch-out"}
630
vrImageChannelNames(vr_object)
631
```
632
633
```
634
       Assay    Layer         Sample Spatial  Channels
635
Assay1  MELC Section1 control_case_3    MELC DAPI,CD45
636
```
637
638
You can extract each of these channels individually.
639
640
```{r eval = FALSE, class.source="watch-out"}
641
vrImages(vr_object, name = "MELC", channel = "DAPI")
642
vrImages(vr_object, name = "MELC", channel = "CD45")
643
```
644
645
646
<table>
647
  <tr>
648
    <td><img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/importdata_DAPI.png" class="center"></td>
649
    <td><img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/importdata_CD45.png" class="center"></td>
650
  </tr>
651
</table>
652
653
</br>
654
655
## Image-only VoltRon objects
656
657
The **formVoltRon** function can also be used to build VoltRon objects where pixels (or tiles) are defined as spatial points. These information are derived from images only which then can be used for multiple downstream analysis purposes. 
658
659
For this we incorporate **importImageData** function and only supply an image object. We will use the H&E image derived from a tissue section that was first analyzed by The 10x Genomics [Xenium In Situ](https://www.10xgenomics.com/platforms/xenium) platform.
660
661
More information on the Xenium and the study can be also be found on the [BioArxiv preprint](https://www.biorxiv.org/content/10.1101/2022.10.06.510405v1). You can download the H&E image from the [10x Genomics website](https://www.10xgenomics.com/products/xenium-in-situ/preview-dataset-human-breast) as well (specifically, import the **Post-Xenium H&E image (TIFF)** data). 
662
663
```{r eval = FALSE, class.source="watch-out"}
664
Xen_R1_image <- importImageData("Xenium_FFPE_Human_Breast_Cancer_Rep1_he_image.tif",
665
                                sample_name = "XeniumR1image", 
666
                                image_name = "H&E")
667
Xen_R1_image
668
```
669
670
```
671
VoltRon Object 
672
XeniumR1image: 
673
  Layers: Section1 
674
Assays: ImageData(Main) 
675
```
676
677
```{r eval = FALSE, class.source="watch-out"}
678
vrImages(Xen_R1_image)
679
```
680
681
<img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/importdata_HE.png" class="center">
682
683
</br>