rstoolbox.plot.plot_in_context

rstoolbox.plot.plot_in_context(df, fig, grid, refdata, igrid=None, values='*', ref_equivalences=None, legends=False, **kwargs)

Plot position of decoys in a backgroud reference dataset.

Note

Personalization is possible by providing argument keys for kdeplot() with the prefix kde_ and for plot() (for the points) with the prefix point_.

Parameters:
  • df (DataFrame) – Data container.
  • fig (Figure) – Figure into which the data is going to be plotted.
  • grid (tuple with two int) – Shape of the grid to plot the values in the figure (rows x columns).
  • refdata (DataFrame) – Data content to use as reference.
  • igrid (tuple with two int) – Initial position of the grid. Defaults to (0, 0)
  • values (list() of str) – Contents from the data container that are expected to be plotted.
  • ref_equivalences (dict) – When names between the query data and the provided data are the same, they will be directly assigned. Here a dictionary db_name:query_name can be provided otherwise.
  • legends (bool) – When True, show the legends of each axis.
Returns:

list() of Axes

Raises:
ValueError:If columns are requested that do not exist in the DataFrame of data and reference.
ValueError:If the given grid does not have enought positions for all the requested values.
ValueError:If refdata or df are not DataFrame.

Example:

In [1]: from rstoolbox.plot import plot_in_context
   ...: from rstoolbox.utils import load_refdata
   ...: import matplotlib.pyplot as plt
   ...: df = load_refdata('scop2')
   ...: slength = 100
   ...: refdf = load_refdata('scop2', 50)
   ...: refdf = refdf[(refdf['length'] >= slength - 5) &
   ...:               (refdf['length'] <= slength + 5)]
   ...: values = ["score", "hbond_sr_bb", "avdegree", "hbond_bb_sc",
   ...:           "cavity", "CYDentropy", "pack", "radius"]
   ...: fig = plt.figure(figsize=(25, 10))
   ...: axs = plot_in_context(df, fig, (2, 4), refdata=refdf, values=values)
   ...: plt.tight_layout()
   ...: 

In [2]: plt.show()

In [3]: plt.close()
../_images/plot_in_context_docs1.png