Skip to content

Commit 1a71332

Browse files
committed
Resolved some conflict
1 parent fc60614 commit 1a71332

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

day3/day3-1_spatial_stats.qmd

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ In what follows, we will perform three types of analyses on different _spatial s
7777

7878
## Cell type-free analysis
7979

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.
8185

8286
```{r day3-1-spatial-stats-4}
8387
#| fig-width: 7
@@ -96,6 +100,12 @@ plotColGraph(sfe,
96100
) + theme_void()
97101
```
98102

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+
99109
### Global indicators of spatial association
100110

101111
Now that we have defined both the neighbourhood of a cell, we can turn to measures of spatial association.
@@ -129,7 +139,7 @@ gene.var <- modelGeneVariances(logcounts(sfe),
129139
num.threads = 1)
130140
# chooseHighlyVariableGenes() expects the residual variance statistics
131141
hvg.index <- chooseHighlyVariableGenes(gene.var$statistics$residuals,
132-
top = 100)
142+
top = 100)
133143
134144
#add the hvgs to the `sfe` - adapted from https://github.com/libscran/scrapper/blob/master/R/se_chooseRnaHvgs.R
135145
is.hvg <- logical(nrow(gene.var$statistics))
@@ -170,7 +180,7 @@ Therefore, we will investigate _local_ indicators of spatial association [@ansel
170180
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$.
171181

172182
::: callout-important
173-
## Exercise
183+
### Exercise
174184

175185
- Calculate local Moran's $I$ for the top three global Moran's $I$ genes from above using the function `Voyager::runUnivariate()`
176186

@@ -275,7 +285,7 @@ plotLocalResult(
275285

276286
## Cell type-based analysis
277287

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
279289

280290
```{r day3-1-spatial-stats-15}
281291
#| fig-width: 10
@@ -398,7 +408,7 @@ Do you think this is a good reconstruction / segmentation?
398408
### Answer
399409
Overall the segmentation seems to have worked fine. However, we note a few things:
400410
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.
402412
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.
403413
:::
404414

@@ -455,7 +465,7 @@ What do you notice?
455465
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.
456466
:::
457467

458-
### Cell type proportions
468+
### Cell-type proportions
459469

460470
Next, we look at the absolute and relative cell type proportions in each tumor region.
461471

@@ -496,7 +506,7 @@ Parts of the multi-cellular section were adapted from the following [vignette](h
496506
## Additional Material
497507

498508
::: {.callout-note collapse="true"}
499-
# Additional Material: Multi-sample analysis
509+
# Multi-sample analysis
500510

501511
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).
502512

@@ -539,7 +549,7 @@ sfeMult
539549
```
540550

541551
::: callout-important
542-
## Question
552+
### Question
543553

544554
- 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".
545555

@@ -548,7 +558,7 @@ sfeMult
548558
:::
549559

550560
::: {.callout-tip collapse="true"}
551-
## Answer
561+
### Answer
552562

553563
First, we need to calculate univariate Moran's $I$ for all samples
554564

@@ -613,7 +623,7 @@ qqline(resid(mdl))
613623
:::
614624

615625
::: {.callout-note collapse="true"}
616-
# Additional Material: Gene expression within structures
626+
# Gene expression within structures
617627

618628
Now we will subset to only the tumor regions.
619629

0 commit comments

Comments
 (0)