weizhouUMICH / SAIGE

GNU Lesser General Public License v3.0
188 stars 73 forks source link

What's af_cases and af_controls exactly? #307

Closed apoliakov closed 2 years ago

apoliakov commented 3 years ago

Hello!

I did some experiments with these flags in single-variant SAIGE:

IsOutputHetHomCountsinCaseCtrl = T, 
IsOutputAFinCaseCtrl = T,

I am on SHA commit 92a3c2cd288474c66d82eeb09ed5dd590fb59f31. The numbers output by the first flag - homN_Allele2_cases, hetN_Allele2_cases... and so on make sense. They match my manual calculations. But what about the other flag. What are af_cases and af_controls?

For example, I got a rare variant where homN_Allele2_cases=0 and hetN_Allele2_cases=0. And yet, I am getting af_cases = 4.373417e-07. So how can that be? I don't have more than 500K samples so I shouldn't see any kind of allele frequency numbers below 1e-6, right? Or am I missing something?

weizhouUMICH commented 3 years ago

Hi @apoliakov,

The af_cases and af_controls are allele frequency in cases and in controls, respectively. To count the homN_Allele2_cases and hetN_Allele2_cases, the dosages of markers are rounded to the nearest integer https://github.com/weizhouUMICH/SAIGE/blob/master/R/SAIGE_SPATest.R#L859

So I think there is a sample/samples who are cases with dosage for the marker < 0.5, so hetN_Allele2_cases = 0. But af_cases = sum(dosage in cases)/(2* n_cases) and it can be that very small number shown above.

Thanks, Wei

apoliakov commented 3 years ago

Hi Wei! Been a while!

Yeah - I didn't have any fractional dosages here. All my dosages were 0, 1, or 2. So that doesn't quite explain it :/

weizhouUMICH commented 3 years ago

Hi Alex, ah really? Wondering if it is because the C++ codes treated them as double instead of int.

On Wed, May 5, 2021 at 1:35 PM Alex Poliakov @.***> wrote:

Hi Wei! Been a while!

Yeah - I didn't have any fractional dosages here. All my dosages were 0, 1, or 2. So that doesn't quite explain it :/

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/weizhouUMICH/SAIGE/issues/307#issuecomment-832878480, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACL52L5OTSAXVQBEDLEMVGTTMF6VXANCNFSM4WOSNT6A .

weizhouUMICH commented 2 years ago

Sorry fo the late reply! We have just released a new version 1.0.0. It has substantial computational efficiency improvements for both Step 1 and Step 2 for single-variant and set-based tests and clearer log output. We have created a new program github page https://github.com/saigegit/SAIGE with the documentation provided https://saigegit.github.io/SAIGE-doc/ The program will be maintained by multiple SAIGE developers there. The docker image has been updated. Please feel free to try the version 1.0.0 and report issues if any.

Thanks! Wei