Skip to content

Apply same balance weights to different samples #368

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

You must be logged in to vote

There is no CLI tool for this yet, but it's a just a few lines of Python to copy bin table columns between files, assuming the bin tables are aligned.

import cooler

# optional
h5opts = dict(compression='gzip', compression_opts=6)

clr1 = cooler.Cooler(f'{path1}::resolutions/{binsize}')
weights = clr1.bins()['weight'][:].values

clr2 = cooler.Cooler(f'{path2}::resolutions/{binsize}')
with clr2.open('r+') as f:
    # Create a weight column
    f['bins'].create_dataset('weight', data=weights, **h5opts)
    
    # .. or overwrite an existing weight column
    f['bins/weight'][:] = weights

Replies: 1 comment

Comment options

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

This discussion was converted from issue #240 on January 24, 2024 16:36.