Skip to content

Commit

Permalink
fix documentation issues of contour functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Dec 3, 2024
1 parent 036c0e5 commit b89b7ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion docs/src/density_maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The output of `ResidueContributions` is by default shown as a simple unicode plo
</center>
```

The `ResidueContribution` object can be used to produce a high-quality contour plot using the `Plots.contourf` function:
The `ResidueContribution` object can be used to produce a high-quality contour plot using the `Plots.contourf` (or `contour`, or `heatmap`) function:

```@docs
Plots.contourf(::ResidueContributions)
Expand Down Expand Up @@ -192,6 +192,7 @@ save(::String, ::ResidueContributions)

The above produces a matrix with a number of columns equal to the number of residues and a number of rows equal to the number of MDDF points. That matrix can be plotted as a contour map with adequate plotting software.


## [3D density map around a macromolecule](@id grid3D)

Three-dimensional representations of the distribution functions can also be obtained from the MDDF results. These 3D representations are obtained from the fact that the MDDFs can be decomposed into the contributions of each solute atom, and that each point in space is closest to a single solute atom as well. Thus, each point in space can be associated to one solute atom, and the contribution of that atom to the MDDF at the corresponding distance can be obtained.
Expand Down Expand Up @@ -225,3 +226,4 @@ In the figure on the left, the points in space around the protein are selected w
Clicking on those points we obtain which are the atoms of the protein contributing to the MDDF at that region. In particular, the arrow on the right points to the strongest red region, which corresponds to an Aspartic acid. These residues are shown explicitly under the density (represented as a transparent surface) on the figure in the center.

The figure on the right displays, overlapped with the hydrogen-bonding residues, the most important contributions to the second peak of the distribution, corresponding to distances from the protein between 2.0 and 3.5Å. Notably, the regions involved are different from the ones forming hydrogen bonds, indicating that non-specific interactions with the protein (and not a second solvation shell) are responsible for the second peak.

22 changes: 11 additions & 11 deletions ext/Plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ using PDBTools: Residue, residue_ticks, Atom, eachresidue, resnum
"""
contourf(
rc::ResidueContributions;
step::Int=1,
oneletter=false,
xlabel="Residue",
ylabel="r / Å",
step::Int=1,
oneletter=false,
xlabel="Residue",
ylabel="r / Å",
kargs...
)
contour(rc::ResidueContributions, args...; kargs...)
heatmap(rc::ResidueContributions, args...; kargs...)
contour(rc::ResidueContributions; kargs...)
heatmap(rc::ResidueContributions; kargs...)
Plot the contribution of each residue to the solute-solvent pair distribution function as a 2D density map.
This function requires loading the `Plots` package. The calling syntax for `contour` and `heatmap` is the same as for `contourf`.
Expand Down Expand Up @@ -64,14 +65,13 @@ julia> plt = contourf(rc; step=5, size=(800,400), title="Title", clims=(-0.1, 0.
This function requires loading the `Plots` package.
Support for all `Plots.contourf` parameters was introduced in ComplexMixtures v2.6.0, and support for
`contour` and `heatmap` were introduced in ComplexMixtures v2.11.0.
`contour` and `heatmap` was introduced in ComplexMixtures v2.11.0.
"""
Plots.contourf, Plots.contour, Plots.heatmap
Plots.contourf(rc::ResidueContributions; kargs...) = _density2D(Plots.contourf, rc; kargs...)

Plots.contourf(rc::ResidueContributions, args...; kargs...) = _density2D(Plots.contourf, rc, args...; kargs...)
Plots.contour(rc::ResidueContributions, args...; kargs...) = _density2D(Plots.contour, rc, args...; kargs...)
Plots.heatmap(rc::ResidueContributions, args...; kargs...) = _density2D(Plots.heatmap, rc, args...; kargs...)
Plots.contour(rc::ResidueContributions; kargs...) = _density2D(Plots.contour, rc; kargs...)
Plots.heatmap(rc::ResidueContributions; kargs...) = _density2D(Plots.heatmap, rc; kargs...)

Check warning on line 74 in ext/Plotting.jl

View check run for this annotation

Codecov / codecov/patch

ext/Plotting.jl#L73-L74

Added lines #L73 - L74 were not covered by tests

function _density2D(
plot_type::Function,
Expand Down

2 comments on commit b89b7ee

@lmiq
Copy link
Member Author

@lmiq lmiq commented on b89b7ee Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

New features

  • Support for plotting 2D density maps as heatmap or contour (without filling), for ResidueContributions objects:
julia> contourf(residue_contributions; oneletter=true)

Image

julia> contour(residue_contributions; oneletter=true)

Image

julia> heatmap(residue_contributions; oneletter=true)

Image

Bug fixes

  • Some bug fixes related to plotting ResidueContributions with repeated or unsorted residue numbers (in combination with PDBTools.jl v2.1.3).
  • Set maximum number of contributions by default when plotting contour plots, to avoid memory crashes (throws warnings).
  • Fix example of 2D density map of example 3 of the documentation, where the terminal methyl groups where not shown.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/120621

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.11.0 -m "<description of version>" b89b7eeacdf22b7f873446e804e981dd79fcee34
git push origin v2.11.0

Please sign in to comment.