dot-ibdCluster: Cluster individuals by local IBD-like similarity in sliding...

.ibdClusterR Documentation

Cluster individuals by local IBD-like similarity in sliding windows

Description

Internal helper that applies a sliding-window clustering procedure across a genotype matrix. For each window of markers, individuals are grouped using an opposing-homozygote style criterion (controlled by maxOH) via a native C++ routine.

Usage

.ibdCluster(genotype, cpus, windowsSize, maxOH)

Arguments

genotype

A numeric matrix of genotypes with individuals in rows and markers/SNPs in columns. This function treats genotype code '1' (heterozygote) as missing by converting it to '9' prior to calling the native routine.

cpus

Integer scalar. Requested number of CPU threads. The underlying C++ implementation uses OpenMP; the actual number of threads may depend on how R and your compiler toolchain were built and configured.

windowsSize

Integer scalar giving the window size (in markers). Must be between 1 and ncol(genotype). Internally, the native routine uses a 0-based offset window length of windowsSize - 1.

maxOH

Integer scalar. Maximum allowed opposing-homozygote count (or a similar mismatch threshold) used by the native grouping algorithm within each window.

Details

This function is a thin R wrapper around the native routine ibdCluster implemented in C++ and called via .Call().

The function scans windows of consecutive markers. For each window starting at marker i, it clusters individuals based on the submatrix genotype[, i:(i+windowsSize-1)] after recoding heterozygotes ('1') to missing ('9'). Computation is parallelized in C++ using OpenMP across window start positions.

Value

A list (R "list" object) of length ncol(genotype) - (windowsSize - 1). Each element corresponds to one sliding window position and contains an integer vector of group assignments produced by the native implementation. (Exact encoding of groups is defined by the underlying mhMat grouping routine.)


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