a b/docs/roianalysis.Rmd
1
---
2
title: "ROI Analysis"
3
output:
4
  html_document:
5
    toc: yes
6
    toc_float:
7
      collapsed: no
8
      smooth_scroll: no
9
---
10
11
<style>
12
.title{
13
  display: none;
14
}
15
body {
16
  text-align: justify
17
}
18
.center {
19
  display: block;
20
  margin-left: auto;
21
  margin-right: auto;
22
}
23
table, th, td {
24
  border-collapse: collapse;
25
  align-self: center;
26
  padding-right: 10px;
27
  padding-left: 10px;
28
}
29
</style>
30
31
```{css, echo=FALSE}
32
.watch-out {
33
  color: black;
34
}
35
```
36
37
```{r setup, include=FALSE}
38
knitr::opts_chunk$set(highlight = TRUE, echo = TRUE)
39
```
40
41
<br>
42
43
# ROI Analysis
44
45
VoltRon is capable of analyzing readouts from distinct spatial technologies including **segmentation (ROI)-based transciptomics assays** that capture large polygonic regions on tissue sections. VoltRon recognizes such readouts including ones from commercially available tools and allows users to implement a workflow similar to ones conducted on bulk RNA-Seq datasets. In this tutorial, we will analyze morphological images and gene expression profiles provided by the readouts of the [Nanostring's GeoMx Digital Spatial Profiler](https://nanostring.com/products/geomx-digital-spatial-profiler/geomx-dsp-overview/) platform, a high-plex spatial profiling technology which produces segmentation-based protein and RNA assays. 
46
47
In this use case, **eight tissue micro array (TMA) tissue sections** were fitted into the scan area of the slide loaded on the GeoMx DSP instrument. These sections were cut from **control and COVID-19 lung tissues** of donors categorized based on disease durations (acute and prolonged). See [GSE190732](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE190732) for more information.  
48
49
You can download these tutorial files from here:
50
51
<table>
52
  <tr>
53
    <th>File</th>
54
    <th>Link</th>
55
  </tr>
56
  <tr>
57
    <td>Counts</td>
58
    <td><a href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GeoMx/DCC-20230427.zip">DDC files</a></td>
59
  </tr>
60
  <tr>
61
    <td>GeoMx Human Whole Transcriptome Atlas</td>
62
    <td><a href="https://nanostring.com/wp-content/uploads/Hs_R_NGS_WTA_v1.0.pkc_.zip">Human RNA WTA for NGS</a></td>
63
  </tr>
64
  <tr>
65
    <td>Segment Summary</td>
66
    <td><a href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GeoMx/segmentSummary.csv"> ROI Metadata file </a></td>
67
  </tr>
68
  <tr>
69
    <td>Morphology Image</td>
70
    <td><a href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GeoMx/Lu1A1B5umtrueexp.tif"> Image file </a></td>
71
  </tr>
72
  <tr>
73
    <td>OME.TIFF Image </td>
74
    <td><a href="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GeoMx/Lu1A1B5umtrueexp.ome.tiff"> OME.TIFF file </a></td>
75
  </tr>
76
    <tr>
77
    <td>OME.TIFF Image (XML) </td>
78
    <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>
79
  </tr>
80
</table>
81
82
<p></p>
83
84
We now import the GeoMx data, and start analyzing 87 user selected segments (i.e. region of interests, **ROI**) to check spatial localization of signals. The **importGeoMx** function requires:
85
86
* The path to the Digital Count Conversion file, **dcc.path**, and Probe Kit Configuration file, **pkc.file**, which are both provided as the output of the [GeoMx NGS Pipeline](https://emea.illumina.com/products/by-type/informatics-products/basespace-sequence-hub/apps/nanostring-geomxr-ngs-pipeline.html). 
87
* The path the to the metadata file, **summarySegment**, and the specific excel sheet that the metadata is found, **summarySegmentSheetName**, the path to the main morphology **image** and the original **ome.tiff (xml)** file, all of which are provided and imported from the DSP Control Center. Please see [GeoMx DSP Data Analysis User Manual](https://nanostring.com/support-documents/geomx-dsp-data-analysis-user-manual/) for more information.
88
89
```{r eval = FALSE, class.source="watch-out"}
90
library(VoltRon)
91
library(xlsx)
92
GeoMxR1 <- importGeoMx(dcc.path = "DCC-20230427/", 
93
                       pkc.file = "Hs_R_NGS_WTA_v1.0.pkc",
94
                       summarySegment = "segmentSummary.csv",
95
                       image = "Lu1A1B5umtrueexp.tif",
96
                       ome.tiff = "Lu1A1B5umtrueexp.ome.tiff.xml",
97
                       sample_name = "GeoMxR1")
98
```
99
100
We can import the GeoMx ROI segments from the **Lu1A1B5umtrueexp.ome.tiff** image file directly by replacing the .xml file with the .ome.tiff file in the **ome.tiff** argument. Note that you need to call the **RBioFormats** library. If you are getting a **java error** when running importGeoMx, try increasing the maximum heap size by supplying the **-Xmx** parameter. Run the code below before rerunning **importGeoMx** again.
101
102
```{r eval = FALSE, class.source="watch-out"}
103
options(java.parameters = "-Xmx4g")
104
library(RBioFormats)
105
```
106
107
<br>
108
109
## Quality Control
110
111
Once the GeoMx data is imported, we can start off with examining key quality control measures and statistics on each segment to investigate each individual ROI such as sequencing saturation and the number of cells (nuclei) within each segment. VoltRon also provides the total number of unique transcripts per ROI and stores in the metadata. 
112
113
```{r eval = FALSE, class.source="watch-out"}
114
library(ggplot2)
115
vrBarPlot(GeoMxR1, 
116
          features = c("Count", "Nuclei.count", "Sequencing.saturation"),
117
          x.label = "ROI.name", group.by = "ROI.type") + 
118
  theme(axis.text.x = element_text(size = 3))
119
```
120
121
<img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_barplot.png" class="center">
122
123
For measuring the quality of individual ROIs, we can add a new metadata column, called **CountPerNuclei**, to check the average quality of cells per ROI. It seems some number of ROIs with low counts per nuclei also have low sequencing saturation. 
124
125
```{r eval = FALSE, class.source="watch-out"}
126
GeoMxR1$CountPerNuclei <- GeoMxR1$Count/GeoMxR1$Nuclei.count
127
vrBarPlot(GeoMxR1, 
128
          features = c("Count", "Nuclei.count", 
129
                       "Sequencing.saturation", "CountPerNuclei"),
130
          x.label = "ROI.name", group.by = "ROI.type", ncol = 2) + 
131
  theme(axis.text.x = element_text(size = 5))
132
```
133
134
<img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_barplot2.png" class="center">
135
136
<br>
137
138
## Processing
139
140
We can now filter ROIs based on our earlier observation of them having low count per nuclei where some also have low sequencing saturation. 
141
142
```{r eval = FALSE, class.source="watch-out"}
143
# Filter for count per nuclei
144
GeoMxR1 <- subset(GeoMxR1, subset = CountPerNuclei > 500)
145
```
146
147
We then filter genes with low counts by extracting the count matrix and putting aside all genes whose maximum count across all 87 ROIs are less than 10.
148
149
```{r eval = FALSE, class.source="watch-out"}
150
GeoMxR1_data <- vrData(GeoMxR1, norm = FALSE)
151
feature_ind <- apply(GeoMxR1_data, 1, function(x) max(x) > 10)
152
selected_features <- vrFeatures(GeoMxR1)[feature_ind]
153
GeoMxR1_lessfeatures <- subset(GeoMxR1, features = selected_features)
154
```
155
156
VoltRon is capable of normalizing data provided by a diverse set of spatial technologies, including the quantile normalization method suggested by the [GeoMx DSP Data Analysis User Manual](https://nanostring.com/support-documents/geomx-dsp-data-analysis-user-manual/) which scales the ROI profiles to the third quartile followed by the geometric mean of all third quartiles multipled to the scaled profile. 
157
158
```{r eval = FALSE, class.source="watch-out"}
159
GeoMxR1 <- normalizeData(GeoMxR1, method = "Q3Norm")
160
```
161
162
<br>
163
164
## Interactive Subsetting
165
166
Spatially informed genomic technologies heavily depend on image manipulation as images provide an additional set of information. Hence, VoltRon incorporates several interactive built-in utilities. One such functionality allows manipulating images of VoltRon assays where users can interactively choose subsets of images. However, we first resize the morphology image by providing the width of the new image (thus height will be reduced to preserve the aspect ratio). 
167
168
```{r eval = FALSE, class.source="watch-out"}
169
# resizing the image
170
# GeoMxR1 <- resizeImage(GeoMxR1, size = 4000)
171
```
172
173
VoltRon provides **a mini Shiny app** for subsetting spatial points of a VoltRon object by using the image as a reference. This app is particularly useful when multiple tissue sections were fitted to a scan area of a slide, such as the one from GeoMx DSP instrument. We use **interactive = TRUE** option in the subset function to call the mini Shiny app, and select bounding boxes of each newly created subset. **Please continue until all eight sections are selected and subsetted**. 
174
175
```{r eval = FALSE, class.source="watch-out"}
176
GeoMxR1_subset <- subset(GeoMxR1, interactive = TRUE)
177
```
178
179
<img width="85%" height="85%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/interactivesubset.gif" class="center">
180
181
We can now merge the list of subsets, or samples, each associated with one of eight sections. You can provide a list of names for the newly subsetted samples. 
182
183
```{r eval = FALSE, class.source="watch-out"}
184
GeoMxR1_subset_list <- GeoMxR1_subset$subsets
185
GeoMxR1 <- merge(GeoMxR1_subset_list[[1]], GeoMxR1_subset_list[-1])
186
GeoMxR1
187
```
188
189
```
190
VoltRon Object 
191
prolonged case 4: 
192
  Layers: Section1 
193
acute case 3: 
194
  Layers: Section1 
195
control case 2: 
196
  Layers: Section1 
197
acute case 1: 
198
  Layers: Section1 
199
acute case 2: 
200
  Layers: Section1 
201
... 
202
There are 8 samples in total 
203
Assays: GeoMx(Main) 
204
```
205
206
<br>
207
208
You may also save the selected image subsets and reproduce the interactive subsetting operation for later use. 
209
210
```{r eval = FALSE, class.source="watch-out"}
211
samples <- c("prolonged case 4", "acute case 3", "control case 2", 
212
             "acute case 1", "acute case 2", "prolonged case 5", 
213
             "prolonged case 3", "control case 1")
214
subset_info_list <- GeoMxR1_subset$subset_info_list[[1]]
215
GeoMxR1_subset_list <- list()
216
for(i in 1:length(subset_info_list)){
217
  GeoMxR1_subset_list[[i]]  <- subset(GeoMxR1, image = subset_info_list[i])
218
  GeoMxR1_subset_list[[i]] <- samples[i]
219
}
220
GeoMxR1 <- merge(GeoMxR1_subset_list[[1]], GeoMxR1_subset_list[-1])
221
```
222
223
<br>
224
225
## Visualization
226
227
We will now select sections of interests from the VoltRon object, and visualize ROIs and features for each of these sections.
228
229
The function **vrSpatialPlot** plots categorical attributes associated with ROIs. In this case, we will visualize types of ROIs that were labelled and annotated during ROI selection. 
230
231
```{r eval = FALSE, class.source="watch-out"}
232
GeoMxR1_subset <- subset(GeoMxR1, sample = c("prolonged case 4","acute case 3"))
233
vrSpatialPlot(GeoMxR1_subset, group.by = "ROI.type", ncol = 3, alpha = 0.6)
234
```
235
236
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_spatialplot.png" class="center">
237
238
The function **vrSpatialFeaturePlot** detects the number of assays within each VoltRon object and visualizes each feature per each spatial image. A grid of images are visualized either the number of assays or the number of features are larger than 1. Here, we visualize the normalized expression of COL1A1 and C1S, two fibrotic markers, across ROIs of two prolonged covid cases. One may observe that the fibrotic regions of prolonged case 5 have considerably more COL1A1 and C1S compared to prolonged case 4. 
239
240
```{r eval = FALSE, class.source="watch-out"}
241
GeoMxR1_subset <- subset(GeoMxR1, sample = c("prolonged case 4","prolonged case 5"))
242
vrSpatialFeaturePlot(GeoMxR1_subset, features = c("COL1A1", "C1S"), group.by = "ROI.name", 
243
                     log = TRUE, label = TRUE, keep.scale = "feature", title.size = 15)
244
```
245
246
<img width="85%" height="85%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_featureplot.png" class="center">
247
248
<br>
249
250
## Dimensionality Reduction
251
252
We can now process the normalized and demultiplexed samples to map ROIs across all sections onto lower dimensional spaces. The functions **getFeatures** and **getPCA** select features (i.e. genes) of interest from the data matrix across all samples and reduce it to a selected number of principal components. 
253
254
```{r eval = FALSE, class.source="watch-out"}
255
GeoMxR1 <- getFeatures(GeoMxR1)
256
GeoMxR1 <- getPCA(GeoMxR1, dims = 30)
257
```
258
259
The function **vrEmbeddingPlot** can be used to visualize embedding spaces (pca, umap, etc.) for any spatial point supported by VoltRon, hence cells, spots and ROI are all visualized using the same set of functions. Here we generate a new metadata column that represents the **disease durations (control, acute and prolonged case)**, then map gene profiles to the first two principal components.
260
261
```{r eval = FALSE, class.source="watch-out"}
262
GeoMxR1$Condition <- gsub(" [0-9]+$", "", GeoMxR1$Sample)
263
vrEmbeddingPlot(GeoMxR1, group.by = c("Condition"), embedding = "pca", pt.size = 3)
264
```
265
266
<img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_embeddingplotsingle.png" class="center">
267
268
VoltRon provides additional dimensionality reduction techniques such as **UMAP**. 
269
270
```{r eval = FALSE, class.source="watch-out"}
271
GeoMxR1 <- getUMAP(GeoMxR1)
272
```
273
274
Gene expression profiles of ROIs associated with prolonged case sections seem to show some heterogeneity. We now color segments by section (or replicate, **Sample**) to observe the sources of variability. Three replicates of prolonged cases exhibit three different clusters of ROIs.
275
276
```{r eval = FALSE, class.source="watch-out"}
277
vrEmbeddingPlot(GeoMxR1, group.by = c("Condition"), embedding = "pca", pt.size = 3)
278
vrEmbeddingPlot(GeoMxR1, group.by = c("ROI.type"), embedding = "pca", pt.size = 3)
279
vrEmbeddingPlot(GeoMxR1, group.by = c("ROI.type"), embedding = "umap", pt.size = 3)
280
```
281
282
<img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_embeddingplot.png" class="center">
283
284
## Differential Expression Analysis
285
286
VoltRon provides wrapping functions for calling tools and methods from popular differential expression analysis package such as [DESeq2](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-014-0550-8). We utilize **DESeq2** to find differentially expressed genes across each pair of ROI types conditions.
287
288
```{r eval = FALSE, class.source="watch-out"}
289
# get DE for all conditions
290
library(DESeq2)
291
library(dplyr)
292
DEresults <- getDiffExp(GeoMxR1, group.by = "ROI.type",
293
                        group.base = "vessel", method = "DESeq2")
294
DEresults_sig <- DEresults %>% filter(!is.na(padj)) %>% 
295
  filter(padj < 0.05, abs(log2FoldChange) > 1)
296
head(DEresults_sig)
297
```
298
299
<div><pre><code style="font-size: 11.7px;">         baseMean log2FoldChange     lfcSE     stat       pvalue         padj     gene             comparison
300
ACTA2    33.48395       1.508701 0.3458464 4.362343 1.286768e-05 4.902586e-03    ACTA2 ROI.type_vessel_epithelium
301
ADAMTS1  22.29160       1.152556 0.2272085 5.072680 3.922515e-07 4.109815e-04  ADAMTS1 ROI.type_vessel_epithelium
302
C11orf96 27.48924       1.142085 0.3041057 3.755554 1.729585e-04 2.588819e-02 C11orf96 ROI.type_vessel_epithelium
303
CNN1     16.87670       1.112662 0.2680222 4.151381 3.304757e-05 9.766004e-03     CNN1 ROI.type_vessel_epithelium
304
CRYAB    21.85960       1.264747 0.2173272 5.819552 5.900570e-09 2.472929e-05    CRYAB ROI.type_vessel_epithelium
305
FLNA     44.50957       1.270025 0.3243115 3.916066 9.000548e-05 1.985331e-02     FLNA ROI.type_vessel_epithelium</code></pre></div>
306
307
<br>
308
309
The **vrHeatmapPlot** takes a set of features for any type of spatial point (cells, spots and ROIs) and visualizes scaled data per each feature. We select **highlight.some = TRUE** to annotate features which could be large in size where you can also select the number of such highlighted genes with **n_highlight**. There seems to be two groups of fibrotic regions that most likely associated with two prolonged case samples. 
310
311
```{r eval = FALSE, class.source="watch-out"}
312
# get DE for all conditions
313
library(ComplexHeatmap)
314
vrHeatmapPlot(GeoMxR1, features = unique(DEresults_sig$gene), group.by = "ROI.type", 
315
              highlight.some = TRUE, n_highlight = 40)
316
```
317
318
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_heatmap.png" class="center">
319
320
<br>
321
322
In order to get a deeper understanding of differences between fibrotic regions across two prolonged case replicates. We first subset the GeoMx data to only sections with fibrotic ROIs. 
323
324
```{r eval = FALSE, class.source="watch-out"}
325
fibrotic_ROI <- vrSpatialPoints(GeoMxR1)[GeoMxR1$ROI.type == "fibrotic"]
326
GeoMxR1_subset <- subset(GeoMxR1, spatialpoints = fibrotic_ROI)
327
vrSpatialPlot(GeoMxR1_subset, group.by = "ROI.type", ncol = 3, alpha = 0.4)
328
```
329
330
<img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_spatialplot_fibrotic.png" class="center">
331
332
The **getDiffExp** function is capable of testing differential expression across all metadata columns, including the **Samples** column that captures labels of different tissue sections. Macrophage markers such as CD68 and CD163 are differentially expressed in fibrotic regions of case 5 compared to case 4, including FN1, a profibrotic gene whose expression can be found on macrophages.  
333
334
```{r eval = FALSE, class.source="watch-out"}
335
DEresults <- getDiffExp(GeoMxR1_subset, group.by = "Sample", 
336
                        group.base = "prolonged case 5", method = "DESeq2")
337
DEresults_sig <- DEresults %>% filter(!is.na(padj)) %>%
338
  filter(padj < 0.05, abs(log2FoldChange) > 1)
339
DEresults_sig <- DEresults_sig[order(DEresults_sig$log2FoldChange, decreasing = TRUE),]
340
head(DEresults_sig)
341
```
342
343
<div><pre><code style="font-size: 10.7px;">       baseMean log2FoldChange     lfcSE      stat       pvalue         padj   gene                               comparison
344
COL3A1 708.5599       6.635411 0.5198805 12.763338 2.626978e-37 1.596809e-33 COL3A1 Sample_prolonged case 5_prolonged case 4
345
COL1A2 836.0790       5.237228 0.4407380 11.882861 1.453071e-32 4.416246e-29 COL1A2 Sample_prolonged case 5_prolonged case 4
346
COL1A1 460.2184       5.175153 0.5237868  9.880267 5.069785e-23 3.081669e-20 COL1A1 Sample_prolonged case 5_prolonged case 4
347
FN1    278.6594       5.083687 0.3717299 13.675754 1.417301e-42 1.723013e-38    FN1 Sample_prolonged case 5_prolonged case 4
348
HBB    202.7693       4.944228 0.4884175 10.122955 4.370193e-24 3.794888e-21    HBB Sample_prolonged case 5_prolonged case 4
349
A2M    466.4328       4.925236 0.4542682 10.842133 2.173435e-27 3.774636e-24    A2M Sample_prolonged case 5_prolonged case 4</code></pre></div>
350
351
<br>
352
353
<!-- Markers of each individual tissue section for each disease duration is shown on the Heatmap.  -->
354
355
<!-- ```{r eval = FALSE, class.source="watch-out"} -->
356
<!-- # get DE for all conditions -->
357
<!-- vrHeatmapPlot(GeoMxR1, features = unique(DEresults_sig$gene),  -->
358
<!--               group.by = "Sample", highlight.some = TRUE) -->
359
<!-- ``` -->
360
361
<!-- <img width="90%" height="90%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_heatmap2.png" class="center"> -->
362
363
<!-- <br> -->
364
365
## ROI Deconvolution
366
367
VoltRon supports multiple bulk RNA deconvolution algorithms to analyze the cellular composition of both ROIs and spots. In order to integrate the scRNA data and the GeoMx data sets within the VoltRon objects, we will use the [MuSiC](https://xuranw.github.io/MuSiC/articles/MuSiC.html) package. We will use a human lung scRNA dataset (GSE198864) as reference, which is found [here](https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GSE198864_lung.rds). 
368
369
```{r eval = FALSE, class.source="watch-out"}
370
set.seed(1)
371
library(Seurat)
372
library(SingleCellExperiment)
373
seu <- readRDS("GSE198864_lung.rds")
374
scRNAlung <- seu[,sample(1:ncol(seu), 10000, replace = FALSE)]
375
376
# Visualize clusters
377
DimPlot(scRNAlung, reduction = "umap", label = T, group.by = "Clusters") + NoLegend()
378
```
379
380
<img width="60%" height="60%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_deconvolution_singlecell.png" class="center">
381
382
We utilize the **getDeconvolution** function to call wrapper functions for deconvolution algorithms (see ). For all layers with GoeMx assays, an additional assay within the same layer with **\_decon** postfix will be created. The **sc.object** argument can either be a **Seurat** or **SingleCellExperiment** object. 
383
384
```{r eval = FALSE, class.source="watch-out"}
385
library(MuSiC)
386
GeoMxR1 <- getDeconvolution(GeoMxR1,
387
                            sc.object = scRNAlung, sc.assay = "RNA", 
388
                            sc.cluster = "Clusters", sc.samples = "orig.ident")
389
```
390
391
```
392
VoltRon Object 
393
prolonged case 4: 
394
  Layers: Section1 
395
acute case 3: 
396
  Layers: Section1 
397
control case 2: 
398
  Layers: Section1 
399
acute case 1: 
400
  Layers: Section1 
401
acute case 2: 
402
  Layers: Section1 
403
... 
404
There are 8 samples in total 
405
Assays: GeoMx(Main) 
406
Features: RNA(Main) NegProbe Decon 
407
```
408
409
We can now visualize cell type compositions of each ROI. Before running **vrProportionPlot** function, we need to set the main feature type as **Decon**. One may see the increased proportion of cells NK cells and T cells in immune ROIs. 
410
411
```{r eval = FALSE, class.source="watch-out"}
412
vrMainFeatureType(GeoMxR1) <- "Decon"
413
vrProportionPlot(GeoMxR1, x.label = "ROI.name")
414
```
415
416
<img width="100%" height="100%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_deconvolution.png" class="center">
417
418
Here, we can subset the GeoMx object further to dive deep into the cellular proportions of each fibrotic region of prolonged cases. Comparing prolonged case 5 against case 4, we see an increase in the cellular population of the stromal cluster defined in [Mothes et. al 2023](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC9922044/) (that are both vascular and airway smooth muscle cells), and an increase abundance of macrophages which may indicate that these macrophages are profibrotic being within and close to fibrotic regions with increased gene expression of FN1. 
419
420
```{r eval = FALSE, class.source="watch-out"}
421
# subsetting fibrotic regions
422
spatialpoints <- vrSpatialPoints(GeoMxR1)[GeoMxR1$ROI.type == "fibrotic"]
423
GeoMxR1_subset <- subset(GeoMxR1, spatialpoints = spatialpoints)
424
425
# Proportion plot
426
vrProportionPlot(GeoMxR1_subset, x.label = "ROI.name", split.method = "facet_grid", 
427
                 split.by = "Sample")
428
429
# barplot 
430
vrBarPlot(GeoMxR1_subset, features = c("stromal", "macrophages"), group.by = "Sample",
431
          x.label = "ROI.name", split.by = "Sample")
432
```
433
434
<img width="80%" height="80%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_heatmap_fibrotic.png" class="center">
435
436
<img width="80%" height="80%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_barplot_prop_fibrotic.png" class="center">
437
438
## H&E Image Integration
439
440
Questions may arise if in fact these ROIs are fibrotic even though they were initially annotated as fibrotic regions. VoltRon provides advanced image registration workflows which we can use to H&E images of from the same TMA blocks where GeoMx slides were established.
441
442
We first import the H&E image of the prolonged case 4 TMA section using the **importImageData** function. This will import the H&E image as a standalone VoltRon object. For more information on image-based VoltRon objects, see the [Downstream analysis of Pixels](pixelanalysis.html) section.
443
444
We will use the H&E image of TMA section taken from the same block as the Prolonged case 4. You can download the image from [here](https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/ROIanalysis/GeoMx/prolonged_case4_HE.tif).
445
446
```{r eval = FALSE, class.source="watch-out"}
447
vrHEimage <- importImageData("prolonged_case4_HE.tif", channel_names = "H&E")
448
vrImages(vrHEimage, scale.perc = 40)
449
```
450
451
<img width="50%" height="50%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/prolonged_case4_HE.png" class="center">
452
453
<br>
454
455
We can now register the GeoMx slide with the newly imported H&E based VoltRon object. Since two images are associated with TMA sections that are not adjacent, we have to rely on the localization of vessels visible in both images for alignment. VoltRon allows manipulating multiple channels of an image object two choose the best background image for manual landmark selection. For more information on both manual and automated registration of VoltRon objects, see [here](registration.html). 
456
457
VoltRon provides multiple registration methods to align images. Here, after running the **registerSpatialData** function, we choose the **Homography + Non-rigid (TPS)** method which utilizes a perspective transformation on the H&E image followed by a thin plate spline (TPS) alignment. The perspective transformation performs a global alignment between the H&E image and the main GeoMx image (here the scan image with combined antibody channels), and the TPS method allows correct local deformations between the perspective transformed H&E image and the GeoMx image for a more accurate
458
459
```{r eval = FALSE, class.source="watch-out"}
460
GeoMxR1_subset <- subset(GeoMxR1, sample = c("prolonged case 4"))
461
GeoMxReg <- registerSpatialData(reference_spatdata = GeoMxR1_subset, 
462
                                query_spatdata = vrHEimage)
463
```
464
465
<img width="80%" height="80%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_manualregistration.png" class="center">
466
467
The result of the registration is a list of registered VoltRon objects which we can use for parsing the registered image as well. In this case, the second element of the resulting list would be the registered H&E based VoltRon object. 
468
469
```{r eval = FALSE, class.source="watch-out"}
470
vrHEimage_reg <- GeoMxReg$registered_spat[[2]]
471
```
472
473
We can check the additional coordinate system now available for the registered H&E image. One is the coordinate system with the original image, and the other with the one that is registered.
474
475
```{r eval = FALSE, class.source="watch-out"}
476
vrSpatialNames(vrHEimage_reg)
477
```
478
479
```
480
[1] "main"     "main_reg"
481
```
482
483
We can also exchange images where the H&E image now is registered to the perspective of the GeoMx channels, and can be defined as a new channel in the original GeoMx object.
484
485
```{r eval = FALSE, class.source="watch-out"}
486
vrImages(GeoMxR1_subset[["Assay1"]], name = "main", channel = "H&E") <- vrImages(vrHEimage_reg, name = "main_reg", channel = "H&E")
487
```
488
489
We can now observe the new channels (H&E) available for the GeoMx assay using **vrImageChannelNames**. H&E is saved as a separate channel along with the originally available antibody channels of the original GeoMx experiment.
490
491
```{r eval = FALSE, class.source="watch-out"}
492
vrImageChannelNames(GeoMxR1_subset)
493
```
494
495
<div><pre><code style="font-size: 12px;">       Assay    Layer           Sample Spatial                                               Channels
496
Assay1 GeoMx Section1 prolonged case 4    main scanimage,DNA,PanCK,CD45,Alpha Smooth Muscle Actin,H&E</code></pre></div>
497
498
We can now visualize the ROIs and their annotations where the registered H&E visible in the background. We define the spatial key **main** and the channel name **H&E**. 
499
500
```{r eval = FALSE, class.source="watch-out"}
501
vrSpatialPlot(GeoMxR1_subset, group.by = "ROI.type", alpha = 0.7, 
502
              spatial = "main", channel = "H&E")
503
```
504
505
<img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_spatialplot_withHE.png" class="center">
506
507
Interactive Visualization can also be used to zoom in to ROIs and investigate the pathology associated with GeoMx ROIs labeled as fibrotic. 
508
509
```{r eval = FALSE, class.source="watch-out"}
510
vrSpatialPlot(GeoMxR1_subset, group.by = "ROI.type", alpha = 0.7, 
511
              spatial = "main", channel = "H&E", 
512
              interactive = TRUE)
513
```
514
515
<img width="60%" height="60%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/roi_spatialplot_withHE_interactive.png" class="center">