### Data structure

Suppose there are *D* ChIP-seq datasets generated using cells from the same individual and the same cell type. Each dataset *d* corresponds to one TF or HM, and has *J*_{
d
} replicate samples (Figure 1a). Different datasets represent different TFs or HMs, or data generated by different labs. For the individual in question, assume one is interested in analyzing *I* heterozygote SNPs with known genotypes. We want to know whether the two alleles of each SNP behave differently in each dataset, and if possible how the AS events are correlated among datasets. For each SNP, the allele consistent with the reference genome is called the *reference allele*, and the other allele is called the *non-reference allele*.

After read mapping and data preprocessing (see Additional file 1: Supplemental Methods S.1), we count reads for each allele at each heterozygote SNP. For SNP *i*, dataset *d* and replicate sample *j*, let *x*_{
idj
} and *y*_{
idj
}be the read counts for the reference allele and non-reference allele respectively. Let *n*_{
idj
}=*x*_{
idj
} + *y*_{
idj
} be the total read count (See Figure 1a for a toy example). Protein-DNA binding can be skewed to the reference allele (SR), skewed to the non-reference allele (SN), or not allele-specific (NS). We use a binary variable *b*_{
id
} to indicate whether SNP *i* is SR (*b*_{
id
}=1) or not (*b*_{
id
}=0) in dataset *d*. If *b*_{
id
}=1, then SNP *i* is assumed to be SR in all replicate samples in dataset *d*. Similarly, we introduce another binary indicator *c*_{
id
} to indicate whether SNP *i* is SN or not in dataset *d*. *b*_{
id
}and *c*_{
id
} cannot be equal to one at the same time. If *b*_{
id
}=0 and *c*_{
id
}=0, then SNP *i* is NS in dataset *d*. The configuration at each SNP *i* can be described by two vectors *B*_{
i
}=(*b*_{i 1},⋯,*b*_{
iD
}) and *C*_{
i
}=(*c*_{i 1},⋯,*c*_{
iD
}) (See Figure 1d for a cartoon illustration). Based on these notations, (*x*_{
idj
},*y*_{
idj
}), or equivalently (*x*_{
idj
},*n*_{
idj
}), are the observed data for SNP *i* in sample (*d,j*), whereas the indicators *b*_{
id
} and *c*_{
id
} are unobserved.

### Main intuition and challenge

Our primary goal is to infer for each SNP whether there is allelic imbalance in each dataset. This is equivalent to inferring *b*_{
id
} and *c*_{
id
}. A simple solution to this problem is to analyze each individual dataset separately, but this approach has low statistical power since the counts (*x*_{
idj
},*n*_{
idj
}) usually are small.

If one knows how different datasets are correlated in terms of allelic imbalance, this knowledge may be used to improve the data analysis. For instance, if the allelic imbalance of two proteins A and B are closely correlated, then observing skewed read counts for protein A will provide information for inferring the allelic imbalance of protein B. Integrating the data from both A and B will increase the effective number of reads available for statistical inference, which will then lead to increased statistical power.

In reality, how different proteins are correlated is usually unknown. However, one may learn it by studying the data from many SNPs. Each SNP has three possible states in each dataset: SR, SN and NS. For *D* datasets, there are 3^{D} possible configurations in total. From studying many SNPs, one can know the relative frequencies (or mixing proportions) of these 3^{D}configurations. The mixing proportions will tell how different datasets are correlated. For instance, let [*s*_{1},*s*_{2},⋯,*s*_{
D
}] be the skewness configuration of a SNP in the *D* datasets. If the mixing proportions for three configurations [*NS*,*NS*,⋯,*NS*], [*SR*,*SR*,⋯,*SR*] and [*SN*,*SN*,⋯,*SN*] are 0.9, 0.05 and 0.05, then no other configurations exist in the data and all datasets are perfectly correlated in terms of the allelic imbalance. In other words, at a particular SNP, if one dataset is SR, then all the other datasets are also SR. If one is SN, then all the others are also SN. On the other hand, if other configurations have non-zero mixing proportions, then not all datasets are perfectly correlated, and at a particular SNP, one allows the possibility that only a subset of datasets are correlated. For instance, if the mixing proportion for a configuration [*SR*,*SR*,*NS*,⋯,*NS*] is 0.03, then there will be 3% of SNPs that are skewed to the reference allele in the first two datasets but not skewed in the other datasets. Therefore, knowing the mixing proportions of all 3^{D}configurations will tell one the correlation structure in the data. This knowledge can then be used to improve statistical inference at each individual SNP by facilitating information sharing across datasets. For example, if the configuration [*SR, SR, SN*] has a much higher mixing proportion than [*SR, SR, NS*], then observing strong skewness towards the reference allele of a SNP in the first two datasets will imply that, a priori, the SNP is highly likely to be skewed to the non-reference allele in the third dataset and has much lower probability to be non-skewed for both alleles. The principle here is the same as the principle represented by the Bayesian hierarchical models in the statistical literature.

A limitation of this approach is that one has to enumerate all 3^{D} AS configurations in order to describe the correlation. As the number of datasets increases, the number of possible configurations increases exponentially. Thus this approach does not scale well with the increasing *D*. Later, in our analysis of GM12878 data, *D*=40 and 3^{D}>10^{19}. This simple approach is clearly intractable.

To circumvent the difficulty of documenting the frequencies of all 3^{D}configurations, iASeq employs a technique that can describe the major correlation patterns in the data using a few probability vectors whose values vary from 0 to 1 rather than being dichotomous (i.e., 0 or 1). This approach significantly reduces the model complexity but keeps the flexibility to account for all 3^{D}configurations. It is easily scalable to increasing dataset number. The correlation structure in the model can then be used to improve the statistical inference of allelic imbalance at each SNP in each individual dataset.

### Probability model

iASeq is based on the Bayesian hierarchical mixture model below that uses several probability vectors to describe the major correlation patterns among multiple datasets (Figure 1). The model assumes that SNPs can be grouped into *K* + 1 classes with different allele-specificity patterns (*K*≪3^{D}), and the observed data are viewed as generated as follows:

● First, a class label *a*_{
i
}is randomly assigned to each SNP *i* according to a probability vector *Π*=(*Π*_{0},*Π*_{1},⋯,*Π*_{
K
}). Here, *Π*_{
k
}=*Pr*(*a*_{
i
}=*k*) is the prior probability to assign a SNP to class *k*. \sum _{k}{\Pi}_{k}=1.

● If the class label *a*_{
i
}=0, then *B*_{
i
}=(0,⋯,0) and *C*_{
i
}=(0,⋯,0). In other words, all SNPs in class 0 are background SNPs, and they are NS in all datasets. If *a*_{
i
}=*k* and *k*≠0, then SNP *i* can be skewed, and its [*b*_{
id
};*c*_{
id
}]s in different datasets are generated independently according to the following probabilities: *Pr*(*b*_{
id
}=1,*c*_{
id
}=0|*a*_{
i
}=*k*)=*v*_{
kd
}and *Pr*(*b*_{
id
}=0,*c*_{
id
}=1|*a*_{
i
}=*k*)=*w*_{
kd
}. We assume *v*_{
kd
} + *w*_{
kd
}<1, i.e., *Pr*(*b*_{
id
}=0,*c*_{
id
}=0|*a*_{
i
}=*k*)=1−*v*_{
kd
}−*w*_{
kd
}>0. The model implies that each class is associated with two vectors of probabilities *V*_{
k
}=(*v*_{k 1},⋯,*v*_{
kD
}) and *W*_{
k
}=(*w*_{k 1},⋯,*w*_{
kD
}). For SNPs in class *k*, *B*_{
i
}and *C*_{
i
}are generated according to the probabilities in *V*_{
k
}and *W*_{
k
}.

● Next, the observed read counts are generated based on the AS configurations specified by *B*_{
i
}s and *C*_{
i
}s. Consider SNP *i* and dataset *d*. If *b*_{
id
}=1, then (*x*_{
idj
},*n*_{
idj
}) in each replicate sample (*d,j*) is generated according to a probability distribution *Pr*(*x*_{
idj
},*n*_{
idj
}|*b*_{
id
}=1,*c*_{
id
}=0)=*Pr*(*n*_{
idj
}|*b*_{
id
}=1,*c*_{
id
}=0)*Pr*(*x*_{
idj
}|*n*_{
idj
},*b*_{
id
}=1,*c*_{
id
}=0)≡*Pr*(*n*_{
idj
})*f*_{idj 1}(*x*_{
idj
}). Here we assume that the marginal distribution of *n*_{
idj
}does not depend on *b*_{
id
}and *c*_{
id
}, and we use *f*_{idj 1}(*x*_{
idj
}) to denote the conditional distribution *Pr*(*x*_{
idj
}|*n*_{
idj
},*b*_{
id
}=1,*c*_{
id
}=0). Data in different replicate samples are assumed to be generated independently. Similarly, if *c*_{
id
}=1, then (*x*_{
idj
},*n*_{
idj
})s are generated according to *Pr*(*x*_{
idj
},*n*_{
idj
}|*b*_{
id
}=0,*c*_{
id
}=1)=*Pr*(*n*_{
idj
})*f*_{idj 2}(*x*_{
idj
}). If *b*_{
id
}=0 and *c*_{
id
}=0, then (*x*_{
idj
},*n*_{
idj
})s are generated according to *Pr*(*x*_{
idj
},*n*_{
idj
}|*b*_{
id
}=0,*c*_{
id
}=0)=*Pr*(*n*_{
idj
})*f*_{idj 0}(*x*_{
idj
}).

For SNP *i* and dataset *d*, we organize data from all replicates *j*=1,⋯,*J*_{
d
} into *X*_{
id
}=(*x*_{id 1},⋯,*x*_{
idJ
}_{
d
}) and *N*_{
id
}=(*n*_{id 1},⋯,*n*_{
idJ
}_{
d
}). For SNP *i*, *X*_{
i
}=(*X*_{i 1},⋯,*X*_{
iD
}) and *N*_{
i
}=(*N*_{i 1},⋯,*N*_{
iD
}) contain data from all datasets. The final observed data are *X*=(*X*_{1},⋯,*X*_{
I
}) and *N*=(*N*_{1},⋯,*N*_{
I
}) which are the ensemble of data from all SNPs.

Let *A*=(*a*_{1},⋯,*a*_{
I
}) be the collection of class membership indictors of all SNPs, and let *B*=(*B*_{1},⋯,*B*_{
I
}) and *C*=(*C*_{1},⋯,*C*_{
I
}) be the SR and SN indictors for all SNPs. *A, B* and *C* are the unobserved missing data one wants to infer.

Organize the probability vectors *V*_{
k
}and *W*_{
k
} from different classes into two matrices \left(\right)close="">\n \n \n \n V\n \n \n K\n \xd7\n D\n \n \n =\n \n \n (\n \n \n V\n \n \n 1\n \n \n T\n \n \n ,\n \cdots \n \n ,\n \n \n V\n \n \n K\n \n \n T\n \n \n )\n \n \n T\n \n \n \n and \left(\right)close="">\n \n \n \n W\n \n \n K\n \xd7\n D\n \n \n =\n \n \n (\n \n \n W\n \n \n 1\n \n \n T\n \n \n ,\n \cdots \n \n ,\n \n \n W\n \n \n K\n \n \n T\n \n \n )\n \n \n T\n \n \n \n. *V*, *W*, and the probability vector *Π* that describes the class abundance are the unknown model parameters. *K* is assumed to be fixed. The choice of *K* and specification of data generating distributions *Pr*(*n*_{
idj
}), *f*_{idj 0}(*x*_{
idj
}), *f*_{idj 1}(*x*_{
idj
}) and *f*_{idj 2}(*x*_{
idj
}) will be discussed later.

Based on this model, each SNP class *k* (*k*≠0) is associated with two vectors of probabilities *V*_{
k
}and *W*_{
k
} which characterize the allelic imbalance preferences in different datasets for SNPs belonging to class *k*. For example, if a class has [*V*_{
k
};*W*_{
k
}] = [(0.8,0.7,0.1,0.1); (0.1,0.1,0.8,0.1)], then SNPs in this class have high probability to be SR in datasets 1 and 2, and high probability to be SN in dataset 3, but they have low probability to be allele-specific in dataset 4. Since *V*_{
k
} and *W*_{
k
}are probabilities rather than 0-1 vectors, each class *k* can generate all 3^{D} AS configurations. Therefore, SNPs in the same class are not required to have the same AS configuration (e.g., a class can have one SNP with configuration [*SR*,*SR*,*NS*,*NS*] while at the same time another SNP with configuration [*SR*,*NS*,*SR*,*NS*]), although they usually have similar AS configurations because SNPs in the same class are all generated using the same probability vectors. Meanwhile, there are *K* different classes, and each class has a different [*V*_{
k
};*W*_{
k
}] which specifies a different preference to generate the skewing configurations. Thus, whereas SNPs in the same class tend to have similar [*B*_{
i
};*C*_{
i
}] configurations, SNPs from different classes tend to have very different configurations. Conceptually, this is similar to a model-based clustering analysis in which SNPs are grouped into *K* + 1 clusters based on their [*B*_{
i
};*C*_{
i
}] configurations. However, an important difference here is that [*B*_{
i
};*C*_{
i
}]s are unknown.

Our model assumes that [*b*_{
id
};*c*_{
id
}]s of the same SNP in different datasets are a priori independent conditional on the class membership *a*_{
i
}. However, [*b*_{
id
};*c*_{
id
}]s from different datasets are not independent marginally if one integrates out the class label *a*_{
i
}. For example, the marginal probability *Pr*([*b*_{
id
};*c*_{
id
}]= [1;0])=\sum _{k}\mathrm{Pr}\left(\right[{b}_{\mathrm{id}};{c}_{\mathrm{id}}]=\phantom{\rule{0.3em}{0ex}}[1;0\left]\right|{a}_{i}=k\left)\mathrm{Pr}\right({a}_{i}=k)=\sum _{k=1}^{K}{\Pi}_{k}{v}_{\mathrm{kd}}. On the other hand, the joint probability \phantom{\rule{0.3em}{0ex}}\mathrm{Pr}\left(\right[\phantom{\rule{0.3em}{0ex}}{\mathit{B}}_{i};{\mathit{C}}_{i}]=[\phantom{\rule{0.3em}{0ex}}(1,1,\phantom{\rule{0.3em}{0ex}}\cdots \phantom{\rule{0.3em}{0ex}},\phantom{\rule{0.3em}{0ex}}1);(0,0,\cdots \phantom{\rule{0.3em}{0ex}},0)\left]\right)\phantom{\rule{0.3em}{0ex}}=\phantom{\rule{0.3em}{0ex}}\sum _{k=1}^{K}{\Pi}_{k}\left(\prod _{d}{v}_{\mathrm{kd}}\right), which is clearly different from the product of the marginals \prod _{d}\mathrm{Pr}\left(\right[{b}_{\mathrm{id}};{c}_{\mathrm{id}}]=[1;0\left]\right)=\prod _{d}\left(\sum _{k=1}^{K}{\Pi}_{k}{v}_{\mathrm{kd}}\right). This explains why our model can be used to describe the correlation among multiple datasets despite the conditional independence assumption. Intuitively, if one views the model as a clustering analysis of SNPs based on [*B*_{
i
};*C*_{
i
}], then each cluster will represent a co-occurrence pattern of allele-specificity across multiple proteins. The marginal correlation among multiple datasets is described by multiple clusters, whereas within each cluster the data in different datasets are generated independently. In real data, a small *K* (i.e., a small number of SNP classes) usually is sufficient to describe the major correlation structure among datasets. Using *Π*, *V* and *W* to describe the correlation among datasets only requires *O*(*KD*) parameters, which is significantly less complex than *O*(3^{D}) parameters. At the same time, the iASeq model still provides the flexibility to accommodate all 3^{D} possible [*B*_{
i
};*C*_{
i
}] configurations as all of them have non-zero probability to occur.

