scale_y_dendro ¶
scale_y_dendro(
clust: ClusterTree,
name: str | None = None,
*,
breaks: Breaks | None = None,
labels: Labels | None = None,
expand: Sequence[Number] | None = None,
reverse: bool | None = None,
format: str | None = None,
guide: FeatureSpec | str | None = None,
position: AxisPosition | None = None,
) -> FeatureSpec
Discrete y scale ordered by a clustering tree, drawn left of the axis (legendry).
The first leaf of the tree's order is at the bottom, as levels of a discrete y
axis are. See :func:scale_x_dendro.
Parameters:
-
clust(ClusterTree) –The tree, from :func:
hclust. -
name(str, default:None) –Axis title.
-
breaks(optional, default:None) –As
scale_y_discrete(). -
labels(optional, default:None) –As
scale_y_discrete(). -
expand(optional, default:None) –As
scale_y_discrete(). -
format(optional, default:None) –As
scale_y_discrete(). -
reverse(bool, default:False) –Reverse the leaf order (the tree flips with it).
-
guide(FeatureSpec or axis_dendro, default:None) –guide_axis_dendro(...)options. -
position(str, default:None) –Side of the axis, as in
scale_x_discrete()/scale_y_discrete(); aside="axis"tree follows the axis there.
Returns:
-
FeatureSpec–Scale specification.
Raises:
-
UnsupportedValueError–If
clustis not an :class:ClusterTreeorguideis another guide.
Examples:
>>> from ggrust import *
>>> frame = {"gene": ["CD3E", "CD8A", "MS4A1"], "t": [5.0, 4.5, 0.1], "b": [0.2, 0.1, 6.0]}
>>> rows = hclust(frame, labels="gene")
>>> long = {
... "gene": frame["gene"] * 2,
... "cell": ["t"] * 3 + ["b"] * 3,
... "value": frame["t"] + frame["b"],
... }
>>> plot = ggplot(long, aes("cell", "gene", fill="value")) + geom_tile()
>>> plot = plot + scale_y_dendro(rows)