Commit 528f77ca authored by Amine  GHOZLANE's avatar Amine GHOZLANE
Browse files

Repair case where the tree is not loaded

parent 978f4414
......@@ -208,13 +208,25 @@ CheckTreeFile <- function(tree)
Error = NULL
Warning = NULL
if(!is.phylo(tree) && is.null(Error)){Error = "The loaded file is not a phylogenetic tree"; tree = NULL}
if(!is.rooted(tree) && is.null(Error) ){Warning = "The tree has been rooted using midpoint method"; tree = midpoint.root(tree)}
if(!is.rooted(tree) && is.null(Error) ){
Warning = "The tree has been rooted using midpoint method";
roottree = try(midpoint.root(tree), TRUE)
if (class(roottree) == "try-error"){
D <- cophenetic(tree)
dd <- max(D)
ii <- which(D == dd)[1]
ii <- c(ceiling(ii/nrow(D)), ii%%nrow(D))
if (ii[2] == 0) ii[2] <- nrow(D)
spp <- rownames(D)[ii]
nn <- which(tree$tip.label == spp[2])
tree <- reroot(tree, nn, tree$edge.length[which(tree$edge[,2] == nn)])
}
else tree=roottree
}
return(list(Error=Error,Warning=Warning,tree=tree))
}
## Get the percentage of annotated OTU
PercentAnnot <- function(counts,taxo)
{
......
......@@ -106,7 +106,9 @@ shinyServer(function(input, output,session) {
CheckTree = CheckTreeFile(data)
data = CheckTree$tree
print(CheckTree$Error)
print(CheckTree$Warning)
print(data)
return(list(data=data,Error = CheckTree$Error,Warning = CheckTree$Warning))
})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment