Colormap-Based Edge Coloring in mdciao Flare Plots
Hi, I am currently using mdciao v1.0.0 to analyze GPCR interface interactions. First, thank you for developing such a useful tool — it has been very helpful for my analyses.
I would like to ask whether there is a way in the current version to color the edges in flare plots based on contact frequencies using a colormap (e.g., RdYlGn), similar to how contact matrices can use colormaps. I have tried freqs2flare, but it appears that edge colors cannot currently be customized according to frequency, and some fragment-related limitations prevent manual workarounds.
I would greatly appreciate your advice on whether any current workaround exists to achieve colormap-based edge coloring. Many thanks in advance
Kind regards Anu
Hi Anu,
Thanks for your kind words, sorry it took us a while to address this. I am happy you find mdciao useful!
If you're using freqs2flare you can use the argument bezier_linecolor to select the color of the curves connecting the dots, i.e. the edges.
This can swap the default black with other colors, like red, green, blue...whatever named-color, hex-value or rgb value that matplotlib can understand. But you cannot pick a colormap and give every edge a different color because, in the flareplot, the frequency value is indicated via opacity not via color.
In your example (RdYlGn), assuming contact-frequency 1 is red and 0 is green, you would have a lot of green edges (zero-valued, i.e. non-existing contacts) crossing the plot.
Note that you CAN finely manipulate anything the flareplot outputs because its attributes (individual matplotlib objects, see below) are always returned as a dictionary. In this example I first pick the color ("red") and then swap every fith edge for "blue" (just to exemplify this manipulation). Also note, I am using ContactGroup.plot_freqs_as_flareplot, since it wraps around freqs2flare and exposes most of its arguments.
Let me know if I can be of further help!
import mdciao
intf = mdciao.examples.Interface_B2AR_Gas()
fig, ax, attrs = intf.plot_freqs_as_flareplot(4.5,
bezier_linecolor="tab:red",
fragment_names=["Gα","β2AR"],
fragments=intf.interface_fragments,
scheme="residues_sparse");
print(attrs.keys())
# dict_keys(['fragment_labels', 'dot_labels', 'dots', 'SS_labels', 'r', 'bezier_lw', 'bezier_curves'])
import numpy as np
for ii, icurve in enumerate(attrs["bezier_curves"]):
if np.mod(ii,5)==0:
icurve.Line2D.set_color("yellow")
fig