Here is a recent example of the derivation of the genotype model from Octopus genotype calling paper:
All samples have known ploidy and copy number, so the likelihood function of reads $R$ given genotype $g$ is:
$p(R|g) = \mathop {\prod }\limits_{n = 1}^{|R|} \frac{1}{{|g|}}\mathop {\sum }\limits_{i = 1}^{|g|} p(r_n|g_i)$
where $|g|$ is the ploidy and $|R|$ is the number of reads. The joint genotype posterior for $S$ samples is therefore given by:
$p({\bf{g}}|{{R}},{\cal{M}}_{{g}}) \propto p({\bf{g}}|{\cal{M}}_g)\mathop {\prod }\limits_{s = 1}^S p({{R}}_s|{\bf{g}}_s)$
where the genotype prior model, $\cal{M}𝑔$, is either the uniform or HWE-coalescent prior. Unfortunately, the number of genotype combinations g grows exponentially in the number of samples S, so we cannot evaluate the full posterior distribution in general. Therefore, other than for trivial cases, we first approximate the sample marginal genotype posterior distribution under the HWE model (without mutations) $𝑝(𝐠𝑠|𝑅,\cal{M}𝑔)$ and use these marginal probabilities to select K genotype combinations $𝐠1,…,𝐠𝐾$ (K is user-defined) to evaluate under the full joint genotype model. The approximate posterior marginals are computed with expectation maximization.
The source code can be found here.