Skip to contents

Combine predictive and observed Gaussian distributions using inverse-variance weighting, then calculate target-event probabilities at the response cutoff.

Usage

calculate_powerup_posteriors(
  predictions,
  observations,
  sample_map = NULL,
  response_cutoff = NULL
)

Arguments

predictions

POWERUP predictions containing sample, perturbation, pred_mean, pred_sd, response_cutoff, and decreasing.

observations

Prepared POWERUP observations containing sample, perturbation, observation_mean, and observation_sd.

sample_map

Optional named character vector mapping prediction sample IDs to observation sample IDs, for example c("ACH-000957" = "LS180_T1"). Samples not named in the vector are left unchanged.

response_cutoff

Optional finite response cutoff used to calculate prior and posterior target-event probabilities. If NULL, the cutoff in predictions is used.

Unmatched perturbations are omitted from posterior calculation and reported with a message. When more than three perturbations are unmatched from either input, only three examples are shown.

Value

A tibble containing the predictive prior, experimental observation, Gaussian posterior response distribution, and prior/posterior target-event probabilities relative to response_cutoff.

Examples

predictions <- data.frame(
  sample = c("sample_a", "sample_a"),
  perturbation = c("target_a", "target_b"),
  pred_mean = c(0.30, 0.70),
  pred_sd = c(0.20, 0.20),
  response_cutoff = c(0.50, 0.50),
  decreasing = c(FALSE, FALSE)
)
observations <- data.frame(
  sample = c("sample_a", "sample_a"),
  perturbation = c("target_a", "target_b"),
  observation_mean = c(0.40, 0.90),
  observation_sd = c(0.10, 0.15)
)

posteriors <- calculate_powerup_posteriors(predictions, observations)
posteriors
#> # A tibble: 2 × 15
#>   sample   perturbation response_cutoff decreasing prior_mean prior_sd
#>   <chr>    <chr>                  <dbl> <lgl>           <dbl>    <dbl>
#> 1 sample_a target_a                 0.5 FALSE             0.3      0.2
#> 2 sample_a target_b                 0.5 FALSE             0.7      0.2
#> # ℹ 9 more variables: prior_prob_target_event <dbl>, observation_mean <dbl>,
#> #   observation_sd <dbl>, posterior_mean <dbl>, posterior_sd <dbl>,
#> #   posterior_pi_lower_95 <dbl>, posterior_pi_upper_95 <dbl>,
#> #   posterior_prob_target_event <dbl>, posterior_status <chr>