fixSW: Fixing Switch Errors

View source: R/fixSwitches.R

fixSWR Documentation

Fixing Switch Errors

Description

Fix switch errors in haplotypes for a half-sib family.

Usage

fixSW(haplotype, ohMax = 0, windowsSize = 100, minLength = 100, cpus = 2)

Arguments

haplotype

matrix. Haplotypes for a half-sib family (two rows per individual).

ohMax

integer. Maximum tolerated opposing homozygotes when grouping each partition (increase if genotyping errors exist).

windowsSize

integer. Partition size (number of SNPs).

minLength

integer. Minimum length between switches.

cpus

integer. Number of CPU threads.

Value

A haplotype matrix with switch errors corrected.

See Also

groupMatSingle and addSwitch

Examples

haplotype <- .simulateHalfsib(7, 2500, type = "haplotype")$phased
switches <- list(500,0,0,1200,c(1000,2000),500,1200)

haplotype2 <- addSwitch(haplotype, switches, 0)

gMat <- groupMatSingle(haplotype2, 100, 2, "haplotype")
imageplot(gMat, title = "Before fixing switches")

haplotype3 <- fixSW(haplotype2, 0, 100, 100)

gMat2 <- groupMatSingle(haplotype3, 100, 2, "haplotype")
imageplot(gMat2, title = "After fixing switches")

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