From 9dd148900fffe493eea3f50d88b04a3514053653 Mon Sep 17 00:00:00 2001 From: Anusri Date: Sun, 12 Nov 2023 14:08:00 +0000 Subject: [PATCH] fixed issue 150, regions used is None --- chrombpnet/evaluation/make_bigwigs/bigwig_helper.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/chrombpnet/evaluation/make_bigwigs/bigwig_helper.py b/chrombpnet/evaluation/make_bigwigs/bigwig_helper.py index 21f42058..faf99603 100644 --- a/chrombpnet/evaluation/make_bigwigs/bigwig_helper.py +++ b/chrombpnet/evaluation/make_bigwigs/bigwig_helper.py @@ -1,6 +1,7 @@ import pyBigWig import numpy as np from chrombpnet.training.utils.data_utils import one_hot +import pandas as pd def read_chrom_sizes(fname): with open(fname) as f: @@ -26,16 +27,18 @@ def get_seq(peaks_df, genome, width): return one_hot.dna_to_one_hot(vals), np.array(peaks_used) -def get_regions(regions_file, seqlen, regions_used): +def get_regions(regions_file, seqlen, regions_used=None): # regions file is assumed to be centered at summit (2nd + 10th column) # it is adjusted to be of length seqlen centered at summit assert(seqlen%2==0) - with open(regions_file) as r: - regions = [x.strip().split('\t') for x in r] + #with open(regions_file) as r: + # regions = [x.strip().split('\t') for x in r] - regions = [[x[0], int(x[1])+int(x[9])-seqlen//2, int(x[1])+int(x[9])+seqlen//2, int(x[1])+int(x[9])] for x in np.array(regions)[regions_used]] + regions = pd.read_csv(regions_file,sep='\t',header=None) + #print(regions) + regions = [[x[0], int(x[1])+int(x[9])-seqlen//2, int(x[1])+int(x[9])+seqlen//2, int(x[1])+int(x[9])] for x in np.array(regions.values)[regions_used]] return regions