famuvie / breedR

Statistical methods for forest genetic resources analysts
http://famuvie.github.io/breedR/
GNU General Public License v3.0
31 stars 24 forks source link

Genotype x Environment #94

Closed treebreeder closed 6 years ago

treebreeder commented 6 years ago

Is it possible to calculate GxE with breedR? Can I include a covariance matrix in the calculation of breeding values that accounts for differences among environments? Any help would be highly appreciated!

famuvie commented 6 years ago

Some models are possible, others not. It depends.

If you work with genetic groups (i.e. independent effects) then yes, you can. See the material from Session 4 of this workshop.

If you want to use a pedigree then no, you can't for the moment, sorry.

treebreeder commented 6 years ago

Many thanks! I worked through the workshop material, but I get an error message when executing the following command:

Group the three independent effects to allow covariation

effects$fsi <- breedR:::effect_group( list(f1 = effects$f1$effects[[1]], f2 = effects$f2$effects[[1]], f3 = effects$f3$effects[[1]]), cov.ini = matrix(c(1, .5, .5, .5, 1, .5, .5, .5, 1), 3, 3) )

Error in breedR:::effect_group(list(f1 = effects$f1$effects[[1]], f2 = effects$f2$effects[[1]], : argument "ntraits" is missing, with no default

famuvie commented 6 years ago

Ah yes. Since the workshop the function gained a new argument ntraits. Just add it manually:

effects$fsi <- breedR:::effect_group(
  list(
    f1 = effects$f1$effects[[1]],
    f2 = effects$f2$effects[[1]],
    f3 = effects$f3$effects[[1]]
  ),
  cov.ini = matrix(c(1, .5, .5, .5, 1, .5, .5, .5, 1), 3, 3),
  ntraits = 1
)
treebreeder commented 6 years ago

Ah yes, that worked well. Many thanks!

However, could it be that the following code has changed as well:

pf90 <- breedR:::progsf90(mf, effects, opt = c("sol se"), res.var.ini = 1)

I am just asking, because I get the message that arguments 'effects' and 'weights' are missing! I changed it into: pf90 <- breedR:::progsf90(mf, effects=effects, weights=c(1,1,1,2), opt = c("sol se"), res.var.ini = 1)

which worked, but I am not sure whether this is right, because 'vm' becomes NULL and can not be rounded subsequently!

Many thanks for your quick responses! Highly appreciated....

treebreeder commented 6 years ago

sorry....I used 'weights=c(1,1,2)' of course for the test data since there were three sites only

famuvie commented 6 years ago

Yes, that's right. You need to add an argument weights. However, they are not a site-wise but observation-wise weights, and they are used for introducing heterogeneous residual variances. Thus, it is a vector of length n_obs rather than n_sites.

Use weights = NULL for a default specification where all observations share the same residual variance.

I didn't get what was vm which became NULL and could not be rounded from your previous message.

treebreeder commented 6 years ago

This issue has been fixed. Many thanks! I am just wondering how BreedR handles data with mixed pedigree information: for instance, I have data where the mother tree is known in most cases, but in some cases this information is missing. So i coded the pedigree as 0 for both "mum" and "dad". Does breedR automatically remove such data from calculations? I tested two versions for calculation, one with such data and one without, but I get pretty different results. And maybe one more question: is missing data for the phenotypes allowed? I see that the algorithm works, but the same happens as mentioned above: results differ a lot, when I remove the missing data before by myself!

famuvie commented 6 years ago

Would you please post these questions under a different issue? So I can answer there and close this one. Thanks.