Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getPrevalence, NA values #486

Merged
merged 14 commits into from
Mar 5, 2024
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.11.3
Version: 1.11.4
Authors@R:
c(person(given = "Felix G.M.", family = "Ernst", role = c("aut"),
email = "[email protected]",
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ Changes in version 1.9.x
Changes in version 1.11.x
+ loadFromMetaphlan: support strain rank
+ agglomerateByRank: agglomerate tree fix
+ getPrevalence: bugfix, if assay contains NA values, it does not end up to NA anymore.
5 changes: 4 additions & 1 deletion R/getPrevalence.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,15 @@ setMethod("getPrevalence", signature = c(x = "ANY"),
stop("'sort' must be TRUE or FALSE.", call. = FALSE)
}
#

if (include_lowest) {
prev <- x >= detection
} else {
prev <- x > detection
}
# If there were taxa with NA values, convert NA values to FALSE -->
# not detected.
prev[ is.na(prev) ] <- FALSE
# Calculate prevalence for each taxa
prev <- rowSums(prev)
# Always return prevalence as a relative frequency.
# This helps to avoid confusion with detection limit
Expand Down
Loading