@@ -22,7 +22,50 @@ def plot_condition_factors(
2222 color_key = None ,
2323 group_cond = False ,
2424):
25- """Plots condition factors"""
25+ """Plot condition factors as a heatmap showing how conditions contribute to components.
26+
27+ This visualization shows how each experimental condition (rows) contributes to
28+ each RISE component (columns). High values indicate strong association between
29+ a condition and a component's pattern. Log transformation and normalization
30+ help reveal relative differences across conditions.
31+
32+ Parameters
33+ ----------
34+ data : anndata.AnnData
35+ AnnData object with RISE decomposition results. Must contain:
36+ - data.uns["Pf2_A"]: Condition factors (n_conditions, rank)
37+ - data.obs[cond]: Condition labels for each cell
38+ ax : matplotlib.axes.Axes
39+ Matplotlib axes object to plot on.
40+ cond : str, optional (default: "Condition")
41+ Name of column in data.obs containing condition labels.
42+ log_transform : bool, optional (default: True)
43+ If True, applies log10 transformation to condition factors before plotting.
44+ This helps visualize differences when values span orders of magnitude.
45+ cond_group_labels : pandas.Series, optional (default: None)
46+ Series mapping conditions to group labels for colored row annotations.
47+ Useful for grouping related conditions (e.g., drug classes, patient cohorts).
48+ ThomsonNorm : bool, optional (default: False)
49+ If True, normalizes factors using only control conditions (those containing 'CTRL').
50+ color_key : list, optional (default: None)
51+ Custom colors for condition group labels. If None, uses default palette.
52+ group_cond : bool, optional (default: False)
53+ If True and cond_group_labels provided, sorts conditions by group.
54+
55+ Examples
56+ --------
57+ >>> from RISE.figures.commonFuncs.plotFactors import plot_condition_factors
58+ >>> import matplotlib.pyplot as plt
59+ >>> fig, ax = plt.subplots(figsize=(8, 8))
60+ >>> plot_condition_factors(adata, ax=ax, cond="Condition", log_transform=True)
61+ >>> plt.tight_layout()
62+ >>> plt.show()
63+
64+ See Also
65+ --------
66+ plot_eigenstate_factors : Visualize eigen-state factors
67+ plot_gene_factors : Visualize gene factors
68+ """
2669 pd .set_option ("display.max_rows" , None )
2770 yt = pd .Series (np .unique (data .obs [cond ]))
2871 X = np .array (data .uns ["Pf2_A" ])
@@ -94,7 +137,36 @@ def plot_condition_factors(
94137
95138
96139def plot_eigenstate_factors (data : anndata .AnnData , ax : Axes ):
97- """Plots Pf2 eigenstate factors"""
140+ """Plot eigen-state factors as a heatmap showing cell state patterns.
141+
142+ Eigen-state factors represent the underlying cell state patterns across components.
143+ Each row represents an eigen-state (a summary of similar cells), and each column
144+ represents a component. High values indicate strong association between a cell
145+ state pattern and a component.
146+
147+ Parameters
148+ ----------
149+ data : anndata.AnnData
150+ AnnData object with RISE decomposition results. Must contain:
151+ - data.uns["Pf2_B"]: Eigen-state factors (rank, rank)
152+ ax : matplotlib.axes.Axes
153+ Matplotlib axes object to plot on.
154+
155+ Examples
156+ --------
157+ >>> from RISE.figures.commonFuncs.plotFactors import plot_eigenstate_factors
158+ >>> import matplotlib.pyplot as plt
159+ >>> fig, ax = plt.subplots(figsize=(4, 4))
160+ >>> plot_eigenstate_factors(adata, ax=ax)
161+ >>> ax.set_ylabel("Eigen-state")
162+ >>> plt.tight_layout()
163+ >>> plt.show()
164+
165+ See Also
166+ --------
167+ plot_condition_factors : Visualize condition factors
168+ plot_gene_factors : Visualize gene factors
169+ """
98170 rank = data .uns ["Pf2_B" ].shape [1 ]
99171 xticks = np .arange (1 , rank + 1 )
100172 X = data .uns ["Pf2_B" ]
@@ -115,7 +187,40 @@ def plot_eigenstate_factors(data: anndata.AnnData, ax: Axes):
115187
116188
117189def plot_gene_factors (data : anndata .AnnData , ax : Axes , weight = 0.08 , trim = True ):
118- """Plots Pf2 gene factors"""
190+ """Plot gene factors as a heatmap showing which genes contribute to each component.
191+
192+ This visualization reveals coordinated gene modules by showing which genes (rows)
193+ are highly weighted in each component (columns). The weight parameter filters out
194+ genes with low contributions, focusing on the most important genes for interpretation.
195+
196+ Parameters
197+ ----------
198+ data : anndata.AnnData
199+ AnnData object with RISE decomposition results. Must contain:
200+ - data.varm["Pf2_C"]: Gene factors (n_genes, rank)
201+ ax : matplotlib.axes.Axes
202+ Matplotlib axes object to plot on.
203+ weight : float, optional (default: 0.08)
204+ Minimum absolute weight threshold for including genes. Genes with maximum
205+ absolute weight below this value across all components are filtered out.
206+ Higher values show fewer, more important genes.
207+ trim : bool, optional (default: True)
208+ If True, filters genes based on the weight parameter. If False, shows all genes.
209+
210+ Examples
211+ --------
212+ >>> from RISE.figures.commonFuncs.plotFactors import plot_gene_factors
213+ >>> import matplotlib.pyplot as plt
214+ >>> fig, ax = plt.subplots(figsize=(7, 8))
215+ >>> plot_gene_factors(adata, ax=ax, weight=0.2, trim=True)
216+ >>> plt.tight_layout()
217+ >>> plt.show()
218+
219+ See Also
220+ --------
221+ plot_condition_factors : Visualize condition factors
222+ plot_gene_pacmap : Overlay gene expression on PaCMAP
223+ """
119224 rank = data .varm ["Pf2_C" ].shape [1 ]
120225 X = np .array (data .varm ["Pf2_C" ])
121226 yt = data .var .index .values
0 commit comments