Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to draw heat map with pheatmap of R language

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to draw a heat map with pheatmap in R language". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to draw a heat map with pheatmap in R language.

Introduction to pheatmap:

Pretty Heatmaps--Implementation of heatmaps that offers more control over dimensions and appearance.

Heat map is an intuitive visualization method to analyze the distribution of experimental data (especially the expression of genes). It can be used to control the quality of experimental data and visualize the difference data. It can also cluster data and samples and observe the similarity of sample experimental data.

There are many parameters for how to use pheatmap. Here are some commonly used parameters:

Mat

Need to draw the heat map of the digital matrix.

Color

To represent the color, assign the gradient color palette colorRampPalette property, select the "blue, white, red" gradient, divided into 100levels, for example: color = colorRampPalette (c ("navy", "white", "red"))

Kmeans_k

The number of rows clustered to draw a heat map. If it is NA, then the rows will not be clustered.

Breaks

Sets the numeric sequence of the range of mat values

Border_color

Represents the color of the cell border on the heat map, using NA if the border is not drawn

Cellwidth

Indicates the width of each cell. Select NA to indicate the adaptation window.

Cellheight

Indicates the height of each cell. Select NA to indicate the adaptation window.

Scale

Indicates the direction in which the values are homogenized, either by row or column, or none, and the value can be "row", "column" or "none"

Cluster_rows

Indicates the clustering of rows, and the value can be FALSE or TRUE

Cluster_cols

Indicates the clustering of columns, and the value can be FALSE or TRUE

Clustering_distance_rows

Represents the distance used in row clustering: Euclidean distance, correlation coefficient, etc.

Clustering_distance_cols

Indicates the distance used in column clustering: Euclidean distance, correlation coefficient, etc.

Clustering_method

Represents a clustering method, and the value can be any of hclust, such as "ward.D", "single", "complete", "average", "mcquitty", "median", "centroid", "ward.D2"

Clustering_callback

Callback function to modify clustering

Cutree_rows

Number of clusters that divide rows based on hierarchical clustering (using cutree) (ignore parameters if rows are not clustered)

Cutree_cols

Number of clusters of columns based on hierarchical clustering (using cutree) (ignore parameters if rows are not clustered)

Treeheight_row

The height of the tree in the row

Treeheight_col

The height of the tree in the column

Legend

TRUE or FALSE, indicating whether the legend is displayed

Legend_breaks

Set the breakpoint of the legend, such as legend_breaks =-1:4

Legend_labels

Legend_breaks tag example: legend_breaks =-1:4, legend_labels = c ("0", "1e-4", "1e-3", "1e-2", "1e-1", "1")

Annotation_row

For the grouping information of rows, you need to use the corresponding row names to match the lines in the data and comments. Note that the color setting will consider discrete or continuous values, and the format is required to be a data box.

Annotation_col

For the grouping information of the column, you need to use the corresponding column name to match the column in the data and comments. The format is required to be a data box.

Annotation_colors

A list of colors used to specify annotation_row and annotation_col track manually.

Annotation_legend

Whether to display the name of the legend.

Annotation_names_row

Whether to display the name of the line comment.

Annotation_names_col

Whether to display the name of the column comment.

Show_rownames

Whether to display the line name

Show_colnames

Whether to display column names

Main

The name of the picture

Fontsize

Font size of the graph

Fontsize_row

The font size of the line name, which is the same as the font size of the graph by default

Fontsize_col

The font size of the column name, which is the same as the font size of the figure by default

Angle_col

The angle of the column label can be selected (0,45,90,270 and 315)

Display_numbers

Indicates whether the value is displayed in the grid of the heat map, and if this is a matrix (the same size as the original matrix), the contents of the matrix are displayed instead of the original value.

Number_format

To set the format of display values, the more commonly used ones are "% .2f" (keeping two places after the decimal point) and "% .1e" (scientific counting shows that one place after the decimal point is retained)

Number_color

Set the color of the display

Fontsize_number

Set the font size of the display

Labels_row

A custom label instead of a row name

Labels_col

A custom label instead of a column name

Filename

Where the picture is saved and the file name

Width

Manually set the width of the output file (in inches)

Height

Manually set the height of the output file (in inches)

Silent

Do not draw a heat map

Na_col

Color of the missing value

Pheatmap package installation and data preparation: install.packages (pheatmap) # installation package # load packagelibrary (pheatmap) data

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report