PlotEigenHeatmap.RdGenerates a pheatmap of the top genes contributing to a specific principal
component from a geneda object. Genes are selected by absolute eigenvector
loading for the chosen PC, and expression values are Z-score scaled per gene.
Optionally annotate columns with metadata variables and add row annotations
showing gene-level percent variance.
PlotEigenHeatmap(
object,
pc = "PC1",
n = 25,
annotate_by = NULL,
annotate_colors = NULL,
return = c("object", "plot")
)A geneda object containing normalized expression data and PCA in DimReduction.
Character. Principal component to visualize (e.g., "PC1").
Integer. Number of genes to select by absolute loading (default: 25).
Character vector of metadata column names for column annotations (optional).
Named list of color vectors for metadata columns. Names should match annotate_by.
One of c("object","plot"). If "plot", draws the heatmap via grid.
A list with topGenes (data.frame with EigenVector and PctVar), expression (scaled matrix), and heatmap (pheatmap object)
if (FALSE) { # \dontrun{
mock_norm <- matrix(rnorm(12, mean = 0, sd = 2), nrow = 4, ncol = 3)
colnames(mock_norm) <- paste0("Sample", 1:3)
rownames(mock_norm) <- paste0("Gene", 1:4)
mock_meta <- data.frame(condition = c("A","B","A"), row.names = colnames(mock_norm))
obj <- GenEDA(normalized = mock_norm, metadata = mock_meta)
res <- PlotEigenHeatmap(obj, pc = "PC1", n = 25,
annotate_by = c("Condition"),
annotate_colors = list(Condition = c("A" = "#1b9e77", "B" = "#d95f02")))
grid::grid.newpage(); grid::grid.draw(res$heatmap$gtable)
} # }