Skip to content

plot(tree, what = "heatmap"): draw a giottoTree's own correlation matrix - #1324

Closed
jiajic wants to merge 1 commit into
gsourcefrom
feat/plot-giotto-tree
Closed

jiajic wants to merge 1 commit into
gsourcefrom
feat/plot-giotto-tree

Conversation

@jiajic

@jiajic jiajic commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

A plot() method for giottoTree:

  • what = "tree" (the default): the plain hclust plot, as before. ... passes through, so plot(tree, hang = -1) keeps working.
  • what = "heatmap": draws attr(tree, "cor_matrix") in leaf order, with the tree's branches on both axes (ComplexHeatmap, already in Suggests). The title names the correlation type and the feature count.

This is the one place where drawing the attached matrix is honest: it's the matrix the branches were built from, so colors and branches can't disagree. It describes the tree, not whatever object is current. For correlations recomputed from an object in a tree's order, use GiottoVisuals::showClusterHeatmap(cluster_custom_order = tree$labels[tree$order]) (GiottoVisuals#154), which deliberately draws no branches. A tree without its matrix errors and points there.

The method is registered as S3method(plot, giottoTree). Inside Giotto, plot is terra's S4 generic, so a plain @export would only have exported the function. It's checked from a user session: both what options dispatch.

This was first pushed by mistake onto #1323's branch after #1323 had merged, and is re-raised here on a fresh branch off gsource.

Verification

test_03_giotto_tree.R:

  • plot(tree, hang = -1) returns the tree with no warning
  • the heatmap's matrix is exactly the tree's cor_matrix in leaf order, and its row dendrogram is the tree
  • a tree without its matrix errors with a pointer to showClusterHeatmap(cluster_custom_order =)

11 tests, 33 expectations, all passing.

🤖 Generated with Claude Code

@jiajic

jiajic commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Moved to GiottoVisuals, where the plotting code lives: giotto-suite/GiottoVisuals#156. The S3 method registers there with no dependency on Giotto, since Giotto imports GiottoVisuals.

@jiajic jiajic closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant