Skip to content

Commit 565845c

Browse files
committed
Refactor plotting code
1 parent 2e1c007 commit 565845c

30 files changed

Lines changed: 133 additions & 137 deletions

‎RISE/figures/__init__.py‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎RISE/figures/common.py‎

Lines changed: 0 additions & 61 deletions
This file was deleted.

‎RISE/figures/commonFuncs/__init__.py‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎RISE/plotting/__init__.py‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
Plotting and visualization functions for RISE.
3+
"""
4+
5+
from .factors import (
6+
plot_condition_factors,
7+
plot_eigenstate_factors,
8+
plot_gene_factors,
9+
)
10+
from .general import (
11+
avegene_per_status,
12+
cell_count_perc_df,
13+
cell_count_perc_lupus_df,
14+
gene_plot_cells,
15+
plot_avegene_per_category,
16+
plot_avegene_per_celltype,
17+
plot_cell_gene_corr,
18+
plot_r2x,
19+
rotate_xaxis,
20+
rotate_yaxis,
21+
)
22+
from .pacmap import (
23+
plot_gene_pacmap,
24+
plot_labels_pacmap,
25+
plot_wp_pacmap,
26+
)
27+
from .stability import (
28+
calculateFMS,
29+
plot_fms_diff_ranks,
30+
plot_fms_percent_drop,
31+
)
32+
33+
__all__ = [
34+
"plot_condition_factors",
35+
"plot_eigenstate_factors",
36+
"plot_gene_factors",
37+
"avegene_per_status",
38+
"cell_count_perc_df",
39+
"cell_count_perc_lupus_df",
40+
"gene_plot_cells",
41+
"plot_avegene_per_category",
42+
"plot_avegene_per_celltype",
43+
"plot_cell_gene_corr",
44+
"plot_r2x",
45+
"rotate_xaxis",
46+
"rotate_yaxis",
47+
"plot_gene_pacmap",
48+
"plot_labels_pacmap",
49+
"plot_wp_pacmap",
50+
"calculateFMS",
51+
"plot_fms_diff_ranks",
52+
"plot_fms_percent_drop",
53+
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import seaborn as sns
55
from matplotlib.axes import Axes
66

7-
from ...factorization import rise_pca_r2x
7+
from ..factorization import rise_pca_r2x
88

99

1010
def plot_r2x(data, rank_vec, ax: Axes):
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def plot_gene_pacmap(gene: str, X: anndata.AnnData, ax: Axes, clip_outliers=0.99
7575
points = np.array(X.obsm["X_pf2_PaCMAP"])
7676

7777
canvas = _get_canvas(points)
78-
data = pd.DataFrame(points, columns=("x", "y"))
78+
data = pd.DataFrame(points, columns=["x", "y"]) # type: ignore
7979

8080
values -= np.min(values)
8181
values /= np.max(values)
@@ -126,7 +126,7 @@ def plot_wp_pacmap(X: anndata.AnnData, cmp: int, ax: Axes, cbarMax: float = 1.0)
126126
cmap = sns.diverging_palette(240, 10, as_cmap=True)
127127

128128
canvas = _get_canvas(points)
129-
data = pd.DataFrame(points, columns=("x", "y"))
129+
data = pd.DataFrame(points, columns=["x", "y"]) # type: ignore
130130

131131
values /= np.max(np.abs(values))
132132

@@ -195,7 +195,7 @@ def plot_labels_pacmap(
195195
labels = labels.iloc[indices]
196196

197197
canvas = _get_canvas(points)
198-
data = pd.DataFrame(points, columns=("x", "y"))
198+
data = pd.DataFrame(points, columns=["x", "y"]) # type: ignore
199199

200200
data["label"] = pd.Categorical(labels)
201201
aggregation = canvas.points(data, "x", "y", agg=ds.count_cat("label"))
Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Figure S4
2+
Decomposition stability analysis and plotting functions.
33
"""
44

55
import anndata
@@ -12,26 +12,9 @@
1212
from tlviz.factor_tools import factor_match_score as fms
1313

1414
from ..factorization import pf2
15-
from .common import getSetup, subplotLabel
1615

17-
# from ..imports import import_thomson
1816

19-
20-
def makeFigure():
21-
ax, f = getSetup((6, 3), (1, 2))
22-
subplotLabel(ax)
23-
24-
# X = import_thomson()
25-
# percentList = np.arange(0.0, 8.0, 5.0)
26-
# plot_fms_percent_drop(X, ax[0], percentList=percentList, runs=3)
27-
28-
# ranks = list(range(1, 3))
29-
# plot_fms_diff_ranks(X, ax[1], ranksList=ranks, runs=3)
30-
31-
return f
32-
33-
34-
def calculateFMS(A: anndata.AnnData, B: anndata.AnnData):
17+
def calculateFMS(A: anndata.AnnData, B: anndata.AnnData) -> float:
3518
"""Calculate Factor Match Score (FMS) between two RISE decompositions.
3619
3720
Factor Match Score measures the similarity between two tensor decompositions
@@ -80,7 +63,7 @@ def calculateFMS(A: anndata.AnnData, B: anndata.AnnData):
8063
)
8164
)
8265

83-
return fms(A_CP, B_CP, consider_weights=False, skip_mode=1) # type: ignore
66+
return fms(A_CP, B_CP, consider_weights=False, skip_mode=1)
8467

8568

8669
def plot_fms_percent_drop(

‎analysis/figures/commonFuncs/plotLupus.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
predaccuracy_ranks_lupus,
1111
roc_lupus_fourtbatch,
1212
)
13-
from RISE.figures.commonFuncs.plotGeneral import cell_count_perc_lupus_df
13+
from RISE.plotting import cell_count_perc_lupus_df
1414

1515

1616
def samples_only_lupus(X: anndata.AnnData):

0 commit comments

Comments
 (0)