显著性检验[4]–秩和检验

一、算法：

In this example, we have a set of 20 reads, 10 of which support the reference allele and 10 of which support the alternate allele. At first glance, that looks like a clear heterozygous 0/1 site. But to be thorough in our analysis and to account for any technical bias, we want to determine if there is a significant difference in the base qualities of the bases that support the reference allele vs. the bases that support the alternate allele.

Before we proceed, we must define our null hypothesis and alternate hypothesis.

Null hypothesis: There is no difference in the base qualities that support the reference allele and the base qualities that support the alternate allele.

Alternate hypothesis: There is a difference in the base qualities that support the reference allele and the base qualities that support the alternate allele.

Step 1: List the relevant observations

Reference allele base qualities: 20, 25, 26, 30, 32, 40, 47, 50, 53, 60 Alternate allele base qualities: 0, 7, 10, 17, 20, 21, 30, 34, 40, 45

Step 2: Rank the observations

First, we arrange all the observations (base qualities) into a list of values ordered from lowest to highest (reference bases are in bold).

0, 7, 10, 17, 20, 20, 21, 25, 26, 30, 30, 32, 34, 40, 40, 45, 47, 50, 53, 60

Next we determine the ranks of the values. Since there are 20 observations (the base qualities), we have 20 ranks to assign. Whenever there are ties between observations for the rank, we take the rank to be equal to the midpoint of the ranks. For example, for 20(ref) and 20(alt), we have a tie in values, so we assign each observation a rank of (5+6)/2 = 5.5.

The ranks from the above list are (reference ranks are in bold):

1, 2, 3, 4, 5.5, 5.5, 7, 8, 9, 10.5, 10.5, 12, 13, 14.5, 14.5, 16, 17, 18, 19, 20

Step 3: Add up the ranks for each group

We now need to add up the ranks for the base qualities that came from the reference allele and the alternate allele.

Rankref=133.5Rankref=133.5
Rankalt=76.5Rankalt=76.5

Step 4: Calculate U for each group

U is a statistic that tells us the difference between the two rank totals. We can use the U statistic to calculate the z-score (explained below), which will give us our p-value.

Calculate U for each group (n = number of observations in each sample)

$$U{ref} = \frac{ n{ref} n{alt} + n{ref} (n{ref}+ 1) }{ 2 } – Rank{ref}$$

$$U{alt} = \frac{ n{alt} n{ref} + n{alt} (n{alt} + 1) }{ 2 } – Rank{alt}$$

$$U_{ref} = \frac{ 10 10 + 10 11 }{ 2 } – 133.5 = 21.5$$

$$U_{alt} = \frac{ 10 10 + 10 11 }{ 2 } – 76.5 = 78.5$$

Step 5: Calculate the overall z-score

Next, we need to calculate the z-score which will allow us to get the p-value. The z-score is a normalized score that allows us to compare the probability of the U score occurring in our distribution. https://statistics.laerd.com/statistical-guides/standard-score.php

The equation to get the z-score is:

z=Umuuz=U−muu

Breaking this equation down:

z=zscorez=z−score
U=lowest of the U scores calculated in previous stepsU=lowest of the U scores calculated in previous steps

$$mu = \text{mean of the U scores above} = \frac{ n{ref} * n{alt} }{ 2 }$$

$$u = \text{standard deviation of U} = \sqrt{ \frac{n{ref} * n{alt} * (n{ref} + n{alt} + 1) }{ 12 } }$$

To calculate our z:

U=21.5U=21.5
mu=10102=50mu=10∗102=50

$$u = \sqrt{ \frac{10 10 (10 + 10 + 1) }{ 12 } } = 13.229$$

So altogether we have:

z=21.55013.229=2.154z=21.5−5013.229=−2.154

Step 6: Calculate and interpret the p-value

The p-value is the probability of obtaining a z-score at least as extreme as the one we got, assuming the null hypothesis is true. In our example, the p-value gives us the probability that there is no difference in the base qualities that support the reference allele and the base qualities that support the alternate allele. The lower the p-value, the less likely it is that there is no difference in the base qualities.

Going to the z-score table, or just using a p-value calculator, we find the p-value to be 0.0312.

This means there is a .0312 chance that the base quality scores of the reference allele and alternate allele are the same. Assuming a p-value cutoff of 0.05, meaning there is less than 5% chance there is no difference in the two groups, and greater than or equal to 95% chance that there is a difference between the two groups, we have enough evidence to reject our null hypothesis that there is no difference in the base qualities of the reference and alternate allele. This indicates there is some bias and that the alternate allele is less well supported by the data than the allele counts suggest.

二、R的具体实现

p-value大于0.05，因此我们可接受null hypothesis H0，即两个群组的均值统计相等。