Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • 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?

  • #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


    • #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


      • #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

        • 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
        • seqadmin
          Strategies for Sequencing Challenging Samples
          by seqadmin


          Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
          03-22-2024, 06:39 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 04-11-2024, 12:08 PM
        0 responses
        18 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        22 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 09:21 AM
        0 responses
        17 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-04-2024, 09:00 AM
        0 responses
        49 views
        0 likes
        Last Post seqadmin  
        Working...
        X