You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: day3/day3-1_spatial_stats.qmd
+20-10Lines changed: 20 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,11 @@ In what follows, we will perform three types of analyses on different _spatial s
77
77
78
78
## Cell type-free analysis
79
79
80
-
Lattice-based analysis is focused on comparing a numerical value across the lattice of measurements. Such a lattice is constructed by defining the neighbourhood of each cell. First, we will define a neighbourhood on which we want to compute spatial statistics metrics. We will use a $k = 5$ nearest neighbourhood of each cell using the function `findSpatialNeighbors`.
80
+
Lattice-based analysis is focused on comparing a numerical value across the lattice of measurements. Such a lattice is constructed by defining the neighbourhood of each cell. First, we will define a neighbourhood on which we want to compute spatial statistics metrics.
81
+
82
+
In binned 10x Visium, it is very natural to consider the direct neighbours of the bins in the Visium lattice, for example with the function `Voyager::findVisiumGraph()`.
83
+
84
+
Here we create a knn graph with the function `SpatialFeatureExperiment::findSpatialNeighbors()`, considering the $k = 5$ nearest neighbourhood of each cell.
81
85
82
86
```{r day3-1-spatial-stats-4}
83
87
#| fig-width: 7
@@ -96,6 +100,12 @@ plotColGraph(sfe,
96
100
) + theme_void()
97
101
```
98
102
103
+
We notice two things:
104
+
105
+
- The $y$-coordinate is flipped compared to the image. This is due to the way that Visium data is acquired. The Visium slide is placed on top of the tissue but the H&E image is acquired from below the tissue.
106
+
107
+
- The irregular lattice is clearly visible.
108
+
99
109
### Global indicators of spatial association
100
110
101
111
Now that we have defined both the neighbourhood of a cell, we can turn to measures of spatial association.
#add the hvgs to the `sfe` - adapted from https://github.com/libscran/scrapper/blob/master/R/se_chooseRnaHvgs.R
135
145
is.hvg <- logical(nrow(gene.var$statistics))
@@ -170,7 +180,7 @@ Therefore, we will investigate _local_ indicators of spatial association [@ansel
170
180
In the case of Moran's $I$, we will now not calculate one measure for the entire field-of-view but rather one metric per location/spot $i$: $I_i$.
171
181
172
182
::: callout-important
173
-
## Exercise
183
+
###Exercise
174
184
175
185
- Calculate local Moran's $I$ for the top three global Moran's $I$ genes from above using the function `Voyager::runUnivariate()`
176
186
@@ -275,7 +285,7 @@ plotLocalResult(
275
285
276
286
## Cell type-based analysis
277
287
278
-
In the cell-based analysis chapter, we will compare the distribution of categorical cell types in space using point pattern analysis. Let us first plot the cell types in space
288
+
In the cell type-based analysis chapter, we will compare the distribution of categorical cell types in space using point pattern analysis. Let us first plot the cell types in space
279
289
280
290
```{r day3-1-spatial-stats-15}
281
291
#| fig-width: 10
@@ -398,7 +408,7 @@ Do you think this is a good reconstruction / segmentation?
398
408
### Answer
399
409
Overall the segmentation seems to have worked fine. However, we note a few things:
400
410
1. There is one very small regions with a few Tumor cells present.
401
-
2. There might be some under-segmentation, i.e., there are some Myeloid and Endothelial cells included in the Tumor regions. As they are part of the Tumor micro-environment we could also include them in our segmentation / defintion of tumor regions.
411
+
2. There might be some under-segmentation, i.e., there are some Myeloid and Endothelial cells included in the Tumor regions. As they are part of the Tumor micro-environment we could also include them in our segmentation / definition of tumor regions.
402
412
In general, the *correct* segmentation depends heavily on the research question. Using `sosta` we have a data driven way of segmentation that is not influenced by subjective annotation bias.
403
413
:::
404
414
@@ -455,7 +465,7 @@ What do you notice?
455
465
As expected, almost all of the tumor cells have negative distances (within the tumor structures). There are some Myeloid, Endothelial and T cells within the tumor regions and in the near vicinity. This hints at the composition of the tumor microenvironment. As outlined above, the values depend on the exact segmentation and definition of the tumor region.
456
466
:::
457
467
458
-
### Celltype proportions
468
+
### Cell-type proportions
459
469
460
470
Next, we look at the absolute and relative cell type proportions in each tumor region.
461
471
@@ -496,7 +506,7 @@ Parts of the multi-cellular section were adapted from the following [vignette](h
496
506
## Additional Material
497
507
498
508
::: {.callout-note collapse="true"}
499
-
# Additional Material: Multi-sample analysis
509
+
# Multi-sample analysis
500
510
501
511
This chapter so far showed how to perform lattice-data analysis for one sample. Lattice data analysis is not yet very common in multi-sample analyses. One option is to compute a measure of global spatial association giving one numerical value per field-of-view. First, we will load 4 slides from the dataset (2 healthy slides and 2 cancerous slides).
502
512
@@ -539,7 +549,7 @@ sfeMult
539
549
```
540
550
541
551
::: callout-important
542
-
## Question
552
+
###Question
543
553
544
554
- Given you have now a `SpatialFeatureExperiment` object with four samples, how would you compare a global indicator of spatial association across conditions, possibly with multiple samples? As an example, calculate global univariate Moran's $I$ for the gene "PIGR".
545
555
@@ -548,7 +558,7 @@ sfeMult
548
558
:::
549
559
550
560
::: {.callout-tip collapse="true"}
551
-
## Answer
561
+
###Answer
552
562
553
563
First, we need to calculate univariate Moran's $I$ for all samples
554
564
@@ -613,7 +623,7 @@ qqline(resid(mdl))
613
623
:::
614
624
615
625
::: {.callout-note collapse="true"}
616
-
# Additional Material: Gene expression within structures
0 commit comments