pyXLMS.plotting package#
Submodules#
pyXLMS.plotting.plot_score_distribution module#
- pyXLMS.plotting.plot_score_distribution.plot_score_distribution(
- data: List[Dict[str, Any]],
- bins: int = 25,
- density: bool = False,
- colors: List[str] = ['#00a087', '#3c5488', '#e64b35'],
- title: str = 'Target and Decoy Score Distribution',
- figsize: Tuple[float, float] = (16.0, 9.0),
- filename_prefix: str | None = None,
Plot the score distribution for a set of crosslink-spectrum-matches or crosslinks.
Plot the target-target, target-decoy, and decoy-decoy score distribution as a histogram for a set of crosslink-spectrum-matches or crosslinks.
- Parameters:
data (list of dict of str, any) – A list of crosslink-spectrum-matches or crosslinks.
bins (int, default = 25) – The number of equal-width bins in the histogram.
density (bool, default = False) – If True, draw and return a probability density: each bin will display the bin’s raw count divided by the total number of counts and the bin width, so that the area under the histogram integrates to 1.
colors (list of str, default = ["#00a087", "#3c5488", "#e64b35"]) – Colors of the histogram lines.
title (str, default = "Target and Decoy Score Distribution") – The title of the histogram.
figsize (tuple of float, float, default = (16.0, 9.0)) – Width, height in inches.
filename_prefix (str, or None) – If given, plot will be saved with and without title in .png and .svg format with the given prefix.
- Returns:
The created figure and axis
from matplotlib.pyplot.subplots()
.- Return type:
tuple of matplotlib.figure.Figure, any
- Raises:
TypeError – If a wrong data type is provided.
ValueError – If parameter data does not contain any crosslink-spectrum-matches or crosslinks.
ValueError – If attribute ‘score’, ‘alpha_decoy’, or ‘beta_decoy’ is not available for any of the data.
Examples
>>> from pyXLMS import parser >>> from pyXLMS import plotting >>> pr = parser.read_msannika("data/ms_annika/XLpeplib_Beveridge_QEx-HFX_DSS_R1_CSMs.xlsx") >>> csms = pr["crosslink-spectrum-matches"] >>> fig, ax = plotting.plot_score_distribution(csms)
pyXLMS.plotting.plot_venn_diagram module#
- pyXLMS.plotting.plot_venn_diagram.plot_venn_diagram(
- data_1: List[Dict[str, Any]],
- data_2: List[Dict[str, Any]],
- data_3: List[Dict[str, Any]] | None = None,
- by: Literal['peptide', 'protein'] = 'peptide',
- labels: List[str] = ['Set 1', 'Set 2', 'Set 3'],
- colors: List[str] = ['#4361EE', '#4CC9F0', '#F72585'],
- alpha: float = 0.6,
- contour: bool = False,
- linewidth: float = 0.5,
- title: str = 'Venn Diagram',
- figsize: Tuple[float, float] = (10.0, 10.0),
- filename_prefix: str | None = None,
Plot the venn diagram for two or three sets of crosslink-spectrum-matches or crosslinks.
Plot the venn diagram for two or three sets of crosslink-spectrum-matches or crosslinks. Overlaps are calculated by either looking at peptide sequence and crosslink position in the peptide using parameter by = “peptide” or by looking at protein crosslink position by using parameter by = “protein”.
- Parameters:
data_1 (list of dict of str, any) – A list of crosslink-spectrum-matches or crosslinks.
data_2 (list of dict of str, any) – A list of crosslink-spectrum-matches or crosslinks.
data_3 (list of dict of str, any, or None, default = None) – Optionally, a third list of crosslink-spectrum-matches or crosslinks.
by (str, one of "peptide" or "protein") – If peptide or protein crosslink position should be used for determining if a crosslink-spectrum-match or crosslink is unique.
labels (List[str], default = ["Set 1", "Set 2", "Set 3"]) – List of labels for the sets.
colors (List[str], default = ["#4361EE", "#4CC9F0", "#F72585"]) – List of valid colors to use for the venn circles.
alpha (float, default = 0.6) – Color opacity.
contour (bool, default = False) – If a contour should be drawn around venn circles.
linewidth (float, default = 0.5) – Linewidth of the contour.
title (str, default = "Venn Diagram") – Title of the venn diagram.
figsize (tuple of float, float, default = (10.0, 10.0)) – Width, height in inches.
filename_prefix (str, or None, default = None) – If given, plot will be saved with and without title in .png and .svg format with the given prefix.
- Returns:
The created figure and axis
from matplotlib.pyplot.subplots()
.- Return type:
tuple of matplotlib.figure.Figure, any
- Raises:
TypeError – If a wrong data type is provided.
TypeError – If parameter by is not one of ‘peptide’ or ‘protein’.
ValueError – If one of the data parameters does not contain any crosslink-spectrum-matches or crosslinks.
ValueError – If attribute ‘alpha_proteins’, ‘alpha_proteins_crosslink_positions’, ‘beta_proteins’, or ‘beta_proteins_crosslink_positions’ is not available for any of the data and parameter ‘by’ was set to ‘protein’.
Examples
>>> from pyXLMS import parser >>> from pyXLMS import plotting >>> a = parser.read("data/ms_annika/XLpeplib_Beveridge_QEx-HFX_DSS_R1_CSMs.txt", engine="MS Annika", crosslinker="DSS") >>> a = a["crosslink-spectrum-matches"] >>> b = parser.read("data/maxquant/run1/crosslinkMsms.txt", engine="MaxQuant", crosslinker="DSS") >>> b = b["crosslink-spectrum-matches"] >>> fig, ax = plotting.plot_venn_diagram(a, b, labels=["MS Annika", "MaxQuant"], colors=["orange", "blue"])
>>> from pyXLMS import parser >>> from pyXLMS import plotting >>> a = parser.read("data/ms_annika/XLpeplib_Beveridge_QEx-HFX_DSS_R1_CSMs.txt", engine="MS Annika", crosslinker="DSS") >>> a = a["crosslink-spectrum-matches"] >>> b = parser.read("data/maxquant/run1/crosslinkMsms.txt", engine="MaxQuant", crosslinker="DSS") >>> b = b["crosslink-spectrum-matches"] >>> c = parser.read("data/plink2/Cas9_plus10_2024.06.20.filtered_cross-linked_spectra.csv", engine="pLink", crosslinker="DSS") >>> c = c["crosslink-spectrum-matches"] >>> fig, ax = plotting.plot_venn_diagram(a, b, c, labels=["MS Annika", "MaxQuant", "pLink"], contour=True)
- pyXLMS.plotting.plot_venn_diagram.venn(
- set_1: Set[Any],
- set_2: Set[Any],
- set_3: Set[Any] | None = None,
- labels: List[str] = ['Set 1', 'Set 2', 'Set 3'],
- colors: List[str] = ['#4361EE', '#4CC9F0', '#F72585'],
- alpha: float = 0.6,
- contour: bool = False,
- linewidth: float = 0.5,
- title: str = 'Venn Diagram',
- figsize: Tuple[float, float] = (10.0, 10.0),
- filename_prefix: str | None = None,
Wrapper with pre-set defaults for creating venn diagrams with the matplotlib-venn package.
Wrapper with pre-set defaults for creating venn diagrams with the matplotlib-venn package github.com/konstantint/matplotlib-venn.
- Parameters:
set_1 (set) – First set of the venn diagram.
set_2 (set) – Second set of the venn diagram.
set_3 (set, or None, default = None) – If not None a three set venn diagram will be drawn, if None the two set venn diagram of
set_1
andset_2
will be drawn.labels (List[str], default = ["Set 1", "Set 2", "Set 3"]) – List of labels for the sets.
colors (List[str], default = ["#4361EE", "#4CC9F0", "#F72585"]) – List of valid colors to use for the venn circles.
alpha (float, default = 0.6) – Color opacity.
contour (bool, default = False) – If a contour should be drawn around venn circles.
linewidth (float, default = 0.5) – Linewidth of the contour.
title (str, default = "Venn Diagram") – Title of the venn diagram.
figsize (tuple of float, float, default = (10.0, 10.0)) – Width, height in inches.
filename_prefix (str, or None, default = None) – If given, plot will be saved with and without title in .png and .svg format with the given prefix.
- Returns:
The created figure and axis
from matplotlib.pyplot.subplots()
.- Return type:
tuple of matplotlib.figure.Figure, any
- Warns:
RuntimeWarning – If more labels or colors than sets are supplied.
- Raises:
IndexError – If less labels or colors than sets are supplied.
Examples
>>> from pyXLMS.plotting import venn >>> fig, ax = venn({"A", "B", "C"}, {"B", "C", "D", "E", "F"}, labels=["A", "F"], colors=["orange", "blue"])
>>> from pyXLMS.plotting import venn >>> fig, ax = venn({"A", "B", "C"}, {"B", "C", "D", "E", "F"}, {"F", "G"})
Module contents#
- pyXLMS.plotting.plot_score_distribution(
- data: List[Dict[str, Any]],
- bins: int = 25,
- density: bool = False,
- colors: List[str] = ['#00a087', '#3c5488', '#e64b35'],
- title: str = 'Target and Decoy Score Distribution',
- figsize: Tuple[float, float] = (16.0, 9.0),
- filename_prefix: str | None = None,
Plot the score distribution for a set of crosslink-spectrum-matches or crosslinks.
Plot the target-target, target-decoy, and decoy-decoy score distribution as a histogram for a set of crosslink-spectrum-matches or crosslinks.
- Parameters:
data (list of dict of str, any) – A list of crosslink-spectrum-matches or crosslinks.
bins (int, default = 25) – The number of equal-width bins in the histogram.
density (bool, default = False) – If True, draw and return a probability density: each bin will display the bin’s raw count divided by the total number of counts and the bin width, so that the area under the histogram integrates to 1.
colors (list of str, default = ["#00a087", "#3c5488", "#e64b35"]) – Colors of the histogram lines.
title (str, default = "Target and Decoy Score Distribution") – The title of the histogram.
figsize (tuple of float, float, default = (16.0, 9.0)) – Width, height in inches.
filename_prefix (str, or None) – If given, plot will be saved with and without title in .png and .svg format with the given prefix.
- Returns:
The created figure and axis
from matplotlib.pyplot.subplots()
.- Return type:
tuple of matplotlib.figure.Figure, any
- Raises:
TypeError – If a wrong data type is provided.
ValueError – If parameter data does not contain any crosslink-spectrum-matches or crosslinks.
ValueError – If attribute ‘score’, ‘alpha_decoy’, or ‘beta_decoy’ is not available for any of the data.
Examples
>>> from pyXLMS import parser >>> from pyXLMS import plotting >>> pr = parser.read_msannika("data/ms_annika/XLpeplib_Beveridge_QEx-HFX_DSS_R1_CSMs.xlsx") >>> csms = pr["crosslink-spectrum-matches"] >>> fig, ax = plotting.plot_score_distribution(csms)
- pyXLMS.plotting.plot_venn_diagram(
- data_1: List[Dict[str, Any]],
- data_2: List[Dict[str, Any]],
- data_3: List[Dict[str, Any]] | None = None,
- by: Literal['peptide', 'protein'] = 'peptide',
- labels: List[str] = ['Set 1', 'Set 2', 'Set 3'],
- colors: List[str] = ['#4361EE', '#4CC9F0', '#F72585'],
- alpha: float = 0.6,
- contour: bool = False,
- linewidth: float = 0.5,
- title: str = 'Venn Diagram',
- figsize: Tuple[float, float] = (10.0, 10.0),
- filename_prefix: str | None = None,
Plot the venn diagram for two or three sets of crosslink-spectrum-matches or crosslinks.
Plot the venn diagram for two or three sets of crosslink-spectrum-matches or crosslinks. Overlaps are calculated by either looking at peptide sequence and crosslink position in the peptide using parameter by = “peptide” or by looking at protein crosslink position by using parameter by = “protein”.
- Parameters:
data_1 (list of dict of str, any) – A list of crosslink-spectrum-matches or crosslinks.
data_2 (list of dict of str, any) – A list of crosslink-spectrum-matches or crosslinks.
data_3 (list of dict of str, any, or None, default = None) – Optionally, a third list of crosslink-spectrum-matches or crosslinks.
by (str, one of "peptide" or "protein") – If peptide or protein crosslink position should be used for determining if a crosslink-spectrum-match or crosslink is unique.
labels (List[str], default = ["Set 1", "Set 2", "Set 3"]) – List of labels for the sets.
colors (List[str], default = ["#4361EE", "#4CC9F0", "#F72585"]) – List of valid colors to use for the venn circles.
alpha (float, default = 0.6) – Color opacity.
contour (bool, default = False) – If a contour should be drawn around venn circles.
linewidth (float, default = 0.5) – Linewidth of the contour.
title (str, default = "Venn Diagram") – Title of the venn diagram.
figsize (tuple of float, float, default = (10.0, 10.0)) – Width, height in inches.
filename_prefix (str, or None, default = None) – If given, plot will be saved with and without title in .png and .svg format with the given prefix.
- Returns:
The created figure and axis
from matplotlib.pyplot.subplots()
.- Return type:
tuple of matplotlib.figure.Figure, any
- Raises:
TypeError – If a wrong data type is provided.
TypeError – If parameter by is not one of ‘peptide’ or ‘protein’.
ValueError – If one of the data parameters does not contain any crosslink-spectrum-matches or crosslinks.
ValueError – If attribute ‘alpha_proteins’, ‘alpha_proteins_crosslink_positions’, ‘beta_proteins’, or ‘beta_proteins_crosslink_positions’ is not available for any of the data and parameter ‘by’ was set to ‘protein’.
Examples
>>> from pyXLMS import parser >>> from pyXLMS import plotting >>> a = parser.read("data/ms_annika/XLpeplib_Beveridge_QEx-HFX_DSS_R1_CSMs.txt", engine="MS Annika", crosslinker="DSS") >>> a = a["crosslink-spectrum-matches"] >>> b = parser.read("data/maxquant/run1/crosslinkMsms.txt", engine="MaxQuant", crosslinker="DSS") >>> b = b["crosslink-spectrum-matches"] >>> fig, ax = plotting.plot_venn_diagram(a, b, labels=["MS Annika", "MaxQuant"], colors=["orange", "blue"])
>>> from pyXLMS import parser >>> from pyXLMS import plotting >>> a = parser.read("data/ms_annika/XLpeplib_Beveridge_QEx-HFX_DSS_R1_CSMs.txt", engine="MS Annika", crosslinker="DSS") >>> a = a["crosslink-spectrum-matches"] >>> b = parser.read("data/maxquant/run1/crosslinkMsms.txt", engine="MaxQuant", crosslinker="DSS") >>> b = b["crosslink-spectrum-matches"] >>> c = parser.read("data/plink2/Cas9_plus10_2024.06.20.filtered_cross-linked_spectra.csv", engine="pLink", crosslinker="DSS") >>> c = c["crosslink-spectrum-matches"] >>> fig, ax = plotting.plot_venn_diagram(a, b, c, labels=["MS Annika", "MaxQuant", "pLink"], contour=True)
- pyXLMS.plotting.venn(
- set_1: Set[Any],
- set_2: Set[Any],
- set_3: Set[Any] | None = None,
- labels: List[str] = ['Set 1', 'Set 2', 'Set 3'],
- colors: List[str] = ['#4361EE', '#4CC9F0', '#F72585'],
- alpha: float = 0.6,
- contour: bool = False,
- linewidth: float = 0.5,
- title: str = 'Venn Diagram',
- figsize: Tuple[float, float] = (10.0, 10.0),
- filename_prefix: str | None = None,
Wrapper with pre-set defaults for creating venn diagrams with the matplotlib-venn package.
Wrapper with pre-set defaults for creating venn diagrams with the matplotlib-venn package github.com/konstantint/matplotlib-venn.
- Parameters:
set_1 (set) – First set of the venn diagram.
set_2 (set) – Second set of the venn diagram.
set_3 (set, or None, default = None) – If not None a three set venn diagram will be drawn, if None the two set venn diagram of
set_1
andset_2
will be drawn.labels (List[str], default = ["Set 1", "Set 2", "Set 3"]) – List of labels for the sets.
colors (List[str], default = ["#4361EE", "#4CC9F0", "#F72585"]) – List of valid colors to use for the venn circles.
alpha (float, default = 0.6) – Color opacity.
contour (bool, default = False) – If a contour should be drawn around venn circles.
linewidth (float, default = 0.5) – Linewidth of the contour.
title (str, default = "Venn Diagram") – Title of the venn diagram.
figsize (tuple of float, float, default = (10.0, 10.0)) – Width, height in inches.
filename_prefix (str, or None, default = None) – If given, plot will be saved with and without title in .png and .svg format with the given prefix.
- Returns:
The created figure and axis
from matplotlib.pyplot.subplots()
.- Return type:
tuple of matplotlib.figure.Figure, any
- Warns:
RuntimeWarning – If more labels or colors than sets are supplied.
- Raises:
IndexError – If less labels or colors than sets are supplied.
Examples
>>> from pyXLMS.plotting import venn >>> fig, ax = venn({"A", "B", "C"}, {"B", "C", "D", "E", "F"}, labels=["A", "F"], colors=["orange", "blue"])
>>> from pyXLMS.plotting import venn >>> fig, ax = venn({"A", "B", "C"}, {"B", "C", "D", "E", "F"}, {"F", "G"})