Lesson 8

A

Locked — confirm your name above to begin.

Imagine you are trying to predict whether some particular person has some particular trait. What the trait is does not matter. It could be a genetic disease, it could be a preference for a particular song, it could be a dialect or a way of speaking. It could be anything. What matters, for the purposes of predicting it, is how heritable the trait is.

The mechanism of heritability can be important for deciding what kind of evolutionary model you use. A model of direct genetic inheritance will be a different model from indirect genetic and non-genetic models of inheritance. But at the core, the first thing you have to establish is whether the trait is heritable at all, because if the trait is not heritable you need a non-evolutionary model.

So for this exercise, we can look at a scenario where, say, 72% of people whose parents have a trait share that trait. 72% of people whose parents have the disease also have the disease. 72% of people whose parents like a song also like that song. That tells us something, but what exactly it tells us is a little unclear. Just knowing that 72% of people whose parents like a song also like that song is, on its own, meaningless without a base rate to compare it to. That is what we are going to explore below.

  • Each square below represents a person. The people are divided between those whose parents have the trait and those whose parents do not.
  • Individual people are colour coded by whether or not they have the trait.
  • There are two sliders. They let you adjust the probability that a person whose parents have the trait shares that trait with their parents, and the probability overall.
  • Try to predict three individuals, where you get to set the rates. Then try to set the rates to match ten different scenarios.
  • The switch relabels the trait. It changes no number on this page.
told the parents have it, you would say: —
told they do not, you would say: —
so knowing the parents moves your answer by: —
that same move, rescaled to run from −1 to 1, is the correlation (r): —
how much less wrong a guess about one person is, once you are told the parents: —

Controls

72%
72%
Pull one person at random out of the group whose parents have it. Do you predict that person has it?

Pairs you have locked in

none yet

To open Stage B

  • Predict three individuals, setting the rates yourself. 0 of 3
  • Then adjust the sliders to answer ten questions. the three pairs first
72% is a rate. What it buys you is a difference between two rates. Stage B is open.
Worth nothing at all. Three rounds. Each one deals a fresh rate for the children of parents who have the trait, and asks you to set the other group’s rate so that knowing the parents tells you nothing. Lock it in and the page deals 200 fresh people six more times to see whether it held.
—
50%
0 of 3 hit

R code

p1 <- 0.72   # parents have itp2 <- 0.72   # parents do notparent <- rep(c(1, 0), each = 100)child  <- rbinom(200, 1, ifelse(parent == 1, p1, p2))# what knowing the parent moves your answer byp1 - p2# the same move, as a correlationr <- cor(parent, child); r# and what that correlation is worth about one person1 - sqrt(1 - r^2)

B

Solve Stage A to unlock this section.

When we are interested in predicting changes in the frequency of something over time, whether or not that thing is passed from parents to offspring is a crucial aspect for predicting. And we call that heritability.

The mechanism of heritability can be important for refining our model and our predictions. But if it is not heritable, we are not going to be using an evolutionary model. Likewise, no matter what the mechanism of heritability is, an evolutionary model will work. How we measure heritability is older than our knowledge of DNA, and is largely unconnected. Plenty of things that do not use DNA at all evolve. DNA is not in any way, shape or form required for it. Even in scenarios where DNA plays a role, it does not always play the role students might expect.

For this exercise we are going to look at limbs. There is essentially zero heritable variation for limb count in human populations. So even though limb count itself is genetic, variation in limb count is not heritable directly, genetically.

That said, other things can be heritable. If I tell you somebody's parent had black lung because they were a coal miner, the probability that their child has black lung is extremely high. Not because the parent passes black lung on directly, but because the probability somebody becomes a coal miner is a lot higher if their parent was a coal miner, and the probability someone gets black lung is a lot higher if they are a coal miner. So you are not inheriting black lung directly. However, the frequency of black lung within a given population is something that evolves, because the propensity itself is a heritable trait. Not perfectly heritable — but as we saw above, perfect heritability is not a thing we will ever get.

In this you are going to explore a pathway by which a heritable latency can influence a phenotype.

  • Below are 1,200 parent–offspring pairs, all with four limbs.
  • Across: the parent's limb count. Up: the child's limb count. Limbs come in whole numbers, so every pair falls on one of nine spots — each disc is one of them, sized by how many pairs are there.
  • The model for what causes limb count changes is shown. Click on arrows to drag them larger or smaller, to change how much a given cause is affecting something.
  • In this model, limbs are lost only to accidents. The probability of an accident itself can be heritable.
  • Every individual is born with genes that specify four limbs, at every setting. Nothing genetic varies here at all.
  • Lock in each setting. The page counts how many tries it took.
missing at least one limb: —  |  genetic variation in limb number: none
parent–offspring correlation: —

The causal model

0% 0.00

To open Stage C

  • Leave the heritable risk at zero, and set the base accident probability so that at least a quarter of everybody loses a limb. Lock it in. not yet
  • Keep that accident rate, and raise the heritable risk until the parent–child correlation is over 0.25. Lock it in. not yet
Nothing genetic moved between those two settings. What moved was who the accidents hit.
Guess the correlation before you look. Three rounds. Each one names an accident rate with the risk passed on in full, and asks where the parent–offspring correlation ends up. Lock in an estimate and the page runs 1,200 fresh pairs six more times to see where it really goes.
—
0.30
0 of 3 hit

R code

