Why genotype coding matters
A two-locus interaction model needs numerical columns for the genotypes at both loci. But a genotype is categorical, and there is more than one defensible way to represent it numerically. A dosage column treats successive copies of an allele as successive steps; dominant or recessive indicators group genotypes; genotype-category indicators preserve all three genotype categories separately. The chosen columns determine which patterns the model can represent.
This tutorial focuses on constructing those columns and their products. It does not establish that a particular coding is biologically correct, or that a product coefficient by itself proves a biological interaction. Coding specifies a statistical representation; its scientific interpretation depends on the outcome model, the analysis scale, and the question being asked.
Single-locus coding choices
The dosage coding \(x\in\{0,1,2\}\) is often called additive coding. The name refers to how the predictor is coded: moving from zero to one alternate allele increases the column by one, as does moving from one to two. It does not assert that the biological effect of each allele copy is identical.
Other codings express different groupings. A dominant indicator is 1 for any genotype carrying at least one alternate allele; a recessive indicator is 1 only for the alternate-allele homozygote. Both are binary columns, but they encode different comparisons.
| Genotype | Dosage \(x\) | Dominant \(D\) | Recessive \(R\) |
|---|---|---|---|
| \(aa\) | 0 | 0 | 0 |
| \(aA\) | 1 | 1 | 0 |
| \(AA\) | 2 | 1 | 1 |
A third option is to represent the three genotype categories without imposing a one-column dosage pattern. Choose one genotype as the reference category, then create an indicator for each of the other two. For example, with \(aa\) as reference, let \(G_{aA}=I(\text{genotype is }aA)\) and \(G_{AA}=I(\text{genotype is }AA)\). The row for \(aa\) has \((G_{aA},G_{AA})=(0,0)\); the other rows have \((1,0)\) and \((0,1)\). This coding retains separate columns for the heterozygote and alternate homozygote.
With an intercept, do not include indicators for all three categories at one locus. Their sum is 1 for every individual, so including all three alongside the intercept creates exact redundancy. Using a reference category and two indicators avoids this particular problem. The same principle applies when constructing a two-locus design.
Worked Example: Coding a Single Locus Three Ways
Suppose three hypothetical individuals have genotypes \(aa\), \(aA\), and \(AA\) at a locus, respectively. Find each individual’s dosage, dominant indicator, recessive indicator, and two reference-coded category indicators using \(aa\) as the reference.
For \(aa\), there are zero copies of \(A\), so \(x=0\). The condition \(x\geq1\) is false and \(x=2\) is false, giving \(D=0\), \(R=0\). It is neither the \(aA\) nor the \(AA\) category, so \((G_{aA},G_{AA})=(0,0)\).
For \(aA\), there is one copy of \(A\), so \(x=1\). Thus \(D=I(1\geq1)=1\) and \(R=I(1=2)=0\). Its category indicators are \((G_{aA},G_{AA})=(1,0)\).
For \(AA\), there are two copies of \(A\), so \(x=2\). Thus \(D=I(2\geq1)=1\) and \(R=I(2=2)=1\). Its category indicators are \((G_{aA},G_{AA})=(0,1)\). These columns encode the same underlying genotype in different ways; they should not be treated as independent measurements.
Constructing two-locus main effects and products
Now consider two biallelic loci. At locus 1, use reference allele \(a\), alternate allele \(A\), dosage \(x_1\), and genotype indicators \(G_{1,aA}\) and \(G_{1,AA}\), with \(aa\) as reference. At locus 2, use reference allele \(b\), alternate allele \(B\), dosage \(x_2\), and indicators \(G_{2,bB}\) and \(G_{2,BB}\), with \(bb\) as reference.
A basic dosage-coded design has an intercept, both locus dosage columns, and their product. The interaction product for an individual is calculated by multiplying that individual’s two dosage values. For other coding choices, the same construction rule applies: form the desired main-effect columns first, then multiply columns across loci to obtain product terms.
Worked Example: Dosage Main Effects and Their Product
For one hypothetical individual, suppose the genotype at locus 1 is \(AA\), and the genotype at locus 2 is \(bB\). Construct the dosage-coded design row with an intercept, the two main-effect columns, and the dosage product.
At locus 1, \(AA\) contains two copies of \(A\), so \(x_1=2\). At locus 2, \(bB\) contains one copy of \(B\), so \(x_2=1\). The product column is \[ x_1x_2=2\times1=2. \]
In the stated column order, the design row is \((1,x_1,x_2,x_1x_2)=(1,2,1,2)\). The first entry is the intercept column, and the final entry is a constructed predictor column—not a new genotype or a second observation.
Dominant and recessive codings can also be combined across loci. For example, a dominant-by-dominant product is \(D_1D_2\). It equals 1 only when each locus has at least one alternate allele. A recessive-at-locus-1 by dominant-at-locus-2 product, \(R_1D_2\), equals 1 only when locus 1 is \(AA\) and locus 2 carries at least one \(B\). The biological grouping being represented must be stated; the phrase “dominant interaction” alone does not specify both component codings.
Worked Example: A Dominant-by-Recessive Product
For a hypothetical individual, suppose locus 1 is \(aA\) and locus 2 is \(BB\). Construct dominant and recessive indicators at each locus, then calculate \(D_1R_2\).
At locus 1, \(aA\) carries at least one \(A\) but is not \(AA\), so \(D_1=1\) and \(R_1=0\). At locus 2, \(BB\) carries at least one \(B\) and has two copies of \(B\), so \(D_2=1\) and \(R_2=1\).
Therefore \(D_1R_2=1\times1=1\). This product column marks individuals with a carrier genotype at locus 1 and a \(BB\) genotype at locus 2. If the second genotype had instead been \(bB\), then \(R_2=0\) and the product would be \(1\times0=0\).
Reference-coded genotype-category products
When each locus is represented by two indicators, a full set of categorical product terms consists of four columns. For the conventions above, these are \(G_{1,aA}G_{2,bB}\), \(G_{1,aA}G_{2,BB}\), \(G_{1,AA}G_{2,bB}\), and \(G_{1,AA}G_{2,BB}\). Together with an intercept and the two indicators for each locus, this design has nine columns: one intercept, four single-locus indicators, and four products.
The product columns are calculated row by row. Since each locus has three possible genotype categories, each individual belongs to exactly one of the nine two-locus genotype combinations. With the specified reference coding, a product column is 1 only for its corresponding pair of nonreference categories; all other product columns are 0 for that individual. The intercept and main-effect columns also remain in the design: product terms supplement them rather than replace them.
Worked Example: Building a Categorical Two-Locus Row
Suppose a hypothetical individual has genotype \(aA\) at locus 1 and \(BB\) at locus 2. Use the reference genotypes \(aa\) and \(bb\), and order the columns as the intercept; the two locus 1 indicators; the two locus 2 indicators; then the four products in the order defined above.
At locus 1, the genotype is \(aA\), so \((G_{1,aA},G_{1,AA})=(1,0)\). At locus 2, the genotype is \(BB\), so \((G_{2,bB},G_{2,BB})=(0,1)\). The four products are \[ (1\times0,\;1\times1,\;0\times0,\;0\times1)=(0,1,0,0). \]
Thus the complete row is \((1,1,0,0,1,0,1,0,0)\). The second product is 1 because this individual is in the \(aA\)-by-\(BB\) combination; the other three products are 0. This row illustrates the design construction only. It does not, on its own, say what outcome difference any coefficient represents.
Why the categorical design has nine columns
The nine-column count can be checked directly. Each locus has three genotype categories, giving nine possible paired categories. The reference-coded construction has one intercept, two indicators for locus 1, two for locus 2, and four products: \[ 1+2+2+(2\times2)=9. \] Each paired genotype category has a distinct pattern in these columns. For the reference-reference pair, all six indicators and products are 0; a nonreference genotype at just one locus activates its corresponding main-effect indicator; and a pair of nonreference genotypes activates the relevant product as well.
This is a coding fact, not a guarantee that a dataset contains observations in all nine combinations. If a combination is absent, the corresponding pattern cannot be learned from observed data without additional assumptions. Whether a particular model is estimable in a specific dataset requires checking its design matrix; merely writing down nine columns does not establish that they are identifiable.
Practical choices and common pitfalls
A coding should follow the scientific and statistical question, not be selected merely because it produces a convenient product term. Dosage coding is compact and imposes a one-step numerical scale. Dominant or recessive coding combines categories according to a specified genotype condition. Reference-coded indicators retain separate categories and provide a flexible categorical representation, at the cost of more columns. None is universally preferable.
Whichever coding is used, state the reference allele, the genotype-to-column rule, the main-effect columns, and exactly which cross-locus products are included. The same genotype can have different numerical values under different coding schemes, so a coefficient or product column cannot be interpreted without that information. These design choices do not require Hardy–Weinberg equilibrium or independence between loci: the coding rules are deterministic mappings from observed genotype calls to columns. Such assumptions may matter in other parts of a genetic analysis, but they are not needed to define these columns.
- Using all category indicators with an intercept. The indicators sum to 1, making the columns redundant. Choose a reference category or use a different explicitly defined parameterization.
- Calling a dosage product a universal interaction measure. \(x_1x_2\) is the product for a particular dosage coding. It is not interchangeable with products from dominant, recessive, or category-indicator coding.
- Dropping main effects when adding products. A product-term design ordinarily retains the selected locus main-effect columns as well; products alone encode a different model.
- Reading biological mechanism from a coding label. “Dominant” or “additive” describes the numerical encoding here. It does not by itself establish dominance, additivity, or a biological mechanism.
- Assuming every written column is estimable. A design column can be defined even when genotype combinations are missing or redundant in the observed sample. Check the observed design before drawing conclusions from a fitted model.
Check Your Understanding
Use the stated reference alleles and coding rules when answering.
- At a locus with reference allele \(c\) and alternate allele \(C\), give the dosage, dominant indicator, and recessive indicator for genotype \(cC\).
- With \(aa\) as reference at locus 1 and \(bb\) as reference at locus 2, which of the four categorical product columns equals 1 for genotype pair \(AA\)-by-\(bB\)?
- For dosage values \(x_1=1\) and \(x_2=2\), calculate the dosage-by-dosage product and write the design row with an intercept.
- Why is it redundant to include all three genotype-category indicators and an intercept at one biallelic locus?
- Does defining a nine-column categorical two-locus design guarantee that all nine genotype combinations are present in a sample? Explain.