1.熱圖制作及ggplot2、pheatmap设江、reshape2包的使用
library(ggplot2)
library(pheatmap)
library(reshape2)
csvpath <- file.choose()
csvpath
df <- read.csv(csvpath,header = T,row.names =1)
df
p <- pheatmap(log((df+200),2), show_rownames = F, cellwidth =5, cellheight=2,cluster_cols = T,
cutree_col =2 ,gaps_col = c(2,4,6), angle_col = 90,fontsize = 5)
row_cluster = cutree(p$tree_row, k=1)
pheatmap(log((df+1),2),cellwidth=15, cellheight=10,cluster_cols=F,cluster_rows=T)
結(jié)果展示:
image.png
2.環(huán)狀熱圖制作
2.1ggcor包的下載及使用(一定要下載ggcor包惩歉,另外ggcor包和ggcorplot可不一樣哦)
devtools::install_git("https://gitee.com/dr_yingli/ggcor")
調(diào)用程序包及基礎(chǔ)代碼
library(ggcor)
library(ambient)
csvpath <- file.choose()
csvpath
df <- read.csv(csvpath,header = T,row.names =1)
df
rand_correlate(38,20) %>%
quickcor(circular = TRUE, cluster = TRUE, open=45) +
geom_colour(colour= "pink", size = 0.38) +
anno_row_tree() +
anno_col_tree() +
set_p_yaxis()
結(jié)果展示:
image.png
(小白如果不知道函數(shù)各個(gè)參數(shù)代表什么的話,一開始可以更改部分參數(shù),試試季蚂,絕對(duì)有用的哈!)
3.組合相關(guān)熱圖制作
ibrary(ggplot2)
library(patchwork)
csvpath <- file.choose()
csvpath
df <- read.csv(csvpath,header = T,row.names =1)
df
A <- quickcor(df) + geom_color()
B <- quickcor(df, type = "upper") + geom_circle2()
C <- quickcor(df, type = "lower") + geom_ellipse2()
D <- quickcor(df, cluster = TRUE) + geom_square()
E <- quickcor(df, cor.test = TRUE) + geom_confbox()
G <- quickcor(df, cor.test = TRUE) +
geom_square(data= get_data(type = "lower"))+
geom_mark(data= get_data(type = "upper")) +
geom_abline(slope = -1, intercept = 12)
(A+B+C)/(E+D+G) + plot_annotation(tag_levels = 'A')
plot(B)
A:
image.png
B:
image.png
C:
image.png
D:
image.png
E:
image.png
G:
image.png
(今天就學(xué)習(xí)這么多,覺著學(xué)習(xí)R還是挺有意思的扭屁,希望自己可以堅(jiān)持下去算谈,當(dāng)然也不能舍本逐末,忘了初心料滥,R只是為了給科研“添磚加瓦”然眼、“錦上添花”),希望它只是一個(gè)工具葵腹!學(xué)有余力的快樂來源高每。