Skip to content

Commit 0860142

Browse files
authored
fix: gridded interface heatmap support (#166)
1 parent 4ddfb20 commit 0860142

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/hv_anndata/_ref.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def __eq__(self, value: object, /) -> bool | NotImplementedType:
132132
"Probably comparing to a dimension created from `Dimension.name`. "
133133
"This will not be supported in the future, please report as an issue. "
134134
)
135-
warnings.warn(msg, FutureWarning, stacklevel=2)
135+
warnings.warn(msg, DeprecationWarning, stacklevel=2)
136136
return True
137137
return super().__eq__(value)
138138

src/hv_anndata/interface.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,11 @@ class AnnDataGriddedInterface(AnnDataInterface):
431431

432432
@classmethod
433433
def shape(cls, dataset: Dataset, *, gridded: bool = False) -> tuple[int, int]:
434-
"""Retrieve shape of 2D data."""
434+
"""Retrieve shape of 2D data in reverse-kdim order."""
435435
del gridded
436436
ax1, ax2 = cls.dims(dataset)
437-
return len(getattr(dataset.data, ax1)), len(getattr(dataset.data, ax2))
437+
# Grid convention matches the row-major layout numpy/pcolormesh expect
438+
return len(getattr(dataset.data, ax2)), len(getattr(dataset.data, ax1))
438439

439440
@classmethod
440441
def _iloc_2d(

src/hv_anndata/plotting/scanpy/_core.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ def heatmap(
184184
185185
adata = data.pbmc68k_processed()
186186
markers = ["C1QA", "PSAP", "CD79A", "CD79B", "CST3", "LYZ"]
187+
hv_sc.heatmap(
188+
adata[:, markers], A.X, [A.obs["n_counts"]]
189+
).opts(hv.opts.HeatMap(xticks=0, aspect=2))
190+
191+
With dendrogram:
192+
193+
.. holoviews::
194+
187195
hv_sc.heatmap(
188196
adata[:, markers], A.X, [A.obs["n_counts"]], add_dendrogram="obs"
189197
).opts(hv.opts.HeatMap(xticks=0, aspect=2))

0 commit comments

Comments
 (0)