Skip to content
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

Flekschas/bigwig multi value summary #99

Merged
merged 16 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clodius/tiles/bigwig.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def natcmp(x, y):
[int(a) if a.isdigit() else a for a in _NS_REGEX.split(y) if a]
)

# order of these parameters is purposefully reverse how they should be ordered
# order of these parameters is purposefully reverse how they should be
# ordered
for key in ['m', 'y', 'x']:
if key in y.lower():
return -1
Expand Down Expand Up @@ -230,7 +231,6 @@ def get_bigwig_tile(
aggregation_mode='mean',
range_mode=None
):

if chromsizes is None:
chromsizes = get_chromsizes(bwpath)

Expand Down
39 changes: 39 additions & 0 deletions test/tiles/bigwig_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,45 @@ def test_bigwig_tiles():
dtype=min_max_tile[0][1]['dtype']
)

mean_tile = hgbi.tiles(filename, ['x.0.0'])
mean_mean_tile = hgbi.tiles(filename, ['x.0.0.mean'])
min_tile = hgbi.tiles(filename, ['x.0.0.min'])
max_tile = hgbi.tiles(filename, ['x.0.0.max'])
std_tile = hgbi.tiles(filename, ['x.0.0.std'])

assert mean_tile[0][1]['max_value'] == mean_mean_tile[0][1]['max_value']
assert mean_tile[0][1]['max_value'] > min_tile[0][1]['max_value']
assert max_tile[0][1]['max_value'] > mean_tile[0][1]['max_value']
assert max_tile[0][1]['max_value'] > mean_tile[0][1]['max_value'] + std_tile[0][1]['max_value']

min_max_tile = hgbi.tiles(filename, ['x.0.0.minMax'])
whisker_tile = hgbi.tiles(filename, ['x.0.0.whisker'])

mean_val = np.frombuffer(
base64.b64decode(mean_tile[0][1]['dense']),
dtype=mean_tile[0][1]['dtype']
)

min_val = np.frombuffer(
base64.b64decode(min_tile[0][1]['dense']),
dtype=min_tile[0][1]['dtype']
)

max_val = np.frombuffer(
base64.b64decode(max_tile[0][1]['dense']),
dtype=max_tile[0][1]['dtype']
)

std_val = np.frombuffer(
base64.b64decode(std_tile[0][1]['dense']),
dtype=std_tile[0][1]['dtype']
)

min_max_val = np.frombuffer(
base64.b64decode(min_max_tile[0][1]['dense']),
dtype=min_max_tile[0][1]['dtype']
)

whisker_val = np.frombuffer(
base64.b64decode(whisker_tile[0][1]['dense']),
dtype=whisker_tile[0][1]['dtype']
Expand Down