Skip to content

Commit

Permalink
Up
Browse files Browse the repository at this point in the history
Signed-off-by: Daena Rys <[email protected]>
  • Loading branch information
Daenarys8 committed May 22, 2024
1 parent 6e4f767 commit e5b3461
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
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.13.16
Version: 1.13.17
Authors@R:
c(person(given = "Felix G.M.", family = "Ernst", role = c("aut"),
email = "[email protected]",
Expand Down
34 changes: 34 additions & 0 deletions tests/testthat/test-3agglomerate.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,40 @@ test_that("agglomerate", {
not_uniq <- mergeFeaturesByRank(se, rank = "Species", make_unique = FALSE)
expect_true( !any( duplicated(rownames(uniq)) ) )
expect_true( any( duplicated(rownames(not_uniq)) ) )


data(GlobalPatterns, package="mia")
tse <- GlobalPatterns
tse <- transformAssay(tse, assay.type="counts", method="relabundance")
altExp(tse, "Family") <- agglomerateByRank(tse, rank="Family")
altExp(tse, "Family1") <- agglomerateByRank(tse, rank="Family", onRankOnly = TRUE)
altExp(tse, "Family2") <- agglomerateByRank(tse, rank="Family", onRankOnly = FALSE)
altExp(tse, "Family3") <- agglomerateByRank(tse, rank="Family", onRankOnly = TRUE, na.rm = TRUE)
altExp(tse, "Family4") <- agglomerateByRank(tse, rank="Family", onRankOnly = TRUE, na.rm = FALSE)
altExp(tse, "Family5") <- agglomerateByVariable(tse, f="Family", MARGIN = 'row')

# Other group is added by agglomerateByPrevalence function to collect features under threshold
actual <- agglomerateByPrevalence(tse, rank="Family", assay.type="relabundance",
detection = 0.5/100, prevalence = 20/100)
actual0 <- agglomerateByPrevalence(altExp(tse, "Family"), assay.type="relabundance",
detection = 0.5/100, prevalence = 20/100)
actual1 <- agglomerateByPrevalence(altExp(tse, "Family1"), assay.type="relabundance",
detection = 0.5/100, prevalence = 20/100)
actual2 <- agglomerateByPrevalence(altExp(tse, "Family2"), assay.type="relabundance",
detection = 0.5/100, prevalence = 20/100)
actual3 <- agglomerateByPrevalence(altExp(tse, "Family3"), assay.type="relabundance",
detection = 0.5/100, prevalence = 20/100)
actual4 <- agglomerateByPrevalence(altExp(tse, "Family4"), assay.type="relabundance",
detection = 0.5/100, prevalence = 20/100)
actual5 <- agglomerateByPrevalence(altExp(tse, "Family5"), assay.type="relabundance",
detection = 0.5/100, prevalence = 20/100)

expect_equal(nrow(actual), nrow(actual0))
expect_equal(nrow(actual), nrow(actual1))
expect_equal(nrow(actual2), 27)
expect_equal(nrow(actual3), 20)
expect_equal(nrow(actual), nrow(actual4))
expect_equal(nrow(actual), nrow(actual5))
})


Expand Down

0 comments on commit e5b3461

Please sign in to comment.