pheatmap(mat, color = colorRampPalette(rev(c("#D73027", "#FC8D59", "#FEE090",
"#FFFFBF", "#E0F3F8", "#91BFDB", "#4575B4")))(100), breaks = NA,
cellwidth = NA, cellheight = NA, scale = "none", cluster_rows = TRUE,
cluster_cols = TRUE, clustering_distance = "correlation",
clustering_method = "complete", treeheight_row = ifelse(cluster_rows, 50, 0),
treeheight_col = ifelse(cluster_cols, 50, 0), legend = TRUE, annotation = NA,
annotation_colors = NA, annotation_legend = TRUE, filename = NA, width = NA,
height = NA, ...)
"row"
, "column"
and "none"
"correlation"
and all the distances supported by dist
, such as "euclidean"
, etc.hclust
.# Generate some data test = matrix(rnorm(200), 20, 10) test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3 test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2 colnames(test) = paste("Test", 1:10, sep = "") rownames(test) = paste("Gene", 1:20, sep = "") # Draw heatmaps pheatmap(test) pheatmap(test, scale = "row", clustering_distance = "correlation") pheatmap(test, color = colorRampPalette(c("navy", "white", "firebrick3"))(50)) pheatmap(test, cluster_row = FALSE) pheatmap(test, legend = FALSE) pheatmap(test, cellwidth = 15, cellheight = 12) pheatmap(test, cellwidth = 15, cellheight = 12, fontsize = 8, filename = "test.pdf") # Generate column annotations annotation = data.frame(Var1 = factor(1:10 %% 2 == 0, labels = c("Class1", "Class2")) , Var2 = 1:10) rownames(annotation) = paste("Test", 1:10, sep = "") pheatmap(test, annotation = annotation) pheatmap(test, annotation = annotation, annotation_legend = FALSE) # Specify colors Var1 = c("navy", "darkgreen") names(Var1) = c("Class1", "Class2") Var2 = c("lightgreen", "navy") ann_colors = list(Var1 = Var1, Var2 = Var2) pheatmap(test, annotation = annotation, annotation_colors = ann_colors)
Run the code above in your browser using DataCamp Workspace