-
Notifications
You must be signed in to change notification settings - Fork 173
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
branch.length parameter to work with phylo4d #102
Conversation
function(object, ...) { | ||
edge <- object[, c("parent", "node")] | ||
edge <- edge[edge[,1] != 0 & edge[,1] != edge[,2], ] | ||
edge.length <- object[, "branch.length"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i <- which(edge[,1] != 0 & edge[,1] != edge[,2])
edge <- edge[i, ]
edge.length <- object[i, "branch.length"]
otherwise edge.length will longer than nrow(edge)
@@ -394,11 +394,15 @@ fortify.phylo4 <- function(model, data, layout="rectangular", yscale="none", | |||
##' @method fortify phylo4d | |||
##' @export | |||
fortify.phylo4d <- function(model, data, layout="rectangular", yscale="none", | |||
ladderize=TRUE, right=FALSE, mrsd=NULL, ...) { | |||
ladderize=TRUE, right=FALSE, branch.length="branch.length", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look careful for other methods, you will find they all missing the branch.length
parameter.
This is not needed as it will be passed by ...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The branch.length
parameter may be passed by ...
, but it is ignored later on in the chain. The change I implemented allows ggtree to scale branch lengths of phylo4d objects.
please correct it and I will accept your you can also update
I want to acknowledge all the contributors. |
taking the example from #47:
will drop the branch length and only show cladogram. Pls show me a not working example. |
Try:
|
good catch. But your solution is not a good idea by converting tree object to data.frame and convert data.frame back to phylo. this issue had been fixed and now you can set |
If you are serious to make PR, you need to be careful of not introducing new bugs by testing your code (e.g. |
Thanks for adding branch.length support for phylo4d. I rewrote my repository to only containn the get.tree function for data.frame. It now builds and I think is ready to be pulled. Sorry about the sloppy coding. |
I find you remove It was fixed in 1a0e6ac. FYI, all the tree IO utilities will be removed when treeio was accepted to deposit on Bioconductor. Your It would be better to have unit test, like https://github.com/GuangchuangYu/treeio/blob/master/tests/testthat/test-as-phylo.R. |
I modified the fortify.phylo4d function to enable the branch.length parameter.
I also wrote a get.tree function for the data.frame type.