Pedigree
Learn Open the tool
Methodology

From pedigree to algorithm

A pedigree is a graph. Once you see it that way, checking an inheritance pattern is a single pass over the nodes.

The problem

A pedigree is a set of people, each with a sex and an affected status, connected by parent child edges. We want a function that takes a pedigree and returns true if it's consistent with a given inheritance pattern, false if some relationship contradicts it.

We'll work through one pattern: autosomal recessive. The other five follow the same shape, with one different rule inside the loop.

The rule

Autosomal recessive inheritance needs two copies of the recessive allele to produce the affected phenotype. Genotype aa is affected, AA and Aa aren't. One pairing gives a certain violation: if both parents are aa, every child must be aa too, since neither parent has an A allele to give. An affected times affected pairing with an unaffected child breaks the rule. Two unaffected parents having an affected child doesn't, that's just two carriers.

The code

Represent each person as a record with four fields: id, affected, father, and mother, where father and mother point to other records, or nil if unknown. Visiting every person once and checking the rule against their parents is enough. No traversal order matters, since the rule only looks at one person and their two immediate parents.

IS-CONSISTENT-WITH-AR(people)
  1. for each person in people
  2. father = person.father
  3. mother = person.mother
  4. if father == nil or mother == nil
  5. continue // nothing to check without both parents
  6. if father.affected and mother.affected and not person.affected
  7. return false
  8. return true

Eight lines, one real check. It runs in O(n) time, one pass, constant work per person.

The other five patterns

Same function, different line 6. X-linked recessive checks an affected son against an affected father and unaffected mother, since a son's X never comes from his father. Autosomal dominant flips the rule around: an affected person with two unaffected parents is the violation, not an unaffected person with two affected parents. Y-linked and mitochondrial only look at one parent, since those patterns only come from one side.

The tool runs all six of these in one pass each, and reports which ones came back true. When more than one does, that's the honest answer for a small pedigree, not something to resolve by guessing.

See the real implementation

The tool runs this exact check, plus the other five patterns, against any pedigree you build.

Open the pedigree tool

If you want the inheritance patterns themselves explained from the start, read our genetics basics article. For a worked example of X-linked recessive inheritance in a real condition, see Duchenne muscular dystrophy.

← Genetics basics Duchenne muscular dystrophy →