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
            Recent Advances in Sequencing Analysis Tools
            by seqadmin


            The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
            05-06-2024, 07:48 AM
          • 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

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, 05-07-2024, 06:57 AM
          0 responses
          12 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 05-06-2024, 07:17 AM
          0 responses
          16 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 05-02-2024, 08:06 AM
          0 responses
          22 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-30-2024, 12:17 PM
          0 responses
          24 views
          0 likes
          Last Post seqadmin  
          Working...
          X