Skip to content

Commit

Permalink
v1.13.6 -- resolve #43
Browse files Browse the repository at this point in the history
  • Loading branch information
lcolladotor committed Sep 15, 2023
1 parent aeaba31 commit be5be0e
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: spatialLIBD
Title: spatialLIBD: an R/Bioconductor package to visualize spatially-resolved
transcriptomics data
Version: 1.13.5
Date: 2023-09-05
Version: 1.13.6
Date: 2023-09-15
Authors@R:
c(
person("Leonardo", "Collado-Torres", role = c("aut", "cre"),
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# spatialLIBD 1.13.6

NEW FEATURES

* `vis_clus_p()`, `vis_clus()`, and `vis_grid_clus()` now all use implement the
`na_color` argument that was present in the `vis_gene()` functions. This
resolves https://github.com/LieberInstitute/spatialLIBD/issues/43 by @boyiguo1.

# spatialLIBD 1.13.5

NEW FEATURES
Expand Down
23 changes: 22 additions & 1 deletion R/vis_clus.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#' @param auto_crop A `logical(1)` indicating whether to automatically crop
#' the image / plotting area, which is useful if the Visium capture area is
#' not centered on the image and if the image is not a square.
#' @param na_color A `character(1)` specifying a color for the NA values.
#' If you set `alpha = NA` then it's best to set `na_color` to a color that has
#' alpha blending already, which will make non-NA values pop up more and the NA
#' values will show with a lighter color. This behavior is lost when `alpha` is
#' set to a non-`NA` value.
#' @param ... Passed to [paste0()][base::paste] for making the title of the
#' plot following the `sampleid`.
#'
Expand Down Expand Up @@ -74,6 +79,20 @@
#' spatial = FALSE
#' )
#' print(p3)
#'
#' ## With some NA values
#' spe$tmp <- spe$layer_guess_reordered
#' spe$tmp[spe$sample_id == "151673"][seq_len(500)] <- NA
#' p4 <- vis_clus(
#' spe = spe,
#' clustervar = "tmp",
#' sampleid = "151673",
#' colors = libd_layer_colors,
#' na_color = "white",
#' ... = " LIBD Layers"
#' )
#' print(p4)
#'
#' }
vis_clus <- function(spe,
sampleid = unique(spe$sample_id)[1],
Expand All @@ -97,6 +116,7 @@ vis_clus <- function(spe,
alpha = NA,
point_size = 2,
auto_crop = TRUE,
na_color = "#CCCCCC40",
...) {
spe_sub <- spe[, spe$sample_id == sampleid]
d <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE)
Expand All @@ -112,6 +132,7 @@ vis_clus <- function(spe,
image_id = image_id,
alpha = alpha,
point_size = point_size,
auto_crop = auto_crop
auto_crop = auto_crop,
na_color = na_color
)
}
5 changes: 3 additions & 2 deletions R/vis_clus_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ vis_clus_p <-
image_id = "lowres",
alpha = NA,
point_size = 2,
auto_crop = TRUE) {
auto_crop = TRUE,
na_color = "#CCCCCC40") {
## Some variables
pxl_row_in_fullres <- pxl_col_in_fullres <- key <- NULL
# stopifnot(all(c("pxl_col_in_fullres", "pxl_row_in_fullres", "key") %in% colnames(d)))
Expand Down Expand Up @@ -112,7 +113,7 @@ vis_clus_p <-
alpha = alpha
) +
coord_fixed(expand = FALSE) +
scale_fill_manual(values = colors) +
scale_fill_manual(values = colors, na.value = na_color) +
xlim(0, ncol(img)) +
ylim(nrow(img), 0) +
xlab("") + ylab("") +
Expand Down
5 changes: 0 additions & 5 deletions R/vis_gene.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
#' dependent on cell density.
#' @param cont_colors A `character()` vector of colors that supersedes the
#' `viridis` argument.
#' @param na_color A `character(1)` specifying a color for the NA values.
#' If you set `alpha = NA` then it's best to set `na_color` to a color that has
#' alpha blending already, which will make non-NA values pop up more and the NA
#' values will show with a lighter color. This behavior is lost when `alpha` is
#' set to a non-`NA` value.
#'
#' @return A [ggplot2][ggplot2::ggplot] object.
#' @export
Expand Down
2 changes: 2 additions & 0 deletions R/vis_grid_clus.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ vis_grid_clus <-
sample_order = unique(spe$sample_id),
point_size = 2,
auto_crop = TRUE,
na_color = "#CCCCCC40",
...) {
stopifnot(all(sample_order %in% unique(spe$sample_id)))

Expand All @@ -79,6 +80,7 @@ vis_grid_clus <-
alpha = alpha,
point_size = point_size,
auto_crop = auto_crop,
na_color = na_color,
...
)
})
Expand Down
6 changes: 6 additions & 0 deletions man/run_app.Rd

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

21 changes: 21 additions & 0 deletions man/vis_clus.Rd

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

9 changes: 8 additions & 1 deletion man/vis_clus_p.Rd

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

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

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

0 comments on commit be5be0e

Please sign in to comment.