
Check a long-format multi-locus marker genotype file, multiallelic-tolerant
Source:R/checkLinkageMarkerGenotypeFile.R
checkLinkageMarkerGenotypeFile.RdValidates the structure of a long-format marker genotype table (one row
per id x locus), the same schema
checkMarkerGenotypeFile checks – but, unlike that function,
does not require every locus to be biallelic. This is a new, sibling
validator for the linkage-aware and haplotype-block metrics family (issue
#153): real colony marker panels (e.g. microsatellite/STR panels) are
routinely multiallelic, a data shape the KING-robust kinship estimator
checked by checkMarkerGenotypeFile cannot represent, but
which buildMarkerGenotypeMatrix pivots without error.
checkMarkerGenotypeFile itself, and everything downstream of
it (markerKinship), is untouched by this function.
Value
The genotype dataframe, checked to ensure the column count,
first-column identity, and row uniqueness are all valid. The returned
dataframe has its column names forced to c("id", "locus", "allele1",
"allele2").
Details
All of checkMarkerGenotypeFile's structural checks are
retained – exactly four columns, id as the first column, no
duplicate id x locus rows – except the per-locus
more-than-two-distinct-alleles rejection, which is deliberately omitted.
Examples
library(nprcgenekeepr)
markerGenotype <- data.frame(
id = c("W", "X", "Y", "Z"),
locus = c("L1", "L1", "L1", "L1"),
allele1 = c("A", "A", "A", "A"),
allele2 = c("B", "C", "A", "D"),
stringsAsFactors = FALSE
)
checkLinkageMarkerGenotypeFile(markerGenotype)
#> id locus allele1 allele2
#> 1 W L1 A B
#> 2 X L1 A C
#> 3 Y L1 A A
#> 4 Z L1 A D