corradjust.plots module#
- class corradjust.plots.PCAVariancePlotter(plot_width=6.4, plot_height=4.8)[source]#
Bases:
object
Create PCA explained variance plot.
- Parameters:
- plot_widthfloat, optional, default=6.4
Plot width.
- plot_heightfloat, optional, default=4.8
Plot height.
- Attributes:
- figmatplotlib.figure.Figure
- axsdict
Keys of axs are strings
"individual"
and"cumulative"
referring to the two panels of the plot. Values of axs are instances of matplotlib.axes.Axes.
- plot(PCA_model, n_PCs)[source]#
Draw the plots.
- Parameters:
- PCA_modelsklearn.decomposition.PCA
PCA model. The fit method should be called on PCA_model prior to calling this method.
- n_PCsint
Number of PCs to plot on the X-axis.
- save_plot(out_path, title=None)[source]#
Save the plot. This method doesn’t call plt.close, so it will display the figure in jupyter notebook in addition to saving the file.
- Parameters:
- out_pathstr
Path to the figure (with extension, e.g.,
".png"
).- titlestr or None, optional, default=None
Short text to show at the top-left corner of the plot.
- class corradjust.plots.GreedyOptimizationPlotter(samp_group_name=None, metric='enrichment-based', palette=[(0.09019607843137255, 0.7450980392156863, 0.8117647058823529), (0.7372549019607844, 0.7411764705882353, 0.13333333333333333), (0.8901960784313725, 0.4666666666666667, 0.7607843137254902), (0.5490196078431373, 0.33725490196078434, 0.29411764705882354), (0.5803921568627451, 0.403921568627451, 0.7411764705882353), (0.8392156862745098, 0.15294117647058825, 0.1568627450980392), (0.17254901960784313, 0.6274509803921569, 0.17254901960784313), (1.0, 0.4980392156862745, 0.054901960784313725), (0.12156862745098039, 0.4666666666666667, 0.7058823529411765)], legend_loc='lower right', legend_fontsize=10, plot_width=6.4, plot_height=4.8)[source]#
Bases:
object
Create a lineplot with score optimization trajectories.
- Parameters:
- samp_group_namestr or None, optional, default=None
Main title with sample group name to use in the plot.
- metric{“enrichment-based”, “BP@K”}, optional, default=”enrichment-based”
Metric for evaluating feature correlations.
- palettestr or list or dict, optional
Name of matplotlib colormap or list of colors for the lines or dict mapping reference collection names to colors. The argument is directly passed to sns.lineplot.
- legend_locstr, optional, default=”lower right”
Where to put the legend (follows matplotlib notation).
- legend_fontsizeint, optional, default=10
Font size of legend text.
- plot_widthfloat, optional, default=6.4
Plot width.
- plot_heightfloat, optional, default=4.8
Plot height.
- Attributes:
- figmatplotlib.figure.Figure
- axmatplotlib.axes.Axes
- plot(df, peak_iter)[source]#
Draw the lines.
- Parameters:
- dfpandas.DataFrame
Data frame with scores. One can generate df by taking
fit.tsv
table and selecting columns for only one sample group. See CorrAdjust._make_best_iter_scores_plot` method for an example.- peak_iterint
This number is used to draw vertical dashed red line at the selected early stopping iteration.
- save_plot(out_path, title=None)[source]#
Save the plot. This method doesn’t call plt.close, so it will display the figure in jupyter notebook in addition to saving the file.
- Parameters:
- out_pathstr
Path to the figure (with extension, e.g.,
.png
).- titlestr or None, optional, default=None
Short text to show at the top-left corner of the plot.
- class corradjust.plots.VolcanoPlotter(corr_scorer, annotate_features=False, annot_fontsize=8, feature_name_fmt=None, signif_color=(1.0, 0.4980392156862745, 0.054901960784313725, 0.9), nonsignif_color=(0.6, 0.6, 0.6, 0.5), panel_size=4.8)[source]#
Bases:
object
Create a volcano plot with feature-wise enrichment statistics.
- Parameters:
- corr_scorerCorrScorer
Instance of CorrScorer.
- annotate_featuresint or None, optional, default=None
How many features with the lowest adjusted p-value to annotate.
- annot_fontsizeint, optional, default=8
Font size of feature names when
annotate_features=True
.- feature_name_fmtfunction or None, optional, default=None
Function that maps feature names to labels to show on the plot when
annotate_features=True
. IfNone
, shows unmodified feature names.- signif_colormatplotlib color, optional
Color to draw statistically significant features.
- nonsignif_colormatplotlib color, optional
Color to draw non-significant features.
- panel_sizefloat, optional, default=4.8
Size of each (square) panel.
- Attributes:
- figmatplotlib.figure.Figure
- axsdict
Keys of axs are tuples
(ref_feature_coll, state)
, wherestate
is either"Raw"
or"Clean"
. Values of axs are instances of matplotlib.axes.Axes.
- plot(feature_scores)[source]#
Create a volcano plot.
- Parameters:
- feature_scoresdict
Dict with feature-wise enrichment scores generated by the CorrAdjust.compute_feature_scores method.
- _plot_one_state(state, feature_scores_state, num_pairs_max)[source]#
Make the plot for
"Raw"
or"Clean"
data.- Parameters:
- state{“Raw”, “Clean”}
- feature_scores_state{feature_scores[“Raw”], feature_scores[“Clean”]}
- num_pairs_maxint
Maximum number for
K_j
to scale the markers and display in legend.
- save_plot(out_path, title=None)[source]#
Save the plot. This method doesn’t call plt.close, so it will display the figure in jupyter notebook in addition to saving the file.
- Parameters:
- out_pathstr
Path to the figure (with extension, e.g.,
.png
).- titlestr or None, optional, default=None
Short text to show at the top-left corner of the plot.
- class corradjust.plots.CorrDistrPlotter(corr_scorer, pairs_subset='all', color_raw_ref=(0.8392156862745098, 0.15294117647058825, 0.1568627450980392), color_raw_non_ref=(1.0, 0.596078431372549, 0.5882352941176471), color_clean_ref=(0.17254901960784313, 0.6274509803921569, 0.17254901960784313), color_clean_non_ref=(0.596078431372549, 0.8745098039215686, 0.5411764705882353), legend_fontsize=10, panel_size=4.8)[source]#
Bases:
object
Create KDE and CDF plots of correlations.
- Parameters:
- corr_scorerCorrScorer
Instance of CorrScorer.
- pairs_subset{“all”, “training”, “validation”}, optional, default=”all”
Which set of feature pairs to use for computing scores.
- color_raw_refcolor, optional, default=sns.color_palette(“tab20”)[0]
Color for raw correlations, reference feature pairs.
- color_raw_non_refcolor, optional, default=sns.color_palette(“tab20”)[1],
Color for raw correlations, non-reference feature pairs.
- color_clean_refcolor, optional, default=sns.color_palette(“tab20”)[2],
Color for clean correlations, reference feature pairs.
- color_clean_non_refcolor, optional, default=sns.color_palette(“tab20”)[3],
Color for clean correlations, non-reference feature pairs.
- legend_fontsizeint, optional, default=10
Font size of legend text.
- panel_sizefloat, optional, default=4.8
Size of each (square) panel.
- Attributes:
- figmatplotlib.figure.Figure
- axsdict
Keys of axs are tuples
(ref_feature_coll, plot_name)
, whereplot_name
is either"corr-KDE"
or"corr-CDF"
. Values of axs are instances of matplotlib.axes.Axes.
- add_plots(corr_scores, state, num_points=100000)[source]#
Make KDE and eCDF plots.
- Parameters:
- corr_scoresdict
Results of CorrAdjust.compute_corr_scores method.
- state{“Raw”, “Clean”}
- num_pointsint, optional, default=100000
How many correlations to sample for plotting.
- save_plot(out_path, title=None)[source]#
Save the plot. This method doesn’t call plt.close, so it will display the figure in jupyter notebook in addition to saving the file.
- Parameters:
- out_pathstr
Path to the figure (with extension, e.g.,
.png
).- titlestr or None, optional, default=None
Short text to show at the top-left corner of the plot.