figures¶
Auxiliary functions for creating analysis figures.
Functions¶
|
Create a ramachandran plot Figure from a calculated dihedral angles matrix. |
|
Create a contact map Figure from a calculated contact matrix. |
|
Create a distance matrix Figure from a calculated distance matrix. |
|
Create a SS frequency Figure from a SS assignment frequency matrix. |
|
Create Plotly traces to be used in the creation of a Structural Metrics Figure. |
|
Create a Structural Metrics Figure from previously created traces. |
|
Create a Figure directly from calculated metrics data. |
|
Create Figures given analysis data for pairs of trajectory,topology files. |
Module Contents¶
- ensemblify.analysis.figures.create_ramachandran_figure(dihedrals_matrix, trajectory_id=None, output_path=None)¶
Create a ramachandran plot Figure from a calculated dihedral angles matrix.
- Parameters:
dihedrals_matrix (
pd.DataFrame | str) – Calculated dihedral angles matrix DataFrame or path to calculated matrix in .csv format. If difference is True, this should be the difference dihedral angles matrix between the uniformly weighted and the reweighted dihedral angles matrix.trajectory_id (
str, optional) – Used on Figure title and prefix for saved ramachandran plot filename. Defaults to None.output_path (
str, optional) – Path to output .html file or output directory where created Figure will be stored. If directory, written file is named ‘ramachandran_plot.html’, optionally with trajectory_id prefix. Defaults to None.
- Returns:
Ploty Figure object displaying a ramachandran plot.
- Return type:
go.Figures
- ensemblify.analysis.figures.create_contact_map_fig(contact_matrix, topology, trajectory_id=None, output_path=None, reweighted=False, difference=False)¶
Create a contact map Figure from a calculated contact matrix.
The topology provides information about number of chains, their chain letters and residue numbers.
- Parameters:
contact_matrix (
pd.DataFrame | str) – Calculated contact matrix DataFrame or path to calculated matrix in .csv format. If difference is True, this should be the difference contact matrix between the uniformly weighted and the reweighted contact matrix.topology (
str) – Path to topology .pdb file.trajectory_id (
str, optional) – Used on Figure title and prefix for saved contact map filename. Defaults to None.output_path (
str, optional) – Path to output .html file or output directory where created Figure will be stored. If directory, written file is named ‘contact_map.html’, optionally with trajectory_id prefix. Defaults to None.reweighted (
bool, optional) – Boolean stating whether we are creating a reweighted contact map figure or a default one. Defaults to False.difference (
bool, optional) – Boolean stating whether we are creating a difference contact map figure or a default one. Defaults to False.
- Returns:
Ploty Figure object displaying a contact map.
- Return type:
go.Figure
- ensemblify.analysis.figures.create_distance_matrix_fig(distance_matrix, topology, trajectory_id=None, output_path=None, max_colorbar=None, min_colorbar=None, reweighted=False, difference=False)¶
Create a distance matrix Figure from a calculated distance matrix.
The topology provides information about number of chains, their chain letters and residue numbers.
- Parameters:
distance_matrix (
pd.DataFrame | str) – Calculated distance matrix DataFrame or path to calculated matrix in .csv format. If difference is True, this should be the difference distance matrix between the uniformly weighted and the reweighted distance matrix.topology (
str) – Path to topology .pdb file.trajectory_id (
str, optional) – Used on Figure title and prefix for saved distance matrix filename. Defaults to None.output_path (
str, optional) – Path to output .html file or output directory where created Figure will be stored. If directory, written file is named ‘distance_matrix.html’, optionally with trajectory_id prefix. Defaults to None.max_colorbar (
int, optional) – Maximum limit for the distance colorbar. Defaults to None, in which case it is derived from the data.min_colorbar (
int, optional) – Minimum limit for the distance colorbar. Defaults to None, in which case it is derived from the data.reweighted (
bool, optional) – Boolean stating whether we are creating a reweighted distance matrix figure or a default one. Defaults to False.difference (
bool, optional) – Boolean stating whether we are creating a difference distance matrix figure or a default one. Defaults to False.
- Returns:
Ploty Figure object displaying a distance matrix.
- Return type:
go.Figure
- ensemblify.analysis.figures.create_ss_frequency_figure(ss_frequency, topology, trajectory_id=None, output_path=None, reweighted=False, difference=False)¶
Create a SS frequency Figure from a SS assignment frequency matrix.
The topology provides information about number of chains, their chain letters and residue numbers.
- Parameters:
ss_frequency (
pd.DataFrame | str) – Calculated secondary structure assignment frequency matrix DataFrame or path to calculated matrix in .csv format.topology (
str) – Path to topology .pdb file.trajectory_id (
str, optional) – Used on Figure title and prefix for saved ss_frequency filename. Defaults to None.output_path (
str, optional) – Path to output .html file or output directory where created Figure will be stored. If directory, written file is named ‘ss_frequency.html’, optionally with trajectory_id prefix. Defaults to None.reweighted (
bool, optional) – Boolean stating whether we are creating a reweighted secondary structure frequency figure or a default one. Defaults to False.difference (
bool, optional) – Boolean stating whether we are creating a difference secondary structure frequency figure or a default one. Defaults to False.
- Returns:
Stacked line plot with the secondary structure frequencies of each secondary structure type for each residue in the structure.
- Return type:
go.Figure
- ensemblify.analysis.figures.create_metrics_traces(metrics, trajectory_id, color='#1f77b4')¶
Create Plotly traces to be used in the creation of a Structural Metrics Figure.
- Parameters:
metrics (
pd.DataFrame | str) – DataFrame where columns are the desired structural metrics and rows are the frames of the trajectory or path to that DataFrame in .csv format.trajectory_id (
str) – prefix identifier for trace names.color (
str, optional) – hex code for the color the created traces will be. Defaults to light blue.
- Returns:
- box_traces (list[go.Box]):
A list of the boxplot traces, one for each structural metric.
- hist_traces (list[go.Histogram]):
A list of the histogram traces, one for each structural metric.
- scatter_traces (list[go.Scatter]):
A list of the scatter Kernel Density Estimate (KDE) traces, one for each structural metric.
- avg_values (list[float]):
A list of the values of the mean for each metric.
- avg_stderr (list[float]):
A list of the values of the standard error of the mean for each metric.
- Return type:
tuple[list[go.Box], list[go.Histogram], list[go.Scatter], list[float], list[float]]
- ensemblify.analysis.figures.create_metrics_fig(trajectory_ids, total_box_traces, total_hist_traces, total_scatter_traces, total_avg_values, total_avg_stderr_values, output_path=None)¶
Create a Structural Metrics Figure from previously created traces.
- Parameters:
trajectory_ids (
list[str]) – List of prefix identifiers that must match the prefix identifiers used for naming the created traces.total_box_traces (
dict[str,list[go.Box]]) – Mapping of trajectory_ids to a list of created Box traces.total_hist_traces (
dict[str,list[go.Histogram]]) – Mapping of trajectory_ids to a list of created Histogram traces.total_scatter_traces (
dict[str,list[go.Scatter]]) – Mapping of trajectory_ids to a list of created Scatter traces.total_avg_values (
dict[str,list[float]]) – Mapping of trajectory_ids to a list of mean values.output_path (
str, optional) – Path to output .html file or output directory where the created Figure will be stored. If directory, written file is named ‘structural_metrics.html’. Defaults to None.total_avg_stderr_values (dict[str, list[float]])
- Returns:
Structural Metrics Figure that allows for comparison between all the created traces.
- Return type:
go.Figure
- ensemblify.analysis.figures.create_single_metrics_fig_directly(metrics, trajectory_id=None)¶
Create a Figure directly from calculated metrics data.
- Parameters:
metrics (
pd.DataFrame | str) – DataFrame where columns are the desired structural metrics and rows are the frames of the trajectory or path to that DataFrame in .csv format.trajectory_id (
str, optional) – Prefix identifier for trace names.
- Returns:
Structural Metrics Figure with the provided calculated metrics data.
- Return type:
go.Figure
- ensemblify.analysis.figures.create_analysis_figures(analysis_data, topologies, trajectory_ids, output_directory=os.getcwd(), color_palette=None)¶
Create Figures given analysis data for pairs of trajectory,topology files.
- Parameters:
analysis_data (
dict[str,list[pd.DataFrame]], optional) – Mapping of data identifiers to lists of DataFrames with the calculated analysis data, one element for each given trajectory,topology,trajectory_id trio. If None, the function will try to read the data from the output_directory.topologies (
list[str]) – List of paths to .pdb topology files.trajectory_ids (
list[str]) – Prefix trajectory identifiers to distinguish between calculated data files.output_directory (
str, optional) – Path to directory where created Figures will be stored. Defaults to current working directory.color_palette (
list[str], optional) – List of color hexcodes, to associate one with each trajectory when creating the Structural Metrics interactive figure.
- Returns:
Mapping of figure identifiers to lists of the created Figures, one for each trajectory outlined in the given analysis data. For example:
data = {‘ContactMaps’ : [ContactMap1,ContactMap2,ContactMap3], ‘DistanceMatrices’ : [DistanceMatrix1,DistanceMatrix2,DistanceMatrix3], ‘SecondaryStructureFrequencies’ : [SSFrequency1,SSFrequency2,SSFrequency3], ‘StructuralMetrics’ : [StructuralMetrics1,StructuralMetrics2,StructuralMetrics3]}
- Return type:
dict[str,list[go.Figure]]