I am trying to permute data and return a maxT p value to adjust for FWER.

I have an example of data:

Code:

```
SNP1 p value= 0.02
SNP1 permutation p values = 0.03, 0.03, 0.03, 0.04, 0.04.
SNP2 p value =0.03
SNP2 permutation p values = 0.4,0.5,0.5,0.6,0.7
SNP3 p value = 0.3
SNP3 p value permutation p values = 0.8,0.9,0.9,0.9,0.9
```

I've tried to come up with an explanation in my head, I would appreciate if someone could tell me where I'm going wrong;

First, you get the smallest permuted P Value across all of the SNPs for each permutation. In this case, it's: Perm1 smallest P val= 0.03 Perm2 = 0.03 Perm3 = 0.03 Perm4 = 0.04 Perm5 = 0.04

Then I was told that the corrected p value for SNP1 is 1/6. To get the 6, is this the 5 permuted p values + my p value? So it's 1/6 chance of seeing a p value as low as mine in the original p value + permuted p value set.

For SNP2 with an uncorrected p value of 0.03, I am totally confused as to how the answer is 5/12. I know ties count as 0.5. So in my smallest permuted data set: 0.03, 0.03, 0.03, 0.04, 0.04: if you add them up (allowing 0.03 and 0.04 to be worth 0.5 each since they are both ties), the sum of the 5 permuted values is 2.5. So then the chance of seeing 0.03, using the logic from step 1, is that it's 2.5/5, or 3.5/6 if you add in the uncorrected p value? Which isn't 5/12, but if you don't add in the original p value 0.03, the answer will be 2.5/6, which is 5/12....but I don't understand why not to add in the original p value in this step, when I did it in step 1.

I'm obviously not understanding something, if someone could really simply explain the calculation process/algorithm for maxT corrected p values for this example I would appreciate it.

Thanks

p.s apologies if I've not posted this correctly, please let me know if there's anything I can do to improve my posting.