Question: collapseReplicates changes the order of the original dataframe in DESeq2
0
29 days ago by
gtechbio0
gtechbio0 wrote:

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 • 73 views
modified 29 days ago by Michael Love24k • written 29 days ago by gtechbio0
Answer: collapseReplicates changes the order of the original dataframe in DESeq2
1
29 days ago by
Michael Love24k
United States
Michael Love24k wrote:

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)]


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

1

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