Skip to content

Data Science Tutorials

  • Home
  • R
  • Statistics
  • Course
  • Machine Learning
  • Guest Blog
  • Contact
  • About Us
  • Toggle search form
  • How to Replace Inf Values with NA in R
    How to Replace Inf Values with NA in R R
  • How to Analyze Likert Scale Data
    How to Analyze Likert Scale Data? Statistics
  • Two-Way ANOVA Example in R
    How to perform a one-sample t-test in R? R
  • How to perform TBATS Model in R
    How to perform TBATS Model in R R
  • Calculate the P-Value from Chi-Square Statistic in R
    Calculate the P-Value from Chi-Square Statistic in R R
  • How to Filter Rows In R
    How to Filter Rows In R? R
  • 5 Free Books to Learn Statistics For Data Science
    5 Free Books to Learn Statistics For Data Science Course
  • Predictive Modeling and Data Science
    Predictive Modeling and Data Science Machine Learning
pheatmap function in R

The pheatmap function in R

Posted on October 25October 25 By Jim No Comments on The pheatmap function in R
Tweet
Share
Share
Pin

The pheatmap function in R, the pheatmap function gives you more control over the final plot than the standard base R heatmap does.

A numerical matrix holding the values to be plotted can be passed.

How to create Anatogram plot in R – Data Science Tutorials

# install.packages("pheatmap")
library(pheatmap)
# Data 
set.seed(123)
m <- matrix(rnorm(200), 10, 10)
colnames(m) <- paste("Col", 1:10)
rownames(m) <- paste("Row", 1:10)
# Heat map
pheatmap(m)

Normalization

If the matrix’s values are not normalized, you can use the scale parameter to normalize them by either the rows (“row”) or the columns (“column”) of the matrix.

How to Create an Interaction Plot in R? – Data Science Tutorials

m <- matrix(rnorm(200), 10, 10)
colnames(m) <- paste("Col", 1:10)
rownames(m) <- paste("Row", 1:10)
# Heat map
pheatmap(m, scale = "column")

Values

Display_numbers = TRUE causes the values for each cell to be displayed. The text’s size and colour can both be changed.

pheatmap(m,
         display_numbers = TRUE,
         number_color = "black", 
         fontsize_number = 8)

How to Rank by Group in R? – Data Science Tutorials

Number of clusters

With kmeans_k, the number of clusters can be altered. If there aren’t enough clusters, you can enlarge the cells using cellheight or cellwidth.

pheatmap(m, kmeans_k = 3, cellheight = 50)

Remove rows dendrogram

pheatmap(m, cluster_rows = FALSE)

Remove columns dendrogram

pheatmap(m, cluster_cols = FALSE)

How to create a ggalluvial plot in R? – Data Science Tutorials

Remove dendrograms

pheatmap(m,
         cluster_cols = FALSE,
         cluster_rows = FALSE)

Border color

pheatmap(m, border_color = "black")

Color palette

pheatmap(m, color = hcl.colors(50, "BluYl"))

Legend breaks

heatmap(m, legend_breaks = c(-2, 0, 2))

Legend labels

pheatmap(m,
         legend_breaks = c(-2, 0, 2),
         legend_labels = c("Low", "Medium", "High"))

How to Use Spread Function in R?-tidyr Part1 (datasciencetut.com)

Remove the legend

pheatmap(m, legend = FALSE)

Check your inbox or spam folder to confirm your subscription.

Tweet
Share
Share
Pin
R

Post navigation

Previous Post: How to create a heatmap in R
Next Post: How to create a hexbin chart in R

Related Posts

  • How to Use Spread Function in R
    How to Use Spread Function in R?-tidyr Part1 R
  • Changing the Font Size in Base R Plots
    Changing the Font Size in Base R Plots R
  • Remove Columns from a data frame
    How to Remove Columns from a data frame in R R
  • Find the Maximum Value by Group in R
    Find the Maximum Value by Group in R R
  • How to Use Mutate function in R
    How to Use Mutate function in R R
  • How do confidence intervals work
    How do confidence intervals work? R

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • About Us
  • Contact
  • Disclaimer
  • Guest Blog
  • Privacy Policy
  • YouTube
  • Twitter
  • Facebook
  • Defensive Programming Strategies in R
  • Plot categorical data in R
  • Top Data Modeling Tools for 2023
  • Ogive Graph in R
  • Is R or Python Better for Data Science in Bangalore

Check your inbox or spam folder to confirm your subscription.

  • Data Scientist Career Path Map in Finance
  • Is Python the ideal language for machine learning
  • Convert character string to name class object
  • How to play sound at end of R Script
  • Pattern Searching in R
  • How to Use “not in” operator in Filter
    How to Use “not in” operator in Filter R
  • How to do Conditional Mutate in R
    How to do Conditional Mutate in R? R
  • Linear Interpolation in R
    Linear Interpolation in R-approx R
  • Interactive 3d plot in R
    Interactive 3d plot in R-Quick Guide R
  • gganatogram Plot in R
    How to create Anatogram plot in R R
  • Comparison between Statistics and Luck
    Lottery Prediction-Comparison between Statistics and Luck Machine Learning
  • How to perform MANOVA test in R
    How to perform the MANOVA test in R? R
  • droplevels in R with examples
    droplevels in R with examples R

Copyright © 2023 Data Science Tutorials.

Powered by PressBook News WordPress theme