Capricorn / data_processing /Read_external_norm.py
chnftq's picture
Upload folder using huggingface_hub
e3814d7 verified
Raw
History Blame Contribute Delete
724 Bytes
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# --------------------------------------------------------
# a script to help read norm file.
# --------------------------------------------------------
import numpy as np
def read_singlechromosome_norm(external_norm_file, n, cell_line, replace_nan = True):
CHR_norm_File = external_norm_file
CHR_norm_File = CHR_norm_File.replace('#(CHR)', 'chr'+str(n))
CHR_norm_File = CHR_norm_File.replace('#(CELLLINE)', cell_line)
raw = open(CHR_norm_File, 'r').readlines()
norm = np.array(list(map(float, raw)))
if replace_nan:
norm[np.isnan(norm)] = 1
return norm