From d99ea892fea85b6dd0482c6ec97c61475b06b206 Mon Sep 17 00:00:00 2001 From: alexsweeten Date: Thu, 13 Jun 2024 11:27:10 -0400 Subject: [PATCH 1/2] Bugfix for comparative mode of different sizes --- src/moddotplot/moddotplot.py | 26 +++++++++++++++++++------- src/moddotplot/static_plots.py | 3 --- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/moddotplot/moddotplot.py b/src/moddotplot/moddotplot.py index 91a9d11..dfeb282 100644 --- a/src/moddotplot/moddotplot.py +++ b/src/moddotplot/moddotplot.py @@ -528,7 +528,9 @@ def main(): # Throw error if compare only selected with one sequence. if len(k_list) < 2 and args.compare_only: - print(f"Error: Can't create a comparative plot with only one sequence") + print( + f"Error: Can't create a comparative plot with only one sequence. Please re-run without --compare-only." + ) sys.exit(2) # -----------LAUNCH INTERACTIVE MODE----------- @@ -910,7 +912,7 @@ def main(): axes_labels=args.axes_ticks, ) - # -----------COMPUTE COMAPRATIVE PLOTS----------- + # -----------COMPUTE COMPARATIVE PLOTS----------- # TODO: Optimize computations so that largest sequence doesn't need to be redone all the time if (args.compare or args.compare_only) and len(sequences) > 1: # Set window size to args.window. Otherwise, set it to n/resolution @@ -937,16 +939,26 @@ def main(): smaller_seq = sequences[j][1] larger_length = len(larger_seq) smaller_length = len(smaller_seq) + larger_seq_name = sequences[i][0] + smaller_seq_name = sequences[j][0] + # Houston we have a problem + if larger_length < smaller_length: + smaller_seq = sequences[i][1] + larger_seq = sequences[j][1] + larger_length = len(larger_seq) + smaller_length = len(smaller_seq) + larger_seq_name = sequences[j][0] + smaller_seq_name = sequences[i][0] print( - f"Computing pairwise identity matrix for {sequences[i][0]} and {sequences[j][0]}... \n" + f"Computing pairwise identity matrix for {larger_seq_name} and {smaller_seq_name}... \n" ) # TODO: Logging here # print(f"\tSparsity value s: {seq_sparsity}\n") print( - f"\tSequence length {sequences[i][0]}: {larger_length + args.kmer - 1}\n" + f"\tSequence length {larger_seq_name}: {larger_length + args.kmer - 1}\n" ) print( - f"\tSequence length {sequences[j][0]}: {smaller_length + args.kmer - 1}\n" + f"\tSequence length {smaller_seq_name}: {smaller_length + args.kmer - 1}\n" ) print(f"\tWindow size w: {win}\n") print(f"\tModimizer sketch size: {expectation}\n") @@ -955,8 +967,8 @@ def main(): pair_mat = createPairwiseMatrix( larger_length, smaller_length, - sequences[i][1], - sequences[j][1], + larger_seq, + smaller_seq, win, seq_sparsity, args.delta, diff --git a/src/moddotplot/static_plots.py b/src/moddotplot/static_plots.py index 55ab85a..b71018d 100644 --- a/src/moddotplot/static_plots.py +++ b/src/moddotplot/static_plots.py @@ -175,8 +175,6 @@ def make_dot(sdf, title_name, palette, palette_orientation, colors, breaks, xlim breaks = [float(number) for number in breaks] if not xlim: xlim = 0 - else: - breaks = [float(number) for number in breaks] hexcodes = [] new_hexcodes = [] if palette in DIVERGING_PALETTES: @@ -403,7 +401,6 @@ def create_plots( sdf, palette, palette_orientation, custom_colors, custom_breakpoints ) - print(xlim) if is_pairwise: heatmap = make_dot( sdf, From 069cc23f73178185f20f7da3b7854898be8db408 Mon Sep 17 00:00:00 2001 From: alexsweeten Date: Thu, 13 Jun 2024 11:28:27 -0400 Subject: [PATCH 2/2] Bump version, remove numpy restriction --- pyproject.toml | 4 ++-- src/moddotplot/const.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 193bc8b..91a59cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ModDotPlot" -version = "0.8.3" +version = "0.8.4" requires-python = ">= 3.7" dependencies = [ "pysam", @@ -16,7 +16,7 @@ dependencies = [ "mmh3", "tk", "setproctitle", - "numpy==1.26.4" + "numpy" ] authors = [ {name = "Alex Sweeten", email = "alex.sweeten@nih.gov"}, diff --git a/src/moddotplot/const.py b/src/moddotplot/const.py index d918332..f283d4a 100644 --- a/src/moddotplot/const.py +++ b/src/moddotplot/const.py @@ -1,4 +1,4 @@ -VERSION = "0.8.3" +VERSION = "0.8.4" COLS = [ "#query_name", "query_start",