Closed sea-shunned closed 2 years ago
Works perfectly when trying to plot 6 subtypes, but won't work for plotting 4 or 5 subtypes. When trying to plot 5 subtypes, the first three are correctly plotted, but then it exits with an error:
IndexError: index 5 is out of bounds for axis 0 with size 5
.
For reference: plot_subtype_order = [1,2,0,5,4,3]; samples_sequence = 5; N_S_max = 6
;
Thanks @Zeena-Shawa
Seems that this occurs when you are create a model (e.g. MixtureSustain
instance), but then try to plot a PVD for a different number of subtypes than N_S_max
with variables (samples_sequence
etc.) loaded in from pickle files.
Possible solutions are:
self._plot_subtype_order
if there is a shape mismatch with samples_sequence
. You can either use an arbitrary subtype order in that case, or reconstruct using the original approach (np.argsort(ml_f_EM)[::-1]
), thus needing to add that as an extra argument.@staticmethod
, so that self isn't needed at all. This would break backwards compatability, but massively increase the flexibility of the plotting function, by no longer requiring an instance (and thus all that is needed is to load pickle files, rather than recreate the instance, which is useful when the compute has been off-loaded to HPC). I prefer this, but it will require people to slightly edit old code.subtype_order
argument is used manually. Least preferred option, as this is not the path of least resistance for the user.Thoughts welcome!
I vote for number 2 — I have no problem with breaking backward compatibility, given that we have no specific releases (and aren't in a release cycle, for example).
Great, that's 2 people, and by the power of democracy that'll do.
Went with option no. 4: public-facing generic function (*.plot_positional_var
) that can be used with pickle_files, that is also used by the original self._plot_sustain_model
to maintain backward compatibility...so best of both worlds (in theory!).
Tested Mixture
& Zscore
versions with the simrun.py
, but not Ordinal
and ZScoreMissing
yet.
The title_font_size, stage_font_size parameters are working when passed in ._plot_sustain_model, but figsize doesnt work. None of these are recognized in combine_cross_validated_sequences though. Maybe you can help clarify a install question. Where do you run the git switch plotting command. I've done in in the sustain env, and within your downloaded folder (pySuStaIn-plotting). As I kept getting git switch is not a command* error, I just ran the pip install . from pySuStaIn-plotting
Made these changes in the scripts...still doesn't recognise figsize parameter
Thanks for testing @Seymour22. Replies below:
figsize
: It works for me (both zscore
and mixture
versions), can you provide more detail?combine_cross_validated_sequences
: Passing arguments here also works for me.git switch
: It's an alternative to git checkout
that requires git v2.23+. git checkout plotting
will do the same thing (see here for more info).Worked great with ordinal sustain, tried out the different arguments and all working well 💯 Thanks Cameron!
Great to hear @Bea-Taylor, and thank you for testing it out!
Edit: I'll add a docstring to plot_positional_var
to explain its usage, though long-term we need to modify the existing notebooks and simulation scripts to use these new functions, demonstrating how they are used (the two main scenarios interfacing with plot_positional_var
and run_sustain_algorithm
.
Hey Cameron this is really useful addition! Was wondering whether it would be useful to have ability to plot each subtype PVD as a separate figure e.g. 3 subtypes currently plotted all together on one plot - have a argument in the plotting function that allows you to output each plot as a separate figure i.e. 3 separate figures for a 3 subtype model
..Also do you think you might be able to add a plotting funciton that allows you to plot number but stage - potentially have an argument that allows you to select subtype 1 by stage etc then an option that plots all subtypes by stage on one plot with each subtype colour coded?
Hey Cameron this is really useful addition! Was wondering whether it would be useful to have ability to plot each subtype PVD as a separate figure e.g. 3 subtypes currently plotted all together on one plot - have a argument in the plotting function that allows you to output each plot as a separate figure i.e. 3 separate figures for a 3 subtype model
and also to be able to save figure for each at time of running to folder!
Hey Cameron this is really useful addition! Was wondering whether it would be useful to have ability to plot each subtype PVD as a separate figure e.g. 3 subtypes currently plotted all together on one plot - have a argument in the plotting function that allows you to output each plot as a separate figure i.e. 3 separate figures for a 3 subtype model
Sure, sounds good! I'll add a separate_subtypes
flag for this, in which case a list of figures and axes objects will be returned.
and also to be able to save figure for each at time of running to folder!
Great point, plot_positional_var
as a standalone function should have some save functionality, which will save the whole figure or individual ones depending on the new option above. I'll add options for save location, save name, and extra kwargs for fig.savefig
.
Thanks @williamscotton for taking a look and your suggestions!
After a few requests for tweaking parts of plots, made a few changes to update the PVD plotting code. Changes summarized below:
*._plot_sustain_model
):title_font_size
,stage_font_size
,label_font_size
,stage_rot
,label_rot
)stage_interval
) for when there are many eventsfigsize
)biomarker_colours
). Colours must passmatplotlib.colors.is_color_like
, i.e. be a name or RGB(A).dict
maps label:colour. Any labels not given are defaulted to black.list
/tuple
presumes default order of labels, and must all be given.plot_format
option added torun_sustain_algorithm
andcombine_cross_validated_sequences
to specify saving format_plot_sustain_model
MixtureSustain
ZscoreSustain
biomarker_order
ZscoreMissingSustain
ZscoreSustain
version