Question: (Closed) making contrast in limma for Affymetrix data
0
gravatar for Jamal
17 months ago by
Jamal0
Jamal0 wrote:


hi guys,  I want to create a contrasts matrix to compare the Affymetrix array (two types of genotypes, two treatment groups (infected) and controls for each genotype and three times for each genotype), for comparison, I wrote the code below Please guide. Where is the problem?

TF <- paste(P1$Genotype, P1$Time, P1$Treatment, sep=".")
TF <- factor(TF)
design <- model.matrix(~0+TF)              
fit <- lmFit(exprs(ndata.raw), design)

cont.matrix <- makeContrasts(
        q1= q.1.E - q.1.C,
        q6= q.6.E - q.6.C,
        q24= q.24.E - q.24.C,
        Q1= Q.1.E - Q.1.C,
        Q6= Q.6.E - Q.6.C,
        Q24= Q.24.E - Q.24.C,
        Diff_1h = (Q.1.E - Q.1.C) - (q.1.E - q.1.C),
        Diff_6h = (Q.6.E - Q.6.C) - (q.6.E - q.6.C),
        Diff_24h = (Q.24.E - Q.24.C) - (q.24.E - q.24.C),
        levels=design)

Is this part of the code (Diff_24h = (Q.24.E - Q.24.C) - (q.24.E - q.24.C))  is correct to compare the two genotypes?

ADD COMMENTlink modified 17 months ago by Gordon Smyth38k • written 17 months ago by Jamal0
1

You haven't stated what the problem is. Do you have an error message? What is your session info? Read the posting guide - asking for general guidance on this forum is not appreciated, especially in the presence of comprehensive documentation.

ADD REPLYlink written 17 months ago by Aaron Lun24k

I have a trouble with making a contrast matrix.

First, compare the treatment of the genotypes with their controls, then I would like to compare the two genotypes (the problem is related to this section,  there is no error, but none of the genes are not significant). 

Diff_1h = (Q.1.E - Q.1.C) - (q.1.E - q.1.C),
Diff_6h = (Q.6.E - Q.6.C) - (q.6.E - q.6.C),
Diff_24h = (Q.24.E - Q.24.C) - (q.24.E - q.24.C)

To compare two genotypes from the above code, is this code wrong?

ADD REPLYlink written 17 months ago by Jamal0

all samples were processed in PBMEC (in vitro bovine mammary epithelial cells) and at the same time. I want to get DEs which up or down-regulated in Q genotype compare with q genotype! I think so but I don't sure, do my contrast code following is correct?

cont.matrix <- makeContrasts(
         q1= q.1.E - q.1.C,
         q6= q.6.E - q.6.C,
         q24= q.24.E - q.24.C,
         Q1= Q.1.E - Q.1.C,
         Q6= Q.6.E - Q.6.C,
         Q24= Q.24.E - Q.24.C,
         Diff_1 = (Q.1.E - Q.1.C) - (q.1.E - q.1.C),
         Diff_6 = (Q.6.E - Q.6.C) - (q.6.E - q.6.C),
         Diff_24 = (Q.24.E - Q.24.C) - (q.24.E - q.24.C),
         levels=design)

My concern is why I don't get any DEs with this code!!! while I expected to have more than 500 DE genes. I would be very grateful if you could guide me here.

However, the following results were obtained by direct comparison of genotypes (Code that you said).

cont.matrix <- makeContrasts(
        q1= q.1.E - q.1.C,
        q6= q.6.E - q.6.C,
        q24= q.24.E - q.24.C,
        Q1= Q.1.E - Q.1.C,
        Q6= Q.6.E - Q.6.C,
        Q24= Q.24.E - Q.24.C,
        Diff_1__C = (Q.1.C - q.1.C),
        Diff_6__C = (Q.6.C - q.6.C),
        Diff_24__C = (Q.24.C - q.24.C),
        Diff_1__T = (Q.1.E - q.1.E),
        Diff_6__T = (Q.6.E - q.6.E),
        Diff_24__T = (Q.24.E - q.24.E ),
        levels=design)
Diff_1__T <- topTable(fit2, number = Inf, coef= 10, adjust="BH")
Diff_1__T <- subset(Diff_1__T, adj.P.Val <= 0.05)
nDiff_1__T <- nrow(subset(Diff_1__T))
nDiff_1__T
[1] 10
Diff_6__T <- topTable(fit2, number = Inf, coef= 11, adjust="BH")
Diff_6__T <- subset(Diff_6__T, adj.P.Val <= 0.05)
nDiff_6__T <- nrow(subset(Diff_6__T))
nDiff_6__T
[1] 0
Diff_24__T <-topTable(fit2, number = Inf, coef= 12, adjust="BH")
Diff_24__T <- subset(Diff_24__T, adj.P.Val <= 0.05)
nDiff_24__T <- nrow(subset(Diff_24__T))
nDiff_24__T
[1] 1395

