Skip to content

Commit

Permalink
Final final fixes for the release
Browse files Browse the repository at this point in the history
  • Loading branch information
mvfki committed Oct 29, 2024
1 parent 176c6ab commit 6488639
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 22 deletions.
2 changes: 0 additions & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
LICENSE
.*rds$
.*RDS$
^\.lintr$
^\.vscode
^.*\.Rproj$
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rliger
Version: 2.1.0
Date: 2024-10-25
Date: 2024-10-29
Type: Package
Title: Linked Inference of Genomic Experimental Relationships
Description: Uses an extension of nonnegative matrix factorization to identify shared and dataset-specific factors. See Welch J, Kozareva V, et al (2019) <doi:10.1016/j.cell.2019.05.006>, and Liu J, Gao C, Sodicoff J, et al (2020) <doi:10.1038/s41596-020-0391-8> for more details.
Expand Down
48 changes: 36 additions & 12 deletions R/visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,13 @@ plotGeneDetectedViolin <- function(
#' function arguments before matching the \code{...} arguments.
#' @param object A \linkS4class{liger} object.
#' @param gene Character vector of gene names.
#' @param groupBy Names of available categorical variable in \code{cellMeta}
#' slot. Use \code{FALSE} for no grouping. Default \code{NULL} looks clustering
#' result but will not group if no clustering found.
#' @param groupBy The name of an available categorical variable in
#' \code{cellMeta} slot. This forms the main x-axis columns. Use \code{FALSE}
#' for no grouping. Default \code{NULL} looks clustering result but will not
#' group if no clustering is found.
#' @param colorBy The name of another categorical variable in \code{cellMeta}
#' slot. This split the main grouping columns and color the violins. Default
#' \code{NULL} will not split and color the violins.
#' @param box Logical, whether to add boxplot. Default \code{FALSE}.
#' @param boxAlpha Numeric, transparency of boxplot. Default \code{0.1}.
#' @param yFunc Function to transform the y-axis. Default is
Expand All @@ -358,10 +362,11 @@ plotClusterGeneViolin <- function(
object,
gene,
groupBy = NULL,
colorBy = NULL,
box = FALSE,
boxAlpha = 0.1,
yFunc = function(x) log1p(x*1e4),
showLegend = FALSE,
showLegend = !is.null(colorBy),
xlabAngle = 40,
...
) {
Expand All @@ -382,19 +387,38 @@ plotClusterGeneViolin <- function(
groupBy <- "group"
featureDF[[groupBy]] <- factor("All")
}
p <- featureDF %>%
if (!is.null(colorBy)) {
colorVar <- .fetchCellMetaVar(
object = object, variables = colorBy, checkCategorical = TRUE
)
featureDF[[colorBy]] <- factor(colorVar)
}

featureDF <- featureDF %>%
.pivot_longer(
cols = seq(ngene),
names_to = "gene",
values_to = "Expression"
) %>%
dplyr::mutate(gene = factor(.data[["gene"]], levels = geneUse)) %>%
ggplot2::ggplot(ggplot2::aes(
x = .data[[groupBy]],
y = .data[["Expression"]],
fill = .data[[groupBy]]
)) +
ggplot2::geom_violin()
dplyr::mutate(gene = factor(.data[["gene"]], levels = geneUse))
if (!is.null(colorBy)) {
p <- ggplot2::ggplot(
data = featureDF,
mapping = ggplot2::aes(
x = .data[[groupBy]],
y = .data[["Expression"]],
fill = .data[[colorBy]]
))
} else {
p <- ggplot2::ggplot(
data = featureDF,
mapping = ggplot2::aes(
x = .data[[groupBy]],
y = .data[["Expression"]],
fill = .data[[groupBy]]
))
}
p <- p + ggplot2::geom_violin()
if (isTRUE(box)) {
p <- p + ggplot2::geom_boxplot(alpha = boxAlpha)
}
Expand Down
2 changes: 0 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Suggests or Enhances not in mainstream repositories:
Availability using Additional_repositories specification:
DoubletFinder yes https://blaserlab.r-universe.dev
RcppPlanc yes https:/welch-lab.r-universe.dev
Package has a VignetteBuilder field but no prebuilt vignette index.
```

```
Expand Down
14 changes: 10 additions & 4 deletions man/plotClusterGeneViolin.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test_visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ test_that("Violin plots", {
)

expect_gg(
plotClusterGeneViolin(pbmcPlot, "S100A8", box = TRUE),
plotClusterGeneViolin(pbmcPlot, "S100A8", box = TRUE, colorBy = "dataset"),
plotClusterGeneViolin(pbmcPlot, "S100A8", groupBy = FALSE)
)
# General
Expand Down

0 comments on commit 6488639

Please sign in to comment.