Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • danielfortin86
    Junior Member
    • Aug 2008
    • 5

    EdgeR LogCPM Bug?

    When I output the logCPM values for my genes, they are identical across contrasts. However, when I output the logFold values these seem to be correctly calculated for each contrast. Is this a bug or am I not understanding what the logCPM is that is returned by glmLRT?

    Code:
    library(edgeR)
    
    # Read in the quantification data
    data <- read.table('File.txt', header = TRUE, row.names = 1)
    
    keep <- rowSums(cpm(data) > 2) >= min(summary(3)) 
    data <- data[keep,]
    
    y <- DGEList(counts = data)
    y <- calcNormFactors(y)
    
    rownames(design) <- colnames(y)
    
    y <- estimateGLMCommonDisp(y, design, verbose = TRUE)
    y <- estimateGLMTrendedDisp(y, design)
    y <- estimateGLMTagwiseDisp(y, design)
    
    # Fit the linear model to the design matrix
    fit <- glmFit(y, design)
    
    # Make Contrast Matrix
    my.contrasts <- makeContrasts(....... # Different contrasts
    	levels = design)
    
    
    # Loop to calculate the contrasts
    for (i in 1:dim(my.contrasts)[2]) {
    # Create the log ratios
    	lrt <- glmLRT(y, fit, contrast = my.contrasts[,i])
    	tempLR <- lrt$table[2]
    	if(exists("LogCPM")){  LogCPM<  <- cbind(LogCPM, tempLR)   }
    	else{ LogCPM  <- tempLR }
    }
    
    # rows of LogCPM are identical?!?
  • Gordon Smyth
    Member
    • Apr 2011
    • 91

    #2
    This is not a bug, rather you are not understanding what logCPM represents.

    The help page for glmLRT says that logCPM is "the average log2-counts-per-million". The average is taken over all libraries in your dataset y, and hence is always the same regardless of the contrast being tested.

    logPCM is intended as a measure of the overall expression level of the transcript, and is displayed by functions such as plotBCV().

    BTW, it is not a simple average. The logCPM is computed using the edgeR function mglmOneGroup(), taking into account the estimated dispersions and the library sizes.

    Gordon

    Comment

    • danielfortin86
      Junior Member
      • Aug 2008
      • 5

      #3
      Thanks! I was interpreting the documentation as meaning that the average was calculated for specific factor level combinations / contrasts. Wouldn't plotting the actual "A" for a specific contrast be more informative? Presumably that can be extracted by multiplying the matrix with the particular coefficients. What's the rationale for plotting the experiment-wide "A" rather than the condition-specific one? My question also applies to dispersion? What about condition-specific dispersion? Any help you could provide would be greatly appreciated!

      D

      Comment

      • Gordon Smyth
        Member
        • Apr 2011
        • 91

        #4
        Originally posted by danielfortin86 View Post
        Thanks! I was interpreting the documentation as meaning that the average was calculated for specific factor level combinations / contrasts.
        But there's nothing in the documentation that says so.
        Wouldn't plotting the actual "A" for a specific contrast be more informative? Presumably that can be extracted by multiplying the matrix with the particular coefficients.
        Since this is your suggestion, the onus is on you to suggest a reason why this would be more informative. For my part, I don't know even how you would define "the actual A" to be for a general contrast. For example, suppose you have contrast=c(-0.4,0.5,0,-0.1). How you would you define A and what would it tell you?
        What's the rationale for plotting the experiment-wide "A" rather than the condition-specific one?
        I already told you in my previous reply.
        My question also applies to dispersion? What about condition-specific dispersion? Any help you could provide would be greatly appreciated!
        I wonder whether you might be underestimating the statistical penalties and uncertainties introduced by fitting overly complicated models and estimating huge numbers of parameters, especially dispersion parameters. It is very unlikely that fitting condition-specific dispersions would be worthwhile, let alone a contrast-specific dispersions. But see

        Comment

        • earonesty
          Member
          • Mar 2011
          • 52

          #5
          Originally posted by Gordon Smyth View Post
          But there's nothing in the documentation that says so.

          Since this is your suggestion, the onus is on you to suggest a reason why this would be more informative. For my part, I don't know even how you would define "the actual A" to be for a general contrast. For example, suppose you have contrast=c(-0.4,0.5,0,-0.1). How you would you define A and what would it tell you?
          It *might* be informative to show a summary of original expression values and variability per group - just so you can see if edgeR's being silly and might need some tweaking ... (like when expression values are zero, or when there's outliers, or when you forgot to use tagwise dispersion, or when you used it... and would like to know what value edgeR used.... etc).

          Comment

          • Gordon Smyth
            Member
            • Apr 2011
            • 91

            #6
            Originally posted by earonesty View Post
            It *might* be informative to show a summary of original expression values and variability per group - just so you can see if edgeR's being silly and might need some tweaking ... (like when expression values are zero, or when there's outliers, or when you forgot to use tagwise dispersion, or when you used it... and would like to know what value edgeR used.... etc).
            Certainly may be useful to look individual expression values for leading genes, and all the edgeR cases studies show how to do this. The original poster was asking for something different however, for the definition of logCPM to be changed.

            Comment

            • earonesty
              Member
              • Mar 2011
              • 52

              #7
              I meant as extra columns for edgeR, not as a "leading gene thing". Stuff like a normalized mean and variability for each group. I've taken to moderating edgeR's results by removing results where the within-group variability is high, for example. (I think people are interpreting the logCPM value in that context... because they are expecting outputs that summarize group-wise summary information and don't see it.)

              Comment

              • parham
                Junior Member
                • May 2013
                • 1

                #8
                when you perform edgeR analysis comparing two groups (mock vs treat), you get a list of genes with probabilities of differential expression with certain logFC. Assuming for this logFC edgeR is calculating a mean expression value for samples within each group,
                (1) how can I see what value is used (by edgeR) for each gene of each group?
                (2) how is this mean expression value calculated? (is it an average cpm values of samples of each group?)

                Comment

                Latest Articles

                Collapse

                • SEQadmin2
                  Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                  by SEQadmin2



                  Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                  ...
                  07-09-2026, 11:10 AM
                • SEQadmin2
                  Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                  by SEQadmin2



                  Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                  There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                  07-08-2026, 05:17 AM
                • GATTACAT
                  Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                  by GATTACAT
                  Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                  07-01-2026, 11:43 AM

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by SEQadmin2, Yesterday, 10:26 AM
                0 responses
                15 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-09-2026, 10:04 AM
                0 responses
                28 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-08-2026, 10:08 AM
                0 responses
                16 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-07-2026, 11:05 AM
                0 responses
                33 views
                0 reactions
                Last Post SEQadmin2  
                Working...