Skip to contents

Calculates the Spearman correlation between the edge weights of two sparse graphs, considering the union of their non-zero edges and filling missing edges with 0. Only the upper triangle of the matrices is considered.

Usage

compute_graph_correlation(W_graph1, W_graph2, max_edges = 2e+06)

Arguments

W_graph1

A sparse, symmetric matrix (`Matrix::dgCMatrix`, `V_p x V_p`). Assumed to have z-scored non-zero entries.

W_graph2

A sparse, symmetric matrix (`Matrix::dgCMatrix`, `V_p x V_p`). Assumed to have z-scored non-zero entries.

max_edges

An integer or `Inf`. If the number of unique edges in the union of the upper triangles exceeds `max_edges`, a random sample of `max_edges` edges will be used for the correlation calculation. Defaults to 2,000,000.

Value

The Spearman correlation coefficient (`rho`) between the edge weights of the two graphs based on the union of their upper triangle edges. Returns `NA` if correlation cannot be computed (e.g., too few edges, zero variance).