Open arnssino opened 6 years ago
Sorry, without a minimal reproducible example I cannot help you. The trick usually is to manually increase the domain of the y-axis (ylim(-5, 20)
) to make sure that all the annotations are displayed.
Hi const-ae,
I had the same issue as arnssino. I really like the 'ggsignif' package, but I would highly recommend that there be a way to move the annotations (labels) for the significance bars and symbols. In my instance, my original data had some extreme outliers, which I did not want to show in my geom_boxplot. So, I removed the extreme outliers for visual purposes. The big issue is that I am unable to correctly display the results of the 'geom_signif' function from the "original data", because the function still wants to put the annotations/labels way up high on the y-axis of my geom_boxplot of the "outliers removed" data.
Fortunately the 'geom_signif' results from the "outliers removed" data were the same on the "original" data (significance level), so it was not an issue. However, if they were different then that would be an issue.
Just a thought.
Best, Brittany
Hi Brittany,
I have to admit, I am still not quite sure that I understand what this issue is about.
I made a small reproducible example, where I use ylim(ymin, ymax)
to cutoff some values and the annotation diseappears. Is that the problem that you are describing?
library(ggplot2)
library(ggsignif)
ggplot(mtcars, aes(x=as.factor(cyl), y=mpg)) +
geom_boxplot() +
geom_signif(comparison = list(c("4", "6")),
y_position = 40) +
coord_cartesian(ylim = c(0, 50))
#> Warning in wilcox.test.default(c(22.8, 24.4, 22.8, 32.4, 30.4, 33.9,
#> 21.5, : cannot compute exact p-value with ties
ggplot(mtcars, aes(x=as.factor(cyl), y=mpg)) +
geom_boxplot() +
geom_signif(comparison = list(c("4", "6")),
y_position = 40) +
coord_cartesian(ylim = c(0, 50)) +
ylim(0, 25)
#> Warning: Removed 6 rows containing non-finite values (stat_boxplot).
#> Warning: Removed 6 rows containing non-finite values (stat_signif).
#> Warning in wilcox.test.default(c(22.8, 24.4, 22.8, NA, NA, NA, 21.5, NA, :
#> cannot compute exact p-value with ties
#> Warning: Removed 3 rows containing missing values (geom_signif).
Created on 2019-07-01 by the reprex package (v0.2.1)
Hello, That is similar to what I was talking about. I tried creating a small reproducible example of my exact problem and it was taking too long - sorry. But your example is similar enough. It would just be really great to have a way to adjust the p-value labels so they're not cut off when adjusting the y-axis limits. Thanks, Brittany
Hi Brittany,
no problem. I agree that it would be nice to have that feature, the problem is that removing elements outside of the ylim()
is pretty deeply engrained in ggplot, so I don't think that there is an easy fix from my side. But what I might be able to do, is to provide a helpful warning that tells the user that the annotation was just cut off and that they should rather use coord_cartesian(ylim=c(...))
or filter the data before calling ggplot()
. Unfortunately, I am fairly busy right now, so I cannot promise that I will get around to address the issue soon.
Best, Constantin
I'm running into a similar issue here, which I think is best split in two parts, taking the original reprex as a starting point (ggsignif=0.6.4
):
library(ggplot2)
library(ggsignif)
ggplot(mtcars, aes(x=as.factor(cyl), y=mpg)) +
geom_boxplot() +
geom_signif(comparison = list(c("4", "6")),
y_position = 40) +
coord_cartesian(ylim = c(0, 50))
Note how the bar below is no longer at 40, but above that (and the end of tips also end above 40). I'm not sure if this is intended.
library(ggplot2)
library(ggsignif)
mtcars$mpg[mtcars$cyl=="4"][1] = 1000
ggplot(mtcars, aes(x=as.factor(cyl), y=mpg)) +
geom_boxplot() +
geom_signif(comparison = list(c("4", "6")),
y_position = 40) +
coord_cartesian(ylim = c(0, 50)) # removing this line draws the comparison higher than y_position
If I then set the limits much above the requested y_position
, the comparison is shown again:
library(ggplot2)
library(ggsignif)
mtcars$mpg[mtcars$cyl=="4"][1] = 1000
ggplot(mtcars, aes(x=as.factor(cyl), y=mpg)) +
geom_boxplot() +
geom_signif(comparison = list(c("4", "6")),
y_position = 40) +
coord_cartesian(ylim = c(0, 100))
Hi,
I am using this wonderful package, which I found very useful to my work, and I am faced with a little problem here. I am trying to do a violin plot using Seurat package.
It needs a bit of refinement because the annotation overlaps other part of the plot, so I set y_position from 8 to 9
However, the annotation disappeared, and I do not know how to fix this. Thank you very much in advance!