TiagoOlivoto / metan

Package for multi-environment trial analysis
https://tiagoolivoto.github.io/metan/
GNU General Public License v3.0
35 stars 17 forks source link

MGIDI selection differential is false if averaged data is negative #20

Closed chabrault closed 1 year ago

chabrault commented 1 year ago

Hi,

First, thanks a lot for the package and especially for MGIDI algorithm. I applied mgidi function both on blup data, with trait values being centered on 0 for the whole population. Hence, I have negative values for the traits. When I output the sel_dif table, I find for some traits negative values in the column SDperc, despite a positive selection differential. As an example, this is my sel_dif table: image

Every time Xo (average value of the trait for the whole population) is negative, the resulting SDperc has the wrong sign.

The explanation is in the code of the MGIDI function L.302. I think it would be more correct to use the absolute value for Xo in the denominator.

Thanks again,

Charlotte

TiagoOlivoto commented 1 year ago

Hi @chabrault, Thanks for pointing this out. I just committed a fix including the abs() in the denominator formula (which is the correct one). Please, let me know if this works now.

chabrault commented 1 year ago

It works fine, thanks a lot!