Reads an uploaded long-format marker genotype file (D1 format: id,
locus, allele1, allele2), validates and pivots it
(checkSequenceGenotypeFile, which applies the
checkMarkerGenotypeFile checks plus a literal-"." rejection
and a maxLoci warning, then
buildMarkerGenotypeMatrix; the Center B upload is validated
the same way),
estimates marker-based kinship independent of pedigree
(markerKinship), and surfaces a per-animal comparison of
pedigree-based mean kinship (indivMeanKin, from the pedigree
kinship given by kinshipMatrix or kinshipFor) alongside the new
marker-based mean kinship (markerMeanKin) -- an independent check
on the pedigree-implied relatedness, not a replacement for it. A second
tab surfaces the heterozygosity diagnostic: per-animal observed
heterozygosity (markerObservedHeterozygosity) alongside
population-level expected heterozygosity
(markerExpectedHeterozygosity). A third tab surfaces the
Mendelian-exclusion parentage diagnostic
(markerParentageExclusion): the pedigree's recorded
dam/sire cross-referenced against the uploaded genotypes, flagging any
recorded parent the genotype evidence contradicts. A fourth tab, "Cross-
Center", surfaces a between-population differentiation statistic
(markerFst) between the first uploaded file (implicitly
"Center A") and a second, independently uploaded Center B genotype file
-- a population-level, two-dataset comparison, unrelated to the
per-animal cross-center identity linking of
resolveCrossCenterIds (Slice 4). A fifth tab, "Candidate
Parent Assignment" (issue #147 Slice 2), surfaces
markerParentageLikelihood: for every (offspring, role) pair
the Parentage Exclusion tab's own diagnostic flags as Mendelian
-inconsistent, it ranks candidate replacement parents by a CERVUS-style
multilocus likelihood (LOD) score. This tab needs no new file input --
it reads the same uploaded genotype file and pedigree already
wired to the other tabs -- and is report-only, matching the Parentage
Exclusion tab's own precedent: it never writes to pedigree.
Candidates come from getPotentialParents, which needs the
pedigree's fromCenter column; without it the table is blank, and the
tab says so above the table.
modMarkerGeneticsServer(id, kinshipMatrix = NULL, pedigree, kinshipFor = NULL)A named list of reactive elements: markerGenotype, the
raw uploaded genotype data frame (or NULL before upload);
markerKinshipMatrix, the marker-based id x id
kinship matrix (or NULL); comparisonTable, the per-animal
indivMeanKin/markerMeanKin comparison data frame (or
NULL; indivMeanKin is NA for every row when the
pedigree kinship matrix is NULL or errors, and for any genotyped
id absent from it); heterozygosityTable, the per-animal
ho/he heterozygosity data frame (he is the
population-wide mean expected heterozygosity, repeated per row) (or
NULL); exclusionTable, the
markerParentageExclusion data frame: one row per recorded
dam/sire pair with exclusionCount, nLoci and a
flagged column (TRUE where the count exceeds the
tolerance), so pairs that are not flagged are included (or
NULL before a genotype file and a pedigree are both available);
crossCenterGenotypeB, the raw uploaded Center B genotype data
frame (or NULL before upload); crossCenterTable, the
markerFst
locus/fst data frame with a
trailing "Pooled" row (or NULL before both center files
are uploaded); candidateAssignmentTable, the
markerParentageLikelihood ranked-candidate data frame (a
zero-row, full-column-shape data frame when no pair is flagged; or
NULL before a genotype file and a pedigree are both available);
isReady, TRUE once comparisonTable has a value, and
FALSE (never an error) when it has none, including when the
uploaded genotype file cannot be used;
locusMetadataTable, the checkLocusMetadata output
(or NULL before a locus-metadata file is uploaded);
realizedRelatednessTable, the
markerRealizedRelatednessVariance output (or NULL
before the pedigree and its kinship are both available);
ldBlockTable, the markerLdBlock output (or
NULL before a genotype file and a locus-metadata file are both
uploaded, or before a pedigree is available if the founders-only
restriction is checked); ldBlockExportTable, the
obfuscateLdBlocks-de-identified export preview (or
NULL before "Generate De-Identified Export Preview" is clicked
with both ldBlockTable and pedigree available);
ldBlockExportConfirmed, FALSE until the confirm-gate
modal's own Confirm button is clicked for the current export preview;
sequenceRohTable, the computeGenomicROH output (or
NULL before a genotype file and a locus-metadata file are both
uploaded, or while a threshold input is invalid);
sequenceExportGenotypeMatrix, sequenceExportRohTable
and sequenceExportManifest, the de-identified genotype matrix,
de-identified F_ROH table and export manifest captured at
"Generate De-Identified Export Preview" (each NULL before
then, and when any genotype id is absent from the pedigree or the ROH
table or pedigree is NULL); sequenceExportConfirmed,
FALSE until that
export's confirm-gate modal is accepted for the current preview;
mhcHaplotypeSummaryTable, the mhcHaplotypeFrequency
summary data frame (or NULL before an MHC haplotype file
is uploaded, or while a rarity threshold is invalid);
mhcHaplotypeCarrierTable, the mhcHaplotypeCarriers
rare-haplotype carrier data frame (same NULL conditions);
mhcExportTables, a list of the summary, de-identified
carriers and manifest data frames captured at "Generate
De-Identified Export Preview" (or NULL before then, without a
pedigree, or while any MHC-file animal is absent from the pedigree);
and mhcExportConfirmed, FALSE until the MHC export's
confirm-gate modal is accepted for the current preview.
character vector of length 1. Module namespace identifier.
optional reactive returning the full pedigree-based
kinship matrix (row and column names are animal IDs), or NULL
while upstream analysis has not yet been run. It is used before
kinshipFor.
reactive returning the current pedigree data frame
(columns id, sire, dam), or NULL while
upstream analysis has not yet been run.
optional function of a character vector of animal IDs
that returns those animals' kinship matrix; with no IDs it returns every
animal's. The Kinship Comparison asks it for every animal once a
genotype file is uploaded and keeps only the means; the realized
relatedness table asks it for every animal once the pedigree and the two
inputs are usable. appServer passes one that applies the twins
and overrides. With neither kinshipMatrix nor kinshipFor,
indivMeanKin is NA and there is no realized relatedness
table. NULL (the default) is not used.
A sixth tab, "Linkage and LD Block Metrics" (issue #153 Slice 5), wires in
three additional analyses. A locus-metadata file (locus,
chrom, pos, optionally cM) is validated and
classified into a three-tier coverage report
(checkLocusMetadata, D2). The realized-relatedness-variance
table (markerRealizedRelatednessVariance, D3a) needs only
the existing pedigree and its kinship plus a curator-supplied
chromosome count and genetic-map length -- no genotype file at all. The
LD-block table (markerLdBlock, D3b) reads its OWN,
dedicated linkageGenotypeFile upload -- deliberately independent
of the other five tabs' shared genotypeFile, since Shiny renders
every tabPanel's output bindings regardless of which tab is
visible: a multiallelic file uploaded through the shared input would
break the other five tabs' own DT outputs simultaneously, not just this
tab's. Validated through the multiallelic-tolerant sibling validator
(checkLinkageMarkerGenotypeFile) rather than
checkSequenceGenotypeFile, the validator for the shared
upload. Any exported LD-block
table is de-identified (obfuscateLdBlocks) behind a
curator confirm-gate reusing modDeidentifiedExportServer's
tested Generate-Preview -> Confirm -> Confirm-OK pattern (D9).
A seventh tab, "Genomic ROH (F_ROH)" (issue #152 Slice 5), computes
computeGenomicROH from the shared genotype and
locus-metadata uploads, with the same confirm-gated, de-identified
export pattern (genotype matrix, F_ROH table, manifest).
An eighth tab, "MHC Haplotype Reporting" (issue #148 Slice 4), reads its
OWN dedicated mhcHaplotypeFile upload (validated by
checkMhcHaplotypeFile) and reports
mhcHaplotypeFrequency's per-haplotype summary and
mhcHaplotypeCarriers's rare-haplotype carrier list at the
two rarity thresholds shown next to the tables, with a persistent
descriptive-only caveat, the call counts and frequency denominator, and
(when pedigree is available) how many pedigree animals have a
designation. Its export (summary, carrier list aliased through
obfuscateMhcHaplotypes, and a manifest) goes through the
same confirm gate. The alias map covers pedigree animals only, so the
export is not generated -- with the reason shown -- while any animal in
the MHC file is absent from the loaded pedigree.
This module never touches the existing single-locus genotype path
(checkGenotypeFile/addGenotype/hasGenotype/
getGVGenotype/geneDrop) -- the D1 long-format schema is a
new, sibling concern.
modMarkerGeneticsUI
Other Shiny modules:
modBreedingGroupsServer(),
modBreedingGroupsUI(),
modCrossCenterIdentityServer(),
modCrossCenterIdentityUI(),
modDeidentifiedExportServer(),
modDeidentifiedExportUI(),
modGeneticDiversityServer(),
modGeneticDiversityUI(),
modGeneticValueServer(),
modGeneticValueUI(),
modGvAndBgDescServer(),
modGvAndBgDescUI(),
modInputServer(),
modInputUI(),
modMarkerGeneticsUI(),
modMatePairServer(),
modMatePairUI(),
modORIPReportingServer(),
modORIPReportingUI(),
modPedigreeServer(),
modPedigreeUI(),
modPotentialParentsServer(),
modPotentialParentsUI(),
modPyramidServer(),
modPyramidUI(),
modSnapshotTrendsServer(),
modSnapshotTrendsUI(),
modSummaryStatsServer(),
modSummaryStatsUI()