how to iterate all comparisons in group with "coef =" ?
1
0
Entering edit mode
Theo • 0
@theodoregeorgomanolis-7993
Last seen 3 months ago
Germany

Hi all, The main question is if someone has figured a way to automate the comparison of all possible combination? In more detail: I would like to continue on the problem of itteration all possible combinations among different conditions. (as seen in questions: comparisons morecomparisons and a few others) If the condition are more than 2 then the coef will only do conditions based on what is the first enry on the sampleTable for column "group": So it will do for A,B,C,D AvsB, AvsC and AvsD but NO BvsC or BvsD or CvsD. The initial function I can automate it as follows:

dds <- DESeqDataSetFromMatrix(countData = as.matrix(countTable),
                                colData = sampleTable,
                                design = ~ group)

I am using the following to run the lfcShrink() for all possible comparisons:

for (i in 2:length(resultsNames(dds))) {
    comparison <- strsplit(resultsNames(dds)[[i]], "_")
    res.raw <- lfcShrink(dds, type = "apeglm", coef = resultsNames(dds)[i])
    name <- paste0(as.data.frame(comparison)[2,1], "_",as.data.frame(comparison)[3,1],"_", as.data.frame(comparison)[4,1])
    res1 <- list(name = res.raw[order(res.raw$padj),])
    names(res1)<- name
    res <- append(res, res1)
}

In order to do the other comparisons, as BvsC I will need to do the following:

dds$group <- relevel(dds$group, ref = "C")  
dds <- nbinomWaldTest(dds)

and then

dds$group <- relevel(dds$group, ref = "D")  
dds <- nbinomWaldTest(dds)

But I can not really figure out how to

Question1: is there a "nice" way to automate this? Can I remove the main comparison factor ("A" in this case and redo the whole thing again) so that some comparisons will not redone?

I hope that the question is clear. Also, I already have implemented a for loop with ashr that produces a list (res as in the example above) with all given comparisons.

DESeq2 • 780 views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 5 hours ago
United States

We don't have a way to automate all comparisons. What you've sketched out is how I would approach it. Easiest is to use ashr with pairwise combinations I would say.

ADD COMMENT
0
Entering edit mode

Thank you Michael Love , this is what I am currently doing but I was hoping to switch to the more sofisticated apeglm schrinkage.

Another question is if I can from the dds object, to get the existed "level" and create a for loup to get all combinations?

ADD REPLY
0
Entering edit mode

Apeglm would involve a lot of manipulation of the coefficients. Ashr and apeglm are both shrinkage estimators, both perform very well in ranking genes. Ashr has a more flexible prior while apeglm uses the assumed data likelihood (e.g. NB here).

We don't really have any code to help with these types of iterative contrast forming.

ADD REPLY

Login before adding your answer.

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