Learn R Programming

hsphase (version 2.0.4)

.fastdist: Calculate Genotypic Distances

Description

Calculates a symmetric matrix of distances between genotypes, based on a given genotype matrix. Each row in the `GenotypeMatrix` represents a genotype, and each column represents a marker. The genotype is coded as 0 for AA, 1 for AB, and 2 for BB. Use 9 to represent missing data.

Usage

.fastdist(GenotypeMatrix)

Value

Returns a symmetric matrix of distances between the genotypes specified in the `GenotypeMatrix`. Row and column names of the returned matrix correspond to the row names of the `GenotypeMatrix`.

Arguments

GenotypeMatrix

A matrix where each row represents a genotype and each column represents a marker. Genotypes should be coded as 0 for AA, 1 for AB, and 2 for BB, with 9 representing missing data.

Examples

Run this code
# Simulate genotype data for 40 individuals across 1000 SNPs
# genotypes <- simulateHalfsib(numInd = 40, numSNP = 1000, recbound = 0:6, type = "genotype")
# Calculate the distance matrix
# dist_matrix <- fastdist(genotypes)
# Display the distance matrix
# print(dist_matrix)

Run the code above in your browser using DataLab