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

Fix species richness for non-integer data (e.g., OTU proportions) #891

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions R/extend_vegan.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ setMethod("vegdist", "phyloseq", function(x, method = "bray", binary = FALSE,
#' @importFrom vegan estimateR
#' @importFrom vegan diversity
#' @importFrom vegan fisher.alpha
#' @importFrom vegan specnumber
#' @export
#' @examples
#' ## There are many more interesting examples at the phyloseq online tutorials.
Expand Down Expand Up @@ -233,10 +234,13 @@ estimate_richness <- function(physeq, split=TRUE, measures=NULL){
# Initialize to NULL
outlist = vector("list")
# Some standard diversity indices
estimRmeas = c("Chao1", "Observed", "ACE")
if( any(estimRmeas %in% measures) ){
if( "Observed" %in% measures ){
outlist <- c(outlist, list(Observed = specnumber(OTU)))
}
estimRmeas = c("Chao1", "ACE")
if( any(estimRmeas %in% measures) ){
outlist <- c(outlist, list(t(data.frame(estimateR(OTU)))))
}
}
if( "Shannon" %in% measures ){
outlist <- c(outlist, list(shannon = diversity(OTU, index="shannon")))
}
Expand Down