Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • KYR
    Member
    • May 2012
    • 18

    [DESeq2] Multiple replicates, multiple treatments

    I'm experiencing issues again with the replicates of our experiment. We should be comparing 3 types of treatments in one heatmap.
    • Ctrl vs T
    • Ctrl vs B
    • Ctrl vs A


    Each of which have 3 replicates. The following code works very well when I don't use replicates, and simply compare one treatment vs control. Also, when calling mcols, it should show the 3 comparisons we will use in our heatmap, though it only says CTRL vs T (if I don't use replicates) or T vs A in this case.

    So here are my two questions:
    1. Is there a better way to define samples$condition?
    2. How should I use mcols to have the 3 comparisons?


    Thanks (ps: I'm not an R expert)

    Code:
    # DESeq1 libraries
    library( "DESeq2" )
    library("Biobase")
    
    # Heatmap libraries
    library(RColorBrewer)
    library( "genefilter" )
    library(gplots) 
    
    # Start loading matrix data
    clba = read.table("matrix_duplicates_merged_CLBA.txt", header=TRUE, row.names=1)
    head(clba)
    
    samplesclba <- data.frame(row.names=c("C1", "C2", "C3", "T1", "T2", "T3", "B1", "B2", "B3", "A1", "A2", "A3"), condition=as.factor(c(rep("C",3), rep("T", 3), rep("B", 3), rep("A", 3))))
    
    ## Relevel doesn't work with replicates
    samples$condition <- relevel(samples$condition, "C")
    [B]Error in samples$condition : object of type 'closure' is not subsettable[/B]
    
    # Launch DESeq2
    ddsclba <- DESeqDataSetFromMatrix(countData = as.matrix(clba), colData=samplesclba, design=~condition)
    ddsclba <- DESeq(ddsclba, betaPrior=FALSE)
    
    # Results
    resclba <- results( ddsclba )
    mcols(resclba, use.names=TRUE)
    DataFrame with 6 rows and 2 columns
                           type                           description
                    <character>                           <character>
    baseMean       intermediate           the base mean over all rows
    log2FoldChange      results  log2 fold change: condition T vs A
    lfcSE               results    standard error: condition T vs A
    stat                results    Wald statistic: condition T vs A
    pvalue              results Wald test p-value: condition T vs A
    padj                results                  BH adjusted p-values
    
    
    
    # Heatmap with top 35 genes
    rldclba <- rlogTransformation(ddsclba)
    topVarGenesclba <- order( rowVars( assay(rldclba) ), decreasing=TRUE ) [1:35]
    hmcol <- colorRampPalette( rev(brewer.pal(9, "RdBu")))(255)
    
    heatmap.2( assay(rldclba)[ topVarGenesclba, ], Colv=FALSE, scale="row", 
    trace="none", dendrogram="row", col = hmcol
    Last edited by KYR; 07-28-2014, 03:41 PM. Reason: typo
  • TiborNagy
    Senior Member
    • Mar 2010
    • 329

    #2
    One problem that I can see in your script is samples$condition. There is no such variable. Relevel works on DESeqDataSet.

    Comment

    • Michael Love
      Senior Member
      • Jul 2013
      • 333

      #3
      We strongly recommend to read in a CSV file for the sample table. This helps to avoid little mistakes (accidental keystroke when scrolling through script) which can change the whole result of the analysis.

      As Tibor mentioned:

      dataframe$column <- value

      only works if dataframe exists already.

      I'm not sure what you expect from mcols(). This function just tells you more information about the columns of the results table. res is the results table itself. And you can customize the results table -- e.g. which comparison to make -- using the arguments to results():

      resTC = results(dds, contrast=c("condition","T","C"))

      this will give a results table of log fold changes (LFC) of T over C. Here a positive LFC means T has higher counts than C. A negative LFC means T has lower counts than C.

      Comment

      • KYR
        Member
        • May 2012
        • 18

        #4
        Originally posted by Michael Love View Post

        I'm not sure what you expect from mcols(). This function just tells you more information about the columns of the results table. res is the results table itself. And you can customize the results table -- e.g. which comparison to make -- using the arguments to results():

        resTC = results(dds, contrast=c("condition","T","C"))

        this will give a results table of log fold changes (LFC) of T over C. Here a positive LFC means T has higher counts than C. A negative LFC means T has lower counts than C.
        Thanks for your answer. I use mcols() to double-check that the comparison is done as I need it, i.e.,

        Ctrl vs T
        Ctrl vs B
        Ctrl vs A

        I still don't understand if, despite what mcols says, the pipeline I wrote is giving me the heatmap I need with the 3 comparisons I wrote above..

        My guess is that mcols() should show the 3 comparisons?!...

        Comment

        • Michael Love
          Senior Member
          • Jul 2013
          • 333

          #5
          In your heatmap above you are plotting the rlog counts for the rows with the highest variance. The rlog is a transformation which has nothing to do with differential expression testing. So you haven't told the software that you want to visualize genes which are differentially expressed in some contrast.

          You can subset and plot genes which are differentially expressed in some comparison like so:

          Code:
          res = results(dds, contrast=c("condition","B","A"))
          sig = which(res$padj < 0.1)
          
          # check if this is too many rows to plot
          length(sig)
          
          # rlog or VST
          rld <- rlog(dds)
          heatmap.2( assay(rld)[sig, ])
          Last edited by Michael Love; 08-03-2014, 05:51 AM. Reason: test =>visualize

          Comment

          Latest Articles

          Collapse

          • SEQadmin2
            Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
            by SEQadmin2


            Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

            The systematic characterization of the human proteome has
            ...
            07-20-2026, 11:48 AM
          • 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

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 07-24-2026, 12:17 PM
          0 responses
          31 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-23-2026, 11:41 AM
          0 responses
          23 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-20-2026, 11:10 AM
          0 responses
          215 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-13-2026, 10:26 AM
          0 responses
          79 views
          0 reactions
          Last Post SEQadmin2  
          Working...