plot_protein_pca#
- RAPDOR.plots.plot_protein_pca(rapdordata, highlight=None, hovername: str = None, cutoff_range=None, cutoff_type=None, colors: Iterable = ('rgb(138, 255, 172)', 'rgb(255, 138, 221)'))#
Plots a 2D PCA (Principal Component Analysis) scatter plot for protein data.
- Parameters:
rapdordata – An object containing protein PCA data. Must have the attributes: - df: A pandas DataFrame with PCA coordinates and metadata. - pca_var: A sequence with explained variances for PC1 and PC2.
highlight (iterable, optional) – A list or set of RAPDOR IDs to highlight in the plot. Highlighted points will be styled differently.
hovername (str, optional) – Name of the column in rapdordata.df to append to hover text.
cutoff_range (tuple, optional) – A tuple (min, max) specifying a numeric filter range. Used to subset the data based on values in the cutoff_type column.
cutoff_type (str, optional) – Name of the column in rapdordata.df used for filtering via cutoff_range. Must be provided if cutoff_range is set.
colors (Iterable, optional) – An iterable of two color values (e.g., hex strings). First color is used for non-highlighted points, second for highlighted points. Defaults to COLOR_SCHEMES[“Flamingo”].
- Returns:
A Plotly scatter plot figure showing the PCA projection.
- Return type:
plotly.graph_objects.Figure
- Raises:
AssertionError – If cutoff_range is provided without cutoff_type.
Example
fig = plot_protein_pca(rapdordata, highlight=[“P12345”], hovername=”gene_name”, cutoff_range=(0, 1), cutoff_type=”q_value”) fig.show()