Plotting functions#

omicspylib.plots.density.plot_density(dataset: ProteinsDataset, log_transform: bool = False, xlabel: str = 'Quantitative value', ylabel: str = 'Density', title: str = 'Distribution of values across experiments', hide_legend: bool = False, ax: Axes | None = None) Axes#

Generic function for creating a density plot over quantitative values of a dataset. It returns a matplotlib axes object that you can further customize. For more detailed customization, call the .to_table() method on the dataset object and create a plot based on your needs.

By default, 0s and nan values are removed.

Parameters:
  • dataset (ProteinsDataset) – A proteins dataset object.

  • log_transform (bool) – If specified, values will be transformed to log2.

  • xlabel (str) – X axis label.

  • ylabel (str) – Y axis label.

  • title (str) – Plot title.

  • hide_legend (bool) – If set to True, legend will be removed.

  • ax (plt.Axes | None) – You can provide a plt.Axes object to create a plot on that. Otherwise, a new object will be created and returned.

Returns:

A matplotlib axes object.

Return type:

plt.Axes

omicspylib.plots.missing_values.plot_missing_values(dataset: ProteinsDataset, xlabel: str = 'Experiment', ylabel: str = 'Number of missing values', title: str = 'Missing values over experiments', min_threshold: float = 0, ax: Axes | None = None) Axes#

Plot the number of missing values per experiment of the dataset.

Parameters:
  • dataset (ProteinsDataset) – Dataset under discussion.

  • xlabel (str, optional) – X-axis label.

  • ylabel (str, optional) – Y-axis label.

  • title (str, optional) – Title of the plot.

  • min_threshold (float, optional) – Values below that threshold will be considered as missing values.

  • ax (plt.Axes, optional) – If an existing axes object is provided, the plot will be drawn on it.

Returns:

ax – A matplotlib axes object containing the plot.

Return type:

plt.Axes

omicspylib.plots.venn.plot_venn2(data: DataFrame, condition_a: str, condition_b: str, color_a: str = 'blue', color_b: str = 'red', title: str = 'Venn Diagram', ax: Axes | None = None) Axes#

Venn diagram between two groups.

Parameters:
  • data

  • condition_a

  • condition_b

  • color_a

  • color_b

  • title

  • ax

Returns:

Matplotlib’s Axes object.

Return type:

plt.Axes

omicspylib.plots.volcano.plot_volcano(data: DataFrame, pval_col: str, fc_col: str, condition_a: str, condition_b: str, color_a: str = 'blue', color_b: str = 'red', pval_threshold: float = 0.05, fold_change_threshold: float = 2.0, xmax: float | None = None, ymax: float | None = None, xlabel: str | None = None, ylabel: str = 't-test P-value (-log10)', title: str | None = None, ax: Axes | None = None) Axes#

Create a volcano plot, by plotting on the x-axis the fold change (in log2 scale) and on the y-axis the p-value (-log10 transformed).

A Pandas data frame needs to be provided to the function, along with the basic values for p-value and fold change. Transformed values will be calculated internally.

Parameters:
  • data (pd.DataFrame) – A Pandas data frame containing the data to be plotted.

  • pval_col (str) – Column name containing the p-values to be plotted. They will be transformed internally with -log10.

  • fc_col (str) – Column name containing the fold change of condition a over b. It will be transformed internally with log2.

  • condition_a (str) – Name of “condition a” to be included in the legend and title.

  • condition_b (str) – Name of “condition b” to be included in the legend and title.

  • color_a (str) – Color for “condition a”.

  • color_b (str) – Color for “condition b”.

  • pval_threshold (float) – Threshold value for considering significant difference. By default, the values below or equal to 0.05 are considered significant.

  • fold_change_threshold (float) – Threshold value for considering significant difference in fold change. By default, 2x fold difference (from any side) is considered significant.

  • xmax (float or None) – If xmax is provided, it will be used to set x limits in the range of (-xmax, xmax). Otherwise, it will be calculated based on the provided data. It corresponds to transformed fold change value.

  • ymax (float or None) – If ymax is provided, it will be used to set the y limit. Otherwise, it will be calculated based on the provided data. Note that it corresponds to transformed p-values.

  • xlabel (str) – If provided will replace the default x-label.

  • ylabel (str) – If provided will replace the default y-label.

  • title (str) – If provided will replace the default title.

  • ax (plt.Axes or None) – If a matplotlib axes object is provided, the plot will be drawn on it. Otherwise, a new plt.Axes object is created and returned to the user.

Returns:

The plt.Axes object where the plot is drawn.

Return type:

plt.Axes