From 8461e5281484474f45b10850dee14eccde6d1cb3 Mon Sep 17 00:00:00 2001 From: freefire <97975089@qq.com> Date: Sat, 11 Jan 2025 22:21:13 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E8=84=9A=E6=9C=AC=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.R | 86 ---------------------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 main.R diff --git a/main.R b/main.R deleted file mode 100644 index 6e75e65..0000000 --- a/main.R +++ /dev/null @@ -1,86 +0,0 @@ -library(grid) -library(ComplexHeatmap) -library(circlize) -library(RColorBrewer) -library(dendextend) -library(dendsort) -library(gridBase) - -# 加载绘图数据 -data <- read.table(file = 'D:/code/R/1.csv', header = TRUE, row.names = 1, sep = ',') - -# 查看数据 -head(data) - -# 转化matrix格式矩阵及数据归一化 -data <- as.matrix(data) -cir1 <- t(scale(t(data))) - -# 处理 NA 值 -cir1[is.na(cir1)] <- 0 - -# 查看归一化后的数据 -head(cir1) - -# 定义热图颜色梯度 -mycol <- colorRamp2(c(-2.5, 0.3, 3.1), c("blue", "white", "red")) -mycol1 <- colorRamp2(c(-2, 0, 2), c("#003399", "white", "#cccc00")) - -# 默认参数绘制普通热图 -Heatmap(cir1, row_names_gp = gpar(fontsize = 6), - column_names_gp = gpar(fontsize = 8), - col = mycol, - name = "legend") - -# 计算数据大小范围 -range(cir1) - -# 绘制基础环形热图 -circos.heatmap(cir1, col = mycol) -circos.clear() - -# 在circos.heatmap()中添加参数进行环形热图的调整和美化 -circos.par(gap.after = c(30)) -circos.heatmap(cir1, col = mycol, - dend.side = "inside", - rownames.side = "outside", - rownames.col = "black", - rownames.cex = 1.2, - rownames.font = 1.2, - bg.border = "black", - cluster = TRUE) -circos.clear() - -# 聚类树的调整和美化 -circos.par(gap.after = c(30)) -circos.heatmap(cir1, col = mycol, dend.side = "inside", - rownames.side = "outside", - track.height = 0.28, - rownames.col = "black", - rownames.cex = 1.3, - rownames.font = 1.3, - cluster = TRUE, - dend.track.height = 0.18, - dend.callback = function(dend, m, si) { - color_branches(dend, k = 15, col = 1:15) - }) -circos.clear() - -# 添加图例标签等 -lg <- Legend(title = "Exp", col_fun = mycol, - direction = c("vertical")) -grid.draw(lg) - -# 添加列名 -circos.track(track.index = get.current.track.index(), panel.fun = function(x, y) { - if (CELL_META$sector.numeric.index == 1) { - cn <- colnames(cir1) - n <- length(cn) - circos.text(rep(CELL_META$cell.xlim[2], n) + convert_x(0.5, "mm"), - 1:n + 5, - cn, cex = 0.6, adj = c(0, 0.5), facing = "inside") - } -}, bg.border = NA) - -circos.clear() -