Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ import pyBigWig as pbw ...@@ -15,6 +15,7 @@ import pyBigWig as pbw
import seaborn as sns import seaborn as sns
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from tqdm import tqdm from tqdm import tqdm
from loguru import logger
def load_bed(bed: Path, bed_name: str) -> List[List[Union[int, str]]]: 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, ...@@ -111,6 +112,10 @@ def inspect_bigwig_regions(bw: Any, region: List,
3 2.00 3 cond1 R1 exon2 3 2.00 3 cond1 R1 exon2
4 2.00 4 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], val = bw.stats(region[0],
max(region[1], 0), max(region[1], 0),
min(region[2], bw.chroms(region[0])), min(region[2], bw.chroms(region[0])),
...@@ -173,6 +178,10 @@ def create_sample_table(bw_file: Path, regions: List[List], ...@@ -173,6 +178,10 @@ def create_sample_table(bw_file: Path, regions: List[List],
for region in tqdm(regions, desc="scanning coverage ..."): for region in tqdm(regions, desc="scanning coverage ..."):
list_df.append(inspect_bigwig_regions(bw, region, replicate, nb_bin, list_df.append(inspect_bigwig_regions(bw, region, replicate, nb_bin,
resize, condition_name)) 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) return pd.concat(list_df, axis=0, ignore_index=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment