-
Notifications
You must be signed in to change notification settings - Fork 246
Add support for inverting phase of genotypes with setGT plugin #2367
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
Conversation
plugins/setGT.c
Outdated
@@ -113,6 +114,7 @@ const char *usage(void) | |||
" X .. allele with bigger read depth as determined from FMT/AD\n" | |||
" p .. phase genotype (0/1 becomes 0|1)\n" | |||
" u .. unphase genotype and sort by allele (1|0 becomes 0/1)\n" | |||
" i .. inverse phase of genotype (0|1 becomes 1|0)\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a native speaker, but I think a better description would be "invert the genotype phase"
plugins/setGT.c
Outdated
@@ -364,6 +367,21 @@ static inline int unphase_gt(int32_t *ptr, int ngts) | |||
return changed; | |||
} | |||
|
|||
// inverse phase for a single sample, ngts is the ploidy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invert, not inverse, here and everywhere..
Thank you for the pull request. Please add a test, see |
@pd3 thank you for your response, I fixed the language and added a test case. Best regards, |
Thank you |
Hello,
I added an option to invert the phase of diploid genotypes in the setGT plugin.
So
0|1
becomes1|0
.This is useful when one wants to invert the whole phase of a file, or selected samples, or based on a filter.
The function only inverts the phase of diploid genotypes (checks
ngt==2
and ifbcf_int32_vector_end
is present).Phase flag is set correctly per BCF specs. Note unphased genotypes are also swapped so
0/1
becomes1/0
.I hope we can get this merged, let me know if there are any changes you would like me to make.
Best regards,
Rick