Plotting Functions
This module defines plotting functions for protein dynamics analysis.
Plotting functions are called by the name of the plotted data/property
and are prefixed with show. Function documentations refers to the
matplotlib.pyplot function utilized for actual plotting. Arguments
and keyword arguments are passed to the Matplotlib functions.
- prody.dynamics.plotting.pimshow(matrix, x_array=None, y_array=None, atoms=None, **kwargs)
Show a matrix using
imshow(). Curves on x- and y-axis can be added. The first return value is theAxesobject for the upper plot, and the second return value is equivalent object for the left plot. The third return value is theAxesImageobject for the matrix plot. The last return value is theAxesobject for the color bar.- Parameters:
matrix (
ndarray) – matrix to be displayedx_array (
ndarray) – data to be plotted above the matrixy_array (
ndarray) – data to be plotted on the left side of the matrixpercentile (float) – A percentile threshold to remove outliers, i.e. only showing data within p-th to 100-p-th percentile.
atoms – a :class: AtomGroup instance for matching residue numbers and chain identifiers
interactive (bool) – turn on or off the interactive options
- Keyword Arguments:
chain – display a bar at the bottom to show chain separations. If set to None, it will be decided depends on whether atoms is provided. Default is None.
domain – the same with chains but show domain separations instead. atoms needs to have domain data associated to it. Default is None.
figure – if set to None, then a new figure will be created if auto_show is True, otherwise it will be plotted on the current figure. If set to a figure number or a
Figureinstance, no matter what ‘auto_show’ value is, plots will be drawn on the figure. Default is None.
- prody.dynamics.plotting.pplot(*args, **kwargs)
Show a plot with the option to use residue numbers and include chain/domain color bars using provided atoms.
- Parameters:
atoms – a :class: AtomGroup instance for matching residue numbers and chain identifiers.
- Keyword Arguments:
chain – display a bar at the bottom to show chain separations. If set to None, it will be decided depends on whether atoms is provided. Default is None.
domain – the same as chain but show domain separations instead. atoms needs to have domain data associated to it. Default is None.
gap – whether to show the gaps in the atoms or not. Default is False.
overlay – whether to overlay the curves based on the chain separations in atoms or not. Default is False.
figure – if set to None, then a new figure will be created if auto_show is True, otherwise it will be plotted on the current figure. If set to a figure number or string or a
Figureinstance, no matter what ‘auto_show’ value is, plots will be drawn on the figure. Default is None.final – if set to False, chain and domain will be set to False no matter what their values are. This is used to stack plots onto one another, and show only one domain/chain bar.
- prody.dynamics.plotting.resetTicks(x, y=None)[source]
Reset X (and Y) axis ticks using values in given array. Ticks in the current figure should not be fractional values for this function to work as expected.
- prody.dynamics.plotting.showAtomicBars(*args, **kwargs)[source]
Show a bar chart with the option to use residue numbers and include chain/domain color bars using provided atoms.
- Parameters:
atoms – a :class: AtomGroup instance for matching residue numbers and chain identifiers.
- Keyword Arguments:
chain – display a bar at the bottom to show chain separations. If set to None, it will be decided depends on whether atoms is provided. Default is None.
domain – the same with chains but show domain separations instead. atoms needs to have domain data associated to it. Default is None.
gap – whether show the gaps in the atoms or not. Default is False.
overlay – whether overlay the curves based on the chain separations in atoms or not. Default is False.
figure – if set to None, then a new figure will be created if auto_show is True, otherwise it will be plotted on the current figure. If set to a figure number or string or a
Figureinstance, no matter what ‘auto_show’ value is, plots will be drawn on the figure. Default is None.final – if set to False, chain and domain will be set to False no matter what their values are. This is used to stack plots onto one another, and show only one domain/chain bar.
- prody.dynamics.plotting.showAtomicLines(*args, **kwargs)[source]
Show a plot with the option to use residue numbers and include chain/domain color bars using provided atoms.
- Parameters:
atoms – a :class: AtomGroup instance for matching residue numbers and chain identifiers.
- Keyword Arguments:
chain – display a bar at the bottom to show chain separations. If set to None, it will be decided depends on whether atoms is provided. Default is None.
domain – the same as chain but show domain separations instead. atoms needs to have domain data associated to it. Default is None.
gap – whether to show the gaps in the atoms or not. Default is False.
overlay – whether to overlay the curves based on the chain separations in atoms or not. Default is False.
figure – if set to None, then a new figure will be created if auto_show is True, otherwise it will be plotted on the current figure. If set to a figure number or string or a
Figureinstance, no matter what ‘auto_show’ value is, plots will be drawn on the figure. Default is None.final – if set to False, chain and domain will be set to False no matter what their values are. This is used to stack plots onto one another, and show only one domain/chain bar.
- prody.dynamics.plotting.showAtomicMatrix(matrix, x_array=None, y_array=None, atoms=None, **kwargs)[source]
Show a matrix using
imshow(). Curves on x- and y-axis can be added. The first return value is theAxesobject for the upper plot, and the second return value is equivalent object for the left plot. The third return value is theAxesImageobject for the matrix plot. The last return value is theAxesobject for the color bar.- Parameters:
matrix (
ndarray) – matrix to be displayedx_array (
ndarray) – data to be plotted above the matrixy_array (
ndarray) – data to be plotted on the left side of the matrixpercentile (float) – A percentile threshold to remove outliers, i.e. only showing data within p-th to 100-p-th percentile.
atoms – a :class: AtomGroup instance for matching residue numbers and chain identifiers
interactive (bool) – turn on or off the interactive options
- Keyword Arguments:
chain – display a bar at the bottom to show chain separations. If set to None, it will be decided depends on whether atoms is provided. Default is None.
domain – the same with chains but show domain separations instead. atoms needs to have domain data associated to it. Default is None.
figure – if set to None, then a new figure will be created if auto_show is True, otherwise it will be plotted on the current figure. If set to a figure number or a
Figureinstance, no matter what ‘auto_show’ value is, plots will be drawn on the figure. Default is None.
- prody.dynamics.plotting.showContactMap(enm, **kwargs)[source]
Show contact map using
showAtomicMatrix(). enm can be either aGNMorAtomicobject.
- prody.dynamics.plotting.showCovarianceMatrix(modes, *args, **kwargs)[source]
Show 3Nx3N covariance matrix (or NxN matrix for GNM) using
showAtomicMatrix(). By default, origin=lower and interpolation=bilinear keyword arguments are passed to this function, but user can overwrite these parameters. See alsocalcCovariance().
- prody.dynamics.plotting.showCrossCorr(modes, *args, **kwargs)[source]
Show cross-correlations using
showAtomicMatrix(). By default, origin=lower and interpolation=bilinear keyword arguments are passed to this function, but user can overwrite these parameters. See alsocalcCrossCorr().
- prody.dynamics.plotting.showCrossProjection(ensemble, mode_x, mode_y, scale=None, *args, **kwargs)[source]
Show a projection of conformational deviations onto modes from different models using
plot(). This function differs fromshowProjection()by accepting modes from two different models.- Parameters:
ensemble (
Ensemble,Conformation,Vector,Trajectory) – an ensemble or a conformation for which deviation(s) will be projected, or a deformation vectormode_x (
Mode,Vector) – projection onto this mode will be shown along x-axismode_y (
Mode,Vector) – projection onto this mode will be shown along y-axisscale (str) – scale width of the projection onto mode
xory, best scaling factor will be calculated and printed on the console, absolute value of scalar makes the with of two projection same, sign of scalar makes the projections yield a positive correlation
- Keyword Arguments:
scalar – scalar factor for projection onto selected mode
color – a color name or a list of color name, default is
'blue'label – label or a list of labels
marker – a marker or a list of markers, default is
'o'linestyle – line style, default is
'None'text – list of text labels, one for each conformation
fontsize – font size for text labels
This function uses calcProjection and its arguments can be passed to it as keyword arguments.
The projected values are by default converted to RMSD. Pass
rmsd=Falseto calculate raw projection values. See pca-xray-plotting for a more elaborate example.Likewise, normalisation is applied by default and can be turned off with
norm=False.
- prody.dynamics.plotting.showCumulFractVars(modes, *args, **kwargs)[source]
Show fraction of variances of modes using
plot(). Note that mode indices are incremented by 1. See alsoshowFractVars()function.
- prody.dynamics.plotting.showCumulOverlap(mode, modes, *args, **kwargs)[source]
Show cumulative overlap using
plot().
- prody.dynamics.plotting.showDiffMatrix(matrix1, matrix2, *args, **kwargs)[source]
Show the difference between two cross-correlation matrices from different models. For given matrix1 and matrix2 show the difference between them in the form of (matrix2 - matrix1) and plot the difference matrix using
showAtomicMatrix(). WhenNMAmodels are passed instead of matrices, the functions could callcalcCrossCorr()function to calculate the matrices for given modes.To display the absolute values in the difference matrix, user could set abs keyword argument True.
By default,
origin="lower"andinterpolation="bilinear"keyword arguments are passed to this function, but user can overwrite these parameters.
- prody.dynamics.plotting.showDomainBar(domains, x=None, loc=0.0, axis='x', **kwargs)[source]
Plot a bar on top of the current axis which is colored based on domain separations.
- Parameters:
- Keyword Arguments:
text – whether to show the text or not. Default is True
text_loc – location of text labels. It can be either above or below
text_color – color of the text labels
color – a dictionary of colors where keys are the domain names
relim – whether to rescale the axes’ limits after adding the bar. Default is True
- prody.dynamics.plotting.showEllipsoid(modes, onto=None, n_std=2, scale=1.0, *args, **kwargs)[source]
Show an ellipsoid using
plot_wireframe().Ellipsoid volume gives an analytical view of the conformational space that given modes describe.
- Parameters:
- prody.dynamics.plotting.showFractVars(modes, *args, **kwargs)[source]
Show fraction of variances using
bar(). Note that mode indices are incremented by 1.
- prody.dynamics.plotting.showMeanMechStiff(stiffness, atoms, header, chain='A', *args, **kwargs)[source]
Show mean value of effective spring constant with secondary structure taken from MechStiff. Header is needed to obatin secondary structure range. Using
"jet_r"as argument color map will be reverse (similar to VMD program coding).
- prody.dynamics.plotting.showMechStiff(stiffness, atoms, **kwargs)[source]
Show mechanical stiffness matrix using
imshow(). By default,origin="lower"keyword arguments are passed to this function, but user can overwrite these parameters.
- prody.dynamics.plotting.showNormDistFunct(model, coords, **kwargs)[source]
Show normalized distance fluctuation matrix using
imshow(). By default,origin="lower"keyword arguments are passed to this function, but user can overwrite these parameters.
- prody.dynamics.plotting.showNormedSqFlucts(modes, *args, **kwargs)[source]
Show normalized square fluctuations via
plot().
- prody.dynamics.plotting.showOverlap(mode, modes, *args, **kwargs)[source]
Show overlap
bar().- Parameters:
- prody.dynamics.plotting.showOverlapTable(modes_x, modes_y, **kwargs)[source]
Show overlap table using
pcolor(). modes_x and modes_y are sets of normal modes, and correspond to x and y axes of the plot. Note that mode indices are incremented by 1. List of modes is assumed to contain a set of contiguous modes from the same model.Default arguments for
pcolor():cmap='jet'norm=matplotlib.colors.Normalize(0, 1)
- prody.dynamics.plotting.showOverlaps(mode, modes, *args, **kwargs)
Show overlap
bar().- Parameters:
- prody.dynamics.plotting.showPairDeformationDist(model, coords, ind1, ind2, *args, **kwargs)[source]
Show distribution of deformations in distance contributed by each mode for selected pair of residues ind1 ind2 using
plot().
- prody.dynamics.plotting.showPerturbResponse(model, atoms=None, show_matrix=True, select=None, **kwargs)[source]
Plot the PRS matrix with the profiles along the right and bottom.
If atoms are provided then residue numbers can be used from there. model and atoms must have the same number of atoms. atoms must be an
Atomicinstance.- Parameters:
model (
NMA,ndarray) – any object with acalcCovariance()method from which to calculate a PRS matrix (e.g.ANMinstance) or a PRS matrix itselfatoms (
AtomGroup) – a :class: AtomGroup instance for matching residue numbers and chain identifiersselect – a
Selectioninstance or selection string for showing residue-specific profiles. This can only be used withshow_matrix=False.
- Tye select:
Selection, str- Keyword Arguments:
show_matrix – whether to show the matrix, default is True
suppress_diag – whether to suppress the diagonal default is True
- prody.dynamics.plotting.showProjection(ensemble=None, modes=None, projection=None, *args, **kwargs)[source]
Show a projection of conformational deviations onto up to three normal modes from the same model.
- Parameters:
ensemble (
Ensemble,Conformation,Vector,Trajectory) – an ensemble, trajectory or a conformation for which deviation(s) will be projected, or a deformation vector
- Keyword Arguments:
show_density – whether to show a density histogram or kernel density estimate rather than a 2D scatter of points or a 1D projection by time (number of steps) on the x-axis. This option is not valid for 3D projections. Default is True for 1D and False for 2D to maintain old behaviour.
use_weights – whether to use weights in a density histogram or kernel density estimate or for the size of points in 2D scatter of points or a 1D projection by time (number of steps) on the x-axis. This option is not valid for 3D projections. Default is False to maintain old behaviour.
weights – weights for histograms or point sizes Default is to use ensemble.getData(‘size’)
color – a color name or a list of color names or values, default is
'blue'label – label or a list of labels
marker – a marker or a list of markers, default is
'o'linestyle – line style, default is
'None'text – list of text labels, one for each conformation
fontsize – font size for text labels
The projected values are by default converted to RMSD. Pass
rmsd=Falseto use projection itself.By default, the projection is not normalized. If you would like it to be, pass
norm=True.Matplotlib function used for plotting depends on the number of modes:
- prody.dynamics.plotting.showRMSFlucts(modes, *args, **kwargs)[source]
Show square fluctuations using
showAtomicLines(). See alsocalcRMSFlucts().
- prody.dynamics.plotting.showScaledSqFlucts(modes, *args, **kwargs)[source]
Show scaled square fluctuations using
plot(). Modes or mode sets given as additional arguments will be scaled to have the same mean squared fluctuations as modes.
- prody.dynamics.plotting.showSelectionMatrix(matrix, atoms, selstr_x=None, selstr_y=None, **kwargs)[source]
Show a matrix similarly to showAtomicMatrix but only for selected atoms based on selstr_x and selstr_y
- Parameters:
If either of these are left as None, then no slicing is performed in that direction.
- prody.dynamics.plotting.showSqFlucts(modes, *args, **kwargs)[source]
Show square fluctuations using
showAtomicLines(). See alsocalcSqFlucts().
- prody.dynamics.plotting.showTree(tree, format='matplotlib', **kwargs)[source]
Given a tree, creates visualization in different formats.
- arg tree: Tree needs to be unrooted and should be generated by tree
generator from Phylo in biopython, which is used by
calcTree()
type tree:
Tree- arg format: depending on the format, you will see different forms of trees.
Acceptable formats are
"plt"(or"mpl"or"matplotlib"),"ascii"and"networkx". Default is"matplotlib".
type format: str
keyword font_size: font size for branch labels type font_size: float
keyword line_width: the line width for each branch type line_width: float
- prody.dynamics.plotting.showTree_networkx(tree, node_size=20, node_color='red', node_shape='o', withlabels=True, scale=1.0, iterations=500, k=None, **kwargs)[source]
Given a tree, creates visualization using
networkx. Seespring_layout()anddraw_networkx_nodes()for more details.- arg tree: Tree needs to be unrooted and should be generated by tree
generator from Phylo in biopython, which is used by
calcTree()
type tree:
Tree