Skip to content

tiny-plot: legend sorted by natural order, other reliability improvements#286

Merged
taimontgomery merged 7 commits intomasterfrom
issue-285
Mar 3, 2023
Merged

tiny-plot: legend sorted by natural order, other reliability improvements#286
taimontgomery merged 7 commits intomasterfrom
issue-285

Conversation

@AlexTate
Copy link
Member

@AlexTate AlexTate commented Mar 1, 2023

Scatter plot legends are now sorted by natural order while preserving the intended point layer order (groups with fewest points are plotted on top of the stack).

This PR also includes a number of reliability improvements:

  • Fixed an edge case that occurs when the outgroup has all zero counts in one or both conditions. Previously this would result in the outgroup having an entry in the legend without any points being plotted
  • Fixed an edge case that occurs when there is no outgroup, and the first group has all zero counts in one or both conditions. Previously this first plotted group wouldn't be recognized as a zero count group, so it would have an entry in the legend without any points being plotted
  • Properly handling an empty scatter plot when neither the outgroup nor the other groups can be plotted due to one or both conditions having all zero counts
  • Fixed calculation of z-order to avoid group-outgroup conflicts and group-line conflicts. Fortunately the way matplotlib breaks z-order ties always worked out in our favor so this issue was never expressed. Now it's proper.
  • Added helpful error messages so that scatter_dge plots aren't silently skipped if inputs are empty (due to class filters, etc.)

Additionally, the sorted_natural() function in tiny.rna.util now accepts a key= parameter just like Python's sorted() does

Closes #285

AlexTate added 5 commits March 1, 2023 12:49
- Fixes an edge case that occurs when the outgroup has all zero counts in one or both conditions. Previously this would result in the outgroup having an entry in the legend without any points being plotted
- Fixes an edge case that occurs when there is no outgroup, and the first group has all zero counts in one or both conditions. Previously this first plotted group wouldn't be handled as a zero count group, so it would have an entry in the legend without any points being plotted.
- Properly creates an empty scatter plot when neither the outgroup nor the other groups can be plotted due to one or both conditions having all zero counts.
 - Correct handling of empty plots, per recent changes to scatter_grouped()
 - Corrections to z-order calculation to prevent outgroup from sharing z-order with any other groups, and to prevent shared z-order between the lines and one of the groups. Fortunately the way mpl breaks z-order ties always worked out in our favor since the outgroup was plotted first
 - Doc string filled out
…ilently skipped if inputs are empty (due to class filters, etc.)
@AlexTate AlexTate requested a review from taimontgomery March 1, 2023 21:38
AlexTate added 2 commits March 2, 2023 16:44
For each worker exception:
- The tracebacks are printed to stdout so that they end up in the logfile

At the conclusion of plotting:
- The replot instructions are printed only once
- A summary of the exceptions organized by plot type is printed (no noisy tracebacks)
- The user-friendly message + summary is printed to stderr so that users see it during pipeline runs

Exception handling is also consistent regardless of sequential/multiprocessing or debug mode
@taimontgomery
Copy link
Collaborator

Tested successfully with ram1 data.

@taimontgomery taimontgomery merged commit da45437 into master Mar 3, 2023
@AlexTate
Copy link
Member Author

AlexTate commented Mar 3, 2023

Exception handling in tiny-plot was also improved so that it is more useful during non-standalone runs.

For each worker exception:

  • The tracebacks are printed to stdout so that they end up in the logfile produced by cwltool

At the conclusion of plotting:

  • The replot instructions are printed only once regardless of the number of workers that failed
  • A summary of the exceptions organized by plot type is printed (no noisy tracebacks)
  • The user-friendly message + summary is printed to stderr so that users see it during pipeline runs

Exception handling is also consistent regardless of sequential/multiprocessing or debug mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tiny-plot: changes to scatter plot legend sorting order

2 participants