Skip to content

Commit 7f6c203

Browse files
committed
update content and solutions
1 parent d3ca0ef commit 7f6c203

File tree

3 files changed

+170
-73
lines changed

3 files changed

+170
-73
lines changed

vignettes/Introduction.Rmd

+46-15
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ knitr::include_graphics(here("inst/images/physalia-min.png"))
5454

5555
You can view the material at the workshop webpage
5656

57-
[here](https://tidyomics.github.io/tidySpatialWorkshop/articles/main.html).
57+
[here](https://tidyomics.github.io/tidySpatialWorkshop/index.html).
5858

5959
## Workshop package installation
6060

@@ -90,6 +90,7 @@ Alternatively download the [git zipped package](https://github.com/tidyomics/tid
9090

9191
# Announcements
9292

93+
Tidyomics is now published in (Nature Methods)[https://www.nature.com/articles/s41592-024-02299-2]. And availabel for (free) here[https://www.biorxiv.org/content/10.1101/2023.09.10.557072v3].
9394

9495
# Introduction to Spatial Omics
9596

@@ -100,35 +101,65 @@ sequencing in experimental and analytical contexts.
100101

101102
### Workshop Structure
102103

103-
#### 1. Welcome and Introduction
104+
#### Day 1
104105

105-
- Overview of the workshop.
106-
- Goals for Day 1.
106+
##### 1. Welcome and Introduction
107107

108-
#### 2. What is Spatial Omics?
108+
- Introduction of the instructor
109+
- Introduction of the crowd
110+
- Overview and goals of the workshop.
111+
112+
##### 2. What is Spatial Omics?
109113

110114
- Definition and significance in modern biology.
111115
- Key applications and impact.
112-
113-
#### 3. Technologies in Spatial Omics
114-
115116
- Overview of different spatial omics technologies.
116117
- Comparison of imaging-based vs sequencing-based approaches.
117118

118-
#### 4. Sequencing Spatial Omics
119+
##### 3. Sequencing Spatial Omics
119120

120121
- Detailed comparison of methodologies.
121122
- Experimental design considerations.
122123
- Data analysis challenges and solutions.
123124

124-
#### 5. Overview of Analysis Frameworks
125+
##### 5. Analysis of sequencing based spatial data
126+
127+
- Getting Started with SpatialExperiment.
128+
- Data Visualisation and Manipulation.
129+
- Quality control and filtering.
130+
- Dimensionality reduction.
131+
- Spatial Clustering.
132+
- Deconvolution of pixel-based spatial data.
133+
134+
#### Day 2
135+
136+
##### 1. Introduction to tidyomics
137+
138+
- Use tidyverse on spatial, single-cell, pseudobulk and bulk genomic data
125139

126-
- Introduction to various analysis frameworks.
127-
- Brief mention of 'tidy' data principles in spatial omics.
140+
##### 2. Working with tidySpatialExperiment
141+
142+
- tidySpatialExperiment package
143+
- Tidyverse commands
144+
- Advanced filtering/gating and pseudobulk
145+
- Work with features
146+
- Summarisation/aggregation
147+
- tidyfying your workflow
148+
- Visualisation
149+
150+
#### Day 3
151+
152+
##### 1. Imaging Spatial Omics
153+
154+
- Detailed comparison of methodologies.
155+
- Experimental design considerations.
156+
- Data analysis challenges and solutions.
128157

129-
#### 6. Wrap-Up and Q&A
158+
##### 2. Spatial analyses of imaging data
130159

131-
- Summarize key takeaways.
132-
- Open floor for questions and discussions.
160+
- Working with imaging-based data in Bioconductor with MoleculeExperiment
161+
- Aggregation and analysis
162+
- Clustering
163+
- Neighborhood analyses
133164

134165

vignettes/Session_1_sequencing_assays.Rmd

+98-32
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ knitr::opts_chunk$set(echo = TRUE, cache = FALSE)
1717

1818
# Session 1: Spatial Analysis of Sequencing Data
1919

20-
Web rendering: https://rpubs.com/mangiolas/1186971
21-
2220
## Overview
2321

2422
This workshop introduces spatial transcriptomics analysis using the Bioconductor framework, with a particular focus on the `SpatialExperiment` package. Participants will learn essential concepts and practical skills for analyzing spatially-resolved genomic data.
@@ -221,7 +219,7 @@ ggspavis::plotSpots(
221219
Explore additional visualisation features offered by the Visium platform, exposing the H&E (hematoxylin and eosin) image.
222220

223221
```{r, fig.width=6, fig.height=6}
224-
ggspavis::plotVisium(spatial_data)
222+
ggspavis::plotVisium(spatial_data, point_size = 0.5)
225223
```
226224

227225
This visualisation focuses on specific tissue features within the dataset, emphasising areas of interest.
@@ -233,7 +231,8 @@ This visualisation focuses on specific tissue features within the dataset, empha
233231
ggspavis::plotVisium(
234232
spatial_data,
235233
annotate = "spatialLIBD",
236-
highlight = "in_tissue"
234+
highlight = "in_tissue",
235+
point_size =0.5
237236
) +
238237
facet_wrap(~sample_id)
239238
@@ -763,19 +762,7 @@ SPOTlight uses a seeded non-negative matrix factorization regression, initialize
763762

764763
#### Producing the reference for single-cell databases
765764

766-
[cellNexus](https://stemangiola.github.io/cellNexus/) is a query interface that allow the programmatic exploration and retrieval of the harmonised, curated and reannotated CELLxGENE single-cell human cell atlas. Data can be retrieved at cell, sample, or dataset levels based on filtering criteria.
767-
768-
Harmonised data is stored in the ARDC Nectar Research Cloud, and most cellNexus functions interact with Nectar via web requests, so a network connection is required for most functionality.
769-
770-
Mangiola et al., 2025 doi [doi.org/10.1101/2023.06.08.542671](https://www.biorxiv.org/content/10.1101/2023.06.08.542671v3)
771-
772-
```{r, echo=FALSE, out.width="700px"}
773-
knitr::include_graphics(here("inst/images/curated_atlas_query.png"))
774-
```
775-
776-
777-
778-
765+
Here, we retrieve and prepare a single-cell RNA reference. The dataset in question, zhong-prefrontal-2018, originates from a study by Zhong et al. (2018), which offers a comprehensive single-cell transcriptomic survey of the human prefrontal cortex during development . Utilising the scRNAseq package, the dataset is fetched and subsequently processed to aggregate counts across cells sharing the same sample and cell type, thereby reducing data complexity and enhancing interpretability. Further filtering steps ensure the removal of empty columns and entries with missing cell type annotations. Finally, the logNormCounts function from the scuttle package is applied to perform log-normalisation, a crucial step for mitigating technical variability and preparing the data for accurate comparative analyses .
779766

780767
```{r, message=FALSE, warning=FALSE, fig.width=6, fig.height=6}
781768
# Get reference
@@ -942,6 +929,9 @@ No, let's look at the correlation matrices to see which cell type are most often
942929
943930
plotCorrelationMatrix(res$mat)
944931
```
932+
```{r}
933+
mat_df = as.data.frame(res$mat)
934+
```
945935

946936
#### Excercise
947937

@@ -954,36 +944,112 @@ Rather than looking at the correlation matrix, overall, let's observe whether th
954944
:::
955945

956946

957-
```{r, fig.width=6, fig.height=6}
958-
res_spatialLIBD = split(data.frame(res$mat), colData(spatial_data_gene_name)$spatialLIBD )
947+
::: {.note}
948+
**Exercise 1.5**
949+
950+
## Exercise 1.5 (adapted to your current cell types)
951+
952+
Some of the most positive correlations in the new matrix are seen between:
953+
954+
- **Microglia** and **Neurons**
955+
- **Astrocytes** and **Stem.cells**
956+
957+
> **Microglia** are the resident immune cells of the central nervous system, constantly surveying the parenchyma and clearing debris.
958+
> **Neurons** are the electrically excitable cells that transmit and process information via synaptic connections.
959+
> **Astrocytes** are star-shaped glia that support neuronal metabolism, regulate extracellular ions and neurotransmitter uptake.
960+
> **Stem.cells** denote undifferentiated progenitors capable of self-renewal and differentiation into multiple neural lineages.
961+
962+
Let us now **visualise** where these pairs of cell types most co-occur in your spatial map. For **each** pair, carry out the following:
963+
964+
1. **Label** any pixel where both cell types exceed 10 % abundance (i.e. > 0.1).
965+
2. **Label** any pixel where the _sum_ of their abundances exceeds 40 % (i.e. > 0.4).
966+
3. **Plot** the spatial coordinates of all pixels, **colouring** them by this new label (for example:
967+
- `0` = neither condition met
968+
- `1` = both abundances > 0.1
969+
- `2` = summed abundance > 0.4
970+
971+
You should end up with two analogous visualisations:
972+
973+
- **Microglia + Neurons**
974+
- **Astrocytes + Stem.cells**
975+
976+
Feel free to reuse your previous code, simply substituting the cell-type columns and updating the thresholds as above.
977+
978+
:::
979+
980+
981+
982+
#### Bonus - Alternative reference from the Human Cell Atlas - using cellNexus
959983

960-
lapply(res_spatialLIBD, function(x) plotCorrelationMatrix(as.matrix(x[,-10])))
984+
[cellNexus](https://stemangiola.github.io/cellNexus/) is a query interface that allow the programmatic exploration and retrieval of the harmonised, curated and reannotated CELLxGENE single-cell human cell atlas. Data can be retrieved at cell, sample, or dataset levels based on filtering criteria.
985+
986+
Harmonised data is stored in the ARDC Nectar Research Cloud, and most cellNexus functions interact with Nectar via web requests, so a network connection is required for most functionality.
987+
988+
Mangiola et al., 2025 doi [doi.org/10.1101/2023.06.08.542671](https://www.biorxiv.org/content/10.1101/2023.06.08.542671v3)
989+
990+
```{r, echo=FALSE, out.width="700px"}
991+
knitr::include_graphics(here("inst/images/curated_atlas_query.png"))
961992
```
962993

963994

995+
```{r, eval = FALSE, message=FALSE, warning=FALSE, fig.width=3, fig.height=3}
996+
# Get reference
997+
library(cellNexus)
998+
library(HDF5Array)
964999
965-
::: {.note}
966-
**Exercise 1.5**
1000+
tmp_file_path = tempfile()
1001+
1002+
brain_reference =
1003+
1004+
# Query metadata across 30M cells
1005+
get_metadata() |>
1006+
1007+
# Filter your data of interest
1008+
dplyr::filter(tissue_groups=="cerebral lobes and cortical areas", disease == "Normal") |>
1009+
1010+
# Collect pseudobulk as SummarizedExperiment
1011+
get_pseudobulk() |>
1012+
1013+
# Normalise for Spotlight
1014+
scuttle::logNormCounts() |>
1015+
1016+
# Save for fast reading
1017+
HDF5Array::saveHDF5SummarizedExperiment(tmp_file_path, replace = TRUE)
1018+
```
9671019

968-
Some of the most positive correlations involve the endothelial cells with Oligodendrocytes and Leptomeningeal cells.
1020+
```{r, eval = FALSE, message=FALSE}
1021+
library(HDF5Array)
9691022
970-
Leptomeningeal cells refer to the cells that make up the leptomeninges, which consist of two of the three layers olet's meninges surrounding the brain and spinal cord: the arachnoid mater and the pia mater. These layers play a critical role in protecting the central nervous system and assisting in various physiological processes.
1023+
brain_reference = HDF5Array::loadHDF5SummarizedExperiment(tmp_file_path)
9711024
972-
Oligodendrocytes are a type of glial cell in the central nervous system (CNS) of vertebrates, including humans and mouse. These cells are crucial for the formation and maintenance of the myelin sheath, a fatty layer that encases the axons of many neurons.
1025+
my_metadata = colData(brain_reference)
9731026
974-
Let's try to visualise the pixel where these cell types most occur.
1027+
knitr::kable(head(my_metadata), format = "html")
1028+
```
9751029

1030+
These are the cell types included in our reference, and the number of pseudobulk samples we have for each cell type.
9761031

977-
- Label pixel that have > 10% (> 0.1) endothelial_cell and leptomeningeal_cell
978-
- Label pixels that have > 40% (> 0.4) across these two cells
979-
- Plot pixels colouring by the new label
1032+
```{r, eval = FALSE}
9801033
981-
:::
1034+
table(brain_reference$cell_type_harmonised)
9821035
983-
```{r}
984-
mat_df = as.data.frame(res$mat)
9851036
```
9861037

1038+
These are the number of samples we have for each of the three data sets.
1039+
1040+
```{r, eval = FALSE}
1041+
1042+
table(brain_reference$dataset_id)
1043+
```
1044+
1045+
The `collection_id` can be used to gather information on the cell database. e.g. <https://cellxgene.cziscience.com/collections/><collection_id>
1046+
1047+
```{r, eval = FALSE}
1048+
table(brain_reference$collection_id)
1049+
```
1050+
1051+
1052+
9871053
**Session Information**
9881054

9891055
```{r}

vignettes/Solutions.Rmd

+26-26
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author:
55
output: rmarkdown::html_vignette
66
# bibliography: "`r file.path(system.file(package='tidySpatialWorkshop', 'vignettes'), 'tidyomics.bib')`"
77
vignette: >
8-
%\VignetteIndexEntry{Sequencing assays}
8+
%\VignetteIndexEntry{Solutions to exercises}
99
%\VignetteEncoding{UTF-8}
1010
%\VignetteEngine{knitr::rmarkdown}
1111
---
@@ -96,31 +96,31 @@ lapply(res_spatialLIBD, function(x) plotCorrelationMatrix(as.matrix(x[,-10])))
9696

9797
```{r, fig.width=7, fig.height=8, eval=FALSE}
9898
99-
100-
101-
is_endothelial_leptomeningeal = mat_df$endothelial_cell >0.1 & mat_df$leptomeningeal_cell>0.1 & mat_df$endothelial_cell + mat_df$leptomeningeal_cell > 0.4
102-
103-
spatial_data$is_endothelial_leptomeningeal = is_endothelial_leptomeningeal
104-
105-
ggspavis::plotSpots(spatial_data, annotate = "is_endothelial_leptomeningeal") +
106-
facet_wrap(~sample_id) +
107-
scale_color_manual(values = c("TRUE"= "red", "FALSE" = "grey"))
108-
theme(legend.position = "none") +
109-
labs(title = "endothelial + leptomeningeal")
110-
111-
112-
113-
114-
is_endothelial_oligodendrocytes = mat_df$endothelial_cell >0.1 & mat_df$oligodendrocyte>0.05 & mat_df$endothelial_cell + mat_df$oligodendrocyte > 0.4
115-
116-
spatial_data$is_endothelial_oligodendrocyte = is_endothelial_oligodendrocytes
117-
118-
ggspavis::plotSpots(spatial_data, annotate = "is_endothelial_oligodendrocyte") +
119-
facet_wrap(~sample_id) +
120-
scale_color_manual(values = c("TRUE"= "blue", "FALSE" = "grey"))
121-
theme(legend.position = "none") +
122-
labs(title = "endothelial + oligodendrocyte")
123-
99+
# 1. Microglia + Neurons
100+
is_microglia_neuron <- mat_df$Microglia > 0.1 &
101+
mat_df$Neurons > 0.1 &
102+
(mat_df$Microglia + mat_df$Neurons) > 0.4
103+
spatial_data$is_microglia_neuron <- is_microglia_neuron
104+
105+
ggspavis::plotSpots(spatial_data, annotate = "is_microglia_neuron") +
106+
facet_wrap(~sample_id) +
107+
scale_color_manual(values = c("TRUE" = "red", "FALSE" = "grey")) +
108+
theme(legend.position = "none") +
109+
labs(title = "Microglia + Neurons")
110+
111+
112+
# 2. Astrocytes + Stem cells
113+
# note the space in the column name — use backticks
114+
is_astrocyte_stem <- mat_df$Astrocytes > 0.1 &
115+
mat_df$`Stem cells` > 0.1 &
116+
(mat_df$Astrocytes + mat_df$`Stem cells`) > 0.4
117+
spatial_data$is_astrocyte_stem <- is_astrocyte_stem
118+
119+
ggspavis::plotSpots(spatial_data, annotate = "is_astrocyte_stem") +
120+
facet_wrap(~sample_id) +
121+
scale_color_manual(values = c("TRUE" = "blue", "FALSE" = "grey")) +
122+
theme(legend.position = "none") +
123+
labs(title = "Astrocytes + Stem cells")
124124
```
125125

126126
**Excercise 1.6**

0 commit comments

Comments
 (0)