Learn mapping with Cancer Cell | Correlation heat map (asymmetric version)

3eb31ed423a45de4b58e157d3ac94b65.jpeg

cor_heapmap

Pictures of this issue

0c631682c99a884674da49a1f8d0f2c3.png

R, Fong C, Smith S, Riely GJ, Rudin CM, Gomez DR, Solit DB, Berger MF, Li BT, Mayo MW, Matei I, Lyden DC, Adusumilli PS, Schultz N, Sanchez-Vega F, Jones DR. Genomic mapping of metastatic organotropism in lung adenocarcinoma. Cancer Cell. 2023 May 8;41(5):970-985.e3. doi: 10.1016/j.ccell.2023.03.018.

In fact, the diagram is Co-occurrence and mutual exclusivity of genes. According to the mode of action of synergy and mutual exclusion, mutations can be divided into the following two categories: "1. Co-occurencing mutations; 2. Mutually exclusive mutations" . Mutually exclusive driver genes often share genes in the same pathway (Pathway) or different progression pathways (such as different tumor types).

For convenience here, we directly use the results of correlation analysis to draw the graph.

The difficulty of this figure is that the upper and lower triangles only display the positive and negative correlation values ​​j and their corresponding significance marks respectively. We only need to perform preliminary preprocessing on the data.

Reproducible results

263b9b0902c8c4e69a8db8a6db43475d.png
fig

Sample data and code collection

Muzhou Notes permanent VIP planning

"rights and interests:"

  1. "Sample data and codes of all tweets in Muzhou Notes ( " Real-time update in VIP group " ).

    e162ebe110e0ccd5ab2df6cd37b3c382.png
    data+code
  2. Muzhou Notes "Scientific Research Exchange Group" .

"TOLL:"

"169¥/person" . You can add WeChat: mzbj0002transfer (or scan the QR code below), or tip directly at the end of the article. Muzhou Notes "2022VIP" can be upgraded directly by paying "70¥" .

点赞, 在看share this article to your circle of friends 集赞30个for 保留30分钟discounts 20¥.

38a4056f80fd211be91702a4440e8d35.png

Drawing

rm(list = ls())
library(corrplot)
# 准备数据(示例数据)
cor_matrix <- cor(mtcars)  # 使用mtcars数据集作为示例数据

# 创建相关性矩阵
corr_matrix <- cor_matrix  # 复制相关性矩阵

corr_matrix[corr_matrix == 1] <- NA # 将值为1的元素替换为NA
corr_matrix[upper.tri(corr_matrix) & corr_matrix > 0] <- 0  # 上三角大于0的值替换为0
corr_matrix[lower.tri(corr_matrix) & corr_matrix < 0] <- 0  # 下三角小于0的值替换为0


p.mat <- cor.mtest(cor_matrix)$p  # 计算相关系数的显著性
# 预处理使得显著性只显示在对应的区域
# 这一步为了让结果好看 有点问题 大家可以加群讨论
p.mat[p.mat == 0] <- 0 
p.mat[corr_matrix != 0] <- 1
# 创建热图
library(ComplexHeatmap)

ht_list <- Heatmap(
  corr_matrix, 
  name = " ", 
  border = "white",
  col = colorRampPalette(c("#417e46", "#f7f8f9", "#6f2f7e"))(100),
  rect_gp = gpar(col = "white", lwd = 2),
  column_order = colnames(corr_matrix),
  row_order = rownames(corr_matrix),
  row_names_side = "left",  # 行标签放在左边
  column_names_side = "top",   # 列标签放在上边
  row_names_gp = gpar(
    fontsize = 10),
  column_names_gp = gpar(
    fontsize = 10),
  heatmap_legend_param = list(
  title = "correlation", 
  direction = "horizontal",
  legend_width = unit(10, "cm"),
  legend_height = unit(4, "cm")),
  cell_fun = function(j, i, x, y, w, h, fill) {
    if(p.mat[i, j] > 0.05) { # 为了结果美观修改,实际上因该上<0.05,可以加群讨论
      grid.text("*", x, y,
                gp = gpar(col = 'white',
                          fontsize = 25))
    } 
  }
  )
pdf('cor_heapmap.pdf',width = 8,height = 8)
draw(ht_list, heatmap_legend_side = "bottom")
dev.off()

Previous issues

  1. Resource summary | 2022 Muzhou Notes original tweet collection (with data and code collection methods)

  2. CNS chart reproduction | Bioinformatics analysis | R drawing resource sharing & discussion group!

  3. R Drawing | A brief discussion on the drawing logic of scatter plots and their variants

  4. How to draw this picture | A somewhat complicated scatter plot

  5. How to draw this picture | Related analysis lollipop picture

  6. Group student letter | Front Immunol | Simple routine for screening early diagnostic markers based on serum proteome

  7. (Free tutorial + code collection) | Follow Cell to learn drawing series collection

  8. Q&A | How to draw beautiful illustrations in a paper?

  9. Follow Cell to learn drawing | Mulberry drawing (ggalluvial)

  10. R practice | Lasso regression model establishment and variable screening

  11. Learn to draw with NC | Advanced interaction network diagram (protein + enrichment pathway) (Cytoscape)

  12. R practice | Add a circle to clustering (ggunchull)

  13. R practice | NGS data time series analysis (maSigPro)

  14. Follow Cell to learn how to draw | Venn Diagram (ggVennDiagram)


0847576728a076f24b1dfab0a159fda1.png
wooden boat notes matrix

Guess you like

Origin blog.csdn.net/weixin_45822007/article/details/130896342