{"action":"created","issue":{"url":"https://api.github.com/repos/cggh/scikit-allel/issues/75","repository_url":"https://api.github.com/repos/cggh/scikit-allel","labels_url":"https://api.github.com/repos/cggh/scikit-allel/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/cggh/scikit-allel/issues/75/comments","events_url":"https://api.github.com/repos/cggh/scikit-allel/issues/75/events","html_url":"https://github.com/cggh/scikit-allel/issues/75","id":140274762,"number":75,"title":"`pairwise_dxy` problems when given `start` and/or `stop` positions","user":{"login":"travc","id":5840897,"avatar_url":"https://avatars.githubusercontent.com/u/5840897?v=3","gravatar_id":"","url":"https://api.github.com/users/travc","html_url":"https://github.com/travc","followers_url":"https://api.github.com/users/travc/followers","following_url":"https://api.github.com/users/travc/following{/other_user}","gists_url":"https://api.github.com/users/travc/gists{/gist_id}","starred_url":"https://api.github.com/users/travc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travc/subscriptions","organizations_url":"https://api.github.com/users/travc/orgs","repos_url":"https://api.github.com/users/travc/repos","events_url":"https://api.github.com/users/travc/events{/privacy}","received_events_url":"https://api.github.com/users/travc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-11T19:47:59Z","updated_at":"2016-03-12T00:03:21Z","closed_at":null,"body":"`pairwise_dxy` has a problem when given `start` and/or `stop` position.\r\nThe unhandled case is actually in `sequence_divergence`.  The slice based on those positions is applied to `ac1` and `ac2`, but not `an1` and `an2`.\r\n\r\nHere's a fix (last 4 lines are new)... apologies for not doing a proper pull request.  This is in the `stats/diversity.py` file.\r\n\r\n```\r\n    def sequence_divergence(pos, ac1, ac2, an1=None, an2=None, start=None,\r\n                                              stop=None, is_accessible=None):\r\n        # check inputs\r\n        if not isinstance(pos, allel.model.ndarray.SortedIndex):\r\n            pos = allel.model.ndarray.SortedIndex(pos, copy=False)\r\n        if start is not None or stop is not None:\r\n            loc = pos.locate_range(start, stop)\r\n            pos = pos[loc]\r\n            ac1 = ac1[loc]\r\n            ac2 = ac2[loc]\r\n            if an1 is not None:\r\n                an1 = an1[loc]\r\n            if an2 is not None:\r\n                an2 = an2[loc]\r\n...\r\n```"},"comment":{"url":"https://api.github.com/repos/cggh/scikit-allel/issues/comments/195610178","html_url":"https://github.com/cggh/scikit-allel/issues/75#issuecomment-195610178","issue_url":"https://api.github.com/repos/cggh/scikit-allel/issues/75","id":195610178,"user":{"login":"alimanfoo","id":703554,"avatar_url":"https://avatars.githubusercontent.com/u/703554?v=3","gravatar_id":"","url":"https://api.github.com/users/alimanfoo","html_url":"https://github.com/alimanfoo","followers_url":"https://api.github.com/users/alimanfoo/followers","following_url":"https://api.github.com/users/alimanfoo/following{/other_user}","gists_url":"https://api.github.com/users/alimanfoo/gists{/gist_id}","starred_url":"https://api.github.com/users/alimanfoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alimanfoo/subscriptions","organizations_url":"https://api.github.com/users/alimanfoo/orgs","repos_url":"https://api.github.com/users/alimanfoo/repos","events_url":"https://api.github.com/users/alimanfoo/events{/privacy}","received_events_url":"https://api.github.com/users/alimanfoo/received_events","type":"User","site_admin":false},"created_at":"2016-03-12T00:03:21Z","updated_at":"2016-03-12T00:03:21Z","body":"Thanks Travis, don't worry about a PR, I'll edit in the fix for the next\nrelease.\n\nOn Fri, Mar 11, 2016 at 7:48 PM, Travis Collier <notifications@github.com>\nwrote:\n\n> pairwise_dxy has a problem when given start and/or stop position.\n> The unhandled case is actually in sequence_divergence. The slice based on\n> those positions is applied to ac1 and ac2, but not an1 and an2.\n>\n> Here's a fix (last 4 lines are new)... apologies for not doing a proper\n> pull request. This is in the stats/diversity.py file.\n>\n>     def sequence_divergence(pos, ac1, ac2, an1=None, an2=None, start=None,\n>                                               stop=None, is_accessible=None):\n>         # check inputs\n>         if not isinstance(pos, allel.model.ndarray.SortedIndex):\n>             pos = allel.model.ndarray.SortedIndex(pos, copy=False)\n>         if start is not None or stop is not None:\n>             loc = pos.locate_range(start, stop)\n>             pos = pos[loc]\n>             ac1 = ac1[loc]\n>             ac2 = ac2[loc]\n>             if an1 is not None:\n>                 an1 = an1[loc]\n>             if an2 is not None:\n>                 an2 = an2[loc]\n> ...\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/cggh/scikit-allel/issues/75>.\n>\n\n\n\n-- \nAlistair Miles\nHead of Epidemiological Informatics\nCentre for Genomics and Global Health <http://cggh.org>\nThe Wellcome Trust Centre for Human Genetics\nRoosevelt Drive\nOxford\nOX3 7BN\nUnited Kingdom\nEmail: alimanfoo@googlemail.com <alimanfoo@gmail.com>\nWeb: http://purl.org/net/aliman\nTwitter: https://twitter.com/alimanfoo\nTel: +44 (0)1865 287721\n"}}