Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Genetics and Selective Breeding Science  (Read 3929 times)

Moeteru

  • Bay Watcher
    • View Profile
Genetics and Selective Breeding Science
« on: July 07, 2020, 12:11:26 pm »

Background:

Genetics and inheritance are supposed to be a thing. This is what Toady had to say in DF Talk #8 (2010):
Quote from: Toady
Currently what we've got are the attributes ... vaguely the attributes to an extent being passed down. It's not like if the parents have two specific numbers it doesn't pick one or the other, but there's a little bit going on there. Then all of the colours, like eye colours, hair colour, I think that uses a dominant/recessive thing now where you pass on two copies and then it picks probably the colour with the lowest index; maybe there's an alphabetic bias right now on which genes are dominant, or it might be the first you listed, it could be the first one you list in the raws that's the dominant gene. I think that's it right now, just attributes and colours, the idea this time around was just to get our feet wet and get something working, and after that really it's easy to add new genes, easy to add all kinds of effects for them. I mean, I have to code it up, it's not something you can just mod in, and of course we'd have to have discussions about this; what's the extent to which personality is passed on versus it being environmental factors and so on, I'm sure we can have all kinds of wonderful arguments on the forums and so on, but right now we're just doing simple things that are pretty cut and dried like colours. Attributes ... it's not quite cut and dried there what passes along and what doesn't and so on, but I think right now that all the attributes pass along, whether or not that's accurate is another question. Also stuff like the shape of the nose and the height modifiers, basically anything called a modifier in the raws - how curly is your hair, how long is your nose, how far apart are your eyes, what colour is your skin/eyes/hair - all those pass along right now, they have genes to pass them along. As far as curses and stuff or whatever ... whatever those end up being we can link it in, but there's nothing right now of course.

The best study of genetics I could find is this one by DeKaFu from 2016, however it only deals with fur colour.
I'm not aware of any recent experiments on attribute inheritance. There are a few threads from 2017 and earlier, but I haven't found any rigorous statistical analysis. Skullsploder got as far as posting results for his control group, but he never followed up with results for the low-strength and high-strength groups.
If I've missed any other experiments, please let me know.


Setup:

This is all done in fortress mode in DF version 0.47.04 with no mods besides a small reduction in stress vulnerability. I don't have DFHack installed, but I'm using Dwarf Therapist to view attributes.

I chose cave crocodiles as my breeding population because they lay a large number of eggs (20-60), giving a large sample size for statistical analysis. They also take 3 years to reach adulthood, which is a little on the long side but gives me plenty of time to move the hatchlings around without risk of any unwanted breeding. Their lifespan is 60-100 years, so particular breeding pairs can be kept around for a long time.

Given that all physical attributes are meant to be heritable, I picked Disease Resistance (DR) for my experiments. Other attributes like strength can change over the course of an animal's life as a result of physical activity, but as far as I know nothing can alter Disease Resistance. Therefore it should be entirely determined by genetics.

Dwarf Therapist actually gives two values for each attribute in the form "A/B". Presumably the first is the current value while the second represents some upper limit. The relationship between them seems to be: B=max(2*A,A+1000). CSV export only gives the first value, so that's what I'm using here.


Experiments:

From an initial batch of tame hatchlings I chose three breeding pairs with low, intermediate, and high values of Disease Resistance. These breeding pairs are labelled as generation 0. They were isolated in three separate breeding chambers before they reached adulthood. The doors were kept locked as much as possible to eliminate any risk of cross-contamination.

A nest box was added to each chamber and they were allowed to lay eggs. Any clutches of fewer than 50 eggs were collected for food, while larger clutches were allowed to hatch. In hindsight I should have probably let the smaller clutches hatch too, but I wanted to avoid having to process multiple batches of hatchlings from each breeding pair. These hatchlings are labelled as generation 1.

When each clutch hatched they were tagged using the nickname feature of Dwarf Therapist and the stats were exported as a CSV file. These were then parsed and analysed using a Python script.

Most of the hatchlings were slaughtered, but I once again selected breeding pairs with particular attributes. I used the same criteria as I used for generation 0, so the hatchlings with the lowest DR were selected from the low-DR group, the ones with intermediate (~1000) DR were selected from the med-DR group, and the ones with the highest DR were selected from the high-DR group. I haven't done anything with these breeding pairs from gen1 yet, but they could be used to test for more complex kinds of inheritance.


Results:

The raw Disease Resistance values for each group and generation are shown below:
Spoiler: Raw Data (click to show/hide)

The aggregate statistics are as follows:
Spoiler: Aggregate Statistics (click to show/hide)
The plus-or-minus uncertainties on the means are calculated using the standard error on the mean.

I also plotted some histograms of the attribute distributions:
Spoiler: Plots (click to show/hide)
These use a bin width of 100. The black markers show the attributes of the parents for each group.


Conclusions:

To put it simply, attributes don't seem to be heritable. All of the means are within roughly one standard error of 1000, which is what you'd expect if they were generated completely randomly. The medium group actually have a very slightly higher mean than the high group. The sample size isn't big enough to give really smooth histograms, but they look fairly normal.

Of course, this comes with a number of caveats. I only tested one attribute out of six, I only ran the experiment for one generation (so far), and I only tested it on egg-layers. It may behave differently for other attributes or for live births. I don't think it's likely that I'll see different results after another generation, but I might try anyway. I've also set aside some cave crocodiles with low and high strength values, so that's something I can easily experiment with.

Any suggestions/requests for further experiments are welcome.
Logged

voliol

  • Bay Watcher
    • View Profile
    • Website
Re: Genetics and Selective Breeding Science
« Reply #1 on: July 07, 2020, 02:03:12 pm »

Modding a live-birther to have a high LITTERSIZE would make that testing easier than relying on the relatively small litters of any vanilla creature.

Salmeuk

  • Bay Watcher
    • View Profile
Re: Genetics and Selective Breeding Science
« Reply #2 on: July 08, 2020, 04:56:43 pm »

First off, this is very well done - you must have studied or work in a statistics-related-field. Second, it's possible disease resistance was added, or somehow modified, after genetics were implemented, leading to a situation where DR is supposed to be inheritable but somehow fails to pass to the next generations.

I would suggest you try gen 2 (just to be sure.  .), and then try a different kind of trait. You could mod in alternative cave croc skin colors if you wanted to work with the same creature, which would certainly make it easier than managing a bunch of dogs.

It's also possible that genetic inheritance of Disease Resistance was not implemented for other species, only dwarves. Though that doesn't seem like Toady's style (usually mechanics of this nature are universal, to allow room for future changes / user modification).

Nice work !
Logged

Moeteru

  • Bay Watcher
    • View Profile
Re: Genetics and Selective Breeding Science
« Reply #3 on: July 11, 2020, 05:36:02 am »

I've finished collecting data for both the second generation of Disease Resistance and the first generation of Strength.
I switched over to using probability density rather than absolute number in the overlayed plots since there's more variation in sample sizes this time.

Disease Resistance Gen2
Spoiler: Raw Data (click to show/hide)
Spoiler: Aggregate Statistics (click to show/hide)
Spoiler: Plots (click to show/hide)

Strength Gen1
Spoiler: Raw Data (click to show/hide)
Spoiler: Aggregate Statistics (click to show/hide)
Spoiler: Plots (click to show/hide)

I still can't see any evidence of any kind of attribute inheritance. I suspect the problem might be that egg-laying was added to DF around 2011, after genetics had already been implemented. Toady may have simply forgotten to transfer the appropriate genetic information into the eggs.
The next step is to follow voliol's suggestion and mod in some kind of mammal with a large LITTERSIZE. I might not do that immediately though. My necromancers (and I) need a break from endless animal-hauling and butchery jobs.
Logged

knutor

  • Bay Watcher
  • ..to hear the lamentation of the elves!
    • View Profile
Re: Genetics and Selective Breeding Science
« Reply #4 on: July 15, 2020, 10:57:17 pm »

Egglayer males spore the same as none egglayers, I always thought. They just gotta be on the embark map to fertilize a fem. How did you isolate your sample pairs, wouldn't 3 males corrupt the parent combos?

I breed everything domestic for DR.
I breed verminhunters for AGI
I breed hunter pets and war pets for STR.

I geld almost all my males, without 50+ scores. I slaughter females with bad stats at birth. Lose a bunch of hide, but it keeps lag in check. We must cheat too. Named pets with lousy stats, must be dfHack:exterminate this.

Use cats, and catsplosion, save yourself time. 

Somethings, also not easily found in Therapist, they are descriptions for eye color, body size, etc.. Body size is good if you decide to tame and  raise Dralthra. Lotsa hair, bones and meat.
Logged
"I don't often drink Mead, but when I do... I prefer Dee Eef's.  -The most interesting Dwarf in the World.  Stay thirsty, my friend.
Shark Dentistry, looking in the Raws.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Genetics and Selective Breeding Science
« Reply #5 on: July 16, 2020, 02:35:27 am »

Breeding through spores stopped being a thing a long time ago (before 0.40.X?). Fertilization requires the male and females to be adjacent to each other, probably orthogonally, and probably for some amount of time. Supposedly caged male can impregnate females in surrounding tiles (not caged, but can be chained), but not vice versa. Thus, isolation just requires locking the into separate rooms.
Logged

knutor

  • Bay Watcher
  • ..to hear the lamentation of the elves!
    • View Profile
Re: Genetics and Selective Breeding Science
« Reply #6 on: July 16, 2020, 03:52:50 pm »

Thank you, Patrick. I am way out of practice. Good to know.
Logged
"I don't often drink Mead, but when I do... I prefer Dee Eef's.  -The most interesting Dwarf in the World.  Stay thirsty, my friend.
Shark Dentistry, looking in the Raws.

Shinotsa

  • Bay Watcher
  • Content lion is content
    • View Profile
Re: Genetics and Selective Breeding Science
« Reply #7 on: July 16, 2020, 10:55:31 pm »

Hey, just wanted to pop in and say fantastic work. There are too many features we assume operate logically, so I appreciate someone testing it out. I’m eager to see heritability in live-births, and (though difficult) would love to see if it could be tested on a sentient race for completeness sake.
Logged
Quote from: EvilTim
"You shouldn't anthropomorphize vehicles. They hate it"

Moeteru

  • Bay Watcher
    • View Profile
Re: Genetics and Selective Breeding Science
« Reply #8 on: July 20, 2020, 11:58:41 am »

Thanks for the comments everyone.

I haven't got round to modding in a custom mammal for testing yet, but I have been recording results from a breeding pair of cats I had laying around. The sample size is only about half of what I had for the cave crocodiles, but I figured people might be interested anyway.
This time the target attribute was endurance.
Spoiler: Raw Data (click to show/hide)
Spoiler: Aggregate Statistics (click to show/hide)
Spoiler: Plot (click to show/hide)

So yeah, I wouldn't go as far as to say it's conclusive proof, but I suspect that attribute inheritance might be broken for all animals. If it is working, the effect is so small as to be effectively useless for any kind of industrial purposes. If you want to produce more meat from your livestock, I'd recommend just using good old fashioned necromancy instead.
I also took a look at their fur/eye/skin colours and those were being inherited properly. More than 90% of them were the same as one or both of the parents.
Logged