LetterSimilarityPlotter
#
- class biotite.sequence.graphics.LetterSimilarityPlotter(axes, matrix=None, color_symbols=False, font_size=None, font_param=None)[source]#
Bases:
LetterPlotter
This
SymbolPlotter
colors the symbols based on the similarity with the other symbols in the same column.The color intensity (or colormap value, respectively) of a symbol scales with similarity of the respective symbol to the other symbols in the same alignment column.
- Parameters:
- axesAxes
A Matplotlib axes, that is used as plotting area.
- matrixSubstitutionMatrix, optional
The substitution matrix to use the similarity scores from. By default the normalized similarity is 1 for identity and 0 for non-identity.
- color_symbolsbool, optional
If true, the symbols themselves are colored. If false, the symbols are black, and the boxes behind the symbols are colored.
- font_sizefloat, optional
Font size of the sequence symbols.
- font_paramdict, optional
Additional parameters that is given to the
matplotlib.Text
instance of each symbol.
Notes
For determination of the color, this a measure called average normalized similarity is used.
The normalized similarity of one symbol a to another symbol b (both in aphabet X) is defined as
\[S_{norm}(a,b) = \frac{S(a,b) - \min\limits_x(S(a,x))} {\max\limits_x(S(a,x)) - \min\limits_x(S(a,x))}\]\[a,b,x \in X\]where S(x,y) is the similarity score of the two symbols x and y described in the substitution matrix. The similarity S(x,-) is always 0. As the normalization is conducted only with respect to a, the normalized similarity is not commutative.
The average normalized similarity of a symbol a is determined by averaging the normalized similarity over each symbol bi in the same alignment column.
\[S_{norm,av}(a) = \frac{1}{n-1} \left[\left(\sum\limits_{i=1}^n S_{norm}(a,b_i)\right) - S_{norm}(a,a)\right]\]The normalized similarity of a to itself is subtracted, because a does also occur in bi.
- get_color(alignment, column_i, seq_i)#
Get the color of a symbol at a specified position in the alignment.
The symbol is specified as position in the alignment’s trace (
trace[pos_i, seq_i]
).PROTECTED: Override when inheriting.
- Parameters:
- alignmentAlignment
The respective alignment.
- column_iint
The position index in the trace.
- seq_iint
The sequence index in the trace.
- Returns:
- colorobject
A Matplotlib compatible color used for the background or the symbol itself at the specifed position.
- plot_symbol(bbox, alignment, column_i, seq_i)#
Get the color of a symbol at a specified position in the alignment.
The symbol is specified as position in the alignment’s trace (
trace[pos_i, seq_i]
).- Parameters:
- bboxBbox
The axes area to plot the symbol in.
- alignmentAlignment
The respective alignment.
- column_iint
The position index in the trace.
- seq_iint
The sequence index in the trace.
- set_color(color=None, cmap=None)#
Set the alignemnt colors used for plotting.
This function takes either a color or a colormap.
- Parameters:
- colortuple or str, optional
A Matplotlib compatible color. If this parameter is given, the box color in an interpolated value between white and the given color, or, if color_symbols is set, between the given color and black. The interpolation percentage is given by the normalized similarity.
- cmapColormap, optional
The boxes (or symbols, if color_symbols is set) are colored based on the normalized similarity value on the given Colormap.