{"action":"created","issue":{"url":"https://api.github.com/repos/Illumina/GTCtoVCF/issues/21","repository_url":"https://api.github.com/repos/Illumina/GTCtoVCF","labels_url":"https://api.github.com/repos/Illumina/GTCtoVCF/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/Illumina/GTCtoVCF/issues/21/comments","events_url":"https://api.github.com/repos/Illumina/GTCtoVCF/issues/21/events","html_url":"https://github.com/Illumina/GTCtoVCF/issues/21","id":355380570,"node_id":"MDU6SXNzdWUzNTUzODA1NzA=","number":21,"title":"Indel haploid calls printed as diploid","user":{"login":"brianhill11","id":4266396,"node_id":"MDQ6VXNlcjQyNjYzOTY=","avatar_url":"https://avatars0.githubusercontent.com/u/4266396?v=4","gravatar_id":"","url":"https://api.github.com/users/brianhill11","html_url":"https://github.com/brianhill11","followers_url":"https://api.github.com/users/brianhill11/followers","following_url":"https://api.github.com/users/brianhill11/following{/other_user}","gists_url":"https://api.github.com/users/brianhill11/gists{/gist_id}","starred_url":"https://api.github.com/users/brianhill11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianhill11/subscriptions","organizations_url":"https://api.github.com/users/brianhill11/orgs","repos_url":"https://api.github.com/users/brianhill11/repos","events_url":"https://api.github.com/users/brianhill11/events{/privacy}","received_events_url":"https://api.github.com/users/brianhill11/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-30T00:30:44Z","updated_at":"2018-09-03T19:07:51Z","closed_at":null,"author_association":"NONE","body":"Hi there, \r\n\r\nWe came across this issue while trying to run bcftools norm command to merge multi-line variants into a single line.  Here is the command and error: \r\n```\r\nbcftools norm -m +any -Oz -o output.sample1234.vcf.gz sample1234.vcf.gz\r\nError at X:48386632: cannot combine diploid with haploid genotype\r\n```\r\n\r\nIt was trying to combine these records (sample seems to be a male): \r\n```\r\nX       48386632        seq-rs797045547 T       TG      .       PASS    .       GT:GQ   0:0.474965\r\nX       48386632        seq-rs587783616 T       G       .       PASS    .       GT:GQ   0/1:0.409332\r\n```\r\n\r\nThe 0/1 genotype call doesn't make sense to me for a male sample. It seems that there are many calls on the X chromosome that are haploid, and many that are diploid. My guess is that this piece of the code is part of the issue:\r\n\r\n```\r\ndef format_vcf_genotype(vcf_allele1_char, vcf_allele2_char, ploidy):\r\n    \"\"\"\r\n    Create a VCF representation of the genotype based on alleles. Format appropriately if haploid.\r\n    Args:\r\n        vcf_allele1_char (string): 0,1,2 etc.\r\n        vcf_allele2_char (string): 0,1,2, etc.\r\n        vcf_record (vcf._Record): Record for the entry analyzed\r\n        ploidy(int): Expected ploidy.\r\n    Returns\r\n        string: String representation of genotype (e.g., \"0/1\"), adjusted for haploid calls if applicable\r\n    \"\"\"\r\n    assert ploidy < 3\r\n\r\n   if ploidy == 1:\r\n        if vcf_allele1_char == vcf_allele2_char:\r\n            return str(vcf_allele1_char)\r\n\r\n    vcf_genotype = \"\"\r\n    if vcf_allele2_char < vcf_allele1_char:\r\n        vcf_genotype = str(vcf_allele2_char) + \"/\" + str(vcf_allele1_char)\r\n    else:\r\n        vcf_genotype = str(vcf_allele1_char) + \"/\" + str(vcf_allele2_char)\r\n    return vcf_genotype\r\n```\r\n\r\nSince indels are printed out as either 0/1 or 1/0 (see the [convert_indel_genotype_to_vcf](https://github.com/Illumina/GTCtoVCF/blob/1a9709baa7116eea56e09dd185bd4358a165f34d/GenotypeFormat.py#L66) function) the check `if vcf_allele1_char == vcf_allele2_char:` never evaluates to true, and therefore falls through and gets printed as a diploid call. \r\n\r\nMy thought was that something like this might make more sense: \r\n```\r\nif ploidy == 1:\r\n        if vcf_allele1_char == vcf_allele2_char:\r\n            return str(vcf_allele1_char)\r\n        else: \r\n            return str(max(vcf_allele1_char, vcf_allele2_char))\r\n\r\n```\r\n\r\nDoes that seem reasonable? If so, I can open a pull request. \r\n\r\nThanks,\r\nBrian"},"comment":{"url":"https://api.github.com/repos/Illumina/GTCtoVCF/issues/comments/418178907","html_url":"https://github.com/Illumina/GTCtoVCF/issues/21#issuecomment-418178907","issue_url":"https://api.github.com/repos/Illumina/GTCtoVCF/issues/21","id":418178907,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODE3ODkwNw==","user":{"login":"brianhill11","id":4266396,"node_id":"MDQ6VXNlcjQyNjYzOTY=","avatar_url":"https://avatars0.githubusercontent.com/u/4266396?v=4","gravatar_id":"","url":"https://api.github.com/users/brianhill11","html_url":"https://github.com/brianhill11","followers_url":"https://api.github.com/users/brianhill11/followers","following_url":"https://api.github.com/users/brianhill11/following{/other_user}","gists_url":"https://api.github.com/users/brianhill11/gists{/gist_id}","starred_url":"https://api.github.com/users/brianhill11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianhill11/subscriptions","organizations_url":"https://api.github.com/users/brianhill11/orgs","repos_url":"https://api.github.com/users/brianhill11/repos","events_url":"https://api.github.com/users/brianhill11/events{/privacy}","received_events_url":"https://api.github.com/users/brianhill11/received_events","type":"User","site_admin":false},"created_at":"2018-09-03T19:07:51Z","updated_at":"2018-09-03T19:07:51Z","author_association":"NONE","body":"Hi Ryan, \r\n\r\nThanks for the reply. It sounds like this is best handled downstream, and not during conversion. \r\n\r\nI'm still trying to wrap my head around what a 0/1 (or 1/0) call would mean in the haploid situation. How could you have both the reference and the alternate when only one should be possible? \r\n\r\nThanks,\r\nBrian "}}
{"actor":{"display_login":"brianhill11"}}