相关性点图和热图高颜值低难度版
2024-04-22 本文已影响0人
小洁忘了怎么分身
今天介绍两个新的画图函数,刚写的
library(tinyarray)
packageVersion("tinyarray")
## [1] '2.3.3'
因为是刚写的所以还没有那么快同步到cran,刚通过了审核,上架可能要明天吧(4月10号)
就先用install.packages("tinyarray")
来装,如果版本低于2.3.3那就说明他们还没审核完,等等再装或者用github的方法装:devtools::install_github("xjsun1221/tinyarray")
1.带有侧边密度图的相关性点图呀
没错就是上次刚自己搓的代码,太长了,有点常用,写成函数方便用呀(ggstatplot最新版本报错,旧版本又各种套娃)
corscatterplot(iris,"Sepal.Length","Sepal.Width")
![](https://img.haomeiwen.com/i9475888/c89a4d0cd0768168.png)
可以看帮助文档自行指定密度图的颜色,趋势线的颜色,支持ggscatter函数的所有参数,虽然没写上,比如调点的大小。
corscatterplot(iris,"Sepal.Length","Sepal.Width",size = 0.5)
![](https://img.haomeiwen.com/i9475888/f974d6f2a8111888.png)
侧边栏也可变成条形图
corscatterplot(iris,"Sepal.Length","Sepal.Width",type = "histogram")
![](https://img.haomeiwen.com/i9475888/0a61fcb5b7edc631.png)
2.相关性热图
同样是因为出镜率高,代码太长。。。
可以是一组基因与另一组基因的相关性,或者是一组基因与与免疫细胞(那就把他们rbind成为一个矩阵再画),不论什么只要能放到一个矩阵里就可以的,一行是一个基因或免疫细胞,一列是一个样本的格式。
这里使用了包里的内置数据,里面一共就8个基因
x = rownames(exprSet_hub1)[1:3]
y = rownames(exprSet_hub1)[4:7]
corheatmap(exprSet_hub1,x,y)
![](https://img.haomeiwen.com/i9475888/ee0f99f19cd3ff0e.png)
同样是颜色可调的,也支持更多的行列。
受示例数据限制,没有太多的发挥空间,放两个用它搞成的图:
![](https://img.haomeiwen.com/i9475888/379233daf92ec955.png)
![](https://img.haomeiwen.com/i9475888/ccb67a689e499b87.png)
横坐标斜着是横坐标数量多时自动的O(∩_∩)O