Unconfigured Ad

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

    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
          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.
          ...
          Today, 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...
          Yesterday, 05:17 AM
        • GATTACAT
          Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
          by GATTACAT
          Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
          07-01-2026, 11:43 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, Today, 10:04 AM
        0 responses
        7 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, Yesterday, 10:08 AM
        0 responses
        6 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 07-07-2026, 11:05 AM
        0 responses
        9 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 07-02-2026, 11:08 AM
        0 responses
        31 views
        0 reactions
        Last Post SEQadmin2  
        Working...