-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
class2tree checks duplicated taxa in higher levels, resolve #934
- Loading branch information
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,6 +396,35 @@ rank_indexing <- function (rankList) { | |
#' @author Vinh Tran {[email protected]} | ||
taxonomy_table_creator <- function (nameList, rankList) { | ||
colnames(nameList)[1] <- "tip" | ||
# remove duplicated taxa (e.g. taxa with higher levels, that already belong | ||
# to the taxonomy string of other taxa) | ||
duplicatedTaxa <- lapply( | ||
nameList$X1, | ||
function (x) { | ||
matchs <-data.frame(which(nameList[,-1] == x, arr.ind=TRUE)) | ||
checkHigherRank <- lapply( | ||
matchs$row, | ||
function(y) { | ||
if (nameList[y,]$X1 != x) return(1) | ||
} | ||
) | ||
if (length(unlist(checkHigherRank)) > 0) | ||
return(strsplit(x, "#", fixed = TRUE)[[1]][1]) | ||
} | ||
) | ||
if (length(unlist(duplicatedTaxa)) > 0) { | ||
msg <- paste("WARNING:", length(unlist(duplicatedTaxa))) | ||
msg <- "duplicated taxa have been ignored!" | ||
if (length(unlist(duplicatedTaxa)) == 1) | ||
msg <- "duplicated taxon has been ignored!" | ||
if (length(unlist(duplicatedTaxa)) < 5) { | ||
msg <- paste(msg, "Including: ") | ||
msg <- c(msg, paste(unlist(duplicatedTaxa), collapse = "; ")) | ||
} | ||
message(msg) | ||
} | ||
nameList <- nameList[!(nameList$tip %in% unlist(duplicatedTaxa)),] | ||
rankList <- rankList[!(rankList$tip %in% unlist(duplicatedTaxa)),] | ||
# get indexed rank list | ||
index2RankDf <- rank_indexing(rankList) | ||
# get ordered rank list | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters