5 Modeling selection for a monogenic trait in hermaphrodites 5.1 Time to talk about sex! In its simplest form... The course in which we are creating this model is dedicated to sex—a mysterious mode of reproduction in which the offspring's hereditary traits are randomly selected from the parents' hereditary traits. We will still model quite complex cases of sexual reproduction, but for now, it makes sense to start with the simplest. Hermaphrodites. Organisms that produce both male and female gametes (sex cells). Why there are exactly two types of gametes and why they are like that, we will see through modeling a little later. Whether the first organisms that transitioned to sexual reproduction were hermaphrodites or gonochoristic, the author of this course does not know; probably, both options are possible. One can assume that the first organisms that reproduced sexually produced one type of gamete—the same for everyone. Gametes from the same organism recognized "their own" (cells are quite capable of this) and did not fuse with their own (it's interesting to think why...), and fused with foreign ones during fertilization. Over time, a transition occurred—either to males producing small gametes and females producing large ones, or to hermaphrodites producing both types of gametes. This is something to be discussed a little later. What is important now is something else. Throughout the evolution of life, transitions from hermaphroditism to gonochorism and vice versa have occurred multiple times. To avoid confusion in different types of reproduction and the terminology used to describe it, we will use the classification shown in the figure. If not everything in it is clear now—that's okay. We will return to it many times. Fig. 5.1.1 Classification of population reproduction types that we will use. Hermaphroditism is, in a sense, a simpler mode of reproduction. The development of organisms is controlled by a hereditary program. Gonochoristic organisms are forced to have two variants of such a program: for development along the male line and along the female line. The presence of alternative developmental programs in the genome, the switching between which must occur through some mechanism, is already a significant complication that requires a rather profound restructuring of the developmental control system. For hermaphrodites, everything is simpler: there is one program—and that's enough, all individuals will develop identically. Another advantage of hermaphroditism is that it does not reduce the number of offspring in a population. In gonochoristic organisms, the maximum number of offspring is determined by how many can be produced by females (in the typical case, which also needs to be discussed—only half of the individuals). From this perspective, populations of gonochoristic organisms are at a disadvantage compared to clonally reproducing populations and hermaphroditic populations! J. Maynard Smith called this phenomenon the "cost of sex"; hermaphrodites do not pay it, as each individual in type II population produces the number of female gametes (and, ultimately, offspring) it is capable of. This circumstance is a strong argument in favor of the assumption that the first organisms with sexual reproduction were hermaphrodites. Hermaphrodites have another advantage related to the ease of simulating their reproduction. Two randomly selected hermaphrodites from the same population can produce common offspring, while two randomly selected gonochoristic individuals can do so only in half of the cases. Thus, let's move on to simulating hermaphrodite reproduction! If you think that hermaphrodites are some rare creatures, you are mistaken. Fig. 5.1.2 Coral polyps are an example of creatures whose reproduction, in its main features, corresponds to the approach adopted in the model discussed in this lecture. In the common case, each polyp in a coral colony can produce either egg cells or sperm, but within one colony (which is genetically a single individual), there are both the former and the latter. 5.2 Patterns of Monogenic Inheritance with Complete Dominance Sexual reproduction is associated with life cycles that have diploid stages, i.e., stages where organisms have a double set of hereditary information. In the next illustration, as a result of the fusion of gametes (egg cell and sperm, which have haploid, single sets of hereditary information), a diploid (with a double set) zygote (fertilized egg) is formed, and from it—a diploid adult organism. Fig. 5.2.1 Characteristic life cycle of a species with sexual reproduction. The adult organism has a diploid genotype formed as a result of fertilization (fusion of gametes, sex cells). It produces haploid gametes. A diploid organism typically has two copies of each gene. These copies can be represented by identical "versions" (alleles) or different ones. The simplest (so simple that it is actually rare in complex organisms) mechanism of allele influence on organism traits is monogenic inheritance with complete dominance. Let's consider this simplest case in more detail. One of the two alleles (let's denote it with a capital letter), the dominant one, suppresses the action of the other, recessive one, denoted by a lowercase letter. Individuals homozygous (having two identical alleles) for the dominant allele have the same external traits (phenotype) as heterozygous individuals (having two different alleles). For biologists, such statements are familiar, but for representatives of other specialties, unfortunately, they are not (although these things are part of the school curriculum). Once again. Individuals with genotypes AA and Aa have phenotype A; individuals with genotype aa have phenotype a. In the model we are about to build, we will consider exactly this case. Let's denote the dominant allele A by the number 1 and the recessive allele a by the number 2. In the case of complete dominance, which we will consider, individuals with genotypes AA (11) and Aa (12) have the A-phenotype (complete dominance), and individuals with genotype aa (22) have the a-phenotype. Regardless of which phenotypes are favored by selection, we must consider six types of crosses. We have assumed that selection favors individuals with the a-phenotype (22), i.e., homozygotes for the recessive allele. Phenotypes favored by selection are marked in red on the diagram. Fig. 5.2.2 In the case of monogenic inheritance, six types of crosses between hermaphroditic parents are possible (and twelve types of crosses between gonochoristic organisms, if sex is considered). All these variants are shown in the diagram. 5.3 Conceptual model of selection for a single trait in a population of diploid monocyclic hermaphrodites with synchronous reproduction Now you know everything necessary to build a model describing selection for homozygotes for the recessive allele in a population of hermaphrodites. This model will be similar to the previous one discussed in Chapter 4. We can immediately build a Type II model, as the modifications we need will be sufficiently limited. I. ENTRANCE: Initial state of the system—initial numbers of all forms (genotypes): α 1 N AA , α 1 N Aa and α 1 N aa; Parameters—population size: N; Malthusian parameter: r; selection coefficient favoring individuals with the a-phenotype; Experimental conditions—model experiment conditions: number of model cycles: cycles; number of iterations, iterat; The changeable parameters combinations—combinations of variable parameters (if necessary, for Type III model): patterns of iterating through different combinations of initial parameters. TRANSFORMATIONS SYSTEM CREATION: Calculation rules data—data with recalculation rules: list of crossing types and offspring arising from such crosses; CALCULATIONS: Initial composition creation—creation of initial composition: If t = 1, the numbers of subpopulations are set by initial parameters, α 1 N AA , α 1 N Aa and α 1 N aa, and these individuals must be randomly mixed: α 1 P = sample( α 1 P, N); Main work cycle—main work cycle: Alpha population (parents): If t > 1, the alpha population is formed during non-selective reduction of the omega population: α t P = sample( ω t–1 P, N). Beta population (pairs): combine individuals from the first half of the alpha population and the second half of the alpha population; since the individuals in the alpha population are randomly arranged, this will ensure random pair formation: β P^ <- α P 1 + α P 2, where p is the integer part of half of N; Gamma population (offspring): for each pair, determine offspring according to the 6 crossing types characterized in the illustration in the previous section; Delta population (selection-thinned offspring): keep all individuals with the a-phenotype favored by selection, and randomly keep such a proportion of individuals with the A-phenotype (instead of those that died—NA); Omega population (from which parents are selected): ω P = na.omit( δ P). 5.4 Implementation of the model in R To calculate the gamma population, it is necessary to specify what offspring will appear from each type of cross. In the script below, this is implemented using a block of six objects Off_... (from the English offspring). The fact is that by summing the codes of the parent genotypes, one can determine what those parents were.


Offs_22 <- c(11, 11) # 22=11+11, AA×AA ⟶ AA; 
Offs_23 <- c(11, 12) # 23=11+12, AA×Aa ⟶ AA : Aa;
Offs_24 <- c(11, 12, 12, 22) # 24=12+12, Aa×Aa ⟶ AA : 2×Aa : aa;
Offs_33 <- c(12, 12) # 33=11+22, AA×aa ⟶ Aa;
Offs_34 <- c(12, 22) # 34=12+22, Aa×aa ⟶ Aa : aa;
Offs_44 <- c(22, 22) # 44=22+22, aa×aa ⟶ aa;

After the sums of the codes of the formed pairs are collected in the Be_Par vector, one can simply count how many pairs of each type were formed and determine how many offspring with which genotypes should appear. Otherwise, the model we are discussing is similar to the previous one, the Type II model, which was built in Chapter 6.


# ДОБІР ЗА ОДНІЄЮ ОЗНАКОЮ В ПОПУЛЯЦІЇ ДИПЛОЇДНИХ МОНОЦИКЛІЧНИХ ГЕРМАФРОДИТІВ З СИНХРОННИМ РОЗМНОЖЕННЯМ (Модель ІІ типу)
# I. ENTRANCE — ВХІД:
# Initial script commands — початкові команди скрипту
# setwd("~/!_Courses/Sex_on_R") # Робоча директорія (лише на комп'ютері Д.Ш.!!!)
rm(list = ls()) # Очищення раніше збережених об'єктів в Environment
set.seed(1234567)
# ПОЗНАЧЕННЯ: 1 - алель A (домінантний); 2 - алель a (рецесивний)
# А-фенотип мають особини з генотипом 11 та 12 (повне домінування), a-фенотип мають особини з генотипом 22. 
# Добір сприяє особинам з a-фенотипом (з генотипом 22)
# Initial state of the system — початковий стан модельованої системи
al_1_N_aa <- 3 # Початкова чисельність гомозигот по рецесивному алелю (позначення - 22) 
al_1_N_Aa <- 1 # Початкова чисельність гетерозигот (позначення - 12)
# Parameters — параметри
N <- 100 # Альфа-чисельність модельної популяції
al_1_N_AA <- N - al_1_N_aa -  al_1_N_Aa # Початкова чисельність гомозигот по домінантному алелю (позначення - 11) 
r <- 2 # параметр Мальтуса (кількість потомків на одного плідника на один цикл роботи моделі)
s <- 0.1 # Коефіцієнт добору на користь особин з a-фенотипом 
# Experimental conditions — умови експерименту з моделлю
cycles <- 100 # Кількість робочих циклів моделі у одній ітерації 
iterat <- 10 # Кількість ітерацій
# II. TRANSFORMATIONS SYSTEM CREATION — СТВОРЕННЯ СИСТЕМИ ПЕРЕТВОРЕНЬ:
# Objects creation — створення об’єктів
Rezult <- matrix(NA, nrow = cycles+1, ncol = iterat) # Матриця для збору підсумків
Fate <- c(rep(NA, s*100), rep(1, (1-s)*100)) # Вектор, вибірка з якого буде визначати долю у доборі
p <- N%/%2 # Кількість пар (цілий залишок від результату поділу кількості особин на 2)
Al_1_Pop <- rep(NA, N) # Створення файлу для початкового складу
Be_Par <- rep(NA, p) # Створення файлу, в якому створюватимуться пари особин
Ga_Pop <- rep(NA, r*2*p) # Створення файлу для результатів розмноження
De_Pop <- rep(NA, r*2*p) # Створення файлу для результатів дії добору
# Calculation rules data — Дані з правилами перерахунків  
# Можливі нащадки для кожної можливої пари (навіть якщо нащадки однакові, треба вказати не менш, ніж 2):
Offs_22 <- c(11, 11) # 22=11+11, AA×AA ⟶ AA; 
Offs_23 <- c(11, 12) # 23=11+12, AA×Aa ⟶ AA : Aa;
Offs_24 <- c(11, 12, 12, 22) # 24=12+12, Aa×Aa ⟶ AA : 2×Aa : aa;
Offs_33 <- c(12, 12) # 33=11+22, AA×aa ⟶ Aa;
Offs_34 <- c(12, 22) # 34=12+22, Aa×aa ⟶ Aa : aa;
Offs_44 <- c(22, 22) # 44=22+22, aa×aa ⟶ aa;
# III. CALCULATIONS — РОЗРАХУНКИ:
# Initial composition creation — утворення початкового складу
if (al_1_N_aa>0) Al_1_Pop[1:al_1_N_aa] <- 22 # Перенесення до початкового складу a-особин
if (al_1_N_Aa>0) Al_1_Pop[(al_1_N_aa+1):(al_1_N_aa+al_1_N_Aa)] <- 12
Al_1_Pop[(al_1_N_aa+al_1_N_Aa+1):N] <- 11 # Перенесення до початкового складу A-особин
# Higher level cycles running — запуск циклів вищого рівня
# Цикл ітерацій:
for (i in 1:iterat) { # Початок циклу певної ітерації
  Al_Pop <- sample(Al_1_Pop, N) # На першому циклі, ще до початку основного циклу, особин слід перемішати
  # Запис до матриці з результатами початкового складу на початку роботи моделі:
  Rezult[1, i] <- (length(which(Al_Pop==22))+0.5*length(which(Al_Pop==12))) / N # Частка гену a
# Main work cycle — основний робочий цикл
  for (t in 1:cycles) { # Робочий цикл моделі
    # Утворення пар:
    Be_Par <- Al_Pop[1:p] + Al_Pop[(p+1):(2*p)] # Перша половина вектору утворює пари з другою половиною
    l22 <- length(which(Be_Par==22)) # Кількість пар з кодом 22 (і далі з іншими кодами)
    l23 <- length(which(Be_Par==23))
    l24 <- length(which(Be_Par==24))
    l33 <- length(which(Be_Par==33))
    l34 <- length(which(Be_Par==34))
    l44 <- length(which(Be_Par==44))
    # Потомство, утворене парами відповідно до об'єктів Offs_..., записується в вектор Ga_Pop:
    if (l22>0) Ga_Pop[1:(r*2*l22)] <- sample(Offs_22, r*2*l22, replace = T) # Пари 22 отримують потомство...
    if (l23>0) Ga_Pop[(r*2*l22+1):(r*2*(l22+l23))] <- sample(Offs_23, r*2*l23, replace = T) # Пари 23...
    if (l24>0) Ga_Pop[(r*2*(l22+l23)+1):(r*2*(l22+l23+l24))] <- sample(Offs_24, r*2*l24, replace = T)
    if (l33>0) Ga_Pop[(r*2*(l22+l23+l24)+1):(r*2*(l22+l23+l24+l33))] <- sample(Offs_33, r*2*l33, replace = T)
    if (l34>0) Ga_Pop[(r*2*(l22+l23+l24+l33)+1):(r*2*(l22+l23+l24+l33+l34))] <- sample(Offs_34, r*2*l34, replace = T)
    if (l44>0) Ga_Pop[(r*2*(l22+l23+l24+l33+l34)+1):(r*2*p)] <- sample(Offs_44, r*2*l44, replace = T)
    # Підраховується, яке потомство утворилося:
    Ga_N_aa <- length(which(Ga_Pop==22)) # Розрахунок кількості потомства з a-фенотипом (генотип 22) 
    Ga_N_Ax <- length(which(Ga_Pop!=22)) # Розрахунок кількості потомства з A-фенотипом (генотипи 11 та 12)
    if (Ga_N_aa > 0) De_Pop[1:Ga_N_aa] <- subset(Ga_Pop, Ga_Pop==22) # особини з a-фенотипом (генотип 22) зберігаються усі
    Lot <- sample(Fate, Ga_N_Ax, replace = T) # Вибірка, що визначає долю особин з A-фенотипом (генотипи 11 та 12)
    De_Pop[(Ga_N_aa+1):(Ga_N_aa+Ga_N_Ax)] <- subset(Ga_Pop, Ga_Pop!=22)*Lot # особини з A-фенотипом перенесені в вектор De_Pop; загиблі позначені NA
    Om_Pop <- na.omit(De_Pop) # Ті, хто вижили (без врахування загиблих); чисельність може бути вищою за N
    Al_Pop <- sample(Om_Pop, N) # Випадково вибрані плідники наступного покоління
# II.4 Збір підсумків і необхідні "запобіжники"
    Rezult[t+1, i] <- (length(which(Al_Pop==22))+0.5*length(which(Al_Pop==12))) / N
    if (length(which(Al_Pop!=11))==0) {Rezult[cycles+1, i] <- 0; break} # У разі перемоги A-особин 
    if (length(which(Al_Pop!=22))==0) {Rezult[cycles+1, i] <- 1; break} # У разі перемоги a-особин
                       } # Кінець робочого циклу
                     } # Кінець циклу ітерації
# IV. FINISHING — ЗАВЕРШЕННЯ:
# Results viewing — перегляд підсумків
head(Rezult) # Перегляд "голови" (початку) матриці з динамікою концентрації a-особин протягом кожної ітерації

##       [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]  [,9] [,10]
## [1,] 0.035 0.035 0.035 0.035 0.035 0.035 0.035 0.035 0.035 0.035
## [2,] 0.060 0.040 0.040 0.025 0.030 0.025 0.050 0.025 0.050 0.050
## [3,] 0.040 0.045 0.040 0.025 0.020 0.025 0.065 0.025 0.080 0.055
## [4,] 0.025 0.030 0.045 0.040 0.035 0.030 0.070 0.020 0.095 0.055
## [5,] 0.035 0.065 0.065 0.015 0.040 0.025 0.070 0.015 0.095 0.065
## [6,] 0.035 0.065 0.055 0.030 0.040 0.030 0.060 0.025 0.120 0.045

tail(Rezult) # Перегляд "хвоста" (кінця) матриці з динамікою концентрації a-особин протягом кожної ітерації

##        [,1] [,2] [,3] [,4] [,5]  [,6]  [,7] [,8] [,9] [,10]
##  [96,]   NA   NA   NA   NA   NA 0.075 0.065   NA   NA 0.920
##  [97,]   NA   NA   NA   NA   NA 0.100 0.065   NA   NA 0.930
##  [98,]   NA   NA   NA   NA   NA 0.090 0.070   NA   NA 0.960
##  [99,]   NA   NA   NA   NA   NA 0.090 0.060   NA   NA 0.960
## [100,]   NA   NA   NA   NA   NA 0.075 0.060   NA   NA 0.965
## [101,]    0    0    0    0    0 0.130 0.055    0    1 0.965

# Results visualization — візуалізація підсумків
plot(Rezult[, 1], type="l", lty=1, col="red", ylim=c(0, 1), 
     main = "Динаміка частки рецесивного алеля,\n що підтримується добором,\n у 10 різних ітераціях",
     xlab="Цикли імітації", ylab="Частка алеля а")
lines(Rezult[, 2], type="l", lty=1, col="blue")
lines(Rezult[, 3], type="l", lty=1, col="brown")
lines(Rezult[, 4], type="l", lty=1, col="chartreuse")
lines(Rezult[, 5], type="l", lty=1, col="coral")
lines(Rezult[, 6], type="l", lty=1, col="darkviolet")
lines(Rezult[, 7], type="l", lty=1, col="gold")
lines(Rezult[, 8], type="l", lty=1, col="deepskyblue")
lines(Rezult[, 9], type="l", lty=1, col="hotpink")
lines(Rezult[, 10], type="l", lty=1, col="lightsalmon")

Fig. 5.3.1 Result of executing the provided code. As you can see, we simply plotted the trajectories of all 10 iterations. What does the obtained graph indicate? We used a sufficiently strong selection (by the standards of the previous model concerning clonal organisms) (s=0.1). However, we see that this selection is not enough to "pull" the frequency of the favored allele to noticeable values in most cases. If the frequency of the favored allele becomes sufficiently high, it naturally continues to increase; if it is low, it wanders in the zone where it is; this often leads to the random disappearance of the favored allele and the termination of the iteration. What is this related to? It's related to the fact that we are favoring the recessive allele through selection. When its frequency is low, most individuals carrying this allele are heterozygotes, meaning they have the Aa genotype and the A phenotype. Selection simply "doesn't see" that these individuals carry the valuable allele! Can you modify this model so that selection favors the dominant allele instead of the recessive one? How will this affect the dynamics of the favored allele? // add bootstrap table styles to pandoc tables function bootstrapStylePandocTables() { $('tr.odd').parent('tbody').parent('table').addClass('table table-condensed'); } $(document).ready(function () { bootstrapStylePandocTables(); }); $(document).ready(function () { window.buildTabsets("TOC"); }); $(document).ready(function () { $('.tabset-dropdown > .nav-tabs > li').click(function () { $(this).parent().toggleClass('nav-tabs-open'); }); }); (function () { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; document.getElementsByTagName("head")[0].appendChild(script); })();