Commit c22ad3fd authored by nfontrod's avatar nfontrod
Browse files

src/visu/figure_maker.py: add a warning message if some bed feature cannot be reported

parent 337afeeb
......@@ -15,6 +15,7 @@ import pyBigWig as pbw
import seaborn as sns
import matplotlib.pyplot as plt
from tqdm import tqdm
from loguru import logger
def load_bed(bed: Path, bed_name: str) -> List[List[Union[int, str]]]:
......@@ -111,6 +112,10 @@ def inspect_bigwig_regions(bw: Any, region: List,
3 2.00 3 cond1 R1 exon2
4 2.00 4 cond1 R1 exon2
"""
r_start = max(region[1], 0)
r_end = min(region[2], bw.chroms(region[0]))
if r_end - r_start < nb_bin:
return pd.DataFrame()
val = bw.stats(region[0],
max(region[1], 0),
min(region[2], bw.chroms(region[0])),
......@@ -173,6 +178,10 @@ def create_sample_table(bw_file: Path, regions: List[List],
for region in tqdm(regions, desc="scanning coverage ..."):
list_df.append(inspect_bigwig_regions(bw, region, replicate, nb_bin,
resize, condition_name))
r = sum([df.empty for df in list_df])
if r > 0:
logger.warning(f"They were {r} bed feature that could not be reported "
f"because of their small size")
return pd.concat(list_df, axis=0, ignore_index=True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment