{"action":"opened","issue":{"url":"https://api.github.com/repos/samtools/samtools/issues/841","repository_url":"https://api.github.com/repos/samtools/samtools","labels_url":"https://api.github.com/repos/samtools/samtools/issues/841/labels{/name}","comments_url":"https://api.github.com/repos/samtools/samtools/issues/841/comments","events_url":"https://api.github.com/repos/samtools/samtools/issues/841/events","html_url":"https://github.com/samtools/samtools/issues/841","id":320094850,"number":841,"title":"samtools bedcov includes bed interval in coverage","user":{"login":"agraubert","id":997749,"avatar_url":"https://avatars2.githubusercontent.com/u/997749?v=4","gravatar_id":"","url":"https://api.github.com/users/agraubert","html_url":"https://github.com/agraubert","followers_url":"https://api.github.com/users/agraubert/followers","following_url":"https://api.github.com/users/agraubert/following{/other_user}","gists_url":"https://api.github.com/users/agraubert/gists{/gist_id}","starred_url":"https://api.github.com/users/agraubert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agraubert/subscriptions","organizations_url":"https://api.github.com/users/agraubert/orgs","repos_url":"https://api.github.com/users/agraubert/repos","events_url":"https://api.github.com/users/agraubert/events{/privacy}","received_events_url":"https://api.github.com/users/agraubert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-03T21:59:26Z","updated_at":"2018-05-03T21:59:26Z","closed_at":null,"author_association":"NONE","body":"I'm running samtools bedcov to get readcounts over specific regions of interest in a bam. When I initially ran `samtools bedcov regions.bed reads.bam` it gave me a readout of coverage in the intervals, including `chr1\t12209228\t12209246\t.\t.\t+\t24`.\r\n\r\nBased on the bedcov documentation, I assume that means that the sum of coverage in that range is 24.  However, I decided to spot check that region with samtools depth: `samtools depth reads.bam -r chr1:12209228-12209246` which reports the following coverage:\r\n\r\n```\r\nchr1\t12209228\t3\r\nchr1\t12209229\t1\r\nchr1\t12209230\t1\r\nchr1\t12209231\t1\r\nchr1\t12209232\t1\r\nchr1\t12209233\t1\r\nchr1\t12209234\t1\r\nchr1\t12209235\t0\r\nchr1\t12209236\t0\r\nchr1\t12209237\t0\r\nchr1\t12209238\t0\r\nchr1\t12209239\t0\r\nchr1\t12209240\t0\r\nchr1\t12209241\t0\r\nchr1\t12209242\t0\r\nchr1\t12209243\t0\r\nchr1\t12209244\t0\r\nchr1\t12209245\t0\r\nchr1\t12209246\t0\r\n```\r\n\r\nI found it surprising that it sums to 9, instead of the expected 24. After inspecting in a genome browser, it appears that the reported count of 9 is correct. \r\n\r\nI did another experiment using bedcov on a singular interval: `chr1:12209233-12209234`, which, in theory, should report 1, as the last base of coverage from that read. However, unexpectedly, bedcov reports 2: `chr1\t12209233\t12209234\tfoo\t.\t+\t2`\r\n\r\nWhen increasing the range by one base, into an area with 0 coverage, the coverage increased further (instead of the expectation that it would remain constant):\r\n`chr1\t12209233\t12209235\tfoo\t.\t+\t3`\r\n\r\nThis unexpected result continues as the range is extended:\r\n```\r\nchr1\t12209233\t12209236\tfoo\t.\t+\t4\r\nchr1\t12209233\t12209237\tfoo\t.\t+\t5\r\nchr1\t12209233\t12209238\tfoo\t.\t+\t6\r\n```\r\n\r\nFor reference, the last trend of ranges were generated individually with the following command:\r\n`samtools bedcov <(echo $'chr1\\t<START POS>\\t<END POS>\\tfoo\\t.\\t+') reads.bam`\r\n\r\n---\r\n\r\nI am on macOS Sierra (10.12.6) using samtools 1.8 installed via homebrew\r\n\r\n```\r\nbash-3.2$ samtools --version\r\nsamtools 1.8\r\nUsing htslib 1.8\r\nCopyright (C) 2018 Genome Research Ltd.\r\n```"}}
{"actor":{"display_login":"agraubert"}}