acc <- 0.00   # chance a given limb is lostrisk <- 0.00  # how much of the risk is passed onn <- 1200zp <- rnorm(n)                      # the parent's own riskzc <- risk*zp + sqrt(1-risk^2)*rnorm(n)   # inherited from itpr <- function(z) {  p <- plogis(qlogis(acc) + 4.2*z)  p * acc / mean(p)          # hold the marginal rate}par_limbs <- 4 - rbinom(n, 2, pr(zp))kid_limbs <- 4 - rbinom(n, 2, pr(zc))var(rep(4, n))                    # the genetic variation: zero, alwayscor(par_limbs, kid_limbs)

C

Solve Stage B to unlock this section.

A lot of birds choose their mates based on the song that they sing, and a lot of birds learn the song from their fathers. Males will often sing a song that sounds like their father's, and females will often prefer a song that sounds like the song her father sang.

The song is learned, but it also drives mating success and mate identity in a lot of birds without any genetic connection — without any genetic driver of the song itself.

We are going to explore an example of this system, where you are going to look at the correlation in song between an offspring and the parent that raised it, and between an offspring and the parent it came from, based on whether the eggs were swapped at laying.

  • 600 chicks and their fathers, with song form described as a single number.
  • The model is drawn beside the points. Click on arrows to adjust the degree of causality.
  • When left alone, the father that raised the chick is the father it came from — one bird, one song, one graph.
  • Swap the eggs and that bird becomes two: a biological father and an adopted one, with a graph each. Watch which of the two the resemblance stays with.
  • Solve the problems below. Lock in each answer; wrong locks are counted and shown.
eggs: left where they were laid
—

The causal model

0.00 0.00
Eggs left alone, no genetic basis for the song. Set the learning so a chick resembles its father at 0.60.

To open Stage D

  • Build a population where a chick resembles its father at 0.60, with no genetic basis for the song. not yet
  • Predict what swapping the eggs will do to the correlation. Then swap them. not yet
  • Find the population where the swap drops 0.60 to 0.25. not yet
The resemblance was real both times. Moving the eggs is what says where it came from.
Guess what survives the swap. Three rounds. Each one names a learning rate and a genetic basis for the song, swaps the eggs at laying, and asks how much a chick will resemble its biological father. Lock in an estimate and the page hatches six more broods at that setting.
—
0.30
0 of 3 hit

R code

cp  <- 0.00   # learningegg <- 0.00   # genetic basis for the songn <- 600G    <- rnorm(n)                      # the father's heritable song value# the song he actually singsdad <- egg*G + sqrt(1-egg^2)*rnorm(n)tutor <- if (swap) dad[sample(n)] else dadve <- max(0.05, 1 - (cp^2 + egg^2 + 2*cp*egg^2))chick <- cp*tutor + egg*G + sqrt(ve)*rnorm(n)cor(chick, dad)     # the biological fathercor(chick, tutor)   # the adopted father

D

Solve Stage C to unlock this section.

Francis Galton was Charles Darwin's cousin, and a horrible racist who ended up inventing the term eugenics. He wanted to prove, at least to himself, that being related to people of stature indicated something about an individual's quality. He spent a large fraction of his life trying to study the question of heritability.

He was working in 1885. There was absolutely no indication of how heritability worked, and in fact he did a lot of things incorrectly. It would be basically 50 years before DNA was nailed down as the molecule of inheritance. His work, despite its misguided factual basis and rather horrible motivations, was nonetheless very successful at its job of finding a way to measure heritability.

We are going to explore his data. 205 families who all had their heights measured, which lets us plot 934 grown children against their parents. Set the heritability, and then find how much of a child's height the heritability does not reach.

  • Galton's data, showing the height of the parents on the across axis and the height of the adult child on the up axis.
  • Female heights are multiplied by 1.08, which is what Galton did, so that all individuals sit on the same scale.
  • Both arrows of the model are yours. The left one sets the heritability of height; the right one sets how much the other factors move a child away from the line.
  • The grey marks are the children's average in each strip of parents. A line with the right heritability runs through them.
  • Pick a strip of parents. Their children light up; the rest of the plot goes grey, and the page counts how many of them the band holds.
your heritability: —  |  your line misses a typical child by: —
predicting for: —  |  where the line puts their children: —
your other factors: —
—
the heritability that fits: locked
the share of the children's variation it accounts for: locked  |  left to everything else: locked
parent–offspring correlation: locked

The causal model

0.00 0.50

The other factors

To finish the lesson

  • Find the heritability that matches the grey marks, and lock it in. not yet
  • Find the non-heritable factor amount that will cover two thirds of the data around the line, and lock it in. not yet
Two numbers come off one line and they are not the same number. The heritability is 0.71 — most of a parent arrives in a child. The other factors still need a band more than two inches wide to hold two children in three, and with no parents at all that band is only a quarter of an inch wider. That gap is the whole of what knowing the parents bought you.

R code

g <- read.csv("data/clean/galton_families.csv")g$kid <- g$childHeight * ifelse(g$gender == "female", 1.08, 1)g$mp  <- g$midparentHeighth2 <- 0.00   # the heritability of heightpred <- mean(g$kid) + h2 * (g$mp - mean(g$mp))sqrt(mean((g$kid - pred)^2))   # how far off your line issd_other <- 0.50   # the other factors, in inches# what the band holds inside one strip of parentscol <- g$mp >= 68.0 & g$mp < 69.5mean(abs(g$kid[col] - pred[col]) <= sd_other)# the numbers the line hands back on its ownfit <- lm(kid ~ mp, data = g)coef(fit)[2]              # the heritabilitysd(resid(fit))           # the other factors you just foundsd(g$kid)                 # and the spread with no parents at all# a different number off the same fitsummary(fit)$r.squared    # the share the heritability accounts forcor(g$mp, g$kid)

Good job!

That is the whole of Lesson 8. Your completion code is below — copy it and hand it in.