Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

53 docs viz ii #62

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading