collapseReplicates changes the order of the original dataframe in DESeq2
1
0
Entering edit mode
gtechbio ▴ 10
@gtechbio-13996
Last seen 10 months ago
Spain

Hi all,

I noticed a strange behaviour of collapseReplicates function of DESeq2 v 1.22.2. After collapsing replicates, DESeq2 for some reorders the columns in the dataframe. Below is an example:

m <- matrixsample.int(100, size = 28*100, replace = T), ncol = 28, nrow = 100)

rownames(m)<-paste0("gene",1:100)

colnames(m)<-c("a1","a2","A0C1","A0C1reseq","A0C2","A0C2reseq","a3",
           "3reseq","a4","5a","6a","a7","a8","a9","a10","a11","a12",
           "a13","a14","a15","a16","a59","a17","a18","A24C1","A24C1reseq",
           "A24C2","A24C2reseq")
grouping<-c("sample1","sample2", "sampleA0C1","sampleA0C1",
        "sampleA0C2","sampleA0C2","sample3", "sample3","sample4","sample5a",
        "sample6","sample7","sample8","sample9","sample10","sample11","sample12",
        "sample13","sample14","sample15","sample16","sample59","sample17","sample18",
        "sampleA24C1","sampleA24C1","sampleA24C2","sampleA24C2")

colData_test<-data.frame(time=c(rep("0",6), rep("1.5",4), rep("3",3), 
                              rep("3c",2), rep("12", 3), rep("24",4), rep("24c",6)),
                         grouping,
                         ids=colnames(m))

pre_dds <- DESeqDataSetFromMatrix(m, colData=colData_test, ~time)

pre_dds_collaps<-collapseReplicates(pre_dds,pre_dds$grouping,pre_dds$ids, renameCols = F)

Then if you do assay(pre_dds_collaps), the order of columns is changed from the original.

Do I do anything wrong?

Disclaimer: cross-posted in Biostars https://www.biostars.org/p/390887/

deseq2 collapseReplicates • 883 views
ADD COMMENT
1
Entering edit mode
@mikelove
Last seen 47 minutes ago
United States

The dds is output in the order of the grouping factor (e.g. the sample ID) that was used to perform the collapsing operation. You can re-order as you like after collapsing, e.g.:

dds <- dds[,order(dds$condition, dds$batch)]
ADD COMMENT
0
Entering edit mode

Hi Michael, thanks for clarifying. If I donĀ“t change the order, the results will be the same, right?

ADD REPLY
1
Entering edit mode

The order of the samples has no effect on the results.

ADD REPLY

Login before adding your answer.

Traffic: 847 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6