Learn R Programming

hsphase (version 3.0.0)

addSwitch: Add Switches

Description

Add switch points to haplotypes by swapping the two haplotype rows for an individual from each switch point to the end of the chromosome.

Usage

addSwitch(haplotypeMatrix, switchPoints, minLength)

Arguments

Value

A matrix of the same dimension as haplotypeMatrix with switches applied.

Details

Important: Each switch point causes a swap of the two haplotype rows for that individual from the switch position to the end.

The switchPoints list must have one element per individual (not per haplotype row). If an element is 0, no switch is applied for that individual.

If you rely on minLength to ignore nearby switches, verify your installed version enforces this rule.

See Also

groupMatSingle and fixSW

Examples

Run this code
haplotype <- matrix(c(0, 0, 0, 0,
                      1, 1, 1, 1,
                      0, 0, 1, 1,
                      1, 1, 0, 0,
                      1, 1, 1, 1,
                      0, 0, 0, 0), byrow = TRUE, nrow = 6)

switchPoints <- list(firstInd = c(2), secondInd = c(1, 3), lastInd = 0)
addSwitch(haplotype, switchPoints, 0)

Run the code above in your browser using DataLab