cytocommunity2 0.1.6__tar.gz → 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cytocommunity2-0.1.6/src/cytocommunity2.egg-info → cytocommunity2-0.1.7}/PKG-INFO +1 -1
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/pyproject.toml +1 -1
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/__init__.py +1 -1
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/dominant.py +1 -4
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/recurrence.py +76 -6
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7/src/cytocommunity2.egg-info}/PKG-INFO +1 -1
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/LICENSE +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/README.md +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/setup.cfg +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/colors.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/config.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/__init__.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/coherence.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/communication/__init__.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/communication/between.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/communication/cca.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/communication/utils.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/communication/within.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/differential_composition.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/dominant_celltype.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/moran.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/__init__.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/cn_selection.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/coherence.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/common.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/communication.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/composition.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/dotplots.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/runtime.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/ensemble.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/learning/__init__.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/learning/api.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/learning/dataset.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/learning/model.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/learning/selection.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/learning/training.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/paths.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/visualization/__init__.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/visualization/spatial.py +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2.egg-info/SOURCES.txt +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2.egg-info/dependency_links.txt +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2.egg-info/requires.txt +0 -0
- {cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2.egg-info/top_level.txt +0 -0
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/dominant.py
RENAMED
|
@@ -53,10 +53,7 @@ def plot_dominant_celltype_results(result, config):
|
|
|
53
53
|
label.set_horizontalalignment("right")
|
|
54
54
|
heat_axis.tick_params(axis="x", length=0, bottom=True, top=False, labelbottom=True)
|
|
55
55
|
heat_axis.tick_params(axis="y", length=0, pad=6)
|
|
56
|
-
heat_axis.
|
|
57
|
-
heat_axis.set_yticks(np.arange(-0.5, rows, 1), minor=True)
|
|
58
|
-
heat_axis.grid(which="minor", color="white", linewidth=0.35)
|
|
59
|
-
heat_axis.tick_params(which="minor", bottom=False, left=False)
|
|
56
|
+
heat_axis.grid(False, which="both")
|
|
60
57
|
for spine in heat_axis.spines.values():
|
|
61
58
|
spine.set_visible(False)
|
|
62
59
|
heatmap_output = output_dir / "heatmap_main.pdf"
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/recurrence.py
RENAMED
|
@@ -8,6 +8,8 @@ from ...paths import build_paths
|
|
|
8
8
|
|
|
9
9
|
NULL_LABEL = "Random-CN null distribution"
|
|
10
10
|
NULL_COLOR = "#0071B2"
|
|
11
|
+
CN_PALETTE = "d3_category20"
|
|
12
|
+
DENSITY_NULL_COLOR = "#B8B8B8"
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
def _significance_label(pvalue):
|
|
@@ -28,11 +30,11 @@ def _kde_curve(values, x_grid):
|
|
|
28
30
|
if len(values) == 0:
|
|
29
31
|
return np.zeros_like(x_grid)
|
|
30
32
|
if np.allclose(values, values[0]):
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
33
|
+
# gaussian_kde cannot estimate a singular distribution. Draw a narrow,
|
|
34
|
+
# finite kernel so a constant-valued CN still remains visible.
|
|
35
|
+
bandwidth = 0.04
|
|
36
|
+
scaled = (x_grid - values[0]) / bandwidth
|
|
37
|
+
return np.exp(-0.5 * scaled**2) / (bandwidth * np.sqrt(2 * np.pi))
|
|
36
38
|
try:
|
|
37
39
|
return gaussian_kde(values)(x_grid)
|
|
38
40
|
except Exception:
|
|
@@ -40,8 +42,21 @@ def _kde_curve(values, x_grid):
|
|
|
40
42
|
return np.interp(x_grid, (edges[:-1] + edges[1:]) / 2, hist, left=0, right=0)
|
|
41
43
|
|
|
42
44
|
|
|
45
|
+
def _cn_color_map(cn_levels):
|
|
46
|
+
"""Return the same CN-to-color mapping used by the spatial CN plots."""
|
|
47
|
+
import sci_palettes
|
|
48
|
+
|
|
49
|
+
colors = list(sci_palettes.PALETTES[CN_PALETTE].values())
|
|
50
|
+
if len(cn_levels) > len(colors):
|
|
51
|
+
raise ValueError(
|
|
52
|
+
f"Palette {CN_PALETTE!r} has {len(colors)} colors, but "
|
|
53
|
+
f"{len(cn_levels)} CNs were provided."
|
|
54
|
+
)
|
|
55
|
+
return dict(zip(cn_levels, colors))
|
|
56
|
+
|
|
57
|
+
|
|
43
58
|
def plot_recurrence_results(config):
|
|
44
|
-
"""Save
|
|
59
|
+
"""Save recurrence violin/KDE figures, including per-CN densities."""
|
|
45
60
|
import matplotlib as mpl
|
|
46
61
|
import matplotlib.pyplot as plt
|
|
47
62
|
import seaborn as sns
|
|
@@ -196,8 +211,63 @@ def plot_recurrence_results(config):
|
|
|
196
211
|
kde_output = output_dir / "Overall_Real_vs_randomCN_null_KDE.pdf"
|
|
197
212
|
figure.savefig(kde_output, dpi=1200)
|
|
198
213
|
plt.close(figure)
|
|
214
|
+
|
|
215
|
+
cn_colors = _cn_color_map(cn_levels)
|
|
216
|
+
null_density = _kde_curve(background_values, x_grid)
|
|
217
|
+
figure, axis = plt.subplots(figsize=(8.4, 5.8))
|
|
218
|
+
axis.fill_between(
|
|
219
|
+
x_grid, 0, null_density, color=DENSITY_NULL_COLOR, alpha=0.18, zorder=0
|
|
220
|
+
)
|
|
221
|
+
axis.plot(
|
|
222
|
+
x_grid,
|
|
223
|
+
null_density,
|
|
224
|
+
color=DENSITY_NULL_COLOR,
|
|
225
|
+
linewidth=2.2,
|
|
226
|
+
linestyle="--",
|
|
227
|
+
label="Null distribution",
|
|
228
|
+
zorder=1,
|
|
229
|
+
)
|
|
230
|
+
for cn in cn_levels:
|
|
231
|
+
values = real.loc[real["CN"] == cn, "OverlapCoefficient"].to_numpy()
|
|
232
|
+
density = _kde_curve(values, x_grid)
|
|
233
|
+
color = cn_colors[cn]
|
|
234
|
+
axis.fill_between(x_grid, 0, density, color=color, alpha=0.09, zorder=2)
|
|
235
|
+
axis.plot(x_grid, density, color=color, linewidth=2.0, label=cn, zorder=3)
|
|
236
|
+
|
|
237
|
+
axis.set_xlabel("Overlap of dominant celltypes across samples")
|
|
238
|
+
axis.set_ylabel("Density")
|
|
239
|
+
axis.set_xlim(0, 1)
|
|
240
|
+
axis.set_ylim(bottom=0)
|
|
241
|
+
axis.spines["top"].set_visible(False)
|
|
242
|
+
axis.spines["right"].set_visible(False)
|
|
243
|
+
handles, labels = axis.get_legend_handles_labels()
|
|
244
|
+
legend_columns = min(6, len(labels))
|
|
245
|
+
legend_order = [
|
|
246
|
+
index
|
|
247
|
+
for column in range(legend_columns)
|
|
248
|
+
for index in (column, legend_columns + column)
|
|
249
|
+
if index < len(labels)
|
|
250
|
+
]
|
|
251
|
+
axis.legend(
|
|
252
|
+
[handles[index] for index in legend_order],
|
|
253
|
+
[labels[index] for index in legend_order],
|
|
254
|
+
frameon=False,
|
|
255
|
+
ncol=legend_columns,
|
|
256
|
+
loc="upper center",
|
|
257
|
+
bbox_to_anchor=(0.5, -0.17),
|
|
258
|
+
columnspacing=1.25,
|
|
259
|
+
handlelength=2.0,
|
|
260
|
+
)
|
|
261
|
+
figure.subplots_adjust(left=0.12, right=0.98, bottom=0.25, top=0.96)
|
|
262
|
+
by_cn_density_output = output_dir / "OC_density_by_CN_with_randomCN_null.pdf"
|
|
263
|
+
figure.savefig(by_cn_density_output, dpi=1200, bbox_inches="tight")
|
|
264
|
+
figure.savefig(
|
|
265
|
+
by_cn_density_output.with_suffix(".png"), dpi=300, bbox_inches="tight"
|
|
266
|
+
)
|
|
267
|
+
plt.close(figure)
|
|
199
268
|
return {
|
|
200
269
|
"by_cn": detailed_output,
|
|
201
270
|
"pooled": pooled_output,
|
|
202
271
|
"kde": kde_output,
|
|
272
|
+
"by_cn_density": by_cn_density_output,
|
|
203
273
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/communication/between.py
RENAMED
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/communication/cca.py
RENAMED
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/communication/utils.py
RENAMED
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/communication/within.py
RENAMED
|
File without changes
|
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/dominant_celltype.py
RENAMED
|
File without changes
|
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/__init__.py
RENAMED
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/cn_selection.py
RENAMED
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/coherence.py
RENAMED
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/common.py
RENAMED
|
File without changes
|
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/composition.py
RENAMED
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2/downstream/plotting/dotplots.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cytocommunity2-0.1.6 → cytocommunity2-0.1.7}/src/cytocommunity2.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|