| pairwise_edges | R Documentation |
Helpers that turn a continuous, pairwise similarity signal into the
thresholded, undirected edges consumed by
derive_split_constraints(mode = "relatedness") and
derive_split_constraints(mode = "spatial"). Only pairs that pass the
threshold become edges; the derivation modes then form groups as connected
components over those edges (transitive closure), so a chain of individually
below-radius neighbours can still land in one group.
relatedness_edges_from_kinship(
pairs,
threshold,
id1 = "id1",
id2 = "id2",
kinship = "kinship"
)
spatial_edges_from_coords(coords, radius, id = "sample_id", coord_cols = NULL)
pairs |
A data.frame of subject pairs with two id columns and a metric column. |
threshold |
Minimum kinship value (inclusive) for a pair to be kept. |
id1, id2 |
Column names in |
kinship |
Column name in |
coords |
A data.frame with one row per sample: a sample id column plus the numeric coordinate columns. |
radius |
Maximum distance (inclusive) for two samples to be adjacent. |
id |
Column name in |
coord_cols |
Character vector of coordinate columns in |
relatedness_edges_from_kinship() keeps subject pairs whose kinship (or
relatedness) coefficient is at least threshold and emits
subject_related_to edges (Subject -> Subject).
spatial_edges_from_coords() keeps sample pairs whose Euclidean
distance over the coordinate columns is at most radius and
emits sample_adjacent_to edges (Sample -> Sample).
Both return a graph_edge_set that can be combined with the other node
and edge sets in build_dependency_graph(). The passing metric value is
carried on each edge as an attribute (kinship / distance).
A graph_edge_set.
pairs <- data.frame(
id1 = c("P1", "P1", "P2"),
id2 = c("P2", "P3", "P3"),
kinship = c(0.25, 0.02, 0.30)
)
relatedness_edges_from_kinship(pairs, threshold = 0.1)
coords <- data.frame(
sample_id = c("S1", "S2", "S3"),
x = c(0, 1, 9),
y = c(0, 1, 9)
)
spatial_edges_from_coords(coords, radius = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.