cellestial 1.0.1__tar.gz → 1.0.2__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.
Files changed (72) hide show
  1. {cellestial-1.0.1 → cellestial-1.0.2}/PKG-INFO +3 -3
  2. {cellestial-1.0.1 → cellestial-1.0.2}/README.md +2 -2
  3. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/complex/annotated_heatmap.py +2 -2
  4. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/frames/_container.py +6 -4
  5. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/frames/build.py +2 -2
  6. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/heatmap/heatmap.py +17 -7
  7. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/heatmap/utilities.py +16 -7
  8. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/util/operations.py +1 -3
  9. {cellestial-1.0.1 → cellestial-1.0.2}/pyproject.toml +5 -2
  10. {cellestial-1.0.1 → cellestial-1.0.2}/LICENSE +0 -0
  11. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/__init__.py +0 -0
  12. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/_version.py +0 -0
  13. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/complex/__init__.py +0 -0
  14. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/datasets/__init__.py +0 -0
  15. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/datasets/datasets.py +0 -0
  16. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/errors.py +0 -0
  17. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/frames/__init__.py +0 -0
  18. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/frames/operations.py +0 -0
  19. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/layers/__init__.py +0 -0
  20. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/layers/_deferred.py +0 -0
  21. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/layers/arrow.py +0 -0
  22. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/layers/bracket.py +0 -0
  23. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/layers/highlight.py +0 -0
  24. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/layers/ondata_legend.py +0 -0
  25. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/layers/outline.py +0 -0
  26. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/layers/stream.py +0 -0
  27. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/layers/utilities.py +0 -0
  28. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/__init__.py +0 -0
  29. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/base/__init__.py +0 -0
  30. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/base/base.py +0 -0
  31. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/basic/__init__.py +0 -0
  32. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/basic/bar.py +0 -0
  33. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/basic/scatter.py +0 -0
  34. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/common/__init__.py +0 -0
  35. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/common/xyplot.py +0 -0
  36. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/common/xyplots.py +0 -0
  37. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/core/__init__.py +0 -0
  38. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/core/blend.py +0 -0
  39. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/core/dimensional.py +0 -0
  40. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/core/distribution.py +0 -0
  41. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/core/distributions.py +0 -0
  42. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/core/embedding_density.py +0 -0
  43. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/core/subdimensional.py +0 -0
  44. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/core/subdimensionals.py +0 -0
  45. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/core/utilities.py +0 -0
  46. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/differential/__init__.py +0 -0
  47. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/differential/markers.py +0 -0
  48. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/differential/utilities.py +0 -0
  49. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/differential/volcano.py +0 -0
  50. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/heatmap/__init__.py +0 -0
  51. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/heatmap/dotplot.py +0 -0
  52. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/heatmap/stacked_violin.py +0 -0
  53. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/heatmap/tracksplot.py +0 -0
  54. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/quick/__init__.py +0 -0
  55. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/quick/elbow.py +0 -0
  56. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/quick/highest.py +0 -0
  57. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/single/quick/ridge.py +0 -0
  58. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/spatial/__init__.py +0 -0
  59. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/spatial/spatial.py +0 -0
  60. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/spatial/spatials.py +0 -0
  61. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/spatial/utilities.py +0 -0
  62. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/themes/__init__.py +0 -0
  63. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/themes/_distributions.py +0 -0
  64. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/themes/_heatmaps.py +0 -0
  65. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/themes/_scatters.py +0 -0
  66. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/util/__init__.py +0 -0
  67. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/util/colors.py +0 -0
  68. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/util/dendrogram.py +0 -0
  69. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/util/errors.py +0 -0
  70. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/util/markers.py +0 -0
  71. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/util/save.py +0 -0
  72. {cellestial-1.0.1 → cellestial-1.0.2}/cellestial/util/utilities.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cellestial
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Interactive single-cell and spatial omics visualization library
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -42,14 +42,14 @@ Description-Content-Type: text/markdown
42
42
  [![codecov](https://codecov.io/gh/datavil/cellestial/branch/master/graph/badge.svg)](https://codecov.io/gh/datavil/cellestial)
43
43
  [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-ff0000)](https://opensource.org/licenses/Apache-2.0)
44
44
  [![Powered by Polars](https://img.shields.io/badge/Powered%20by-Polars-377eb8?logo=polars&logoColor=white)](https://www.pola.rs/)
45
- [![Graphics: Lets-Plot](https://img.shields.io/badge/Graphics-Lets--Plot-FF00CC?logo=jetbrains&logoColor=white)](https://lets-plot.org/)
45
+ [![Graphics: ggrust](https://img.shields.io/badge/Graphics-ggrust-FF00CC?logo=rust&logoColor=white)](https://ggrust.datavil.org/)
46
46
  [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.21710311.svg)](https://doi.org/10.5281/zenodo.21710311)
47
47
 
48
48
  <img align="left" src="https://raw.githubusercontent.com/datavil/cellestial/master/assets/cellestial.anim.svg" alt="Cellestial Logo" width="280">
49
49
 
50
50
  The __Grammar of Graphics__ for single-cell omics.
51
51
 
52
- __Cellestial__ is an interactive and a highly customizable _Single-Cell_ & _Spatial_ omics data visualization library. Built on top [Lets-Plot](https://lets-plot.org/), it offers a ggplot-like layered and modular approach offering __high customizability__ and __publication-ready figures__.
52
+ __Cellestial__ is an interactive and a highly customizable _Single-Cell_ & _Spatial_ omics data visualization library. Built on top of [ggrust](https://ggrust.datavil.org/) (a Rust implementation of ggplot2), it offers a ggplot-like layered and modular approach offering __high customizability__ and __publication-ready figures__.
53
53
 
54
54
  Cellestial is highly integrated with scverse's [AnnData](https://github.com/scverse/anndata) with room for integration with any upcoming single-cell omics data type in the Python single-cell omics ecosystem.
55
55
 
@@ -5,14 +5,14 @@
5
5
  [![codecov](https://codecov.io/gh/datavil/cellestial/branch/master/graph/badge.svg)](https://codecov.io/gh/datavil/cellestial)
6
6
  [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-ff0000)](https://opensource.org/licenses/Apache-2.0)
7
7
  [![Powered by Polars](https://img.shields.io/badge/Powered%20by-Polars-377eb8?logo=polars&logoColor=white)](https://www.pola.rs/)
8
- [![Graphics: Lets-Plot](https://img.shields.io/badge/Graphics-Lets--Plot-FF00CC?logo=jetbrains&logoColor=white)](https://lets-plot.org/)
8
+ [![Graphics: ggrust](https://img.shields.io/badge/Graphics-ggrust-FF00CC?logo=rust&logoColor=white)](https://ggrust.datavil.org/)
9
9
  [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.21710311.svg)](https://doi.org/10.5281/zenodo.21710311)
10
10
 
11
11
  <img align="left" src="https://raw.githubusercontent.com/datavil/cellestial/master/assets/cellestial.anim.svg" alt="Cellestial Logo" width="280">
12
12
 
13
13
  The __Grammar of Graphics__ for single-cell omics.
14
14
 
15
- __Cellestial__ is an interactive and a highly customizable _Single-Cell_ & _Spatial_ omics data visualization library. Built on top [Lets-Plot](https://lets-plot.org/), it offers a ggplot-like layered and modular approach offering __high customizability__ and __publication-ready figures__.
15
+ __Cellestial__ is an interactive and a highly customizable _Single-Cell_ & _Spatial_ omics data visualization library. Built on top of [ggrust](https://ggrust.datavil.org/) (a Rust implementation of ggplot2), it offers a ggplot-like layered and modular approach offering __high customizability__ and __publication-ready figures__.
16
16
 
17
17
  Cellestial is highly integrated with scverse's [AnnData](https://github.com/scverse/anndata) with room for integration with any upcoming single-cell omics data type in the Python single-cell omics ecosystem.
18
18
 
@@ -116,8 +116,8 @@ def _as_layers(layers: FeatureSpec | Sequence[FeatureSpec] | None) -> list[Featu
116
116
  if layers is None:
117
117
  return []
118
118
  if isinstance(layers, (list, tuple)):
119
- return list(layers) # ty:ignore[invalid-return-type]
120
- return [layers] # ty:ignore[invalid-return-type]
119
+ return list(layers)
120
+ return [layers] # ty:ignore[invalid-explicit-return]
121
121
 
122
122
 
123
123
  def _apply_layers(plot: PlotSpec, layers: Sequence[FeatureSpec]) -> PlotSpec:
@@ -251,7 +251,7 @@ class _Container:
251
251
  positions = self._data.var_names.get_indexer_for(list(keys))
252
252
  matrix = self._data.X[:, positions] # ty: ignore[not-subscriptable]
253
253
  if issparse(matrix):
254
- matrix = matrix.toarray() # ty:ignore[unresolved-attribute]
254
+ matrix = matrix.toarray() # ty:ignore[missing-union-attribute]
255
255
  else:
256
256
  matrix = np.asarray(matrix)
257
257
 
@@ -271,8 +271,9 @@ class _MuDataContainer(_Container):
271
271
 
272
272
  __slots__ = ()
273
273
 
274
- # Narrows the base declaration so `.mod` / `.obsmap` resolve.
275
- _data: MuData
274
+ # Narrows the base declaration so `.mod` / `.obsmap` resolve. Safe: `_data`
275
+ # is only assigned in `__init__`, which this subclass receives a MuData for.
276
+ _data: MuData # ty: ignore[incompatible-mutable-override]
276
277
 
277
278
  def modality_names(self) -> list[str]:
278
279
  return list(self._data.mod)
@@ -322,6 +323,7 @@ class _MuDataContainer(_Container):
322
323
  return column.removeprefix(prefix)
323
324
  if (
324
325
  column in self._data.obs.columns
326
+ and modality is not None
325
327
  and modality in self._data.mod
326
328
  and column in self._data.mod[modality].obs.columns
327
329
  ):
@@ -472,7 +474,7 @@ class _MuDataContainer(_Container):
472
474
  self._require_matrix(part, [name], f"modality `{modality}`")
473
475
  matrix = part.X[:, part.var_names.get_indexer_for([name])] # ty: ignore[not-subscriptable]
474
476
  if issparse(matrix):
475
- matrix = matrix.toarray() # ty:ignore[unresolved-attribute]
477
+ matrix = matrix.toarray() # ty:ignore[missing-union-attribute]
476
478
  values = np.asarray(matrix).reshape(-1)
477
479
 
478
480
  # `obsmap` holds 1-based positions into the modality, 0 meaning the
@@ -231,7 +231,7 @@ def _anndata_observations_frame(
231
231
 
232
232
  embedding = partm[X]
233
233
  if issparse(embedding):
234
- embedding = embedding[:, :column_count].toarray() # ty:ignore[unresolved-attribute]
234
+ embedding = embedding[:, :column_count].toarray() # ty:ignore[missing-attribute]
235
235
  for column_index in range(column_count):
236
236
  columns.append(
237
237
  pl.Series(f"{X.upper()}{column_index + 1}", embedding[:, column_index])
@@ -351,7 +351,7 @@ def _anndata_variables_frame(
351
351
 
352
352
  embedding = partm[X]
353
353
  if issparse(embedding):
354
- embedding = embedding[:, :column_count].toarray() # ty:ignore[unresolved-attribute]
354
+ embedding = embedding[:, :column_count].toarray() # ty:ignore[missing-attribute]
355
355
  for column_index in range(column_count):
356
356
  columns.append(
357
357
  pl.Series(f"{X.upper()}{column_index + 1}", embedding[:, column_index])
@@ -57,7 +57,7 @@ if TYPE_CHECKING:
57
57
  from ggrust.plot.core import FeatureSpec, PlotSpec
58
58
 
59
59
  _COLOR_BAR_LEGEND_SIZE = (70, 250) # pixels (width, height)
60
- _X_EXPAND = 0.05 # x axis padding on each side, as a fraction of the data range
60
+ _X_EXPAND = 0.05 # x axis padding on the left, as a fraction of the data range
61
61
 
62
62
 
63
63
  def heatmap(
@@ -438,7 +438,7 @@ def heatmap(
438
438
  frame.lazy().filter(pl.col(key).is_not_null()).select(group_by) for key in keys
439
439
  )
440
440
  .unique(maintain_order=True)
441
- .collect()[group_by] # ty: ignore[not-subscriptable]
441
+ .collect()[group_by]
442
442
  .cast(pl.String)
443
443
  .to_list()
444
444
  )
@@ -490,9 +490,6 @@ def heatmap(
490
490
  )
491
491
  htmp = ggplot(frame) + geom_layer + _THEME_HEATMAP
492
492
 
493
- # X scale: variable labels
494
- htmp += scale_x_continuous(breaks=list(range(n_x)), labels=x_keys, expand=[_X_EXPAND, 0])
495
-
496
493
  # Compute the edges of the data.
497
494
  data_bottom = -0.5
498
495
  data_top = n_y - 0.5
@@ -555,6 +552,20 @@ def heatmap(
555
552
  size=group_bars_size,
556
553
  )
557
554
 
555
+ # X scale: variable labels. Padded on the left only, so the last column meets
556
+ # whatever sits right of the panel (dendrogram, legend).
557
+ x_data_min = -0.5
558
+ if not aggregate and group_bars:
559
+ x_data_min = float(group_bar_frame["x"][0])
560
+ x_max_limit = n_x - 0.5
561
+ x_min_limit = x_data_min - _X_EXPAND * (x_max_limit - x_data_min)
562
+ htmp += scale_x_continuous(
563
+ breaks=list(range(n_x)),
564
+ labels=x_keys,
565
+ limits=[x_min_limit, x_max_limit],
566
+ expand=[0, 0],
567
+ )
568
+
558
569
  # GROUP separator lines (horizontal, within heatmap)
559
570
  if group_lines and len(y_order_groups) > 1:
560
571
  lines_frame = _get_group_lines_frame(
@@ -573,7 +584,6 @@ def heatmap(
573
584
  )
574
585
 
575
586
  # DENDROGRAM (right side, along y-axis), drawn with the y tick line
576
- x_max_limit = n_x - 0.5
577
587
  if dendrogram:
578
588
  htmp += _dendrogram_line_theme(color=dendrogram_color, size=dendrogram_size)
579
589
 
@@ -596,7 +606,7 @@ def heatmap(
596
606
  legend_width, legend_height = _COLOR_BAR_LEGEND_SIZE
597
607
  htmp = _fixed_cell_layout(
598
608
  htmp,
599
- x_span=(x_max_limit + 0.5) * (1 + 2 * _X_EXPAND),
609
+ x_span=x_max_limit - x_min_limit,
600
610
  y_span=y_max_limit - data_bottom,
601
611
  y_limits=[data_bottom, y_max_limit],
602
612
  x_labels=x_keys,
@@ -808,6 +808,19 @@ def _compute_violin_polygons(
808
808
  # Deterministic subsample per (variable, group) before KDE.
809
809
  rng = np.random.default_rng(0) if kde_max_samples is not None else None
810
810
 
811
+ # Split once into (variable, group) cells instead of filtering per cell;
812
+ # `maintain_order` keeps row order, so subsampling picks the same values.
813
+ group_column = "_violin_group"
814
+ cell_frames = (
815
+ frame.select(
816
+ pl.col(variable_column),
817
+ pl.col(group_by).cast(pl.String).alias(group_column),
818
+ pl.col(value_column),
819
+ )
820
+ .drop_nulls(value_column)
821
+ .partition_by([variable_column, group_column], as_dict=True, maintain_order=True)
822
+ )
823
+
811
824
  for x_index, var_key in enumerate(x_keys):
812
825
  if var_key not in var_range:
813
826
  continue
@@ -816,17 +829,13 @@ def _compute_violin_polygons(
816
829
  continue
817
830
  value_span = var_max - var_min
818
831
 
819
- var_frame = frame.filter(pl.col(variable_column) == var_key)
820
832
  kde_results: dict[str, tuple[int, np.ndarray, np.ndarray, int, float]] = {}
821
833
 
822
834
  for y_index, group_key in enumerate(y_order_groups):
823
- group_values = (
824
- var_frame.filter(pl.col(group_by).cast(pl.String) == group_key)[value_column]
825
- .drop_nulls()
826
- .to_numpy()
827
- )
828
- if len(group_values) == 0:
835
+ cell_frame = cell_frames.get((var_key, group_key))
836
+ if cell_frame is None:
829
837
  continue
838
+ group_values = cell_frame[value_column].to_numpy()
830
839
  aggregated_value = (
831
840
  float(np.median(group_values))
832
841
  if aggregate == "median"
@@ -44,9 +44,7 @@ def _normalize_widths(
44
44
  widths = cast(
45
45
  "list[float] | list[Sequence[float]]",
46
46
  [
47
- row_widths.tolist() # ty:ignore[no-matching-overload]
48
- if isinstance(row_widths, np.ndarray)
49
- else row_widths
47
+ row_widths.tolist() if isinstance(row_widths, np.ndarray) else row_widths
50
48
  for row_widths in cast("Sequence[object]", widths)
51
49
  ],
52
50
  )
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cellestial"
3
- version = "1.0.1"
3
+ version = "1.0.2"
4
4
  description = "Interactive single-cell and spatial omics visualization library"
5
5
  authors = [
6
6
  { name = "Zaf4", email = "zafermolbio@gmail.com" },
@@ -63,7 +63,7 @@ scanpy = {extras = ["leiden"], version = "^1.10.4"}
63
63
  pycairo = "^1.27.0"
64
64
  cairosvg = "^2.7.1"
65
65
  scvelo = "^0.3.3"
66
- ty = "^0.0.34"
66
+ ty = "^1.0.0"
67
67
  tqdm = "^4.67.3"
68
68
  pytest = "^9.0.3"
69
69
  pytest-cov = "^7.1.0"
@@ -97,3 +97,6 @@ data_file = "tests/.coverage"
97
97
  [build-system]
98
98
  requires = ["poetry-core"]
99
99
  build-backend = "poetry.core.masonry.api"
100
+
101
+ [tool.ty.src]
102
+ include = ["cellestial"]
File without changes