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.

showCrossCorr
(modes, *args, **kwargs)[source]¶ Show crosscorrelations using
imshow()
. By default, origin=lower and interpolation=bilinear keyword arguments are passed to this function, but user can overwrite these parameters. See alsocalcCrossCorr()
.

showCumulOverlap
(mode, modes, *args, **kwargs)[source]¶ Show cumulative overlap using
plot()
.Parameters: modes ( ModeSet
,ANM
,GNM
,PCA
) – multiple modes

showFractVars
(modes, *args, **kwargs)[source]¶ Show fraction of variances using
bar()
. Note that mode indices are incremented by 1.

showCumulFractVars
(modes, *args, **kwargs)[source]¶ Show fraction of variances of modes using
plot()
. Note that mode indices are incremented by 1. See alsoshowFractVars()
function.

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=plt.cm.jet
norm=matplotlib.colors.Normalize(0, 1)

showProjection
(ensemble, modes, *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  modes (
Mode
,ModeSet
,NMA
) – up to three normal modes  color (str, list) – a color name or a list of color names or values,
default is
'blue'
 label (str, list) – label or a list of labels
 marker (str, list) – a marker or a list of markers, default is
'o'
 linestyle (str) – line style, default is
'None'
 text (list) – list of text labels, one for each conformation
 fontsize (int) – font size for text labels
 new_fig (bool) – if
True
then a new figure will be created before plotting. default is True
The projected values are by default converted to RMSD. Pass
rmsd=False
to use projection itself.Matplotlib function used for plotting depends on the number of modes:
 ensemble (

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 vector  mode_x (
Mode
,Vector
) – projection onto this mode will be shown along xaxis  mode_y (
Mode
,Vector
) – projection onto this mode will be shown along yaxis  scale (str) – scale width of the projection onto mode
x
ory
, 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  scalar (float) – scalar factor for projection onto selected mode
 color (str, list) – a color name or a list of color name, default is
'blue'
 label (str, list) – label or a list of labels
 marker (str, list) – a marker or a list of markers, default is
'o'
 linestyle (str) – line style, default is
'None'
 text (list) – list of text labels, one for each conformation
 fontsize (int) – font size for text labels
The projected values are by default converted to RMSD. Pass
rmsd=False
to calculate raw projection values. See Plotting for a more elaborate example. ensemble (

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:

showSqFlucts
(modes, *args, **kwargs)[source]¶ Show square fluctuations using
plot()
. See alsocalcSqFlucts()
.

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.

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.

showDiffMatrix
(matrix1, matrix2, *args, **kwargs)[source]¶ Show the difference between two crosscorrelation 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
showMatrix()
. WhenNMA
models 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 and interpolation=bilinear keyword arguments are passed to this function, but user can overwrite these parameters.

showMechStiff
(model, coords, *args, **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.

showNormDistFunct
(model, coords, *args, **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.

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()
.

showMeanMechStiff
(model, coords, 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).

showPerturbResponse
(**kwargs)[source]¶ Plot the PRS matrix with the profiles along the right and bottom.
If no PRS matrix or profiles are provided, these will be calculated first using the provided options with a provided model (e.g. ANM, GNM or EDA). So as to obtain different sensors and effectors, normMatrix=True by default.
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
AtomGroup
instance.Parameters:  prs_matrix (array) – a perturbation response matrix
 effectiveness (array) – an effectiveness profile from a PRS matrix
 sensitivity (array) – a sensitivity profile from a PRS matrix
 model (NMA) – any object with a calcCovariance method
e.g.
ANM
instance  atoms (AtomGroup) – a :class: AtomGroup instance
 returnData (bool) – whether to return data for further analysis default is False
 percentile (float) – percentile argument for showMatrix
Return values are prs_matrix, effectiveness, sensitivity, ax1, ax2, im, ax3, ax4 The PRS matrix, effectiveness and sensitivity will not be returned if provided. If returnData is False then only the last five objects are returned.

showPerturbResponseProfiles
(prs_matrix, atoms=None, **kwargs)[source]¶ Plot as a line graph the average response to perturbation of a particular residue (a row of a perturbation response matrix) or the average effect of perturbation of a particular residue (a column of a normalized perturbation response matrix).
If no PRS matrix or profiles are provided, these will be calculated first using the provided options with a provided model (e.g. ANM, GNM or EDA). So as to obtain different sensitivity and effectiveness, normMatrix=True by default.
If no residue number is given then the effectiveness and sensitivity profiles will be plotted instead. These two profiles are also returned as arrays for further analysis if they aren’t already provided.
Parameters:  prs_matrix (ndarray) – a perturbation response matrix
 atoms (AtomGroup) – a :class: AtomGroup instance for matching residue numbers and chain IDs.
 effectiveness (list) – an effectiveness profile from a PRS matrix
 sensitivity (list) – a sensitivity profile from a PRS matrix
 model (NMA) – any object with a calcCovariance method
e.g.
ANM
instance model and atoms must have the same number of atoms.  chain (str) – chain identifier for the residue of interest default is to make a plot for each chain in the protein
 resnum (int) – residue number for the residue of interest
 direction (str) – the direction you want to use to read data out of the PRS matrix for plotting: the options are ‘effect’ or ‘response’. Default is ‘effect’. A row gives the effect on each residue of peturbing the specified residue. A column gives the response of the specified residue to perturbing each residue. If no residue number is provided then this option will be ignored
 returnData – whether to return profiles for further analysis default is False

showMatrix
(matrix=None, x_array=None, y_array=None, **kwargs)[source]¶ Show a matrix using
imshow()
. Curves on x and yaxis can be added. The first return value is theAxes
object for the upper plot, and the second return value is equivalent object for the left plot. The third return value is theAxesImage
object for the matrix plot. The last return value is theAxes
object for the color bar.Parameters:  matrix (
ndarray
) – Matrix to be displayed.  x_array (
ndarray
) – Data to be plotted above the matrix.  y_array (
ndarray
) – Data to be plotted on the left side of the matrix.  percentile (float) – A percentile threshold to remove outliers, i.e. only showing data within pth to 100pth percentile.
 vmin (float) – Minimum value that can be used together with vmax as an alternative way to remove outliers
 vmax (float) – Maximum value that can be used together with vmin as alternative way to remove outliers
 atoms – a :class: AtomGroup instance for matching residue numbers and chain IDs.
 num_div (int) – the number of divisions for each chain default 2
 resnum_tick_labels (list or dictionary) – residue number labels in place of num_div. A list can be used to set the same labels on all chains or a dictionary of lists to set different labels for each chain
 add_last_resi (bool) – whether to add a label for the last residue default False
 label_size (int) – size for resnum labels default is 6, which works well for 4 residues on 4 chains
 matrix (

showPlot
(y, **kwargs)[source]¶ Show a plot with the option to include chain color bars using provided atoms.
Parameters:  atoms – a :class: AtomGroup instance for matching residue numbers and chain IDs.
 num_div (int) – the number of divisions for each chain default 2
 resnum_tick_labels (list or dictionary) – residue number labels in place of num_div. A list can be used to set the same labels on all chains or a dictionary of lists to set different labels for each chain
 add_last_resi (bool) – whether to add a label for the last residue default False
 label_size (int) – size for resnum labels default is 6, which works well for 4 residues on 4 chains
 overlay_chains (bool) – overlay the chains rather than having them one after another default False
 domain_bar (bool) – color the bar at the bottom by domains rather than chains default False

showTree
(tree, format='ascii', **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. type tree: Bio.Phylo.BaseTree.Tree arg format: Depending on the format, you will see different forms of trees. Acceptable formats are plt and ascii. type format: str arg font_size: Font size for branch labels type: float arg line_width: The line width for each branch type: float