inst/doc/BayesVolcano.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
if (!require("BayesVolcano", quietly = TRUE)) {
  install.packages("BayesVolcano")
}

## -----------------------------------------------------------------------------
data("posterior")
head(posterior[, 1:4])

## -----------------------------------------------------------------------------
data("annotation_df")
head(annotation_df)

## -----------------------------------------------------------------------------
d <- prepare_volcano_input(posterior = posterior, annotation = annotation_df)

## -----------------------------------------------------------------------------
str(d)

## -----------------------------------------------------------------------------
d <- prepare_volcano_input(
  posterior = posterior,
  annotation = annotation_df,
  null.effect = 0.5,
  CrI_level = 0.7
)

## ----fig.width=7,fig.height=6-------------------------------------------------
plot_volcano(d)

## ----fig.width=7,fig.height=6-------------------------------------------------
plot_volcano(d,
  CrI = TRUE
)

## ----fig.width=7,fig.height=6-------------------------------------------------
plot_volcano(d,
  CrI = TRUE,
  CrI_width = TRUE
)

## ----fig.width=7,fig.height=6-------------------------------------------------
plot_volcano(d,
  color = "group"
)
plot_volcano(d,
  color = "value"
)

## ----fig.width=7,fig.height=6-------------------------------------------------
plot_volcano(d,
  CrI = TRUE,
  CrI_width = TRUE,
  color = "group"
)

## ----fig.width=7,fig.height=6-------------------------------------------------
# Customization requires the ggplot2 package
if (!require("BayesVolcano", quietly = TRUE)) {
  install.packages("BayesVolcano")
}
library(ggplot2)

p <- plot_volcano(d)

p + xlab("my informative parameter") +
  ggtitle("My amazing plot")

## ----fig.width=7,fig.height=6-------------------------------------------------
p <- plot_volcano(d)
p + geom_text(aes(label = label))

# ggrepel version
# library(ggrepel)
# p +
# geom_text_repel(aes(label=label))

## ----fig.width=7,fig.height=6-------------------------------------------------
p <- plot_volcano(d)

p + geom_text(aes(label = ifelse(abs(parameter.median) > 1.6 & # only show for parameter value > 0.5
  pi > 0.95, # only show for pi > 0.95
label, # which variable contains the label
""
))) # do not display label if outside of set ranges

## -----------------------------------------------------------------------------
sessionInfo()

Try the BayesVolcano package in your browser

Any scripts or data that you put into this service are public.

BayesVolcano documentation built on March 31, 2026, 5:06 p.m.