-
Notifications
You must be signed in to change notification settings - Fork 43
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
make map_signif_level more flexible #52
Conversation
Hi, thank you very much for the pull request. I am currently travelling, but will take a look next week. |
draw_key_point leads to weird errors when trying to use manual xmin/xmax/annotation with data grouped by multiple aesthetics
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.
Hi Ilia, thanks again a lot for the PR. I have added some comments to the code and it would be great if you could comment on them.
Best, Constantin
R/significance_annotation.R
Outdated
}else{ | ||
if(is.numeric(p_value)){ | ||
if(p_value < .Machine$double.eps){ | ||
sprintf("p < %.2e", .Machine$double.eps) | ||
}else{ | ||
as.character(sprrintf("p = %.2g"), p_value) | ||
as.character(sprintf("p = %.2g"), p_value) |
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 think printing just the number without the "p = " in front is the better default, can you change that back?
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.
done. I just thought it would be more consistent with "p < 2e-16".
@@ -215,7 +215,7 @@ GeomSignif <- ggplot2::ggproto("GeomSignif", ggplot2::Geom, | |||
required_aes = c("x", "xend", "y", "yend", "annotation"), | |||
default_aes = ggplot2::aes(shape = 19, colour = "black", textsize = 3.88, angle = 0, hjust = 0.5, | |||
vjust = 0, alpha = NA, family = "", fontface = 1, lineheight = 1.2, linetype=1, size=0.5), | |||
draw_key = ggplot2::draw_key_point, | |||
draw_key = function(...){grid::nullGrob()}, |
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.
What does this change do?
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.
completely prevents drawing of a legend key for the ggsignif layer. In my case, I was trying to use ggsignif with geom_sina from ggforce and kept getting weird errors until I made this change.
@@ -145,6 +145,7 @@ StatSignif <- ggplot2::ggproto("StatSignif", ggplot2::Stat, | |||
#' @param map_signif_level boolean value, if the p-value are directly written as annotation or asterisks are used instead. | |||
#' Alternatively one can provide a named numeric vector to create custom mappings from p-values to annotation: | |||
#' For example: c("***"=0.001, "**"=0.01, "*"=0.05) | |||
#' Alternatively, one can provide a function that takes a numeric argument (the p-value) and returns a string |
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.
Could you maybe also add an example that demonstrates how to use the custom function, for example to show how to print the p-values as "p = 0.03"?
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.
done
Thank you again, I have merged the PR and will submit the updated package to CRAN soon. |
map_signif_level can now take a user-supplied function to format the p-value. Also, this pull-request changes the default threshold for printing exact p-values to .Machine$double.eps (should still be 2e-16 on most computers)