Regards

 

ADD REPLYlink modified 17 months ago by Gordon Smyth38k • written 17 months ago by Jamal0
1

If you're adding more information, don't post it as an answer unless you're answering your own question. Either edit your original post, or add a comment to your original post.

Anyway, I don't see the problem. You did the comparison, you didn't get many DE genes. That's life. Unless you have known positive controls, there is no evidence that your analysis is wrong.

Incidentally, setting coef="Diff_1__T" is much safer than setting coef=10, as the former is robust to addition or removal of earlier contrasts in your call to makeContrasts.

ADD REPLYlink modified 17 months ago • written 17 months ago by Aaron Lun24k

Hello Jamal!

We believe that this post does not fit the main topic of this site.

Your question has been answered as far as is possible and there's nothing more than can be added. Choosing which contrasts to make for your data is your own responsibility.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ADD REPLYlink modified 17 months ago • written 17 months ago by Gordon Smyth38k
Answer: making contrast in limma for Affymetrix data
1
gravatar for Aaron Lun
17 months ago by
Aaron Lun24k
Cambridge, United Kingdom
Aaron Lun24k wrote:

As you may be aware, the following contrasts:

Diff_1h = (Q.1.E - Q.1.C) - (q.1.E - q.1.C),
Diff_6h = (Q.6.E - Q.6.C) - (q.6.E - q.6.C),
Diff_24h = (Q.24.E - Q.24.C) - (q.24.E - q.24.C)

... do not directly compare genotypes. Rather, they compare the genotype-specific log-fold changes between treatments. In other words, the null hypothesis for Diff_1h is that the effect of treatment in Q.1 is the same as the effect of treatment in q.1 (and similarly for the other contrasts).

That null hypothesis may or may not be interesting to you. But if you want to directly compare genotypes, you should be doing:

Diff_1C = Q.1.C - q.1.c,
Diff_1E = Q.1.E - q.1.e,
# ... etc.

Moreover, not having any significant genes is not necessarily an error. It just means that (i) there are no true DE genes there, or (ii) you don't have enough power to detect them. Sometimes the latter may be caused by hidden factors of variation, which can be handled with methods like sva or RUV. Other times, you just don't have enough replicates, in which case you need to go collect some more data.

ADD COMMENTlink written 17 months ago by Aaron Lun24k

Dear Aaron ,

Are you sure that it is possible to compare betweens genotypes directly?

Diff_1C = Q.1.C - q.1.c,
Diff_1E = Q.1.E - q.1.e,

And one more question is how to learn to do these comparisons, generally?

 

Thank you again for your patience and guidance !!

ADD REPLYlink modified 17 months ago • written 17 months ago by Jamal0

There is nothing stopping you from comparing the genotypes directly, unless there are confounding factors in your experimental design that you have not mentioned (e.g., all samples for a given genotype were processed on separate days or in different batches). If these confounding factors are present, then you cannot compare the genotypes directly.

You can learn how to do these comparisons by reading through the limma user's guide. It's a long document, but reading it thoroughly is faster than waiting for a response here. Help is more effective when you have already read the documentation.

ADD REPLYlink modified 17 months ago • written 17 months ago by Aaron Lun24k

Dear Aaron,

I already read the user guide. Unfortunately, I did not fully understand this section and I doubt it in the results. I will be very grateful if you resolve my doubt.

ADD REPLYlink modified 17 months ago by Gordon Smyth38k • written 17 months ago by Jamal0
Answer: making contrast in limma for Affymetrix data
0
gravatar for Gordon Smyth
17 months ago by
Gordon Smyth38k
Walter and Eliza Hall Institute of Medical Research, Melbourne, Australia
Gordon Smyth38k wrote:

Dear Jamal,

You can examine the number of DE genes for all the contrasts much more easily by

> summary(decideTests(fit2))

Anyway, I am going to close this question because Aaron has answered you and there is nothing more we can do to help you. It is clear that the limma software is working correctly for you and that you already understand how to form contrasts. It is not however our responsibility to tell you which contrasts are meaningful for your data, nor can we take any responsibility for the number of the DE genes that you might get. Analysing and interpreting your own data is your own responsibility. Asking the same question repeatedly (both here and in 3 emails to me) doesn't help at all.

Best wishes
Gordon

 

ADD COMMENTlink modified 17 months ago • written 17 months ago by Gordon Smyth38k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 283 users visited in the last hour