Skip to content

Commit

Permalink
Update UniFrac.r
Browse files Browse the repository at this point in the history
bugfix for replacing negative values produced by cmultRepl by smallest possible double.
  • Loading branch information
ruthgrace committed Mar 23, 2016
1 parent 58393b8 commit d2d9a39
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion UniFrac.r
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ getDistanceMatrix <- function(otuTable,tree,method="weighted",verbose=FALSE,prun
# add priors to zeros based on bayesian approach
otuTable.adjustedZeros <- cmultRepl(otuTable, method="CZM", output="counts")
# make any negative numbers as close to zero as possible - this is probably due to a precision error.
otuTable.adjustedZeros[which(otuTable.adjustedZeros < 0)] <- .Machine$double.eps
otuTable.adjustedZeros <- apply(otuTable.adjustedZeros,2,function(x) { x[which(x < 0)] <- .Machine$double.eps; return(x) })
readsPerSample <- apply(otuTable.adjustedZeros,1,sum)
otu.prop.adjustedZeros <- otuTable.adjustedZeros/readsPerSample
otu.prop.adjustedZeros <- as.matrix(otu.prop.adjustedZeros)
Expand Down

0 comments on commit d2d9a39

Please sign in to comment.