Skip to content

Commit

Permalink
fix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
avantikalal committed Nov 9, 2024
1 parent 75b99b5 commit 0ceea11
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/grelu/interpret/modisco.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@ def _add_tomtom_to_modisco_report(

# Paths to outputs
html_file = os.path.join(modisco_dir, "motifs.html")
meme_logo_dir = os.path.join(modisco_dir, "trimmed_meme_logos")
if not os.path.exists(meme_logo_dir):
os.makedirs(meme_logo_dir)

# Loading html report
report = pd.read_html(html_file)[0]
cols = report.columns.tolist()
report["query"] = report.apply(
lambda row: row.pattern[:3] + "_" + row.pattern.split(".")[-1], axis=1
)
report["modisco_cwm_fwd"] = report.pattern.apply(lambda x: f"{x}.cwm.fwd.png")
report["modisco_cwm_rev"] = report.pattern.apply(lambda x: f"{x}.cwm.rev.png")
report["modisco_cwm_fwd"] = report.pattern.apply(
lambda x: os.path.join("trimmed_logos", f"{x}.cwm.fwd.png")
)
report["modisco_cwm_rev"] = report.pattern.apply(
lambda x: os.path.join("trimmed_logos", f"{x}.cwm.rev.png")
)

# Compiling top TOMTOM matches
tomtom_dict = dict()
Expand Down Expand Up @@ -65,8 +72,12 @@ def _add_tomtom_to_modisco_report(
if pd.isnull(row[name]):
logos.append("NA")
else:
make_logo(row[name], modisco_dir, motifs)
logos.append(f"{row[name]}.png")
make_logo(
row[name],
meme_logo_dir,
motifs,
)
logos.append(os.path.join("trimmed_meme_logos", f"{row[name]}.png"))
else:
break
report[f"{name}_logo"] = logos
Expand Down

0 comments on commit 0ceea11

Please sign in to comment.