Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker effect mean value is calculated wrong? #6

Closed
oddoking opened this issue Dec 22, 2023 · 5 comments
Closed

Marker effect mean value is calculated wrong? #6

oddoking opened this issue Dec 22, 2023 · 5 comments

Comments

@oddoking
Copy link
Contributor

In the TraitModel, the marker effect mean is summing all the marker effects along the n (pop size) dimension. I think it should use the mean function, not the sum function. I verified using our data whose mean is zero, but Chromax is summing the value. Also after taking the mean, the marker effect values should be subtracted by the mean so that when calculating GEBV, your code will be correct by adding back the mean.

屏幕截图 2023-12-22 145502

@younik
Copy link
Contributor

younik commented Dec 22, 2023

Thanks for helping us improve ChromaX!

That mean refers to the mean value of GEBV assuming the population is drawn from a uniform distribution on all possible individuals; i.e. every marker has an equal probability of having a value 0 or 1. The first axis in marker_effects is the marker axis; the second will be the number of traits.

If you want to compute the mean of your current population, you should do something like this:

gebvs = simulator.GEBV(population)
gebvs.mean(axis=0)

Moreover, these values are only for the diploid population (see #1), I hope to have time to design it better soon.

So with the previous assumptions, the mean of a random population will be the sum of the marker_effects as the summed markers values on the diploidy axis will have values 2 with 25% probability, 1 with 50% probability, and 0 with 25% probability.

Does this make sense? Sorry for the confusion, I should make it clearer and maybe even private those values (I needed them for some of my experiments, but they are not very interesting for the user maybe).

@oddoking
Copy link
Contributor Author

GEBV.xlsx
image

Thanks for your reply. I think it deserves a follow-up chat. I attached an example of how to calcuate GEBV for one individual. The chromax mean is the sum of marker effects (1.4), When I calculate the GEBV, it is the dot product of monoploidy and marker effect. In chromax, the value will be added by the 'mean' (1.4). So I get differernt results.

Do you have an underlying assumption (uniform distribution) so your calculation is correct? also the _effect_properties is called twice when I load a population outputing two means. Where it is called beside my own call?
image

@younik
Copy link
Contributor

younik commented Dec 26, 2023

Oh, I see it now, and it is a bug indeed, thanks a lot @oddoking

There are two different means defined in that class. One is a user-specified one, that should correctly be added to the dot product. The other is what I explained in my previous message and shouldn't be added; it is just something theoretical that I used for GEBV normalization.

Can you check if #7 looks good for you? Thank you!

A random TraitModel is also generated to simulate GxE effects to simulate phenotyping. If you don't use the phenotype function, you can ignore it

@oddoking
Copy link
Contributor Author

@younik Thanks for responding. I am glad we are contributing. I had a look at your fix. I feel it is not complete. I will create a pull request later to show my thoughts. That would be the easy way for our discussion. Happy New Year~

@younik
Copy link
Contributor

younik commented Jan 8, 2024

Fixed by #7

@younik younik closed this as completed Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants