AdmiralenOla / Scoary

Pan-genome wide association studies
GNU General Public License v3.0
147 stars 35 forks source link

Support for non-binary traits #96

Open MrTomRod opened 2 years ago

MrTomRod commented 2 years ago

Dear @AdmiralenOla

Under Coming soon, you list Support for non-binary traits.

This could be of interest to me. What approach are you thinking of? (Simply binarizing continuous traits?) What use case would it answer?

Btw, since you have probably moved on to other things, I am considering adding this feature to your code myself. Would this be okay with you?

Best, MrTomRod

AdmiralenOla commented 2 years ago

Dear @MrTomRod

Yes, I've been wanting to add that feature for five years now. I'm not sure about the best way to implement it though, since much of the Scoary functionality is so intimately tied to having binary categories. Some of the approaches I've given some thought:

As you've noticed Scoary is not exactly in very active development at the moment due to other pressing obligations, but I maintain the ambition to continue development on it. I will happily accept PRs or spin-offs as long as you credit the original work. Thanks for offering!

All the best, Ola

MrTomRod commented 2 years ago

I have been using GaussionMixture to split by a continuous trait. This is a histogram of an example trait:

image

(has / has_not indicate whether a strain has the highest-scoring orthogene. Sorry for not plotting the estimated Gaussian distributions.)

My approach is simple and straightforward, but maybe not too powerful. I need something to quickly work on thousands of continuous traits.

I'm not sure if I fully understand your suggestions, will have to think about that some more. Would you be willing to discuss this sometimes or perhaps even support me a little if I decided to do this?

Btw, I've been using Boschloo's test instead of Fisher's, since it is perfectly matches the problem and is more powerful. It is slower, though. Not sure if it's worth it.

AdmiralenOla commented 2 years ago

That looks promising! And thanks for teaching me about Boschloo's test.

Absolutely willing to work with you on this in the time I can contribute. You can get in contact with me at any time through my e-mail: olbb@fhi.no.

MrTomRod commented 2 years ago

I wanted to compare Fisher's vs Boschloo's test. To do this, I simulated 10 pangenomes for each combination of sample size: [25, 50, 75, 100, 150, 200] and penetrance: [90, 75]. (As in the paper.) While the p-values from Boschloo's test are uniformly higher, the sensitivity decreased! These are the results:

fisher-boschloo-fig1

Each dot represents the results from one simulated pangenome. The x-axis is the rank of the 'causal' gene in the final table computed using Fisher's minus the rank computed using Boschloo's. In other words, if the resulting value is negative, Fisher's performed better, and if it is positive, Boschloo's performed better.

I performed a Wilcoxon signed-rank test to see if Fisher and Boschloo perform differently: pvalue=0.057.

While Boschloo's test (imo justifiedly) gives a lower p-value, Fisher's seems to perform better at ranking genes with the simulated data. I have no clue why that is, though.

MrTomRod commented 2 years ago

Updated plot with improved ranking, based on pvalue instead of position in table. Didn't change the result.

fisher-boschloo-fig1

pvalue=0.0024

MrTomRod commented 2 years ago

I performed the same analysis with my fast-fisher library. It is now incredibly fast.

The causal gene always got the same rank as with scipy's implementation, except for two simulated datasets: in one, the rank was one higher, in the other, it was one lower.

image

TseWue commented 2 years ago

Heya, Any chance this feature will come soon? I'ts exactly what I have been looking for and would perfectly fit into my workflow. I'm also happy to test.

Best wishes, Tse

MrTomRod commented 2 years ago

You want to run Scoary on continuous traits?

I'm working on an update for Scoary, but it's not ready yet. Approximately another month until testing makes sense.

I will use GaussianMixture for splitting.

You could simply pre-process your continuous traits with GaussianMixture yourself and then feed them into Scoary.

bloomarun commented 1 year ago

I think @MrTomRod did the necessary updates and put it as Scoary-2. Kindly check his GitHub repo