dot-prManual: Manual recursive clustering using an OH matrix and a fixed...

.prManualR Documentation

Manual recursive clustering using an OH matrix and a fixed threshold

Description

Performs a recursive hierarchical clustering on an opposing-homozygotes (OH) matrix using Ward clustering and splits clusters until the maximum within- cluster OH value is below a user-supplied threshold (maxsnpnooh).

Usage

.prManual(oh, maxsnpnooh)

Arguments

oh

A numeric matrix representing opposing-homozygotes (OH) counts between individuals. Row and column names should be individual IDs. The matrix is expected to be square and symmetric.

maxsnpnooh

Numeric scalar giving the maximum allowed within-group OH value. Groups with a larger maximum OH value (and size > 2) are split recursively.

Details

The function returns a two-column data frame with individual IDs and a group code. Group codes are generated randomly (via rnorm()) and therefore are not stable across runs.

The recursion proceeds as follows:

  1. Compute a pairwise distance object from oh using .fastdist and convert it to a dist object.

  2. Apply hierarchical clustering using hclust with method = "ward.D".

  3. Cut the dendrogram into two groups using cutree.

  4. For each group, compute the maximum within-group OH value; if it exceeds maxsnpnooh and the group has more than two individuals, recurse into that subgroup. Otherwise, write group assignments and stop.

Value

A data.frame with columns:

id

Individual ID (character).

group

An integer-like group code (generated randomly; not reproducible).

Side effects

This function writes to and reads from a file named "temp.txt" in the current working directory, and then deletes it. It also prints maxsnpnooh to the console.

See Also

hclust, cutree, as.dist


hsphase documentation built on Feb. 17, 2026, 5:07 p.m.