Skip to content

Custom breakpoints and colors not used #57

@koisland

Description

@koisland

Hi Alex,

Thanks for building a great tool!

I ran into an issue running ModDotPlot v0.9.9 in static mode and setting custom breakpoints/colors. It looks like ModDotPlot is not using them.

To reproduce with Python 3.12.0 with conda:

# Clone latest commit
git clone git@github.com:marbl/ModDotPlot.git
cd ModDotPlot
git checkout a2268ee0a92f4bc2a06851ccb817bb170a7af7d9

# Make a conda environment and install
conda create --name mdp python==3.12.0
conda activate mdp
python -m pip install .

# Test HG002chr13 MATERNAL case (default)
moddotplot static \
	-f sequences/hg002_chr13_MATERNAL:1-4000000.fa \
	-o chr13_MATERNAL_default

# With breakpoints
moddotplot static \
	-f sequences/hg002_chr13_MATERNAL:1-4000000.fa \
	-o chr13_MATERNAL_breakpoints \
	--colors "#4b3991" "#2974af" "#4a9da8" "#57b894" "#9dd893" "#e1f686" "#fdda79" "#fb9e4f" "#ee5634" "#c9273e" "#8a0033" \
	--breakpoints 86 90 97.5 97.75 98.0 98.25 98.5 98.75 99.0 99.25 99.5 100.0
Default With breakpoints Expected

This seems to be due to unset variables in a few locations.

The fix for both cases is simple and produces the expected output.

@@ -431,7 +431,7 @@ def get_colors(sdf, ncolors, is_freq, custom_breakpoints):
     else:
         breaks = [bot + i * interval for i in range(ncolors + 1)]
     if custom_breakpoints:
-        np.asarray(custom_breakpoints, dtype=np.float64)
+        breaks = np.asarray(custom_breakpoints, dtype=np.float64)
     labels = np.arange(len(breaks) - 1)
     # corner case of only one %id value
     if len(breaks) == 1:
@@ -601,7 +601,7 @@ def make_dot(
     if not breaks:
         breaks = generate_breaks(int(min_val), int(max_val))
     else:
-        [int(x) for x in breaks]
+        breaks = [int(x) for x in breaks]
     xlim = xlim or 0
     # Compute window size (handling exceptions)
     try:

I can open a PR with these changes if that works for you.

On a separate note, is there a reason only 12 colors can be set?

assert ncolors > 2 and ncolors < 12

Thanks!
Keith

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions