Learn R Programming

SlimR (version 1.1.1)

plot.pheatmap: Plot Method for pheatmap Objects

Description

This S3 method allows pheatmap objects (returned by Celltype_Calculate()) to be plotted using the generic plot() function. Without this method, attempting to use plot() on a pheatmap object results in an error.

Usage

# S3 method for pheatmap
plot(x, ...)

Value

Invisibly returns the input pheatmap object after displaying it

Arguments

x

A pheatmap object, typically from cluster_results$Heatmap_plot

...

Additional arguments (currently ignored)

Details

Pheatmap objects contain a gtable component that needs to be drawn using grid graphics. This method handles that automatically when plot() is called.

Alternative ways to display pheatmaps:

  • print(pheatmap_object) - Works natively

  • plot(pheatmap_object) - Works after loading SlimR

  • grid::grid.draw(pheatmap_object$gtable) - Direct access

Examples

Run this code
if (FALSE) {
# After running Celltype_Calculate()
cluster_results <- Celltype_Calculate(
    seurat_obj = sce,
    gene_list = Markers_list,
    species = "Human"
)

# Now both of these work:
print(cluster_results$Heatmap_plot)
plot(cluster_results$Heatmap_plot)
}

Run the code above in your browser using DataLab