plot_group_network: Plot a Selected Group Network

View source: R/plot_all_networks.R

plot_group_networkR Documentation

Plot a Selected Group Network

Description

Uses the saved BFDR mask from [select_group_edges()] or a staged [run_scNPM()] fit. No probability rethresholding occurs in BFDR mode.

Usage

plot_group_network(
  edge_mat,
  gene_names = NULL,
  group_type = c("treatment", "control"),
  edge_color = "#ADD8E6",
  ...,
  selection = c("bfdr", "frequency"),
  frequency_threshold = 0.5
)

Arguments

edge_mat

A named network entry such as 'fit$group_fdr$networks$treatment_1', or its annotated 'probability_matrix'. An unannotated frequency matrix is accepted only in frequency mode.

gene_names

Gene names in the same order as the matrix. Omit to use the row names stored in the BFDR network.

group_type

Treatment or control; used for an empty-network message.

edge_color

Network edge color.

...

Additional parameters passed to plot_network_core().

selection

'bfdr' (default) uses the saved decision mask. 'frequency' explicitly requests the former descriptive display rule.

frequency_threshold

Cutoff for frequency mode only, default 0.5 with the inclusive >= operator. It is not a BFDR rule.

Value

A ggplot object or NULL for an empty selected network.

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)
plot_group_network(group$networks$treatment_1)

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