Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
TuomasBorman committed Jan 21, 2025
1 parent f72d505 commit 5d68c54
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mia
Type: Package
Version: 1.15.16
Version: 1.15.17
Authors@R:
c(person(given = "Tuomas", family = "Borman", role = c("aut", "cre"),
email = "tuomas.v.borman@utu.fi",
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,4 @@ Changes in version 1.15.x
+ Add functions for classifying taxa based on their average abundance
+ Add addPrevalence function that adds results of getPrevalence to rowData
+ Added support for dimred to getCrossAssociation
+ Add wrapper for PhILR transformation
8 changes: 7 additions & 1 deletion R/transformCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
#' difference threshold and determines the first point where the relative
#' change in differences between consecutive quantiles exceeds this
#' threshold. (Default: \code{0.1}).
#' \item \code{tree}: \code{phylo}. Phylogeny used in PhILR transformation.
#' If \code{NULL}, the tree is retrieved from \code{x}.
#' (Default: \code{NULL}).
#' \item \code{node.labels}: \code{Character vector}. Linkages between
#' \code{tree} and \code{x}. Used in PhILR transformation.
#' (Default: \code{NULL}).
#' }
#' @details
#'
Expand Down Expand Up @@ -691,7 +697,7 @@ setMethod("transformAssay", signature = c(x = "SingleCellExperiment"),
# Check that node.label is NULL or it specifies links between rownames and
# node labs
if( !( is.null(node.label) ||
is.character(node.label) && length(node.label) == n_FUN(x) ) ){
is.character(node.label) && length(node.label) == n_FUN(x) ) ){
stop("'node.label' must be NULL or a vector specifying links between ",
"features and node labs of 'tree'.", call. = FALSE)
}
Expand Down
6 changes: 6 additions & 0 deletions man/transformAssay.Rd

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

34 changes: 34 additions & 0 deletions tests/testthat/test-5transformCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,40 @@ test_that("transformAssay", {
test <- transformAssay(tse, method = "relabundance", altexp = altExpNames(tse))
test <- altExp(test, "Genus")
expect_equal(assay(test, "relabundance"), assay(ref, "relabundance"))

# Check that philt transformation works
skip_if_not(require("philr", quietly = TRUE))
data("GlobalPatterns")
tse <- GlobalPatterns
# The default is columns, and colTree is not present
expect_error(transformAssay(tse, method = "philr", pseudocount = 1))
# There must not be 0s
expect_error(transformAssay(tse, method = "philr", MARGIN = 1))
# Give error if tree does not match
data("esophagus")
expect_error(transformAssay(
tse, method = "philr", MARGIN = 1, pseudocount = 1,
tree = rowTree(esophagus)))
tse <- agglomerateByRank(tse, rank = "Phylum")
tse <- transformAssay(
tse, method = "philr", pseudocount = 1, MARGIN = 1L,
part.weights = "enorm.x.gm.counts",
ilr.weights = "blw.sqrt") |>
expect_message()
expect_true( "philr" %in% altExpNames(tse) )
#
test <- philr::philr(
t(assay(tse, "counts")+1),
rowTree(tse),
part.weights = "enorm.x.gm.counts",
ilr.weights = "blw.sqrt"
) |> t()
expect_equal(
assay(altExp(tse, "philr"), "philr"),
test,
check.attributes = FALSE
)
expect_equal(colData(tse), colData(altExp(tse, "philr")))
}

# TSE object
Expand Down

0 comments on commit 5d68c54

Please sign in to comment.