Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • id0
    Senior Member
    • Sep 2012
    • 130

    DESeq2 multi-factor designs

    In DESeq2, you can set up a multi-factor design like:
    Code:
    design(dds) <- formula(~ celltype + treatment)
    This would give you the differences attributable to the "treatment" while accounting for the "celltype".

    However, what if you are interested in the differences in response to treatment in different cell types? Instead of looking for the effects of treatment regardless of cell type, you want the effects of treatments that are unique to a specific cell type. How would you get those?
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    Either include an interaction (~celltype*treatment) or just make a "group" factor like:
    Code:
    group <- factor(sprintf("%s_%s", celltype, treatment))
    and then use a model of ~group and use contrasts for the comparisons of interest. You'll get the same results with either method.

    Comment

    • Michael Love
      Senior Member
      • Jul 2013
      • 333

      #3
      Devon's right with a small caveat. Because of log fold change shrinkage (betaPrior=TRUE is default), the results are not exactly the same (they would be the same with betaPrior=FALSE). The interaction model only shrinks the interaction term, while the group model shrinks all the group effects. My advice is: if you are interested in testing for cell type specificity, use the interaction model, because the interaction terms allow you to easily test this. If you are only interested in comparing the treatment effect in each cell type, use the group model, and the contrasts are easy to form this way.

      Comment

      • id0
        Senior Member
        • Sep 2012
        • 130

        #4
        I didn't realize that the interaction and group models would give the same results (at least with betaPrior=FALSE). That is really interesting.

        So if I have two cell types (A and B) and two treatments (Yes and No) and then I combine them for the group model, which contrast is equivalent to the interaction model? I am not sure how I could get the difference in response to treatment using the group model.

        Comment

        • Michael Love
          Senior Member
          • Jul 2013
          • 333

          #5
          The contrast is (ctA_trY + ctB_trN) - (ctA_trN + ctB_trY)

          This is from doing arithmetic on (ctA_trY - ctA_trN) - (ctB_trY - ctB_trN)

          Here's an example in base R. Note the interation term (-2.11)

          Code:
          > y <- rnorm(8)
          > ct <- c(0,0,1,1,0,0,1,1)
          > tr <- c(0,0,0,0,1,1,1,1)
          > lm(y ~ ct*tr)
          
          Call:
          lm(formula = y ~ ct * tr)
          
          Coefficients:
          (Intercept)           ct           tr        ct:tr
              -0.6356       1.1513       0.7684      -2.1120
          Now with group. here, I add + 0 to the design, but you wouldn't do this in DESeq2 with betaPrior=TRUE because we fit a term for each group in addition to an intercept.

          Code:
          > g <- factor(c(1,1,2,2,3,3,4,4))
          > lm(y ~ g + 0)
          
          Call:
          lm(formula = y ~ g + 0)
          
          Coefficients:
               g1       g2       g3       g4
          -0.6356   0.5157   0.1329  -0.8278
          
          > beta <- coef(lm(y ~ g + 0))
          > (beta[1] + beta[4]) - (beta[2] + beta[3])
                 g1
          -2.111991

          Comment

          • id0
            Senior Member
            • Sep 2012
            • 130

            #6
            Thank you for that great explanation.

            The only part I don't understand is this:
            The contrast is (ctA_trY + ctB_trN) - (ctA_trN + ctB_trY)
            How would I provide that to the DESeq2 results function contrasts parameter?

            Comment

            • Michael Love
              Senior Member
              • Jul 2013
              • 333

              #7
              you would use the list style of specifying contrasts, see ?results for more details

              Code:
              results(dds, contrast=list(c("ctA_trY","ctB_trN"),c("ctA_trN","ctB_trY")))

              Comment

              Latest Articles

              Collapse

              • SEQadmin2
                Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                by SEQadmin2


                I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.


                Here are nine questions we think about, in roughly the order they matter, before...
                Today, 07:11 AM
              • SEQadmin2
                From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
                by SEQadmin2


                Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


                The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
                ...
                06-02-2026, 10:05 AM
              • SEQadmin2
                Single-Cell Sequencing at an Inflection Point: Early Impacts of New Platforms and Emerging Trends
                by SEQadmin2


                With the launch of new single-cell sequencing platforms in 2026, the field stands at an exciting inflection point. This article surveys the most impactful advances in the field and discusses how they’re reshaping research in cancer, immunology, and beyond.


                Introduction

                Single-cell sequencing technologies have undergone remarkable advances over the past decade, transitioning from low-throughput experimental approaches to highly scalable platforms capable of...
                05-22-2026, 06:42 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, Yesterday, 06:09 AM
              0 responses
              16 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-09-2026, 11:58 AM
              0 responses
              37 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-05-2026, 10:09 AM
              0 responses
              42 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-04-2026, 08:59 AM
              0 responses
              49 views
              0 reactions
              Last Post SEQadmin2  
              Working...