Pictures of this issue
❝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
Sample data and code collection
Muzhou Notes permanent VIP planning
"rights and interests:"
"Sample data and codes of all tweets in Muzhou Notes ( " Real-time update in VIP group " ).
data+code Muzhou Notes "Scientific Research Exchange Group" .
"TOLL:"
"169¥/person" . You can add WeChat: mzbj0002
transfer (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分钟
discounts20¥
.
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
CNS chart reproduction | Bioinformatics analysis | R drawing resource sharing & discussion group!
R Drawing | A brief discussion on the drawing logic of scatter plots and their variants
How to draw this picture | A somewhat complicated scatter plot
How to draw this picture | Related analysis lollipop picture
(Free tutorial + code collection) | Follow Cell to learn drawing series collection
Follow Cell to learn drawing | Mulberry drawing (ggalluvial)
R practice | Lasso regression model establishment and variable screening
Follow Cell to learn how to draw | Venn Diagram (ggVennDiagram)