Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# clip first diagonals and high values
clipval = np.nanmedian(np.diag(seq_hic_raw,2))
for i in [-1,0,1]: set_diag(seq_hic_raw,clipval,i)
seq_hic_raw = np.clip(seq_hic_raw, 0, seq_hic_raw)
seq_hic_raw[seq_hic_nan] = np.nan
# adaptively coarsegrain based on raw counts
seq_hic_smoothed = adaptive_coarsegrain(
seq_hic_raw,
genome_hic_cool.matrix(balance=False).fetch(mseq_str),
cutoff= 2, max_levels=8)
#todo: pass an option to add a certain pseudocount value, or the minimum nonzero value
if options.as_obsexp == True:
# interpolate single missing bins
seq_hic_interpolated = interpolate_bad_singletons(seq_hic_smoothed, mask=(~seq_hic_nan),
fillDiagonal=True, returnMask=False, secondPass=True,verbose=False)
seq_hic_nan = np.isnan(seq_hic_interpolated)
# compute observed/expected
seq_hic_obsexp = observed_over_expected(seq_hic_interpolated, ~seq_hic_nan)[0]
# todo: allow passing a global expected rather than computing locally
# log
seq_hic_obsexp = np.log(seq_hic_obsexp)
# set nan to 0
seq_hic_obsexp = np.nan_to_num(seq_hic_obsexp)
# todo: make obsexp_clip an option for obs/exp
seq_hic = np.clip(seq_hic_obsexp,-2,2)