Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
william-hutchison committed Aug 8, 2023
1 parent 4d85087 commit 9163279
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 13 deletions.
53 changes: 48 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "tidySpatialExperiment - part of tidytranscriptomics"
title: "tidySpatialExperiment - part of tidyomics"
output: github_document
---

Expand All @@ -11,7 +11,7 @@ output: github_document
[![Lifecycle:experimental](https://img.shields.io/badge/lifecycle-experimental-blue.svg)](https://www.tidyverse.org/lifecycle/#experimental) [![R build status](https://github.com/william-hutchison/tidySpatialExperiment/actions/workflows/check-bioc.yml/badge.svg)](https://github.com/william-hutchison/tidySpatialExperiment/actions)
<!-- badges: end -->

You can find more packages from the tidytranscriptomics ecosystem here:
You can find more packages from the *tidyomics* ecosystem here:

- [tidySingleCellExperiment](https://github.com/stemangiola/tidySingleCellExperiment) for tidy manipulation of SingleCellExperiment objects
- [tidySummarizedExperiment](https://github.com/stemangiola/tidySummarizedExperiment) for tidy manipulation of SummarizedExperiment objects
Expand Down Expand Up @@ -58,7 +58,6 @@ install.packages("devtools")
devtools::install_github("william-hutchison/tidySpatialExperiment")
```

# Examples
## Load data

Here, we load and view an example SpatialExperiment object. The output we see is of the SpatialExperiment-tibble abstraction.
Expand All @@ -69,6 +68,13 @@ library(tidySpatialExperiment)
example(read10xVisium)
```

```{r, echo=FALSE}
# Load chromote for knitting
library(chromote)
```

## View data

```{r}
# View the SpatialExperiment-tibble abstraction
spe
Expand All @@ -89,6 +95,7 @@ spe |>
imgData()
```

# Integration with the *tidyverse* ecosystem
## Manipulate with dplyr

Most functions from *dplyr* are available for use with the SpatialExperiment-tibble abstraction. For example, `filter` can be used to select cells by a variable of interest.
Expand Down Expand Up @@ -151,13 +158,48 @@ The `plot_ly` function can also be used to create a plot from a SpatialExperimen
spe |>
filter(sample_id == "section1") |>
plot_ly(
x = ~ array_row,
y = ~ array_col,
x = ~ array_col,
y = ~ array_row,
color = ~ in_tissue,
type = "scatter"
)
```

# Integration with the *tidyomics* ecosystem

## Interactively select cells with tidygate

Different packages from the tidyomics ecosystem are easy to use together. Here, the tidygate package is used to interactively gate cells based on their array location.

```{r, eval=FALSE}
spe_regions <-
spe |>
filter(sample_id == "section1") |>
mutate(region = tidygate::gate_chr(array_col, array_row))
```

![](README_files/tidygate_demo.gif)

```{r, echo=FALSE}
# Manually set gate information to match demonstration
spe_regions <-
spe |>
filter(sample_id == "section1") |>
mutate(region = ifelse(
array_row < 48 &
array_row > 20 &
array_col < 80 &
array_col > 60,
1, 0))
```
The gated cells can then be divided into pseudobulks within a SummarizedExperiment object using tidySpatialExperiment's `aggregate_cells' utility function.

```{r}
spe_regions_aggregated <-
spe_regions |>
aggregate_cells(region)
```

# Important considerations

tidySpatialExperiment is still in development and contains some rough edges. Below are examples of behaviour that is currently unclear. I will be adding warning messages / making changes to address these problems in the coming weeks.
Expand All @@ -172,6 +214,7 @@ spe |>
```

The sample_id column cannot be removed with tidyverse functions, and can only be modified if the changes are accepted by SpatialExperiment's `colData` function.

```{r, error=TRUE}
# sample_id is not removed, despite the user's request
spe |>
Expand Down
45 changes: 37 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tidySpatialExperiment - part of tidytranscriptomics
tidySpatialExperiment - part of tidyomics
================

<!-- README.md is generated from README.Rmd. Please edit that file -->
Expand All @@ -12,7 +12,7 @@ tidySpatialExperiment - part of tidytranscriptomics
status](https://github.com/william-hutchison/tidySpatialExperiment/actions/workflows/check-bioc.yml/badge.svg)](https://github.com/william-hutchison/tidySpatialExperiment/actions)
<!-- badges: end -->

You can find more packages from the tidytranscriptomics ecosystem here:
You can find more packages from the *tidyomics* ecosystem here:

- [tidySingleCellExperiment](https://github.com/stemangiola/tidySingleCellExperiment)
for tidy manipulation of SingleCellExperiment objects
Expand Down Expand Up @@ -78,8 +78,6 @@ GitHub with:
install.packages("devtools")
devtools::install_github("william-hutchison/tidySpatialExperiment")

# Examples

## Load data

Here, we load and view an example SpatialExperiment object. The output
Expand All @@ -91,6 +89,8 @@ library(tidySpatialExperiment)
example(read10xVisium)
```

## View data

``` r
# View the SpatialExperiment-tibble abstraction
spe
Expand Down Expand Up @@ -157,6 +157,8 @@ spe |>
## 1 section1 lowres #### 0.0510334
## 2 section2 lowres #### 0.0510334

# Integration with the *tidyverse* ecosystem

## Manipulate with dplyr

Most functions from *dplyr* are available for use with the
Expand Down Expand Up @@ -274,7 +276,7 @@ spe |>
ggplot2::coord_flip()
```

![](README_files/figure-gfm/unnamed-chunk-7-1.png)<!-- -->
![](README_files/figure-gfm/unnamed-chunk-8-1.png)<!-- -->

## Plot with plotly

Expand All @@ -285,14 +287,41 @@ SpatialExperiment object.
spe |>
filter(sample_id == "section1") |>
plot_ly(
x = ~ array_row,
y = ~ array_col,
x = ~ array_col,
y = ~ array_row,
color = ~ in_tissue,
type = "scatter"
)
```

![](README_files/figure-gfm/unnamed-chunk-8-1.png)<!-- -->
![](README_files/figure-gfm/unnamed-chunk-9-1.png)<!-- -->

# Integration with the *tidyomics* ecosystem

## Interactively select cells with tidygate

Different packages from the tidyomics ecosystem are easy to use
together. Here, the tidygate package is used to interactively gate cells
based on their array location.

``` r
spe_regions <-
spe |>
filter(sample_id == "section1") |>
mutate(region = tidygate::gate_chr(array_col, array_row))
```

![](README_files/tidygate_demo.gif)

The gated cells can then be divided into pseudobulks within a
SummarizedExperiment object using tidySpatialExperiment’s
\`aggregate_cells’ utility function.

``` r
spe_regions_aggregated <-
spe_regions |>
aggregate_cells(region)
```

# Important considerations

Expand Down
Binary file modified README_files/figure-gfm/unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added README_files/figure-gfm/unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added README_files/tidygate_demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9163279

Please sign in to comment.