ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Error in grid.Call.graphics(C_setviewport, vp, TRUE) : non-finite location and/or size for viewport

Open Lan-h opened this issue 4 years ago • 1 comments

Hi,

Thank you for the ggtree package. Unfortunately, I did not manage to use geom_insent. Here is the error message I get:

Error in grid.Call.graphics(C_setviewport, vp, TRUE) : non-finite location and/or size for viewport

This error has been mentioned in a previous issue after it has been closed: https://github.com/YuLab-SMU/ggtree/issues/289

Here is the tree and data I would like to plot: current_tree = read.tree(text = "(seq10:3,(seq18:6)seq11:3,(seq15:4,seq20:5)seq12:4,(seq16:3)seq14:5,seq19:9,seq2:1,seq3:1,seq4:1,(seq7:1)seq5:1,(seq17:8)seq6:1,seq8:2,(seq13:1)seq9:3)seq1:0;" )

dat A B C node 223 760 57 seq1 0 9 4 seq11 1 4 8 seq12 2 3 7 seq14 1 6 2 seq5 1 6 2 seq6 1 4 2 seq9

pies <- nodepie(dat, cols=1:3, alpha=.6) # works pggtree <- ggtree(current_tree) # works inset(pggtree, pies, width = .1, height = .1) # not working

I tried to change the insent function according to this commit: https://github.com/YuLab-SMU/ggtree/commit/5e2806b637890172bf1cc5036e15b2ee8d623edb#, to reinstall the packages etc... but it did not work

Session info: rvcheck_0.2.1 ggimage_0.3.0 ggtree_3.0.4 ape_5.6-1

Thank you in advance for your help!

NB: the tree is not binary here but I don't think it is the main issue

Lan-h avatar Jan 31 '22 16:01 Lan-h

I think I managed to make it work by replacing the node labels in the data frame as follow:

x = as.tibble(current_tree) head(x) parent node branch.length label 1 7 3 0 seq1 2 7 5 3 seq3 3 8 9 2 seq4 *(after some ordering steps) * dat$node = x$node

Lan-h avatar Feb 07 '22 12:02 Lan-h