variani / lme4qtl

Mixed models @lme4 + custom covariances + parameter constraints
GNU General Public License v3.0
48 stars 10 forks source link

how to apply GRM matrix into longitudinal data? #27

Closed ConnieXuhm closed 3 years ago

ConnieXuhm commented 3 years ago

Hi @variani @deruncie , I have a longitudinal data with four time point, to do the GWAS study. I have two questions: 1) If lme4qtl cope with GRM matrix (n=a) and long-data (n=4a)? 2) Whether assocLmer can deal the GE interactions, like I want to put the "timesnp" into the equation. Thanks a lot!

variani commented 3 years ago

Hi,

The longitudinal model with GRM should work in lme4qtl. The pull request #18 nicely makes this happen. You GRM matrix of n-by-n size is enough to pass to relmatLmer: you have repeated measurements per sample ID and these IDs are present in rownames/colnames of GRM.

assocLmer is an example function to conduct GWAS. You need to create your own function that accommodates two specific parts of your model: longitudinal measurements & GxE test.

Hope this helps.

Best, Andrey

levlitichev commented 11 months ago

Hi Andrey,

Thanks for putting together a nice package. I have a follow-up question related to the discussion above.

I believe ecologists refer to the situation above as the "repeated measures animal model." In this model, it is important to account for both additive genetic effects (with a genetic relatedness matrix) and "repeatability." Here are two references related to this: "How to fit an animal model" and "An ecologist's guide to the animal model".

In other words, say we have the following model:

y ~ age + sex + [GRM]

where y is some outcome, age and sex are fixed effects, and [GRM] is a random effect that uses the genetic relatedness matrix. With this model, the GRM term will include both additive genetic effects and repeatability. I would like to fit the following model:

y ~ age + sex + (1|animal) + [GRM]

where (1|animal) is a random effect that just accounts for repeatability. Here is my guess for how to do this:

relmatLmer(
    y ~ age + sex + (1|animal) + (1|animal_repeatability), 
    relmat = list(animal = kinship_matrix), 
    df)

where (1|animal_repeatability) is the same as (1|animal), just named differently.

Do you think this would be appropriate? Thanks in advance for your thoughts.

-Lev

variani commented 11 months ago

Hi Lev,

I think you guessed the trick right: have multiple ID names. In the lme4qtl paper, you can check models m3, m4 and m5, where 'rid' is a copy of 'id' variable to accommodate two sources of covariances, residual and genetic.

Feel free to share some R code to simulate data & do model fitting with lme4qtl. I am happy to help if you find any issues.

Best, Andrey

levlitichev commented 11 months ago

Hi Andrey,

Thanks for confirming.

With the approach you describe, I was able to exactly reproduce results that I had previously obtained with ASReml:

image

With example code:

# lme4qtl
relmatLmer(
  y ~ age + sex + (1|animal) + (1|animal_repeatability), 
  relmat = list(animal = kinship_matrix), 
  df)

# asreml
asreml(
  fixed = ~ age + sex,
  random = ~ vm(animal, kinship_matrix) + ide(animal),
  data = df)

Thanks again for the quick response, Lev

variani commented 11 months ago

Nice to see that the two methods agree! Thank you for posting the results here.