Question: How to extract common genes that are DE in each comparisons?
0
2.9 years ago by
rkp0
rkp0 wrote:

I have made a Contrasts matrix as

design <- model.matrix(~0+f)
colnames(design) <- levels(f)
design
fit <- lmFit(eset,design)
names(fit)
cont.matrix <- makeContrasts(C9T9="Control9-Treated9",C24T24="Control24-Treated24",........................................,levels=design)
cont.matrix
fit2  <- contrasts.fit(fit, cont.matrix)
fit2  <- eBayes(fit2)
colnames(fit2)
topTable(fit2,coef=1)
topTable(fit2,coef="C9T9")

I have total of 8 comparisons and successfully extracted up and down-regulated  genes from each comparisons using topTable, beside also identified the total number of up and down-regulated genes from each comparisons using

summary(decideTests(fit2))

but I am facing problem to identify/extract common genes that are DE in each of comparisons. Therefore, It is my kind request to all of you, please provides any suggestions for extracting of common genes that are DE in each of the comparisons.

Thanking you.

Kind regards,

Rajesh

modified 2.9 years ago • written 2.9 years ago by rkp0

Hi Aaron,

Thank you very much for your reply but I am unable to find genes that are DE in all comparisons. It given the probe id of all the genes present in datasets instead of DEG.

> is.de <- decideTests(fit2, method="global")
> de.in.all <- rowSumsis.de!=0) == ncol is.de)
> length(de.in.all)
[1] 22810
> up.in.all <- rowSumsis.de == 1) == ncol is.de)
> length(up.in.all)
[1] 22810

de.in.all is a logical vector, so its length will obviously be the same as the number of genes. The relevant bit of information is in which elements are TRUE, i.e., which(de.in.all) if you want the indices of the relevant genes.

> is.de <- decideTests(fit2, method="global")
> de.in.all <- rowSumsis.de!=0) == ncolis.de)
> length(de.in.all)
[1] 22810
> up.in.all <- rowSumsis.de == 1) == ncolis.de)
> length(up.in.all)
[1] 22810

Answer: How to extract common genes that are DE in each comparisons?
1
2.9 years ago by
Aaron Lun25k
Cambridge, United Kingdom
Aaron Lun25k wrote:

You should be able to do something like:

is.de <- decideTests(fit2, method="global")
de.in.all <- rowSums(is.de!=0) == ncol(is.de)

... which will select the genes that are DE in all comparisons at a FDR of 5%. The "global" method ensures that the same significance threshold is applied to all contrasts. Otherwise, a gene with the same t-statistic in each of two contrasts may be considered DE in one contrast and not DE in the other, just because of the effect of other genes on the multiplicity correction. Note that the above method will not select for DE genes that change in the same direction, in which case you should do something like the below for upregulated genes:

up.in.all <- rowSums(is.de == 1) == ncol(is.de)