### Data generating distributions

To fully specify the model, one also needs to specify the data generating distributions *Pr*(*x*_{
idj
},*n*_{
idj
}|*b*_{
id
},*c*_{
id
})=*Pr*(*n*_{
idj
})*Pr*(*x*_{
idj
}|*n*_{
idj
},*b*_{
id
},*c*_{
id
}). The primary goal of iASeq is to infer whether two alleles are different. We assume that information on allele-specificity is only contained in *Pr*(*x*_{
idj
}|*n*_{
idj
},*b*_{
id
},*c*_{
id
}), and therefore the exact form of *Pr*(*n*_{
idj
}), i.e., the marginal probability distribution of the total read count, is irrelevant for our purpose. As such, we mainly focus on modeling the conditional distribution of *x*_{
idj
}given *n*_{
idj
}, *b*_{
id
} and *c*_{
id
}, i.e., the three distributions *f*_{idj 0}(*x*), *f*_{idj 1}(*x*) and *f*_{idj 2}(*x*).

iASeq models these distributions hierarchically in two steps. First, *x*_{
idj
} is assumed to follow a binomial distribution *x*_{
idj
}|*n*_{
idj
},*p*_{
idj
}∼*Bin*(*n*_{
idj
},*p*_{
idj
}), where *p*_{
idj
} is the probability that a read generated at SNP *i* in sample (*d*,*j*) represents the reference allele. Next, we model *p*_{
idj
}depending on the values of *b*_{
id
}and *c*_{
id
}.

If *b*_{
id
}=0 and *c*_{
id
}=0, SNP *i* is NS in dataset *d*. In this case, we assume that *p*_{
idj
}follows a Beta distribution *Beta*(*α*_{
dj
}*β*_{
dj
}) with mean *p*_{dj 0}=*α*_{
dj
}/(*α*_{
dj
} + *β*_{
dj
}). Note that a simpler model for *p*_{
idj
} would be to set it to a constant *p*_{dj 0} which reflects the background ratio of read counts between two alleles. However, previous studies have shown that many background SNPs can have *p*_{
idj
} slightly different from the average background *p*_{dj 0}even though they do not have biologically meaningful allele-specificity [33]. As a result, a constant *p*_{dj 0} is not sufficient to describe the background variation. For this reason, we adopt the Beta distribution to describe *p*_{
idj
} instead of setting it to a constant (See the blue lines illustrated for *f*(*p*_{
idj
}|*b*_{
id
}=0,*c*_{
id
}=0) in Figure 1c). In the ideal world, the mean of the Beta distribution, *p*_{dj 0}, would be equal to 0.5. However, in reality *p*_{dj 0}may be slightly different from 0.5 due to various sources of read mapping biases. For example, allowing the same number of mismatches, reads from the reference allele are easier to be mapped back to the reference genome than reads from the non-reference allele. Therefore, in iASeq *p*_{dj 0}may take values different from 0.5. Indeed, it is determined by the parameters *α*_{
dj
} and *β*_{
dj
} in the Beta distribution which are estimated from the data using a moment matching approach (see Additional file 1: Supplemental Method S.2). Once estimated, *α*_{
dj
}, *β*_{
dj
} and *p*_{dj 0}are treated as fixed and known parameters. Based on the model for *p*_{
idj
}, we integrate out all possible values of *p*_{
idj
} to obtain the distribution of *x*_{
idj
}conditional on *b*_{
id
}=0 and *c*_{
id
}=0, which is a beta-binomial distribution:

