Skip to content

Commit

Permalink
Update plotExpression.R (#211)
Browse files Browse the repository at this point in the history
* Update plotExpression.R

Ensure `log2_values` actually does what it's supposed to

* Add unit test

* Bump version

---------

Co-authored-by: Alan O'Callaghan <[email protected]>
  • Loading branch information
PeteHaitch and alanocallaghan authored Jul 18, 2024
1 parent 7091047 commit d14427e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Authors@R: c(
person("Leo", "Lahti", role=c("ctb"), email="[email protected]", comment = c(ORCID = "0000-0001-5537-637X")),
person("Tuomas", "Borman", role = c("ctb"), comment = c(ORCID = "0000-0002-8563-8884"))
)
Version: 1.33.3
Date: 2024-07-16
Version: 1.33.4
Date: 2024-07-18
License: GPL-3
Title: Single-Cell Analysis Toolkit for Gene Expression Data in R
Description: A collection of tools for doing various analyses of
Expand Down
2 changes: 1 addition & 1 deletion R/plotExpression.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ plotExpression <- function(object, features, x = NULL,
nfeatures <- length(features)

if (log2_values) {
exprs_val <- lapply(exprs_vals, function(x) log2(x + 1))
exprs_vals <- lapply(exprs_vals, function(x) log2(x + 1))
ylab <- paste0("Expression (", assay.type, "; log2-scale)")
} else {
ylab <- paste0("Expression (", assay.type, ")")
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-plot-exprs.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,10 @@ test_that("plotExpression with binning", {
bins = 10, colour_by = "Gene_0002", hex = TRUE,
summary_fun = "mean"))
})


test_that("log2_values works as expected", {
g1 <- plotExpression(example_sce, features=rownames(example_sce)[1:10], assay.type="counts", log2_values=FALSE)
g2 <- plotExpression(example_sce, features=rownames(example_sce)[1:10], assay.type="counts", log2_values=TRUE)
expect_false(isTRUE(all.equal(g1$data$Y, g2$data$Y)))
})

0 comments on commit d14427e

Please sign in to comment.