Skip to content

Commit

Permalink
Merge pull request #34 from boyiguo1/v1.3.1
Browse files Browse the repository at this point in the history
V1.3.1 small updates
  • Loading branch information
boyiguo1 authored Nov 9, 2023
2 parents c3a3da9 + 58b8e4c commit 098801a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 52 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: escheR
Title: Unified multi-dimensional visualizations with Gestalt principles
Version: 1.3.0
Version: 1.3.1
Authors@R: c(
person("Boyi", "Guo",
email = "[email protected]", role = c("aut", "cre"),
Expand Down Expand Up @@ -54,5 +54,6 @@ Suggests:
scran,
scater,
scuttle,
Seurat
Seurat,
hexbin
VignetteBuilder: knitr
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# escheR 1.3.1
SIGNIFICANT USER-VISIBLE CHANGES
* Add functions `add_fill_bin` and `add_ground_bin` to provide hexgon binning strategy to mitigate the overplotting of data points
* Provide an example to use `add_fill_bin` and `add_ground_bin` with `make_escheR` to create hexgon binning plot



# escheR 1.2.0
SIGNIFICANT USER-VISIBLE CHANGES
* Add generic functions to support `SingleCellExperiment` object by
Expand Down
57 changes: 7 additions & 50 deletions vignettes/more_than_visium.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,71 +49,28 @@ make_escheR(
```

# Hex Binning
```{r}
```{r bin_plot}
spe$counts_MOBP <- counts(spe)[which(rowData(spe)$gene_name=="MOBP"),]
spe$ground_truth <- factor(spe$ground_truth)
# Hex Binning version
# make_escheR(
# spe,
# dimred = "PCA"
# ) +
# # Create hex binning
# stat_summary_hex(
# aes(z = ground_truth, group = -1, color = after_stat(value), fill = after_stat(rep(NA_integer_, length(value)))
# ),
# linewidth = 1.2,
# fun = function(x){
# # browser()
# ll <- data.frame(table(x))
# as.character(ll[which.max(ll$Freq),"x"])
# }, bins = 30
# ) +
# # Create hex binning
# stat_summary_hex(
# aes(z = counts_MOBP, fill = after_stat(value)),
# color = "transparent",
# fun = sum, bins = 30) +
# scale_size_area
# Point Binning version
make_escheR(
spe,
dimred = "PCA"
) |>
add_ground_bin(
var = "ground_truth") |>
var = "ground_truth"
) |>
add_fill_bin(
var = "counts_MOBP"
) +
) +
# Customize aesthetics
scale_fill_gradient(low = "white", high = "black", name = "MOBP Count")+
scale_color_discrete(name = "Spatial Domains") +
theme_minimal()
#
# stat_summary_hex(
# aes(z = ground_truth, group = -1, color = after_stat(value), fill = after_stat(rep(NA_integer_, length(value)))
# ),
# geom = "point",
# shape = 21,
# size = 3,
# stroke = 1,
# # linewidth = 1.2,
# fun = function(x){
# # browser()
# ll <- data.frame(table(x))
# as.character(ll[which.max(ll$Freq),"x"])
# }, bins = 30
# ) +
# stat_summary_hex(
# aes(z = counts_MOBP, fill = after_stat(value)),
# color = "transparent",
# geom = "point",
# shape = 21,
# size = 2.8,
# fun = sum, bins = 30)
```
> Note 1: The strategy of binning to avoid overplotting is previously proposed in [`schex`](https://www.bioconductor.org/packages/release/bioc/html/schex.html). While we provide an impelmentation in `escheR`, we would caution our users that the binning strategy could lead to intermixing of cluster memberships. In our impelmentation, the majority membership of the datapoints belonging to a bin is selected as the label. Users should use the binning strategy under their own discretion, and interpret the visualization carefully.
> Note 1: The strategy of binning to avoid overplotting is previously proposed in [`schex`](https://www.bioconductor.org/packages/release/bioc/html/schex.html). While we provide an implementation in `escheR`, we would caution our users that the binning strategy could lead to intermixing of cluster memberships. In our implementation, the majority membership of the data points belonging to a bin is selected as the label of the bin. Users should use the binning strategy under their own discretion, and interpret the visualization carefully.
> Note 2: `add_fill_bin()` shoudl be applied after `add_ground_bin()` for the better visualization outcome.
# Image-based `SpatialExperiment` Object
Expand Down

0 comments on commit 098801a

Please sign in to comment.