\begin{array}{ll}\phantom{\rule{-14.0pt}{0ex}}{f}_{\mathrm{idj}0}\left({x}_{\mathrm{idj}}\right)& =\mathrm{Pr}\left({x}_{\mathrm{idj}}|{n}_{\mathrm{idj}},{b}_{\mathrm{id}}=0,{c}_{\mathrm{id}}=0\right)\phantom{\rule{2em}{0ex}}\\ ={\int}_{0}^{1}\mathrm{Pr}\left({x}_{\mathrm{idj}}\right|{n}_{\mathrm{idj}},{p}_{\mathrm{idj}},{b}_{\mathrm{id}}=0,{c}_{\mathrm{id}}=0)\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{1em}{0ex}}\times f\left({p}_{\mathrm{idj}}|{b}_{\mathrm{id}}=0,{c}_{\mathrm{id}}=0\right)d{p}_{\mathrm{idj}}\phantom{\rule{2em}{0ex}}\\ =\frac{{C}_{{n}_{\mathrm{idj}}}^{{x}_{\mathrm{idj}}}}{B\left({\alpha}_{\mathrm{dj}},{\beta}_{\mathrm{dj}}\right)}\phantom{\rule{0.3em}{0ex}}{\int}_{0}^{1}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}{p}^{{x}_{\mathrm{idj}}\phantom{\rule{0.3em}{0ex}}+\phantom{\rule{0.3em}{0ex}}{\alpha}_{\mathrm{dj}}-1}{(1\phantom{\rule{0.3em}{0ex}}-\phantom{\rule{0.3em}{0ex}}p)}^{{n}_{\mathrm{idj}}-{x}_{\mathrm{idj}}+{\beta}_{\mathrm{dj}}-1}\phantom{\rule{0.3em}{0ex}}\mathrm{dp}\phantom{\rule{2em}{0ex}}\\ =\frac{{C}_{{n}_{\mathrm{idj}}}^{{x}_{\mathrm{idj}}}B\left({x}_{\mathrm{idj}}+{\alpha}_{\mathrm{dj}},{n}_{\mathrm{idj}}-{x}_{\mathrm{idj}}+{\beta}_{\mathrm{dj}}\right)}{B\left({\alpha}_{\mathrm{dj}},{\beta}_{\mathrm{dj}}\right)}\phantom{\rule{2em}{0ex}}\end{array}

(1)

Here \left(\right)close="">\n \n \n \n C\n \n \n n\n \n \n k\n \n \n \n is the binomial coefficients “*n* choose *k*”, and *B*(*.* *.*) is the beta function.

If *b*_{
id
}=1 and *c*_{
id
}=0, SNP *i* is SR in dataset *d*. In this case, we assume that *p*_{
idj
} follows a uniform distribution *U*[*p*_{dj 0},1](See the dark blue lines illustrated for *f*(*p*_{
idj
}|*b*_{
id
}=1,*c*_{
id
}=0) in Figure 1c). Here *p*_{dj 0}=*α*_{
dj
}/(*α*_{
dj
} + *β*_{
dj
}) is defined as above. After integrating out *p*_{
idj
}, the distribution of *x*_{
idj
}conditional on *b*_{
id
}=1 and *c*_{
id
}=0 is

\begin{array}{ll}\phantom{\rule{-14.0pt}{0ex}}{f}_{\mathrm{idj}1}\left({x}_{\mathrm{idj}}\right)& =\mathrm{Pr}\left({x}_{\mathrm{idj}}\right|{n}_{\mathrm{idj}},{b}_{\mathrm{id}}=1,{c}_{\mathrm{id}}=0)\phantom{\rule{2em}{0ex}}\\ ={\int}_{0}^{1}\mathrm{Pr}\left({x}_{\mathrm{idj}}\right|{n}_{\mathrm{idj}},{p}_{\mathrm{idj}},{b}_{\mathrm{id}}=1,{c}_{\mathrm{id}}=0)\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{1em}{0ex}}\times f\left({p}_{\mathrm{idj}}\right|{b}_{\mathrm{id}}=1,{c}_{\mathrm{id}}=0)d{p}_{\mathrm{idj}}\phantom{\rule{2em}{0ex}}\\ =\frac{{C}_{{n}_{\mathrm{idj}}}^{{x}_{\mathrm{idj}}}}{1-{p}_{\mathrm{dj}0}}{\int}_{{p}_{\mathrm{dj}0}}^{1}{p}^{{x}_{\mathrm{idj}}}{(1-p)}^{{n}_{\mathrm{idj}}-{x}_{\mathrm{idj}}}\mathrm{dp}\phantom{\rule{2em}{0ex}}\end{array}

(2)

If *b*_{
id
}=0 and *c*_{
id
}=1, SNP *i* is SN in dataset *d*, and we assume that *p*_{
idj
} follows a uniform distribution *U*[0,*p*_{dj 0}] (See the light blue lines illustrated for *f*(*p*_{
idj
}|*b*_{
id
}=0,*c*_{
id
}=1) in Figure 1c). After integrating out *p*_{
idj
}, the distribution of *x*_{
idj
}conditional on *b*_{
id
}=0 and *c*_{
id
}=1 is

