Skip to content

Commit

Permalink
update vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
stemangiola committed May 20, 2024
1 parent 4da771a commit 82ed552
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 48 deletions.
39 changes: 1 addition & 38 deletions vignettes/Session_2_Tidy_spatial_analyses.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ spatial_data_filtered |>
As you can appreciate, the relationship between the number of genes, probed Purcell and their mitochondrial prescription abundance it's quite consistent.

:::: {.note}
**Excercise**
**Excercise 2.1**

To to practice the use of `tidyomics` on spatial data, we propose a few exercises that connect manipulation, calculations and visualisation. These exercises are just meant to be simple use cases that exploit tidy R streamlined language.

Expand All @@ -600,43 +600,6 @@ We assume that the cells we filtered as non-alive or damaged, characterised by b
Use `tidyomic`s/`tidyverse` tools to label dead cells and perform differential expression within each region. Some of the comments you can use are: `mutate`, `nest`, `aggregate_cells`.
::::

**Solution**

```{r}
library(tidySummarizedExperiment)
library(tidybulk)
differential_analysis =
spatial_data |>
mutate(
dead =
# Stringent threshold
subsets_mito_percent > 20 |
sum < 700 |
detected < 500
) |>
aggregate_cells(c(sample_id, spatialLIBD, dead)) |>
keep_abundant(factor_of_interest = c(dead)) |>
nest(data = - spatialLIBD) |>
# filter regions having both alive and dead cells
filter( map_int(data, ~ .x |> distinct(sample_id, dead) |> nrow() ) == 6 ) |>
mutate(data = map(
data,
test_differential_abundance,
~ dead + sample_id,
method = "edgeR_quasi_likelihood",
test_above_log2_fold_change = log(2)
))
differential_analysis |>
mutate(data = map(data, pivot_transcript)) |>
unnest(data) |>
filter(FDR<0.05)
# tidybulk::test_differential_abundance(~ dead + sample_id + (1 | spatialLIBD), method = "glmmseq_lme4")
```

**Session Information**

Expand Down
13 changes: 3 additions & 10 deletions vignettes/Session_3_imaging_assays.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,6 @@ tx_spe_sample_1 |>
scale_color_manual(values = colorRampPalette( brewer.pal(9,"Set1") )(150) ) +
guides(color = "none")
```

### 3. Cell type caracterisation

```{r}
```

### 4. Neighborhood analyses
Expand All @@ -295,12 +288,12 @@ https://www.bioconductor.org/packages/release/bioc/vignettes/hoodscanR/inst/doc/
https://divingintogeneticsandgenomics.com/post/neighborhood-cellular-niches-analysis-with-spatial-transcriptome-data-in-seurat-and-bioconductor/

:::: {.note}
**Excercise**
**Exercise**

**Spatial-aware clustering:** Apply the spatial aware clustering method BANKSY. Taking as example the code run for session 2.
::::

### 5. Neighborhood analysis


```{r, fig.width=7, fig.height=8, message=FALSE}
Expand Down Expand Up @@ -368,7 +361,7 @@ tx_spe_sample_1 |>
```


### 6. Supplementary: `MoleculeExperiment` package
### 5. Supplementary: `MoleculeExperiment` package

https://www.bioconductor.org/packages/release/bioc/vignettes/MoleculeExperiment/inst/doc/MoleculeExperiment.html

Expand Down
39 changes: 39 additions & 0 deletions vignettes/Solutions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,42 @@ plotSpotQC(
facet_wrap(~sample_id)
```

:::: {.note}
**Excercise 2.1**
::::

```{r}
library(tidySummarizedExperiment)
library(tidybulk)
differential_analysis =
spatial_data |>
mutate(
dead =
# Stringent threshold
subsets_mito_percent > 20 |
sum < 700 |
detected < 500
) |>
aggregate_cells(c(sample_id, spatialLIBD, dead)) |>
keep_abundant(factor_of_interest = c(dead)) |>
nest(data = - spatialLIBD) |>
# filter regions having both alive and dead cells
filter( map_int(data, ~ .x |> distinct(sample_id, dead) |> nrow() ) == 6 ) |>
mutate(data = map(
data,
test_differential_abundance,
~ dead + sample_id,
method = "edgeR_quasi_likelihood",
test_above_log2_fold_change = log(2)
))
differential_analysis |>
mutate(data = map(data, pivot_transcript)) |>
unnest(data) |>
filter(FDR<0.05)
# tidybulk::test_differential_abundance(~ dead + sample_id + (1 | spatialLIBD), method = "glmmseq_lme4")
```

0 comments on commit 82ed552

Please sign in to comment.