Skip to content

Commit bb42cae

Browse files
polish documentation
1 parent 23e2551 commit bb42cae

File tree

12 files changed

+82
-64
lines changed

12 files changed

+82
-64
lines changed

DESCRIPTION

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ BugReports: https://github.com/KatjaDanielzik/BayesVolcano/issues
1212
Description: Bayesian models are used to estimate effect sizes (e.g., gene expression changes,
1313
protein abundance differences, drug response effects) while accounting for uncertainty,
1414
small sample sizes, and complex experimental designs.
15-
However, Bayesian outputs are often difficult to interpret at a glance.
16-
One way to quickly identify important biological changes of frequentist analysis
15+
However, Bayesian posteriors of models with many parameters are often difficult to interpret at a glance.
16+
One way to quickly identify important biological changes based on frequentist analysis
1717
are volcano plots (using fold-changes and p-values).
18-
Bayesian volcano plots bring together the uncertainty aware power of Bayesian
19-
models and the familiar visualization of volcano plots.
18+
Bayesian volcano plots bring together the explicit treatment of uncertainty in
19+
Bayesian models and the familiar visualization of volcano plots.
2020
License: GPL (>= 3)
2121
Encoding: UTF-8
2222
Roxygen: list(markdown = TRUE)

R/plot_volcano.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ plot_volcano <- function(result,
4545
label.parameter.threshold = NULL,
4646
label.pi.threshold = NULL,
4747
title = "Bayesian Volcano Plot",
48-
xlab = "parameter value"){
48+
xlab = "median parameter value"){
4949

5050
# Input validation
5151
if (!is.list(result) || !("result" %in% names(result)) || !("meta" %in% names(result))) {
@@ -93,14 +93,14 @@ plot_volcano <- function(result,
9393

9494
# create base plot ####
9595
## get threshold
96-
t <- result$meta$threshold
96+
t <- result$meta$zero.effect
9797

98-
subtitle <- paste0("vertical black line: threshold for pi = ",t)
98+
subtitle <- paste0("vertical black line: zero effect of parameter = ",t)
9999

100100
p <- ggplot(df,(aes(x=parameter.median,y=pi.value))) +
101101
geom_point()+
102102
theme_bw()+
103-
# mark user set threshold
103+
# mark user set zero.effect
104104
geom_vline(aes(xintercept=t))+
105105
xlab(xlab)+
106106
ylab("pi")+

R/prepare_volcano_df.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
#' \item \code{label}: the biological label (e.g., `cell.line`, `time.point`)
1313
#' \item Optional: other columns (e.g., `group`, `condition`) for future coloring
1414
#' }
15-
#' @param threshold For which threshold to calculate pi. Default is 0.
15+
#' @param zero.effect Central parameter value corresponding to no effect (default t=0).
1616
#' @param CrI.low lower bound of credible interval
1717
#' @param CrI.high upper bound of credible interval
1818
#'
1919
#' @details
2020
#' Only returns pi-values and summaries for parameters that are in posterior and
21-
#' annotation_df.
21+
#' annotation_df. For formula see README or Vignette
2222
#'
2323
#'
2424
#' @return A list with:
@@ -37,7 +37,7 @@
3737
#' \itemize{
3838
#' \item \code{CrI.low}: lower CrI boundary set by user
3939
#' \item \code{CrI.high}: upper CrI boundary set by user
40-
#' \item \code{threshold}: threshold for pi set by user
40+
#' \item \code{zero.effect}: zero.effect for pi set by user
4141
#' }
4242
#'}
4343
#'
@@ -77,16 +77,16 @@
7777
prepare_volcano_df <- function(
7878
posterior,
7979
annotation_df,
80-
threshold = 0,
80+
zero.effect = 0,
8181
CrI.low = 0.025,
8282
CrI.high = 0.975
8383
) {
8484
# Input validation
8585
if (!is.data.frame(posterior)) {
8686
stop("Argument 'posterior' must be a data frame.")
8787
}
88-
if(!is.numeric(threshold)){
89-
stop("threshold has to be numeric")
88+
if(!is.numeric(zero.effect)){
89+
stop("zero.effect has to be numeric")
9090
}
9191
if (any(!is.numeric(c(CrI.low, CrI.high)))) {
9292
stop("CrI.low and CrI.high must be numeric.")
@@ -117,7 +117,8 @@ prepare_volcano_df <- function(
117117
values <- posterior[[param]]
118118

119119
# Compute stats
120-
pi_value <- .pi_value(values,threshold)
120+
pi_value <- .pi_value(value = values,
121+
zero.effect = zero.effect)
121122
median_val <- median(values)
122123
crI_low <- stats::quantile(values, probs = CrI.low, na.rm = TRUE)
123124
crI_high <- stats::quantile(values, probs = CrI.high, na.rm = TRUE)
@@ -147,5 +148,5 @@ prepare_volcano_df <- function(
147148

148149
return(list(result=result,meta=list(CrI.low=as.numeric(CrI.low),
149150
CrI.high=as.numeric(CrI.high),
150-
threshold=as.numeric(threshold))))
151+
zero.effect=as.numeric(zero.effect))))
151152
}

R/utils.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
#' Calculates pi-value as integral under
44
#'
55
#' @param value numerical vector of posterior draws
6-
#' @param threshold numerical value indicating for which treshhold to calculate pi
6+
#' @param zero.effect numerical value indicating for which treshhold to calculate pi
77
#'
88
#' @returns pi-value
99
#' @keywords internal
10-
.pi_value <- function(value, threshold) {
10+
.pi_value <- function(value, zero.effect) {
1111
l <- length(value)
12-
pi <- 2*max(sum(value<=threshold)/l, sum(value>=threshold)/l)-1
12+
pi <- 2*max(sum(value<=zero.effect)/l, sum(value>=zero.effect)/l)-1
1313
return(pi)
1414
}

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,33 @@ to interpret at a glance.
1616
One way to quickly identify important biological changes based on frequentist analysis
1717
are volcano plots (using fold-changes and p-values).
1818

19-
Bayesian volcano plots bring together the uncertainty aware power of Bayesian
20-
models and the familiar visualization of volcano plots by:
19+
Bayesian volcano plots bring together the explicit treatment of uncertainty in
20+
Bayesian models and the familiar visualization of volcano plots by:
21+
22+
1) Calculation and using ![equation](https://latex.codecogs.com/svg.image?%5Cpi)-values
23+
on the y-axis as a summary of posterior parameter values lying beyond a threshold.
24+
With *i* being one entity that was modeled, *param* the estimated parameter and *t*
25+
the central parameter value corresponding to no effect (default t=0).
26+
27+
![equation](https://latex.codecogs.com/svg.image?%5Cpi_%7Bi%7D=2*max%5Cleft(%5Cint_%7Bparam_%7Bi%7D=-%5Cinfty%7D%5E%7Bt%7Dp(param_%7Bi%7D)%5C,dparam_%7Bi%7D,%5Cint_%7Bparam_%7Bi%7D=t%7D%5E%7B%5Cinfty%7Dp(param_%7Bi%7D)%5C,dparam_%7Bi%7D%5Cright)-1)
28+
29+
30+
2) Preserving the familiar, intuitive volcano structure.
31+
32+
The figure below shows the distribution of the posterior samples on the right
33+
and their translation into a Bayesian volcano plot on the righth.
34+
35+
![](man/figures/README-explain_volcano.png)
36+
2137

22-
1) Showing posterior medians on the x-axis.
23-
2) Calculation and using ![equation](https://latex.codecogs.com/svg.image?%5Cpi)-values on the y-axis as a summary
24-
of posterior parameter values lying beyond a threshold.
25-
With *i* being one entity that was modeled and *param* the estimated parameter
26-
![equation](https://latex.codecogs.com/svg.image?%5Cpi_%7Bi%7D=2*max%5Cleft(%5Cint_%7Bparam_%7Bi%7D=-%5Cinfty%7D%5E%7B0%7Dp(param_%7Bi%7D)%5C,d%20param_%7Bi%7D,%5Cint_%7Bparam_%7Bi%7D=0%7D%5E%7B%5Cinfty%7Dp(param_%7Bi%7D)%5C,d%20param_%7Bi%7D%5Cright)-1%20)
2738

2839
3) Optional displaying credible intervals (CrIs) to visualize uncertainty.
29-
4) Preserving the familiar, intuitive volcano structure.
3040

31-
We are not the first to think about the concept of Bayesian volcano plots [Sousa et al. 2020](https://doi.org/10.1016/j.aca.2019.11.006) introduced them as a single
32-
use case (their b-values correspond to our pi-values)
33-
but to our knowledge we are the first to provide an R-package
41+
We are not the first to think about the concept of Bayesian volcano plots: [Sousa et al. 2020](https://doi.org/10.1016/j.aca.2019.11.006) introduced them as a single
42+
use case (pi-value= 1 - b-value) but to our knowledge we are the first to provide an R-package
3443
for easy calculation of pi-values and visualization.
3544

45+
3646
## Installation
3747

3848
You can install the development version of BayesVolcano from [GitHub](https://github.com/) with:
@@ -62,9 +72,10 @@ result <- prepare_volcano_df(
6272
annotation_df = annotation_df
6373
)
6474
plot_volcano(result,
65-
color="group",
66-
label="label",
67-
label.pi.threshold = 0.9,
75+
CrI = FALSE, # optional display of credible intervals
76+
color="group", # optional color coding
77+
label="label", # optional text labels
78+
label.pi.threshold = 0.9, # optional thresholds for labels
6879
label.parameter.threshold = 0.5)
6980
```
7081

man/dot-pi_value.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
2.67 KB
Loading
78.5 KB
Loading

man/plot_volcano.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/prepare_volcano_df.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)