View source: R/compute_edge_pvalues.R
| compute_edge_pvalues | R Documentation |
This function computes p-values for the differences in edge presence between populations using statistical tests (e.g., Fisher's exact test, chi-squared test).
compute_edge_pvalues(edge_counts, N, method = "fisher", adjust_method = "none")
edge_counts |
An array of edge counts from |
N |
A vector of sample sizes for each population. |
method |
The statistical test method to use: "fisher", "chi.squared", or "prop". Default is "fisher". The "prop" method requires exactly two populations. The method is validated even when the graphs have no edges. |
adjust_method |
The method for p-value adjustment for multiple testing
(one of |
A matrix of p-values for each edge.
# Generate synthetic populations
control_graphs <- generate_category_graphs(
n_graphs = 5,
n_nodes = 10,
n_communities = 2,
base_intra_prob = 0.8,
base_inter_prob = 0.2,
seed = 1
)
patient_graphs <- generate_category_graphs(
n_graphs = 5,
n_nodes = 10,
n_communities = 2,
base_intra_prob = 0.6,
base_inter_prob = 0.4,
seed = 2
)
populations <- list(Control = control_graphs, Patient = patient_graphs)
# Compute edge frequencies
frequencies <- compute_edge_frequencies(populations)
edge_counts <- frequencies$edge_counts
N <- lengths(populations)
# Compute p-values for edge differences
edge_pvalues <- compute_edge_pvalues(edge_counts, N)
# View p-values for the first few edges
print(edge_pvalues[1:5, 1:5])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.