plotting_lib package
Submodules
plotting_lib.plotting_functions module
- lbfextract.plotting_lib.plotting_functions.correlation_map_plot(df: DataFrame) Figure[source]
This function creates a plot of the correlation matrix between the provided signals.
- Params df:
pandas DataFrame containing the signal per BED file to be plotted
- Returns:
A matplotlib.Figure object containing the plot
- lbfextract.plotting_lib.plotting_functions.create_heatmap_bed_per_position(df, fig: Figure = None, ax: Axes = None, title: str = '', ylabel: str = None, general_font_size: int = 15, title_font_size: int = 20, annotation_center_line: str = None, label_color_bar: str = '') tuple[Figure, Axes][source]
Creates a heatmap of the given DataFrame containing the signals for each BED file with optional annotations and customizations.
- Parameters:
df – The DataFrame to plot as a heatmap.
fig – The figure object to use for plotting. If not provided, a new figure will be created.
ax – The axes object to use for plotting. If not provided, new axes will be created.
title – The title for the plot. Default is an empty string.
ylabel – The label for the y-axis. Default is None.
general_font_size – The font size for the axis labels. Default is 15.
title_font_size – The font size for the title. Default is 20.
annotation_center_line – The label for the vertical center line annotation. Default is None.
label_color_bar – The label for the color bar. Default is an empty string.
- Returns:
A tuple containing the figure and axes objects (fig, ax).
- lbfextract.plotting_lib.plotting_functions.create_masked_corr_matrix_plot(df: DataFrame, fig: Figure = None, ax: Axes = None, title: str = None, title_font_size: int = 20, general_font_size: int = 15, axlabel: str = None, label_color_bar: str = '') tuple[Figure, Axes][source]
Creates a masked correlation matrix plot.
- Parameters:
df – The DataFrame to compute and plot the correlation matrix from.
fig – The figure object to use for plotting. If not provided, a new figure will be created.
ax – The axes object to use for plotting. If not provided, new axes will be created.
title – The title for the plot. If not provided, no title will be set.
title_font_size – The font size for the title. Default is 20.
general_font_size – The font size for the axis labels. Default is 15.
axlabel – The label for the x and y axes. Default is None.
label_color_bar – The label for the color bar. Default is an empty string.
- Returns:
A tuple containing the figure and axes objects (fig, ax).
- lbfextract.plotting_lib.plotting_functions.plot_fragment_length_distribution(array: array, start_pos: int, end_pos: int, title: str = 'FLD per position') Figure[source]
Plots the fragment length distribution per position.
- Parameters:
array – The array containing the fragment length data.
start_pos – The starting position for the distribution plot.
end_pos – The ending position for the distribution plot.
title – The title for the plot. Default is “FLD per position”.
- Returns:
The figure object containing the plots.
- lbfextract.plotting_lib.plotting_functions.plot_heatmap_diff_active_gi(data, clusters: dict, split_key, save: bool, adjusted_pval: dict[Series], log2_fc: dict[Series], figsize=(10, 10), filename: str = 'heatmap_diff_active_signals.pdf', output_path: Path = None, col_cluster=True, row_cluster=True, col_split_gap=0.8, row_split_gap=0.8, label='values', row_dendrogram=True, show_rownames=True, show_colnames=True, subplot_gap=5, legend_vpad=15, tree_kws=None, verbose=0, legend_gap=5, legend_hpad=5, cmap='RdYlBu_r', xticklabels_kws={'labelcolor': 'black', 'labelrotation': -90}, **kwargs)[source]
- lbfextract.plotting_lib.plotting_functions.plot_heatmap_kde_amplitude(array=None, fig=None, ax=None, title=None, title_font_size=20, general_font_size=15, tf_to_annotate=('CTCF',), ylabel=None, flanking=1500, annotation_center_line='center', window_center=50, top=5, bottom=5) tuple[Figure, Axes][source]
Plots various analyses of the given array, including a PCA plot, signal plot, signal per position plot, and correlation plot.
- Parameters:
array – The 2D array to plot and analyze.
fig – The figure object to use for plotting. If not provided, a new figure will be created.
ax – The axes object to use for plotting. If not provided, new axes will be created.
title – The title for the plots. If not provided, no title will be set.
title_font_size – The font size for the title. Default is 20.
general_font_size – The font size for the axis labels. Default is 15.
tf_to_annotate – Transcription factors to annotate on the PCA plot. Default is (“CTCF”,).
ylabel – The label for the y-axis of the correlation plot.
flanking – The number of flanking base pairs to consider in the analysis. Default is 1500.
annotation_center_line – The center line annotation for the heatmap. Default is “center”.
window_center – The number of base pairs to consider around the center for amplitude calculation. Default is 50.
top – The number of top rows to consider for analysis. Default is 5.
bottom – The number of bottom rows to consider for analysis. Default is 5.
- Returns:
A tuple containing the figure and axes objects (fig, ax).
- lbfextract.plotting_lib.plotting_functions.plot_heatmap_signal_batch(fig=None, ax=None, array=None, title=None, title_font_size=20, general_font_size=15) tuple[Figure, Axes][source]
Plots a heatmap of the given array using seaborn’s heatmap function.
- Parameters:
fig – The figure object to use for plotting. If not provided, a new figure will be created.
ax – The axes object to use for plotting. If not provided, new axes will be created.
array – The 2D array to plot as a heatmap.
title – The title for the heatmap. If not provided, no title will be set.
title_font_size – The font size for the title. Default is 20.
general_font_size – The font size for the axis labels. Default is 15.
- Returns:
A tuple containing the figure and axes objects (fig, ax).
- lbfextract.plotting_lib.plotting_functions.plot_signal(summary: array, apply_savgol: bool = True, savgol_window_length: int = 33, savgol_polyorder: int = 3, ax: Axes = None, fig: Figure = None, color: int | str = None, label: str = None, label_center_line: str = None, title: str = None, title_font_size: int = 20, general_font_size: int = 15, plot_center_line_label: bool = True, line_type: str = '-') tuple[Figure, Axes][source]
Plot a signal with optional Savitzky-Golay smoothing.
This function plots the given signal, optionally applying a Savitzky-Golay filter to smooth the data. Various customization options for the plot are available, including axis, figure, color, labels, and title settings.
- Parameters:
summary – A numpy array containing the signal data to be plotted.
apply_savgol – A boolean flag indicating whether to apply Savitzky-Golay smoothing to the signal. Default is True.
savgol_window_length – The length of the window used for Savitzky-Golay smoothing. Must be an odd integer. Default is 33.
savgol_polyorder – The order of the polynomial used for Savitzky-Golay smoothing. Default is 3.
ax – A matplotlib Axes object to plot on. If None, a new axis will be created.
fig – A matplotlib Figure object to plot on. If None, a new figure will be created.
color – The color of the plot line. Can be a string (e.g., ‘r’ or ‘blue’) or an integer. If None, the default color will be used.
label – A label for the plot line. This will be used in the legend if provided.
label_center_line – A label for the center line, if it is plotted.
title – The title of the plot. If None, no title will be displayed.
title_font_size – The font size of the title. Default is 20.
general_font_size – The general font size for the plot text. Default is 15.
plot_center_line_label – A boolean flag indicating whether to plot the center line label. Default is True.
line_type – The type of line to plot (e.g., ‘-’, ‘–’, ‘-.’, ‘:’). Default is ‘-‘.
- Returns:
A tuple containing the matplotlib Figure and Axes objects used for the plot.
- lbfextract.plotting_lib.plotting_functions.plot_signal_batch(df: DataFrame, apply_savgol: bool = False, savgol_window_length: int = 11, savgol_polyorder: int = 3, signal: str = 'coverage', title: str = 'coverage at TFBS', figsize: tuple[int, int] = (20, 10), ax: Axes = None, fig: Figure = None, color: str = None, label: str = None, alpha: float = 1, linewidth: int = 1, flanking: int = 1500, xlabel: str = None, top: int = 5, bottom: int = 5, window_center: int = 50, mask_rows: list[bool] = None, max_signals: int = 10, sort_values: bool = True) tuple[Figure, Axes][source]
Plots the signal for the top and bottom BED files based on their peak or deep in the central part of the signal one next to the others optionally using Savitzky-Golay filter and various customization options.
- Parameters:
df – The DataFrame containing the signal data to plot.
apply_savgol – Whether to apply the Savitzky-Golay filter to smooth the signal. Default is False.
savgol_window_length – The window length parameter for the Savitzky-Golay filter. Default is 11.
savgol_polyorder – The polynomial order parameter for the Savitzky-Golay filter. Default is 3.
signal – The signal label for the y-axis. Default is “coverage”.
title – The title for the plot. Default is “coverage at TFBS”.
figsize – The size of the figure. Default is (20, 10).
ax – The axes object to use for plotting. If not provided, new axes will be created.
fig – The figure object to use for plotting. If not provided, a new figure will be created.
color – The color of the plot line. Default is None.
label – The label for the plot line. Default is None.
alpha – The transparency level of the plot line. Default is 1.
linewidth – The width of the plot line. Default is 1.
flanking – The number of flanking base pairs to consider in the analysis. Default is 1500.
xlabel – The label for the x-axis. Default is None.
top – The number of top rows to consider for analysis. Default is 5.
bottom – The number of bottom rows to consider for analysis. Default is 5.
window_center – The number of base pairs to consider around the center for amplitude calculation. Default is 50.
mask_rows – The mask rows to apply to the DataFrame. Default is None.
max_signals – It describes the maximum number of BED files signals to be plotted.
sort_values – It describes whether the profiles should be sorted based on their amplitude
- Returns:
A tuple containing the figure and axes objects (fig, ax).