Generates 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.
Usage
PlotEigenHeatmap(
object,
pc = "PC1",
n = 25,
annotate_by = NULL,
annotate_colors = NULL,
return = c("object", "plot")
)Arguments
- object
A
genedaobject containing normalized expression data and PCA inDimReduction.- pc
Character. Principal component to visualize (e.g., "PC1").
- n
Integer. Number of genes to select by absolute loading (default: 25).
- annotate_by
Character vector of metadata column names for column annotations (optional).
- annotate_colors
Named list of color vectors for metadata columns. Names should match
annotate_by.- return
One of c("object","plot"). If "plot", draws the heatmap via grid.
Value
A list with topGenes (data.frame with EigenVector and PctVar),
expression (scaled matrix), and heatmap (pheatmap object)
Examples
data(Snail1KO)
counts <- as.matrix(Snail1KO$rawCounts)
counts <- counts[rowSums(counts >= 10) >= 3, ]
meta <- Snail1KO$metadata
rownames(meta) <- meta$Sample
norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1)
obj <- GenEDA(normalized = norm, metadata = meta, counts = counts)
obj <- FindVariableFeatures(obj, nfeatures = 1000)
obj <- RunPCA(obj)
#> Calculating principal components from top 1000 HVGs
#> Percent variations:
#> PC1: 88.56 %
#> PC2: 5.9 %
#> PC3: 2.91 %
#> PC4: 1.55 %
#> PC5: 1.08 %
#> PC6: 0 %
res <- PlotEigenHeatmap(obj,
pc = "PC1", n = 25,
annotate_by = "Genotype",
annotate_colors = list(Genotype = c(
WT = "grey40", Snai1_KO =
"firebrick3"
)),
return = "plot"
)
