Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bioBob
    Member
    • Mar 2011
    • 72

    #1

    DESeq2 column/row arrangement

    Hi,

    I am trying to automate some of my analysis and am pulling in condition and data information from a master experiment design sheet and a HTSeq count table for the entire experiment. Because I am getting the sheet from the investigator and the HTSeq count is in run order using identifiers from the lab, the two sheets might be in different orders. Example:

    HTML Code:
    slim_expt[,1:2]
           SampleID     Day
    P3-D1     P3-D1 control
    P3-D2     P3-D2 control
    P3-D3     P3-D3 control
    P3-D4     P3-D4 control
    P12-D1   P12-D1 treated
    P12-D2   P12-D2 treated
    P12-D3   P12-D3 treated
    P12-D4   P12-D4 treated
    HTML Code:
    head(slim_HTS_table)
                       P12-D1 P12-D2 P12-D3 P12-D4 P3-D1 P3-D2 P3-D3 P3-D4
    ENSMUSG00000000001   1546   1322   1248   1156  2162  2211  2811  2223
    ENSMUSG00000000003      0      0      0      0     0     0     0     0
    ENSMUSG00000000028     14     23     11     17    42    30    53    55
    Note that the first sample in the experiment design sheet is not the first sample on the HTSeq count matrix.

    Now I do this:
    slim_dds<-DESeqDataSetFromMatrix(countData = slim_HTS_table, colData = slim_expt, design = ~Day)

    And wallah, the sample names are now in order, but the count matrix order was preserved, ie samples are now misassigned.

    HTML Code:
    head(counts(slim_dds))
                       P3-D1 P3-D2 P3-D3 P3-D4 P12-D1 P12-D2 P12-D3 P12-D4
    ENSMUSG00000000001  1546  1322  1248  1156   2162   2211   2811   2223
    ENSMUSG00000000003     0     0     0     0      0      0      0      0
    ENSMUSG00000000028    14    23    11    17     42     30     53     55
    Is there an easy flag to fix this or do I simply need to sort both data frames (by row or column as appropriate) prior to creating the DESeq data set?
  • Simon Anders
    Senior Member
    • Feb 2010
    • 995

    #2
    Yes, you need to bring your count table into the right order beforehands.

    Do, for example:

    slim_dds <- DESeqDataSetFromMatrix(
    countData = slim_HTS_table[ , rownames(colData) ],
    colData = slim_expt,
    design = ~Day)

    However, it is unfortunate that DESeqDataSetFromMatrix silently mixed up the column names. It takes the rownames from the colData frame and used them as sample names, overwriting the columns names of the count matrix. It should issue a warning, or even an error, in such case. We'll change that,

    Comment

    • Michael Love
      Senior Member
      • Jul 2013
      • 333

      #3
      Good idea, I will implement a check for this in the devel branch. I think it should be an error.

      Comment

      • Michael Love
        Senior Member
        • Jul 2013
        • 333

        #4
        I've implemented a test for this in version 1.3.46. If the names are the same, but in the wrong order, it throws an error.

        > count <- matrix(1:20, ncol=4)
        > colnames(count) <- c("a","b","c","d")
        > cols <- data.frame(condition=factor(c(1,1,2,2)))
        > rownames(cols) <- c("1","2","3","4")
        > DESeqDataSetFromMatrix(count, cols, ~ condition)
        class: DESeqDataSet
        dim: 5 4
        exptData(0):
        assays(1): counts
        rownames: NULL
        rowData metadata column names(0):
        colnames(4): 1 2 3 4
        colData names(1): condition
        > rownames(cols) <- c("a","b","c","d")
        > DESeqDataSetFromMatrix(count, cols, ~ condition)
        class: DESeqDataSet
        dim: 5 4
        exptData(0):
        assays(1): counts
        rownames: NULL
        rowData metadata column names(0):
        colnames(4): a b c d
        colData names(1): condition
        > rownames(cols) <- c("b","c","d","a")
        !> DESeqDataSetFromMatrix(count, cols, ~ condition)
        Error in DESeqDataSetFromMatrix(count, cols, ~condition) :
        rownames of the colData:
        b,c,d,a
        are not in the same order as the colnames of the countData:
        a,b,c,d

        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
          ...
          10-14-2026, 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, 11:13 AM
        0 responses
        19 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, Yesterday, 10:48 AM
        0 responses
        18 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-15-2026, 10:52 AM
        0 responses
        36 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-14-2026, 05:39 AM
        0 responses
        42 views
        0 reactions
        Last Post SEQadmin2  
        Working...