Skip to content

Commit

Permalink
Merge pull request #33 from aertslab/dev
Browse files Browse the repository at this point in the history
 small bug fixes
  • Loading branch information
nkempynck authored Oct 2, 2024
2 parents 5d26e6b + 6e9e45b commit a08d805
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 28 deletions.
228 changes: 217 additions & 11 deletions docs/tutorials/model_training_and_eval.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/crested/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def import_bigwigs(
df = pd.DataFrame(
data_matrix,
columns=consensus_peaks["region"],
index=[os.path.basename(file).split(".")[0] for file in bw_files],
index=[os.path.basename(file).rpartition('.')[0].replace('.', '_') for file in bw_files],
)

# Create AnnData object
Expand Down
12 changes: 6 additions & 6 deletions src/crested/pl/patterns/_modisco_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ def create_clustermap(

data = pd.DataFrame(pattern_matrix)

if isinstance(color_palette, str):
palette = sns.color_palette(color_palette, len(set(classes)))
else:
palette = color_palette
#if isinstance(color_palette, str):
# palette = sns.color_palette(color_palette, len(set(classes)))
#else:
# palette = color_palette

class_lut = dict(zip(set(classes), palette))
row_colors = pd.Series(classes).map(class_lut)
#class_lut = dict(zip(set(classes), palette))
#row_colors = pd.Series(classes).map(class_lut)

if pat_seqs is not None:
plt.rc("text", usetex=False) # Turn off LaTeX to speed up rendering
Expand Down
16 changes: 7 additions & 9 deletions src/crested/tl/_modisco_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,19 +368,17 @@ def match_score_patterns(a: dict, b: dict) -> float:
-------
Match score between the patterns.
"""
#a_pos = a['pos_pattern']
#b_pos = b['pos_pattern']

#score = tangermeme_tomtom.tomtom(Qs = [_get_ic(a["contrib_scores"], a_pos).T], Ts = [_get_ic(b["contrib_scores"], b_pos).T])
_,_,ic_a = compute_ic(a['ppm'])
_,_,ic_b = compute_ic(b['ppm'])
#print(a['id'])
#vizsequence.plot_weights(ic_a)
#print(b['id'])
#vizsequence.plot_weights(ic_b)
score = tangermeme_tomtom.tomtom(Qs = [ic_a.T], Ts = [ic_b.T])
try:
score = tangermeme_tomtom.tomtom(Qs = [ic_a.T], Ts = [ic_b.T])[0,0][0]
except Exception as e:
print(f"Warning: TOMTOM error while comparing patterns {a['id']} and {b['id']}. Returning no match.")
print(f"Error details: {e}")
score = 1

log_score = -np.log10(max(score[0,0][0], 1e-12))
log_score = -np.log10(max(score, 1e-12))

return log_score

Expand Down
2 changes: 1 addition & 1 deletion src/crested/tl/_tfmodisco.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def match_to_patterns(

if verbose:
print(
f'Match between {pattern_id} and {all_patterns[str(match_idx)]["pattern"]["id"]} with similarity score {str(max_sim)}'
f'Match between {pattern_id} and {all_patterns[str(match_idx)]["pattern"]["id"]} with similarity score {max_sim:.2f}'
)

all_patterns[str(match_idx)]["instances"][pattern_id] = p
Expand Down

0 comments on commit a08d805

Please sign in to comment.