\begin{array}{ll}\phantom{\rule{-14.0pt}{0ex}}{f}_{\mathrm{idj}2}\left({x}_{\mathrm{idj}}\right)& =\mathrm{Pr}\left({x}_{\mathrm{idj}}\right|{n}_{\mathrm{idj}},{b}_{\mathrm{id}}=0,{c}_{\mathrm{id}}=1)\phantom{\rule{2em}{0ex}}\\ ={\int}_{0}^{1}f\left({x}_{\mathrm{idj}}\right|{n}_{\mathrm{idj}},{p}_{\mathrm{idj}},{b}_{\mathrm{id}}=0,{c}_{\mathrm{id}}=1)\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{1em}{0ex}}\times f\left({p}_{\mathrm{idj}}\right|{b}_{\mathrm{id}}=0,{c}_{\mathrm{id}}=1)d{p}_{\mathrm{idj}}\phantom{\rule{2em}{0ex}}\\ =\frac{{C}_{{n}_{\mathrm{idj}}}^{{x}_{\mathrm{idj}}}}{{p}_{\mathrm{dj}0}}{\int}_{0}^{{p}_{\mathrm{dj}0}}{p}^{{x}_{\mathrm{idj}}}{(1-p)}^{{n}_{\mathrm{idj}}-{x}_{\mathrm{idj}}}\mathrm{dp}\phantom{\rule{2em}{0ex}}\end{array}

(3)

### Joint probabilities and model fitting

Based on the model above, the complete data likelihood can be derived as:

\begin{array}{ll}\phantom{\rule{-14.0pt}{0ex}}\mathrm{Pr}& \left(X,N,A,B,C\right|\Pi ,V,W)\phantom{\rule{2em}{0ex}}\\ =\mathrm{Pr}\left(\mathit{N}\right)\mathrm{Pr}\left(X,A,B,C\right|N,\Pi ,V,W)\phantom{\rule{2em}{0ex}}\\ =\mathrm{Pr}\left(\mathit{N}\right)\prod _{i=1}^{I}\phantom{\rule{2.77695pt}{0ex}}\phantom{\rule{2.77695pt}{0ex}}\mathrm{Pr}({\mathit{X}}_{i},{a}_{i},\phantom{\rule{0.3em}{0ex}}{\mathit{B}}_{i},\phantom{\rule{0.3em}{0ex}}{\mathit{C}}_{i}|{\mathit{N}}_{i},\phantom{\rule{0.3em}{0ex}}\Pi ,\phantom{\rule{0.3em}{0ex}}V\phantom{\rule{0.3em}{0ex}},\phantom{\rule{0.3em}{0ex}}W)\phantom{\rule{2em}{0ex}}\end{array}

(4)

Define {L}_{\mathrm{id}0}=\prod _{j=1}^{{J}_{d}}{f}_{\mathrm{idj}0}\left({x}_{\mathrm{idj}}\right), {L}_{\mathrm{id}1}=\prod _{j=1}^{{J}_{d}}{f}_{\mathrm{idj}1}\left({x}_{\mathrm{idj}}\right) and {L}_{\mathrm{id}2}=\prod _{j=1}^{{J}_{d}}{f}_{\mathrm{idj}2}\left({x}_{\mathrm{idj}}\right). Define *δ*(*.*) to be an indicator function. *δ*(*.*)=1 if its argument is true, and *δ*(*.*)=0 otherwise. We have

\begin{array}{l}\phantom{\rule{-14.0pt}{0ex}}\mathrm{Pr}\left({\mathit{X}}_{i},{a}_{i},{\mathit{B}}_{i},{\mathit{C}}_{i}|{\mathit{N}}_{i},\Pi ,V,W\right)\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{-14.0pt}{0ex}}=\mathrm{Pr}\left({a}_{i}|\Pi \right)\phantom{\rule{0.3em}{0ex}}\prod _{d=1}^{D}\phantom{\rule{0.3em}{0ex}}\mathrm{Pr}\left({b}_{\mathrm{id}},{c}_{\mathrm{id}}|{a}_{i},\phantom{\rule{0.3em}{0ex}}V,\phantom{\rule{0.3em}{0ex}}W\right)\phantom{\rule{0.3em}{0ex}}\mathrm{Pr}\phantom{\rule{0.3em}{0ex}}\left({\mathit{X}}_{\mathrm{id}}|{\mathit{N}}_{\mathrm{id}},{a}_{i},{b}_{\mathrm{id}},{c}_{\mathrm{id}}\right)\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{-14.0pt}{0ex}}={\left\{\phantom{\rule{0.3em}{0ex}}{\Pi}_{0}\prod _{d=1}^{D}{L}_{\mathrm{id}0}\right\}}^{\delta \left({a}_{i}=0\right)}\prod _{k=1}^{K}\left\{{\Pi}_{k}\prod _{d=1}^{D}{\left[{v}_{\mathrm{kd}}{L}_{\mathrm{id}1}\right]}^{{b}_{\mathrm{id}}}\phantom{\rule{0.3em}{0ex}}{\left[{w}_{\mathrm{kd}}{L}_{\mathrm{id}2}\right]}^{{c}_{\mathrm{id}}}\right.\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{1em}{0ex}}\times {\left(\right)close="\}">{\left[(1-{v}_{\mathrm{kd}}-{w}_{\mathrm{kd}}){L}_{\mathrm{id}0}\right]}^{1-{b}_{\mathrm{id}}-{c}_{\mathrm{id}}}}^{}\delta \left({a}_{i}=k\right)& \phantom{\rule{2em}{0ex}}\end{array}\n

