Skip to content

Commit

Permalink
Merge pull request #99 from higlass/flekschas/bigwig-multi-value-summary
Browse files Browse the repository at this point in the history
Flekschas/bigwig multi value summary
  • Loading branch information
nvictus authored Sep 30, 2019
2 parents 9490f38 + 31c64ea commit 1672e8e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
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 @@ -50,6 +50,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

0 comments on commit 1672e8e

Please sign in to comment.