select_group_edges: Select Group Networks by Posterior Expected False Discovery...

View source: R/group_fdr.R

select_group_edgesR Documentation

Select Group Networks by Posterior Expected False Discovery Proportion

Description

Reconstructs marginal Rao-Blackwell slab probabilities from final-stage joint probabilities: p10 + p11 for treatment and p01 + p11 for control. Each condition and subtype is a separate family of G*(G-1)/2 unordered pairs. Probabilities are sorted decreasingly, complete tie blocks are evaluated, and the largest prefix with mean error 1-p at most fdr_level is retained. Selection uses p >= cutoff; an empty set has cutoff Inf and BFDR zero.

Usage

select_group_edges(result, fdr_level = 0.05, min_draws = 200L)

Arguments

result

Output of a staged [run_scNPM()] fit with joint probabilities.

fdr_level

BFDR target in (0,1), default 0.05, separately for each network.

min_draws

Minimum retained iterations, at least 20, default 200. Below this value, probabilities and curves are returned with empty masks.

Details

Selection is performed on the full gene panel before any subnetwork is extracted. Returned masks should be shared by plotting and sensitivity calculations. BFDR applies to each original network, not to a subsequent union over subtypes. Edge states are continuous spike/slab allocations. This estimates posterior expected FDP under the selected final model; it is not a uniform frequentist FDR guarantee. Existing staged 1.0.5 fits with saved joint probabilities can be processed without rerunning the sampler.

Value

A list with 'networks', 'summary', 'table', 'selected', 'probabilities', 'masks', 'target', 'status' and draw counts. Each named network (for example 'treatment_1') contains 'probability_matrix', 'mask', 'cutoff', 'estimated_bfdr', 'threshold_curve', 'table' and 'selected'. 'probabilities' and 'masks' each contain treatment/control G x G x K arrays. 'probability_matrix' carries a saved selection attribute for plotting.

Examples

# Synthetic retained posterior summaries for one matched pair.
# These values illustrate selection; no MCMC is run in this example.
gn <- paste0("G", 1:3)
p <- matrix(c(0,.99,.97,.99,0,.60,.97,.60,0), 3,
            dimnames = list(gn, gn))
z <- array(0, c(3,3,1))
p10 <- array(p, c(3,3,1)); p00 <- array(1-p, c(3,3,1))
diag(p00[, , 1]) <- 0
example_fit <- list(
  K = 1L, G = 3L, gene_names = gn, inference_mode = "staged",
  matching_result_df = data.frame(treatment_cluster=1L, matched_control_cluster=1L),
  sampling_schedule = list(feedback_disabled_for_retained=TRUE, retained_draws=500L),
  joint_edge_probabilities = list(p00=p00, p10=p10, p01=z, p11=z)
)
group <- select_group_edges(example_fit)
group$summary

scNPM documentation built on Oct. 19, 2026, 5:10 p.m.