R绘图:相关性分析与作图(单基因相关性)
上回咱们介绍了多基因之间的相关性分析及绘图
今天我们来讲一下,单基因之间得相关性分析及作图,这个在实验性得文章中用到得更广泛
首先还是加载数据,数据来源于TCGA数据下载与ID转换
rm(list=ls())
library(ggstatsplot)#加载包
load(file = "mRNAdata.Rda")#加载数据
将数据转置,并转换成数据框,取log
dat<-as.data.frame(t(mRNAdata))
dat<-log2(dat+1)
我们用LDHA和PKM来示范绘图,方法选择pearson,显示平均值
ggscatterstats(dat,
y =LDHA,
x =PKM,
type = "pearson",
centrality.para = "mean",
margins = "both",
xfill = "#009E73",
yfill = "#D55E00",
marginal.type = "histogram",
title = "Relationship between LDHA and PKM")
还可以换成其他风格,有histogram, density, boxplot, violin, densigram可以选择
density
ggscatterstats(dat,
y =LDHA,
x =PKM,
type = "pearson",
centrality.para = "mean",
margins = "both",
xfill = "#009E73",
yfill = "#D55E00",
marginal.type = "density", #类型可以换成density,boxplot,violin,densigram
title = "Relationship between LDHA and PKM")
boxplot
ggscatterstats(dat,
y =LDHA,
x =PKM,
type = "pearson",
centrality.para = "mean",
margins = "both",
xfill = "#009E73",
yfill = "#D55E00",
marginal.type = "boxplot", #类型可以换成density,boxplot,violin,densigram
title = "Relationship between LDHA and PKM")
violin
ggscatterstats(dat,
y =LDHA,
x =PKM,
type = "pearson",
centrality.para = "mean",
margins = "both",
xfill = "#009E73",
yfill = "#D55E00",
marginal.type = "violin", #类型可以换成density,boxplot,violin,densigram
title = "Relationship between LDHA and PKM")
densigram
ggscatterstats(dat,
y =LDHA,
x =PKM,
type = "pearson",
centrality.para = "mean",
margins = "both",
xfill = "#009E73",
yfill = "#D55E00",
marginal.type = "densigram", #类型可以换成density,boxplot,violin,densigram
title = "Relationship between LDHA and PKM")
只要有数据,出图就很简单了。
好了,今天就分享到这啦
下面是福利专用贴
目前有
1. 火山图,热图示例文件及完整代码
2. R语言学习基础知识代码
3. R语言实战(中文完整版)
4. R数据科学(中文完整版)
5. ggplot2:数据分析与图形艺术
6. 30分钟学会ggplot2
7. TCGA数据整理(所有肿瘤)
8. ggplot2速查表pdf(可复制)
万水千山总是情,点个在看行不行,哈哈哈哈哈哈哈
赞 (0)