Skip to content

Commit

Permalink
Merge pull request #62 from MannLabs/53-docs-viz-ii
Browse files Browse the repository at this point in the history
53 docs viz ii
  • Loading branch information
jalew188 authored Jun 18, 2024
2 parents 39fed08 + 113fba5 commit 8d6534c
Showing 1 changed file with 107 additions and 7 deletions.
114 changes: 107 additions & 7 deletions alpharaw/viz/xic_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@


class XIC_Plot:
# hovermode = "x" | "y" | "closest" | False | "x unified" | "y unified"
"""
Only apply for 3D-MS, i.e. without mobility
"""

hovermode = "closest"
"""
hovermode = "x", "y", "closest", False, "x unified", "y unified"
"""

plot_height = 550
colorscale_qualitative = "Alphabet"
colorscale_sequential = "Viridis"
Expand All @@ -33,10 +40,6 @@ class XIC_Plot:
# list of XIC_Trace objects
traces: list = []

"""
Only apply for 3D-MS, i.e. without mobility
"""

def plot(
self,
spectrum_df: pd.DataFrame,
Expand All @@ -47,7 +50,37 @@ def plot(
create_new_fig=True,
plot_rows=1,
ith_plot_row=0,
):
) -> go.Figure:
"""
Main entry of `XIC_Plot`.
Parameters
----------
spectrum_df : pd.DataFrame
The spectrum dataframe in alpharaw format
peak_df : pd.DataFrame
The peak dataframe in alpharaw format
query_df : pd.DataFrame
The query dataframe generated by:
:func:`alpharaw.viz.df_utils.make_query_df_for_peptide`, or
:func:`alpharaw.viz.df_utils.make_query_df`
title : str, optional
Plot title, by default ""
add_peak_area : bool, optional
If add peak area in the hover text, by default False
create_new_fig : bool, optional
If create a new figure, otherwise plot in `self.fig`, by default True
plot_rows : int, optional
If create_new_fig, how many rows (subplots) to create, by default 1
ith_plot_row : int, optional
If not create_new_fig, this parameter refers to the row number
in `self.fig`, by default 0
Returns
-------
go.Figure
XIC plot figure
"""
if "rt_sec" in query_df.columns:
rt_sec = query_df.rt_sec.values[0]
else:
Expand Down Expand Up @@ -178,7 +211,47 @@ def plot_query_masses(
create_new_fig=True,
plot_rows=1,
ith_plot_row=0,
):
) -> go.Figure:
"""
The other entry of `XIC_Plot`
Parameters
----------
spectrum_df : pd.DataFrame
The spectrum dataframe in alpharaw format
peak_df : pd.DataFrame
The peak dataframe in alpharaw format
query_masses : np.ndarray
The query m/z values to extract XIC profiles
query_ion_names : typing.List[str]
The query ion names
query_rt_sec : float
RT in seconds
precursor_left_mz : float
Left m/z of precursor window for given queries to extract XIC
precursor_right_mz : float
Right m/z of precursor window for given queries to extract XIC
marker_colors : list, optional
Colors of each XIC profile, by default None
other_plot_infos : typing.List[str], optional
Other plot information for hover text, by default None
query_intensities : np.ndarray, optional
Query intensities for mirror plot, by default None
title : str, optional
Plot title, by default ""
create_new_fig : bool, optional
If create a new figure, otherwise plot in `self.fig`, by default True
plot_rows : int, optional
If create_new_fig, how many rows (subplots) to create, by default 1
ith_plot_row : int, optional
If not create_new_fig, this parameter refers to the row number
in `self.fig`, by default 0
Returns
-------
go.Figure
XIC plot figure
"""
if create_new_fig:
self._init_plot(rows=plot_rows)
mass_tols = (
Expand Down Expand Up @@ -391,6 +464,33 @@ def get_peak_area(
precursor_left_mz: float = -1.0,
precursor_right_mz: float = -1.0,
) -> np.ndarray:
"""
Get peak area values for each of query in `query_masses`
Parameters
----------
spectrum_df : pd.DataFrame
The spectrum dataframe
peak_df : pd.DataFrame
The peak dataframe
query_masses : np.ndarray
The query m/z values
mass_tols : np.ndarray
The query m/z tolerance in Da
query_start_rt_sec : float
Start RT in seconds
query_stop_rt_sec : float
Stop RT in seconds
precursor_left_mz : float
Left m/z of precursor window for given queries to extract XIC
precursor_right_mz : float
Right m/z of precursor window for given queries to extract XIC
Returns
-------
np.ndarray
peak area values for each of query
"""
spec_idxes = get_spec_idxes_from_df(
spectrum_df,
query_start_rt_sec=query_start_rt_sec,
Expand Down

0 comments on commit 8d6534c

Please sign in to comment.