View source: R/plot_all_networks.R
| plot_diff_network | R Documentation |
Plots differential networks (treatment - control) with flexible output: - Combined mode: solid/dashed edges in a single plot (default) - Separate mode: solid/dashed edges as two independent plots
plot_diff_network(
diff_mat,
gene_names,
solid_threshold = 0.5,
dashed_threshold = -0.5,
solid_color = "#ADD8E6",
dashed_color = "#ADD8E6",
output_mode = c("combined", "separate"),
...
)
diff_mat |
Differential matrix (treatment - control, rows/columns = gene names). Matrices returned by Bayesian-mode run_scNPM carry a scNPM_selection attribute; its selected edge masks are used directly, without re-thresholding. |
gene_names |
Vector of gene names (matches diff_mat row/column names). |
solid_threshold |
Minimum positive difference for unannotated matrices (default = 0.5); ignored for matrices carrying Bayesian selection masks. |
dashed_threshold |
Maximum negative difference for unannotated matrices (default = -0.5); ignored for matrices carrying Bayesian selection masks. |
solid_color |
Color for solid edges (treatment-enhanced, default = "#ADD8E6", the original scNPM light blue; set e.g. "#2ECC71" for green). |
dashed_color |
Color for dashed edges (treatment-reduced, default = "#ADD8E6", the original scNPM light blue; set e.g. "#F39C12" for orange). |
output_mode |
Output type: "combined" (single plot, default) or "separate" (two plots). |
... |
Additional parameters passed to plot_network_core() (separate mode) or internal plotting (combined mode). |
- If output_mode = "combined": ggplot object (single plot with solid/dashed edges) or NULL (no edges) - If output_mode = "separate": list of ggplot objects (solid/dashed) or NULL for empty edges
# Self-contained example with a small random differential matrix (< 5 sec)
set.seed(1)
gn <- paste0("Gene_", 1:10)
dm <- matrix(rnorm(100), 10, 10, dimnames = list(gn, gn))
dm <- (dm + t(dm)) / 2
diag(dm) <- 0
# Mode 1 - Combined (solid+dashed in one plot, default colors: light blue)
p_combined <- plot_diff_network(
diff_mat = dm,
gene_names = gn,
output_mode = "combined"
)
# Mode 2 - Separate (solid/dashed as two plots; custom colors optional)
p_separate <- plot_diff_network(
diff_mat = dm,
gene_names = gn,
output_mode = "separate",
solid_color = "#2ECC71",
dashed_color = "#F39C12",
label_size = 3
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.