Skip to content

Commit

Permalink
Fix(integration): generate tiles directly instead of after the fact -…
Browse files Browse the repository at this point in the history
… lead to issue down the line
  • Loading branch information
patrickCNMartin committed Dec 5, 2024
1 parent 840a37a commit 710498a
Show file tree
Hide file tree
Showing 9 changed files with 1,223 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
49 changes: 49 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
release:
types: [published]
workflow_dispatch:

name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
folder: docs
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.2
VignetteBuilder: knitr
URL: https://patrickcnmartin.github.io/Vesalius/,https://github.com/patrickCNMartin/Vesalius
URL: https://patrickcnmartin.github.io/Vesalius/, https://github.com/patrickCNMartin/Vesalius, https://wonlab-cs.github.io/Vesalius/
Config/testthat/edition: 3
Config/rextendr/version: 0.2.0.9000
18 changes: 17 additions & 1 deletion R/integration.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#' should be merged with the reference data (see details)
#' @param labels_reference character - which columns in the reference data assay
#' should be merged with the mapped data (see details)
#' @param regenerate_tiles logical - should tiles be regenrated from integrated
#' coordinates
#' @param verbose logical - should progressed message be printed
#' @details After mapping coordinates from a query onto a reference, vesalius
#' provides a way to then integrate the assays together. This function will:
Expand Down Expand Up @@ -53,6 +55,10 @@ integrate_assays <- function(mapped,
use_counts = "raw",
labels_mapped = NULL,
labels_reference = NULL,
regenerate_tiles = TRUE,
tensor_resolution = 1,
filter_grid = 1,
filter_threshold = 1,
verbose = TRUE) {
simple_bar(verbose)
#-------------------------------------------------------------------------#
Expand Down Expand Up @@ -92,7 +98,16 @@ integrate_assays <- function(mapped,
coordinates,
labels_mapped,
labels_reference)
vesalius_assay <- build_vesalius_assay(coordinates = coordinates, verbose = FALSE)
vesalius_assay <- build_vesalius_assay(
coordinates = coordinates,
verbose = FALSE)
if (regenerate_tiles) {
vesalius_assay <- generate_tiles(vesalius_assay,
tensor_resolution = tensor_resolution,
filter_grid = filter_grid,
filter_threshold = filter_threshold,
verbose = verbose)
}
vesalius_assay <- update_vesalius_assay(vesalius_assay,
data = integrated$counts,
slot = "counts",
Expand Down Expand Up @@ -128,6 +143,7 @@ integrate_assays <- function(mapped,
vesalius_assay <- commit_log(vesalius_assay,
commit,
"Integrated")

simple_bar(verbose)
return(vesalius_assay)
}
Expand Down
2 changes: 1 addition & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
url: ~
url: wonlab-cs.github.io/Vesalius/
template:
bootstrap: 5

7 changes: 7 additions & 0 deletions man/integrate_assays.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/vesalius_package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions vignettes/vesalius.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ images.
p3 <- image_plot(vesalius, dimensions = 1, embedding = "UMAP") +
labs(title = "Grey UMAP dim 1")
p4 <- image_plot(vesalius, dimensions = c(1, 2, 3), embedding = "UMAP") +
labs(title = "Grey UMAP dim 1, 2, and 3")
labs(title = "RGB UMAP dim 1, 2, and 3")
```

```{r out_plot_grey, eval = TRUE, echo = TRUE, fig.width = 10, fig.height = 10}
Expand Down Expand Up @@ -387,6 +387,7 @@ vesalius <- generate_embeddings(vesalius,
filter_threshold = 1,
filter_grid = 1)
vesalius <- smooth_image(vesalius, embedding = "PCA", sigma = 5, iter = 10)
vesalius <- equalize_image(vesalius, sleft = 5, sright = 5)
vesalius <- segment_image(vesalius, col_resolution = 2)
vesalius <- isolate_territories(vesalius)
Expand Down Expand Up @@ -425,14 +426,13 @@ matched <- generate_embeddings(matched,
dim_reduction = "PCA",
nfeatures = 200,
verbose = FALSE)
matched <- regularise_image(matched, lambda = 1)
matched <- smooth_image(matched, sigma = 5, iter = 10)
matched <- equalize_image(matched, sleft = 5, sright = 5)
matched <- segment_image(matched,col_resolution = 2)
```
We can then look at the resulting embeddings

```{r map_image_plot, eval = TRUE, echo = TRUE}
```{r map_image_plot, eval = TRUE, echo = TRUE,fig.width = 12}
m <- image_plot(vesalius)
m1 <- image_plot(jitter_ves)
m2 <- image_plot(matched)
Expand All @@ -443,10 +443,11 @@ m + m1 + m2

We can also look at the new territories.

```{r map_territory, eval = TRUE, echo = TRUE}
```{r map_territory, eval = TRUE, echo = TRUE,fig.width = 12}
t <- territory_plot(vesalius)
t1 <- territory_plot(jitter_ves)
t2 <- territory_plot(matched)
t + t1 + t2
```

## Integrating data sets
Expand All @@ -457,22 +458,23 @@ expression analysis.
```{r map_inter, eval = TRUE, echo = TRUE}
inter <- integrate_assays(matched,
vesalius)
```

Since this data set now contains an integrated latent space, we can also call
territories on this object. There is no need to create new embeddings. They are
provided during integration.

```{r inter_territory, eval = TRUE, echo = TRUE}
inter <- regularise_image(inter, lambda = 1)
inter <- smooth_image(inter, sigma = 5, iter = 10)
inter <- equalize_image(inter, sleft = 5, sright = 5)
inter <- segment_image(col_resolution = 2)
inter <- segment_image(inter, col_resolution = 2)
```

We can view the resulting embeddings and territories.

```{r inter_plot, eval = TRUE, echo = TRUE}
```{r inter_plot, eval = TRUE, echo = TRUE, fig.width = 9}
i <- image_plot(inter)
i1 <- territory_plot(inter)
Expand Down
Loading

0 comments on commit 710498a

Please sign in to comment.