<p>I have data that looks like this: 3 column SNPs their gene based on Annovar and a p-value for every SNP. What I would like is to aggregate the p values for every gene.</p>
<pre class="lang-r prettyprint-override"><code>snps &lt;- data.frame(
  snp_id = c(&quot;rs1&quot;, &quot;rs2&quot;, &quot;rs3&quot;, &quot;rs4&quot;, &quot;rs5&quot;, &quot;rs6&quot;, &quot;rs7&quot;, &quot;rs8&quot;),
  gene = c(&quot;gene1&quot;, &quot;gene1&quot;, &quot;gene1&quot;, &quot;gene1&quot;, &quot;gene2&quot;, &quot;gene2&quot;, &quot;gene2&quot;, &quot;gene2&quot;),
  pvalue = c(0.7703884, 0.9648540, 0.9648540, 0.9648540, 0.54, 0.03, 0.03, 0.8)
)
</code></pre>
<p>what I need to do is :</p>
<ol>
<li>For each gene, sort the p-values in ascending order.</li>
<li>For each p-value in the sorted list, multiply it by the number of SNPs in that gene.</li>
<li>Divide the result from step 2 by the rank of the p-value in the sorted list (i.e., its index in the list).</li>
<li>Take the minimum value from step 3 as the new p-value for that gene.</li>
<li>Adjust the p-values using the false discovery rate (FDR) correction method.</li>
</ol>
<p>This is the formula for each gene :combined p-value <span class="math-container">$\min(n p_{(i)}/i)$</span> where <span class="math-container">$p_{(1)}, …, p_{(n)}$</span> are the ordered p-values.</p>
<p>I tried this code  with the usage of <code>simes.test</code> package in R:</p>
<pre class="lang-r prettyprint-override"><code>library(mppa)

x=c(0.77,0.964,0.964,0.964)
simes.test(x)
</code></pre>
<p>The answer is 1.285. This is the source code of the <code>simes.test</code> function:</p>
<pre class="lang-r prettyprint-override"><code>function (x, returnstat = FALSE) 
{
    r = rank(x)
    T = min(length(x) * x/r)
    if (returnstat) 
        c(T, T)
    else T
}
</code></pre>
<p>How is it possible for the pvalue to be larger then 1? What is the problem? I would be happy if you could share your knowledge in this situation.</p>

CC BY-SA 4.0
2023-03-20T19:18:08.440Z
What is a p-value for an SNP?
Ram RS
CC BY-SA 4.0
2023-03-23T18:36:56.590Z
It can happen it seems. detailed discussion of this topic can be found here http://stat.wharton.upenn.edu/~steele/Courses/956/ResourceDetails/MultipleComparision/Writght92.pdf
stefanH
<r><p-values>
Simes method in R
# Simes method in R

(Asked by: username_0 on 2023-03-20)

I have data that looks like this: 3 column SNPs their gene based on Annovar and a p-value for every SNP. What I would like is to aggregate the p values for every gene.
snps <- data.frame(
  snp_id = c("rs1", "rs2", "rs3", "rs4", "rs5", "rs6", "rs7", "rs8"),
  gene = c("gene1", "gene1", "gene1", "gene1", "gene2", "gene2", "gene2", "gene2"),
  pvalue = c(0.7703884, 0.9648540, 0.9648540, 0.9648540, 0.54, 0.03, 0.03, 0.8)
)

what I need to do is :

For each gene, sort the p-values in ascending order.
For each p-value in the sorted list, multiply it by the number of SNPs in that gene.
Divide the result from step 2 by the rank of the p-value in the sorted list (i.e., its index in the list).
Take the minimum value from step 3 as the new p-value for that gene.
Adjust the p-values using the false discovery rate (FDR) correction method.

This is the formula for each gene :combined p-value $\min(n p_{(i)}/i)$ where $p_{(1)}, …, p_{(n)}$ are the ordered p-values.
I tried this code  with the usage of simes.test package in R:
library(mppa)

x=c(0.77,0.964,0.964,0.964)
simes.test(x)

The answer is 1.285. This is the source code of the simes.test function:
function (x, returnstat = FALSE) 
{
    r = rank(x)
    T = min(length(x) * x/r)
    if (returnstat) 
        c(T, T)
    else T
}

How is it possible for the pvalue to be larger then 1? What is the problem? I would be happy if you could share your knowledge in this situation.

**Tags:** r, p-values
> **Comments:**
> **username_1**: What is a p-value for an SNP?  
> **username_2**: It can happen it seems. detailed discussion of this topic can be found here http://stat.wharton.upenn.edu/~steele/Courses/956/ResourceDetails/MultipleComparision/Writght92.pdf  

---

## 0 answers

