Skip to content
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

Ggtree fails to display boxplots with high values #96

Closed
seth-1 opened this issue Nov 16, 2016 · 12 comments
Closed

Ggtree fails to display boxplots with high values #96

seth-1 opened this issue Nov 16, 2016 · 12 comments

Comments

@seth-1
Copy link

seth-1 commented Nov 16, 2016

Hi! Thanks for creating this great package!

I tried to combine a boxplot and a tree using facet_plot. Unfortunately, when displaying boxplots with high values, the plot seems to adjust ylim automatically so the plot 'disappears'.

tr <- rtree(30)
p <- ggtree(tr)
d4 = data.frame(id=rep(tr$tip.label, each=20), val=as.vector(sapply(1:30, function(i) rnorm(20, mean=i))) )
# Works fine
facet_plot(p, panel="Boxplot", data=d4, geom_boxploth, mapping = aes(x=val, group = label))

d5 <- d4
d5$val <- d5$val*100
# Disappears to the bottom of the device
facet_plot(p, panel="Boxplot", data=d5, geom_boxploth, mapping = aes(x=val, group = label)) 

Correct plot

correctplot

Compressed plot

highvalues

@GuangchuangYu
Copy link
Member

> p <- ggtree:::add_panel(p, 'Boxplot')
> df = p %+>% d5
> head(df)
  label branch.length y isTip  .panel      val
1    t1     0.1369876 4  TRUE Boxplot 2722.792
2    t1     0.1369876 4  TRUE Boxplot 2606.299
3    t1     0.1369876 4  TRUE Boxplot 2707.818
4    t1     0.1369876 4  TRUE Boxplot 2769.059
5    t1     0.1369876 4  TRUE Boxplot 2623.170
6    t1     0.1369876 4  TRUE Boxplot 2845.702
> ggplot(df) + geom_boxploth(aes(x=val, y=label, group=label)) -> p1
> ggplot(df) + geom_boxploth(aes(x=val, y=y, group=label)) -> p2
> multiplot(p1, p2, ncol=2)

screen shot 2016-11-16 at 9 21 32 pm

This seems to be an issue of ggstance. Maybe @lionel- can help.

@lionel-
Copy link

lionel- commented Nov 16, 2016

It seems to work fine with latest ggstance/ggplot2.

@wcornwell
Copy link

I am also having this issue with these versions:

ggtree_1.7.4
ggplot2_2.2.0.9000
ggstance_0.3

not sure what's going on but I'm getting the same behaviour as @seth-1 describes.

@Andreas-Bio
Copy link

Andreas-Bio commented Dec 27, 2016

I get the same error. A temporary workaround that works for me is to divide all data in the right panel by 10000.

My guess is that the y coordinate is not transferred correctly. Because if the right figure data goes larger as the number of tips it goes crazy. If it is smaller it is fine.

clipboard01

ggstance_0.3
ggtree_1.6.5 
ggplot2_2.2.0

data[,2] <- data[,2]/10000

clipboard02

@lionel-
Copy link

lionel- commented Dec 28, 2016

could you post your R version please? ggstance fails CRAN's checks with old versions of R, this may be related.

@Andreas-Bio
Copy link

Andreas-Bio commented Dec 31, 2016

sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252

attached base packages:
[1] stats4 parallel stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggstance_0.3 ggtree_1.6.5 ggplot2_2.2.0 Biostrings_2.42.1 XVector_0.14.0
[6] IRanges_2.8.1 S4Vectors_0.12.1 BiocGenerics_0.20.0 rentrez_1.0.4 taxize_0.8.0
[11] magrittr_1.5 ips_0.0-7 XML_3.98-1.5 colorspace_1.3-2 ape_4.0

@lionel-
Copy link

lionel- commented Jan 31, 2017

Hi all. Could you confirm that with the latest ggstance version (the one on github as it has not yet been sent to CRAN), the issue is fixed?

@wcornwell
Copy link

The scaling issue looks like resolved, at least for me. Thanks!

By the way, is there any way to get an axis on the horizontal boxplot atm?

@lionel-
Copy link

lionel- commented Feb 1, 2017

I'm not sure what you mean? But anything that is possible with vertical boxplots should be possible with horizontal ones, otherwise it's presumably a bug.

@GuangchuangYu
Copy link
Member

@lionel- here is another example, https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/bioc-ggtree/RgI8M4DDBT8/7Kp-hyNqAQAJ.

screen shot 2017-03-09 at 12 03 50 pm

Although y is correct, as shown in layer_data(p, 5)$y %>% range, without ylim the figure can't render properly.

@lionel-
Copy link

lionel- commented Mar 9, 2017

Can you open an issue with a small reprex at the ggstance repo please.

@GuangchuangYu
Copy link
Member

GuangchuangYu commented Jul 20, 2018

good news from @lionel- that the issue has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants