Skip to content

Query regarding the behavior of bbi.fetch in situations where window_size < bin_size #27

Answered by nvictus
smitkadvani asked this question in Q&A
Discussion options

You must be logged in to vote

I think the behavior, while relaxed, is reasonable given the request. You are asking to divide the range [4500015, 4500016) into 40 evenly-spaced bins, so it interpolates appropriately. The UCSC code was designed for plotting in the genome browser, after all. For plotting with matplotlib this would look like:

chrom, start, end = "chr1", 4500015, 4500016
n_bins = 40
x = np.linspace(start, end, n_bins + 1)
y = f.fetch(chrom, start, end, bins=n_bins)

plt.stairs(values=y, edges=x)

Note that bins= does not indicate the size of the bins, but the number of bins to divide the interval into. In your example, the bin size ends up being 0.025bp.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by nvictus
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #26 on May 27, 2023 20:23.