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

make map_signif_level more flexible #52

Merged
merged 6 commits into from
Feb 20, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions R/significance_annotation.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ StatSignif <- ggplot2::ggproto("StatSignif", ggplot2::Stat,
stop(paste0("annotations contains a different number of elements (", length(params$annotations),
") than comparisons or xmin (", max(length(params$comparisons),length(params$xmin), 1), ")."))

if(all(params$map_signif_level == TRUE)){
if(all(is.logical(params$map_signif_level)) && all(params$map_signif_level == TRUE)){
params$map_signif_level <- c("***"=0.001, "**"=0.01, "*"=0.05)
}else if(is.numeric(params$map_signif_level)){
if(is.null(names(params$map_signif_level)) ){
Expand Down Expand Up @@ -82,12 +82,14 @@ StatSignif <- ggplot2::ggproto("StatSignif", ggplot2::Stat,
}else{
temp_value
}
}else if(is.function(map_signif_level)){
map_signif_level(p_value)
}else{
if(is.numeric(p_value)){
if(p_value < 2.2e-16){
"< 2.2e-16"
if(p_value < .Machine$double.eps){
sprintf("p < %.2e", .Machine$double.eps)
}else{
as.character(signif(p_value, digits=2))
as.character(sprintf("p = %.2g"), p_value)
Copy link
Owner

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?

Copy link
Contributor Author

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".

}
}else{
as.character(p_value)
Expand Down