diff --git a/src/hic_TAD_caller/create_TAD_HiC_files/calling_tads.py b/src/hic_TAD_caller/create_TAD_HiC_files/calling_tads.py index 7f1997388205ea04b399321990fede9e7fffcd40..1c7750ddc6ae8b40183b27393b730ae6a0ad300d 100644 --- a/src/hic_TAD_caller/create_TAD_HiC_files/calling_tads.py +++ b/src/hic_TAD_caller/create_TAD_HiC_files/calling_tads.py @@ -149,7 +149,7 @@ def check_n_save_bed(bed_file: Path, name_file: str, resolution: int) -> Path: df = data[["chr1", "x1", "x2"]].copy() new_name = name_file.replace("_grch38.hic", "") df.sort_values(["chr1", "x1"], ascending=True, inplace=True) - df["chr1"] = "chr" + df["chr1"] + df["chr1"] = "chr" + df["chr1"].astype(str) df["name"] = [f"{new_name}_{x + 1}" for x in range(df.shape[0])] df["score"] = ["."] * df.shape[0] df["strand"] = ["+"] * df.shape[0] @@ -157,17 +157,15 @@ def check_n_save_bed(bed_file: Path, name_file: str, resolution: int) -> Path: return outfile -def liftover(tad_file: Path, resolution: int) -> Path: +def liftover(tad_file: Path) -> Path: """ LiftOver tads. :param tad_file: A simplified TAD file produced from ArrowHead - :param resolution: The resolution of interest :return: The bed file containing TAD with hg19 coordinates """ ConfigHiC.lost_folder.mkdir(exist_ok=True, parents=True) - outfile = tad_file.parents[1] / \ - f"{resolution}_{tad_file.name.replace('grch38', 'hg19')}" + outfile = tad_file.parents[1] / tad_file.name.replace('grch38', 'hg19') if not outfile.is_file(): lost_file = ConfigHiC.lost_folder / outfile.name.replace(".bed", "_lost.bed") @@ -199,10 +197,10 @@ def process_hic_files(exp_table: pd.DataFrame, logging.info(" Reformating TADs") tad_file = check_n_save_bed(tad_file, hic_file.name, resolution) logging.info(" LiftOver TADs") - liftover_file = liftover(tad_file, resolution) + liftover_file = liftover(tad_file) logging.info(" Creating communities") final_file = liftover_file.parent / \ - f"communities_{resolution}_{liftover_file.name}" + f"communities_{liftover_file.name}" targeted_tad_to_communities(str(liftover_file), str(final_file), "gene")