DESeq2: group-group distance analysis (not only sample-sample distance)?
1
0
Entering edit mode
KimS • 0
@kims-13267
Last seen 6.9 years ago

Dear all,

I am new to DESeq2 and R and am in need of a distance analysis between different cell types in an RNAseq analysis. We have 10 cell types and 2 biological replicates for each. The sample-to-sample distance was easy to obtain with the code provided in the manual (thank you! and see below), but is there an easy way to assess the group-to-group distance too? (i.e. cell type to cell type). E.g. is it fair to average the counts of biological replicates in the dds, and if so, how? Is there a way to choose JS-distance over Euclidean?

rld <- rlogTransformation(dds, blind=TRUE)

distsRL <- dist(t(assay(rld)))
mat <- as.matrix(distsRL)
rownames(mat) <- colnames(mat) <- with(colData(dds),paste(celltype))

I truly thank you for any assistance that you can offer, 

KS

deseq2 • 1.4k views
ADD COMMENT
0
Entering edit mode

Hi Michael, 

Yes, this would absolutely work. 

That you kindly for your effort in advance!

KS

ADD REPLY
0
Entering edit mode
@mikelove
Last seen 2 hours ago
United States

How about the sum of squared shrunken log2 fold changes as a distance? I can write a script to calculate this for you.

ADD COMMENT
0
Entering edit mode

So you can do:

dds <- DESeq(dds, betaPrior=TRUE)
coefs <- coef(dds)[,-1]
dist.mat <- matrix(nrow=ncol(coefs),ncol=ncol(coefs))
diag(dist.mat) <- 1
for (i in 1:(ncol(coefs)-1)) {
  for (j in (i+1):ncol(coefs)) {
    dist.mat[j,i] <- dist.mat[i,j] <- sqrt(sum((coefs[,i] - coefs[,j])^2))
  }
​}
ADD REPLY
0
Entering edit mode

Thank you, Michael.

When run, the all dist.mat values are NA, except the diagonal. The dimensions look good (10 by 10). Can you have another quick look at this and/or let me know how to help?

ADD REPLY
0
Entering edit mode

Put an na.rm=TRUE in the sum. The NA are from genes with all 0 counts.

ADD REPLY
0
Entering edit mode

Perfect! And thank you for your time! 

ADD REPLY

Login before adding your answer.

Traffic: 593 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