Calculate POWERUP posterior response distributions
Source:R/posteriors.R
calculate_powerup_posteriors.RdCombine predictive and observed distributions using inverse-variance weighting on an optional outcome-appropriate latent Gaussian scale. Returned response summaries remain on the original biological response scale.
Usage
calculate_powerup_posteriors(
predictions,
observations,
sample_map = NULL,
response_cutoff = NULL,
response_transform = c("identity", "logit", "log", "log10")
)Arguments
- predictions
POWERUP predictions containing
sample,perturbation,pred_mean,pred_sd,response_cutoff, anddecreasing.- observations
Prepared POWERUP observations containing
sample,perturbation,observation_mean, andobservation_sd. Barcode-count observations may additionally provide a directly estimated latent 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 inpredictionsis used.- response_transform
Scale used for Gaussian evidence integration. One of
"identity","logit","log", or"log10"."identity"preserves the original Gaussian-Gaussian behavior. Use"logit"for responses in(0, 1)and"log"or"log10"for strictly positive responses.
Value
A tibble containing original-scale predictive, experimental, and posterior summaries, target-event probabilities, and latent-scale diagnostics used for the update. Unmatched perturbations are omitted from posterior calculation and reported with a message.
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 × 23
#> 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
#> # ℹ 17 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>,
#> # response_transform <chr>, response_cutoff_latent <dbl>,
#> # prior_latent_mean <dbl>, prior_latent_sd <dbl>,
#> # observation_latent_mean <dbl>, observation_latent_sd <dbl>, …