(5)

To infer *Π*, *V* and *W*, we employ a Bayesian approach by imposing a Dirichlet prior *D*(*η*,⋯,*η*) on *Π* and imposing independent Dirichlet priors *D*(*η*,*η*,*η*) on all triplets (*v*_{
kd
},*w*_{
kd
},1−*v*_{
kd
}−*w*_{
kd
}). The joint posterior distribution of unknown parameters and indicators given the observed data is:

\begin{array}{ll}\phantom{\rule{-14.0pt}{0ex}}\mathrm{Pr}& \left(A,\phantom{\rule{0.3em}{0ex}}B,\phantom{\rule{0.3em}{0ex}}C,\phantom{\rule{0.3em}{0ex}}\Pi ,\phantom{\rule{0.3em}{0ex}}V,\phantom{\rule{0.3em}{0ex}}W|X,N\right)\phantom{\rule{2em}{0ex}}\\ \propto \mathrm{Pr}\left(X,N,A,B,C|\Pi ,V,W\right)\phantom{\rule{2.77695pt}{0ex}}f\left(\Pi ,V,W\right)\phantom{\rule{2em}{0ex}}\\ \propto \prod _{i=1}^{I}\phantom{\rule{0.3em}{0ex}}\mathrm{Pr}\phantom{\rule{0.3em}{0ex}}\left({\mathit{X}}_{i},{a}_{i},{\mathit{B}}_{i},\phantom{\rule{0.3em}{0ex}}{\mathit{C}}_{i}|{\mathit{N}}_{i},\phantom{\rule{0.3em}{0ex}}\Pi ,\phantom{\rule{0.3em}{0ex}}V,\phantom{\rule{0.3em}{0ex}}W\right)\left\{\prod _{k=0}^{K}{\Pi}_{k}^{\eta -1}\right\}\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{1em}{0ex}}\times \left\{\prod _{k=1}^{K}\prod _{d=1}^{D}{v}_{\mathrm{kd}}^{\eta -1}\phantom{\rule{0.3em}{0ex}}{w}_{\mathrm{kd}}^{\eta -1}{\left(1-{v}_{\mathrm{kd}}-{w}_{\mathrm{kd}}\right)}^{\eta -1}\right\}\phantom{\rule{2em}{0ex}}\end{array}

(6)

Conditional on the observed data, *Pr*(*N*) is a constant that does not contain parameters of interest, therefore it is absorbed into a proportionality constant not shown in the formula above. Using this joint posterior, an EM algorithm can be derived to search for posterior mode (\widehat{\Pi},\widehat{\mathit{V}},\widehat{\mathit{W}}) of \mathrm{Pr}(\Pi ,\mathit{V},\mathit{W}|\mathit{X},\mathit{N})=\sum _{\mathit{A},\mathit{B},\mathit{C}}\mathrm{Pr}(\mathit{A},\mathit{B},\mathit{C},\Pi ,\mathit{V},\mathit{W}|\mathit{X},\mathit{N}) in which the missing indictors *A*, *B* and *C* are all integrated out (see Additional file 1: Supplemental Method S.4).

For the Dirichlet prior, we use *η*=2 (see Additional file 1: Supplemental Method S.3 for a discussion on the choice of parameter for the Dirichlet prior). In the EM algorithm, we assume that the class number *K* is given. In order to choose the optimal *K*, we run the algorithm multiple times using different values of *K*. We choose the best *K* using the Bayesian Information Criterion (BIC) (see Additional file 1: Supplemental Method S.5).

### Statistical inference of allele-specificity

The estimated *Π*, *V* and *W* can describe the correlation patterns of allele-specificity among datasets. Given *Π*, *V* and *W*, one can infer whether SNP *i* belongs to class *k* based on the posterior probability *Pr*(*a*_{
i
} = *k*|*X*_{
i
},*N*_{
i
},*Π*,*V*,*W*) (see Additional file 1: Supplemental Method S.4 equations S.12-S.13). One can then infer whether each SNP *i* is skewed in each individual dataset *d* based on the posterior probability \mathrm{Pr}({b}_{\mathrm{id}},{c}_{\mathrm{id}}|{\mathit{X}}_{i},{\mathit{N}}_{i},\Pi ,\mathit{V},\mathit{W})=\sum _{{a}_{i}}\mathrm{Pr}({a}_{i},{b}_{\mathrm{id}},{c}_{\mathrm{id}}|{\mathit{X}}_{i},{\mathit{N}}_{i},*Π*,*V*,*W*) after summing over all possible values of *a*_{
i
}(see Additional file 1: Supplemental Method S.4 equation S.14). Note that

