lhe17 / nebula

GNU General Public License v2.0
26 stars 6 forks source link

Random effects and complex contrasts #37

Open miguecass opened 8 months ago

miguecass commented 8 months ago

Hi,

I ran your method for my data and it was surprisingly fast, so congrats on that first. However, I have some doubts:

1) In the output random effect is always NULL in my case. I assumed the random effect is the second input (metadata$Batch) in the function nebula? Otherwise I am not sure where to put it, because in your tutorial it was not included in the design.

re = nebula(data,metadata$Batch,pred=df, covariance = TRUE)

2) Another doubt is about the covariances. I have 78 covariances but they are not named. So I am not sure about the order of the namings. My design matrix has 12 coefficients but I would like to know what is the order of the covariances since I have 78 of them and I need to compute some complex contrasts.

EDIT: Actually thinking it a bit more, would I need the covariance matrix to compute DE genes for my contrasts? Can I just not multiply the coefficients for each gene by my contrast matrix? (Same as with limma approach)

Thanks in advance,

Best Miguel

lhe17 commented 8 months ago

Hi Miguel,

Thank you for your questions.

  1. If you add "output_re=TRUE" to nebula, then you will see the random effects in the output.
  2. To get the covariance matrix, you could run the following as illustrated in the tutorial

    cov= matrix(NA,12,12) # 12 is the number of the coefs in your design matrix

gene_i = 1 # gene_i is the index of the gene of which you want the covariance

cov[lower.tri(cov,diag=T)] = as.numeric(re$covariance[gene_i,])

cov[upper.tri(cov)] = t(cov)[upper.tri(cov)] # cov is the covariance

Best regards,

Liang

On Fri, Oct 13, 2023 at 7:34 AM miguecass @.***> wrote:

Hi,

I ran your method for my data and it was surprisingly fast, so congrats on that first. However, I have some doubts:

  1. In the output random effect is always NULL in my case. I assumed the random effect is the second input in the function nebula? Otherwise I am not sure where to put it, because in your tutorial it was not included in the design.

re = nebula(data,metadata$Batch,pred=df, covariance = TRUE)

  1. Another doubt is about the covariances. I have 78 covariances but they are not named. So I am not sure about the order of the namings. My design matrix has 12 coefficients but I would like to know what is the order of the coefficients because I need to compute some complex contrasts.

Thanks in advance,

Best Miguel

— Reply to this email directly, view it on GitHub https://github.com/lhe17/nebula/issues/37, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGDISURJUFTTCGJ7DFQZ2P3X7ERK5ANCNFSM6AAAAAA57ANPHU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

miguecass commented 8 months ago

Thanks for the response. Even if output_re is FALSE the fixed coefficients from the model are already taking into account the random effect, right?

lhe17 commented 8 months ago

Hi Miguel,

Yes, that is correct.

Best regards, Liang

On Sat, Oct 14, 2023 at 11:23 AM miguecass @.***> wrote:

Thanks for the response. Even if output_re is FALSE the fixed coefficients from the model are already taking into account the random effect, right?

— Reply to this email directly, view it on GitHub https://github.com/lhe17/nebula/issues/37#issuecomment-1762965594, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGDISUQAGQDGRO5WA4U5QRLX7KU6BANCNFSM6AAAAAA57ANPHU . You are receiving this because you commented.Message ID: @.***>