Skip to content

agglomerateByPrevalence introduces wrong relative abundances #791

@artur-sannikov

Description

@artur-sannikov

Describe the bug
After running agglomerateByPrevalence on a relative abundance assay, the total sum of relative abundances per sample is no longer 1.

To Reproduce

library(mia)
data("GlobalPatterns", package = "mia")
tse <- GlobalPatterns

tse <- transformAssay(tse, method = "relabundance")
print(sum(assay(tse, "relabundance")[, "CL3"])) # [1] 1

tse <- agglomerateByPrevalence(
  tse,
  assay.type = "relabundance",
  rank = "Genus"
)
print(sum(assay(tse, "relabundance")[, "CL3"])) # [1] 0.3980999

Expected behavior
It's supposed to return 1 after the agglomeration.

Additional context
Independently verified with another dataset: https://ebi-metagenomics.github.io/HoloFoodR/articles/case_study.html#analyzing-microbiota-time-and-treatment-effects

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions