mdciao.plots.compare_groups_of_contacts¶
-
mdciao.plots.
compare_groups_of_contacts
(groups, colors=None, mutations_dict={}, width=0.2, ax=None, figsize=(10, 5), fontsize=16, anchor=None, plot_singles=False, exclude=None, ctc_cutoff_Ang=None, AA_format='short', defrag='@', per_residue=False, title='comparison', distro=False, interface=False, **kwargs_plot_unified_freq_dicts)¶ Compare contact groups across different systems using different plots and strategies
- Parameters
groups (iterable (list or dict)) –
The contact groups. If dict, the keys will be used as names for the contact groups, e.g. “WT”, “MUT” etc, if list the keys will be auto-generated. The values can be:
ContactGroup
objectsdictionaries where the keys are residue-pairs
(one letter-codes, no fragment info, as in
ContactGroup.ctc_labels_short
) and the values are contact frequencies [0,1] * ascii-files with the contact the frequencies in the firstcolumn and labels in the second and/or third column, see
frequency_str_ASCII_file
andfreq_ascii2dict
.xlsx files with the header in the second row, containing at least the column-names “label” and “freqs”
Note
If a
ContactGroup
is passed, then actc_cutoff_Ang
needs to be passed along, otherwise frequencies cannot be computed on-the-flycolors (iterable (list or dict), or str, default is None) –
If list, the colors will be assigned in the same order of
groups
.If dict, has to have the same keys as
groups
.If str, it has to be a case-sensitve colormap-name of matplotlib: https://matplotlib.org/stable/tutorials/colors/colormaps.html
If None, the ‘tab10’ colormap (tableau) is chosen
mutations_dict (dictionary, default is {}) – A mutation dictionary that contains allows to plot together residues that would otherwise be identified as different contacts. If there were two mutations, e.g A30K and D35A the mutation dictionary will be {“A30”:”K30”, “D35”:”A35”}. You can also use this parameter for correcting indexing offsets, e.g {“GDP395”:”GDP”, “GDP396”:”GDP”}
width (float, default is .2) – The witdth of the bars
ax (
Axes
) – Axis to draw onfigsize (tuple, default is (10,5)) – The figure size in inches, in case it is instantiated automatically by not passing an
ax
fontsize (float, default is 16) – The fontsize to use
anchor (str, default is None) – This string will be deleted from the contact labels, leaving only the partner-residue to identify the contact. The deletion takes place after the
mutations_dict
has been applied. The final anchor label will be that of the deleted keys (allows for keeping e.g. pre-existing consensus nomenclature). No consistency-checks are carried out, i.e. use at your own riskplot_singles (bool, default is False) – Produce one extra figure with as many subplots as systems in
dictionary_of_groups
, where each system is plotted separately. The labels used will have been already “mutated” usingmutations_dict
and “anchored” usinganchor
. This plot is temporary and cannot be savedexclude (list, default is None) – keys containing these strings will be excluded. NOTE: This is not implemented yet, will raise an error
ctc_cutoff_Ang (float, default is None) – Needed value to compute frequencies on-the-fly if the input was using
ContactGroup
objectsAA_format (str, default is "short") – see
frequency_dict
for more infodefrag (str, default is "@") – see
unify_freq_dicts
for more infoper_residue (bool, default is False) – Unify dictionaries by residue and not by pairs. If True,
remove_identities
is set to False automatically when callingplot_unified_freq_dicts
title (str, default is "comparison") – The title for the plot
distro (bool, default is False) – Instead of plotting contact frequencies, plot contact distributions
interface (bool, default is False) – Asks if per_residue=True and then sorts the residues into interface fragments. Will fail if the passed
groups
don’t have self.is_interface==True
- Returns
myfig (
Figure
) – Figure with the comparison plotfreqs (dictionary) – Unified frequency dictionaries, including mutations and anchor
plotted_freqs (dictionary) – Like
freqs
but sorted and purged according to the user-defined input options, s.t. it represents the plotted values