Giter Site home page Giter Site logo

Comments (2)

ArtPoon avatar ArtPoon commented on August 19, 2024

Looks like the problem is there:

ggfree/R/tree.R

Lines 1106 to 1109 in a9717ae

if (obj$layout == 'rectangular') {
parents <- sapply(e$parent, function(p) which(obj$edges$child==p))
segments(x0=e$x0, y0=e$y0, y1=obj$edges$y0[parents], col=col, ...)
}

This returns parents as a list, not an integer vector as expected:

> head(parents)
[[1]]
[1] 4

[[2]]
[1] 5

[[3]]
[1] 6

[[4]]
[1] 7

[[5]]
[1] 8

[[6]]
[1] 9
> table(sapply(parents, length))

    0     1 
    1 45598 
> which.min(sapply(parents, length))
[1] 45519
> parents[45519]
[[1]]
integer(0)
> e[45519,]
      parent child    length isTip x0        x1       y0       y1
86210  67061 84808 0.3695876 FALSE  0 0.3695876 65882.59 65882.59
> which(obj$edges$child == 67061)
integer(0)
> Ntip(phy)
[1] 67060

The node in question is the root.

from ggfree.

ArtPoon avatar ArtPoon commented on August 19, 2024

Potential fix:

@@ -1105,6 +1107,8 @@ draw.clade <- function(obj, tips, col='red', is.mono=TRUE, max.tips=100, ...) {
 
   if (obj$layout == 'rectangular') {
     parents <- sapply(e$parent, function(p) which(obj$edges$child==p))
+    # exclude root node
+    parents <- unlist(parents)
     segments(x0=e$x0, y0=e$y0, y1=obj$edges$y0[parents], col=col, ...)
   }
   else if (obj$layout == 'radial') {

But there are extra lines being drawn:
test

from ggfree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.