Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Benjamini–Hochberg procedure in R

    Tell me if I am wrong but this is the Benjamini–Hochberg procedure is that simple ?

    Code:
    # produce a table of FDR using with pval already sorted in increasing order
    fdr = function(pval){
    
     size=length(pval)
    
     if(size<2) return(pval)
    
     FDR=c(pval[size])
    
     for( i in 1:(size-1)) FDR=c(FDR,min(pval[size-i]*(size)/(size-i),FDR[i]))
    
     return(rev(FDR))
    }
    Last edited by raphael123; 02-18-2014, 09:16 AM. Reason: little adjustment for the higher p-value

  • #2
    Essentially, though the exact algorithm isn't the same. This is what p.adjust actually does when computing using the BH method. While this is faster (no for loop in R, cummin is presumably written in C where loops aren't a problem), the output is more or less the same (within rounding error at least):

    Code:
    n <- length(p)
    lp <- length(p)
    i <- lp:1L
    o <- order(p, decreasing = TRUE)
    ro <- order(o) #This is the index of the initial p-values, highest to lowest
    pmin(1, cummin(n/i * p[o]))[ro]

    Comment


    • #3
      Thank you ! We have the same output ! Your code is more elegant but harder to understand
      equivalent of :

      p.adjust(pval,method="BH")
      Last edited by raphael123; 02-18-2014, 09:34 AM.

      Comment


      • #4
        Hello,
        The method:
        n <- length(p)
        lp <- length(p)
        i <- lp:1L
        o <- order(p, decreasing = TRUE)
        ro <- order(o) #This is the index of the initial p-values, highest to lowest
        pmin(1, cummin(n/i * p[o]))[ro]

        is given different results than p.adjust.

        I did some tests with (300000 pvalue) and nothing was siginificant with p.adjust but 77 was with the upper method.

        Cheers,

        Comment


        • #5
          If you don't otherwise specify a method, p.adjust() will return the Holm's method adjusted p-value rather than the BH method that I outlined. At least that's what I recall being the case. You should get the same results if you specify "p.adjust(some_p_values, method='BH')".

          Comment

          Latest Articles

          Collapse

          • seqadmin
            Essential Discoveries and Tools in Epitranscriptomics
            by seqadmin




            The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
            04-22-2024, 07:01 AM
          • seqadmin
            Current Approaches to Protein Sequencing
            by seqadmin


            Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
            04-04-2024, 04:25 PM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, 04-25-2024, 11:49 AM
          0 responses
          18 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-24-2024, 08:47 AM
          0 responses
          17 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-11-2024, 12:08 PM
          0 responses
          62 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-10-2024, 10:19 PM
          0 responses
          60 views
          0 likes
          Last Post seqadmin  
          Working...
          X