Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FelipeAd
    Member
    • Jan 2011
    • 17

    #1

    DESEQ2 control vs treat based on alphabetic order?

    Hello,

    I am using DESeq2 for differential expression analysis of RNA Seq data.

    My question is: which is considered "control" or "treated" in the "countData" and "condition" table.

    Let me explain.

    When having "countData" table in the format of "control" "control" "control" "control" "treated" "treated" "treated" "treated" table, a also assign the "condition" as follows:

    condition <- factor(c(rep("control", 4), rep("treat", 4)))

    Following analysis, I reach to the

    res <- results(dds)

    and
    head(res) gives

    log2 fold change (MAP): condition treat vs ctrl
    Wald test p-value: condition treat vs ctrl

    The exact same result I get when I reverse the "condition":

    condition <- factor(c(rep("treat", 4), rep("control", 4)))

    or when I reverse the countData.

    But when I set

    condition <- factor(c(rep("atreat", 4), rep("control", 4)))

    my head(res) gives

    log2 fold change (MAP): condition ctrl vs atreat
    Wald test p-value: condition ctrl vs atreat

    So it seems that the vs comment is based on alphabetic order?
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    Factors are ordered alphabetically in R unless you specify the order yourself:
    Code:
    condition <- factor(c(rep("WT",4),rep("Mut",4)), levels=c("WT","Mut"))
    Have a look at:
    Code:
    levels(condition)

    Comment

    • Michael Love
      Senior Member
      • Jul 2013
      • 333

      #3
      It's not DESeq2, but R's base function 'factor' which determines the order of levels in a factor.

      You can control the order of the levels either using the 'contrast' argument, or while you are setting up the factors.

      If you read over the DESeq2 vignette:

      vignette("DESeq2")

      We have in the beginning:

      "1.2.5 Note on factor levels

      In the three examples above, we applied the function factor to the column of interest in colData, supplying a character vector of levels. It is important to supply levels (otherwise the levels are chosen in alphabetical order) and to put the “control” or “untreated” level as the first element (”reference level”), so that the log2 fold changes produced by default will be the expected comparison against the reference level, that is log2 (treated/untreated). An R function for easily changing the reference level is relevel. An example of setting the reference level of a factor with relevel is..."
      Last edited by Michael Love; 06-26-2015, 10:21 AM.

      Comment

      • FelipeAd
        Member
        • Jan 2011
        • 17

        #4
        Thank you both.

        The:

        condition <- factor(c(rep("WT",4),rep("Mut",4)), levels=c("WT","Mut"))

        solved the problem.

        Comment

        Latest Articles

        Collapse

        • SEQadmin2
          Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
          by SEQadmin2



          Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

          Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
          ...
          Yesterday, 09:55 AM
        • SEQadmin2
          New Genomics Technologies Take Aim at Long-Standing Limits
          by SEQadmin2


          Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

          We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
          ...
          09-28-2026, 10:25 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, Yesterday, 05:39 AM
        0 responses
        11 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-13-2026, 09:56 AM
        0 responses
        14 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-09-2026, 11:14 AM
        0 responses
        27 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 09-29-2026, 09:51 AM
        0 responses
        77 views
        0 reactions
        Last Post SEQadmin2  
        Working...