\phantom{\rule{-15.0pt}{0ex}}\begin{array}{l}\mathrm{Pr}\left({b}_{\mathrm{id}},\phantom{\rule{0.3em}{0ex}}{c}_{\mathrm{id}}|{\mathit{X}}_{i},\phantom{\rule{0.3em}{0ex}}{\mathit{N}}_{i},\phantom{\rule{0.3em}{0ex}}\Pi ,\phantom{\rule{0.3em}{0ex}}V,\phantom{\rule{0.3em}{0ex}}W\right)=\\ \sum _{k}\phantom{\rule{0.3em}{0ex}}\mathrm{Pr}\left({a}_{i}\phantom{\rule{0.3em}{0ex}}=\phantom{\rule{0.3em}{0ex}}k|{\mathit{X}}_{i},\phantom{\rule{0.3em}{0ex}}{\mathit{N}}_{i},\phantom{\rule{0.3em}{0ex}}\Pi ,\phantom{\rule{0.3em}{0ex}}V,\phantom{\rule{0.3em}{0ex}}W\right)\mathrm{Pr}\left({b}_{\mathrm{id}},{c}_{\mathrm{id}}|{a}_{i}\phantom{\rule{0.3em}{0ex}}=\phantom{\rule{0.3em}{0ex}}k,{\mathit{X}}_{i},{\mathit{N}}_{i},\Pi ,V,W\right)\end{array}

(7)

Define

\begin{array}{l}{\stackrel{~}{P}}_{\mathrm{id}}=\mathrm{max}\left\{\left(\right)close="">\mathrm{Pr}\left({b}_{\mathrm{id}}=1,{c}_{\mathrm{id}}=0|{\mathit{X}}_{i},{\mathit{N}}_{i},\Pi ,V,W\right),\right.\end{array}\n \n \n \n close="}">\n \n close="">\n \n Pr\n \n \n \n \n b\n \n \n id\n \n \n =\n 0\n ,\n \n \n c\n \n \n id\n \n \n =\n 1\n |\n \n \n X\n \n \n i\n \n \n ,\n \n \n N\n \n \n i\n \n \n ,\n \n \Pi \n ,\n V\n ,\n W\n \n \n \n \n \n \n \n

(8)

Using {\stackrel{~}{P}}_{\mathrm{id}}, SNPs can be rank ordered for biologists to choose candidates to design follow-up studies. For each top ranked SNP, one can determine its skewing direction by comparing *Pr*(*b*_{
id
}=1,*c*_{
id
}=0|*X*_{
i
},*N*_{
i
},*Π*,*V*,*W*) and *Pr*(*b*_{
id
}=0,*c*_{
id
}=1|*X*_{
i
},*N*_{
i
},*Π*,*V*,*W*). The one with the larger value determines the direction. Finally, the posterior probabilities of top *N* SNPs can be converted to an estimate of false discovery rate (FDR) using \mathrm{FDR}\left(N\right)=\sum _{i\in \mathrm{top}\phantom{\rule{2.22198pt}{0ex}}N\phantom{\rule{2.22198pt}{0ex}}\mathrm{SNPs}}(1-{\stackrel{~}{P}}_{\mathrm{id}})/N.

Formula 7 shows that two types of information contribute to *Pr*(*b*_{
id
},*c*_{
id
}|*X*_{
i
},*N*_{
i
},*Π*,*V*,*W*): (1) *Pr*(*a*_{
i
}=*k*|*X*_{
i
},*N*_{
i
},*Π*,*V*,*W*), which is determined using information from all *D* datasets, and (2) *Pr*(*b*_{
id
},*c*_{
id
}|*a*_{
i
}=*k*,*X*_{
i
},*N*_{
i
},*Π*,*V*,*W*), which only uses information specific to dataset *d* conditional on *Π*, *V* and *W*. Thus for each particular dataset *d*, the dataset-specific information is weighted by information obtained from other datasets to determine the SNP ranking. Intuitively, if allelic imbalance in two datasets are correlated, then observing an AS event in one dataset will suggest that a relatively weak skewing event observed at the same SNP in the other dataset is very likely to be a true AS event. In contrast, if no AS event is observed in one dataset, then a relatively weak skewing event observed at the same SNP in the other dataset is likely to be a false positive. This is the underlying nature of using *Pr*(*a*_{
i
}=*k*|*X*_{
i
},*N*_{
i
},*Π*,*V*,*W*) to re-weigh information in *Pr*(*b*_{
id
},*c*_{
id
}|*a*_{
i
}=*k*,*X*_{
i
},*N*_{
i
},*Π*,*V*,*W*), and it provides the foundation for improving SNP ranking by borrowing information across datasets. In real applications, *Π*, *V*,*W* are unknown, and they are replaced by the posterior mode obtained from the EM algorithm.