火山图标记基因_火山地形图

2022-11-01 10:21:43 浏览数 (2)

现在很多文章开始出现这样的一种情况,在绘制火山图中,显示我们所关注的基因,那么如何去显示呢?很多人可能会这么做,在绘制普通的火山图之后,使用AI对图进行修改,添加部分基因,但是现在我要介绍的是如何用R绘制 library(ggpubr) library(ggthemes) data <- read.csv(“easy_input_limma.csv”, head=T,sep=’,’) #绘制基本热图 data l o g p &lt; − − l o g 10 ( d a t a logp &lt;- -log10(data logp<−−log10(dataadj.P.Val) ggscatter(data,x=“logFC”,y=“logp”) theme_base()

#新增一列,选出上调和下调 data G r o u p = &quot; n o t − s i g n i f i c a n t &quot; d a t a Group=&quot;not-significant&quot; data Group=“not−significant“dataGroup[which((dataKaTeX parse error: Expected ‘EOF’, got ‘&’ at position 16: adj.P.Val<0.05)&̲(datalogFC > 2))]=“up-regulated” data G r o u p [ w h i c h ( ( d a t a Group[which((data Group[which((dataadj.P.Val<0.05)&(dataKaTeX parse error: Expected ‘EOF’, got ‘#’ at position 32: …own-regulated” #̲查看上调和下调的基因个数 ta…Group) #绘制新的火山图 ggscatter(data,x=“logFC”,y=“logp”,color=“Group”) theme_base()

#添加颜色和点的大小 ggscatter(data,x=“logFC”,y=“logp”,color=“Group”,palette=c( “blue”,“gray”,“red”),size=1) theme_base()

ggscatter(data,x=“logFC”,y=“logp”,color=“Group”,palette=c( “blue”,“gray”,“red”),size=1) theme_base() geom_hline(yintercept=1.3, linetype=“dashed”) geom_vline(xintercept=c(-2,2),linetype=“dashed”)

#新增一列,这一列是需要展示的基因名在这里我展示前10 data l a b e l = &quot; &quot; d a t a &lt; − d a t a [ o r d e r ( d a t a label=&quot;&quot; data&lt;-data[order(data label=““data<−data[order(datalogp),] #data S y m b o l &lt; − r o w n a m e s ( d a t a ) u p . g e n e &lt; − h e a d ( d a t a Symbol&lt;-rownames(data) up.gene&lt;-head(data Symbol<−rownames(data)up.gene<−head(dataSymbol[which(data G r o u p = = &quot; u p − r e g u l a t e d &quot; ) ] , 10 ) d o w n . g e n e &lt; − h e a d ( d a t a Group==&quot;up-regulated&quot;)],10) down.gene&lt;-head(data Group==“up−regulated“)],10)down.gene<−head(dataSymbol[which(dataKaTeX parse error: Expected ‘EOF’, got ‘#’ at position 31: …gulated”)],10) #̲将up.gene和down.g…label[match(data.top.genes,dataKaTeX parse error: Expected ‘EOF’, got ‘#’ at position 26: …data.top.genes #̲重新绘制 ggscatter(…label,font_label=8,repel=T) theme_base() geom_hline(yintercept=0.05, linetype=“dashed”) geom_vline(xintercept=c(-2,2),linetype=“dashed”)

很多人会说,这样的终究不太分明,我想让点的大小来反映FC,这样可以做到吗?当然可以了!如果有想了解的,可以试试,其实很简单的。

最近看到一个更加强大的包,绘制的火山图更加好看 EnhancedVolcano包 1、首先安装这个包 if (!requireNamespace(‘devtools’, quietly = TRUE)) install.packages(‘devtools’) devtools::install_github(‘kevinblighe/EnhancedVolcano’) 加载包 library(EnhancedVolcano) #res1是带有基因ID的列名,log2FoldChange是去过对数的差异倍数的列名,pvalue可以选择是校正前和校正后的,xlim是对log2FoldChange的范围进行限定 EnhancedVolcano(res1, lab = rownames(res1), x = ‘log2FoldChange’, y = ‘pvalue’,xlim = c(-5, 8)) 绘制之后就是这样了

2、 还可以通过这个包直接修改点的大小和标签的大小 #title图片的名称, transcriptPointSize点的大小, transcriptLabSize标签的大小 EnhancedVolcano(res2,lab = rownames(res2), x = ‘log2FoldChange’,y = ‘pvalue’, xlim = c(-8, 8),title = ‘N061011 versus N61311’,pCutoff = 10e-16, FCcutoff = 1.5, transcriptPointSize = 1.5,transcriptLabSize = 3.0) 3、调整点的颜色和透明度 #colAlpha点的透明度,col是点的颜色,默认第一个是NS,第二个是log2FC,第三个是P,第四个是p&log2FC EnhancedVolcano(res2, lab = rownames(res2),x = ‘log2FoldChange’, y = ‘pvalue’,xlim = c(-8, 8),title = ‘N061011 versus N61311’, pCutoff = 10e-16, FCcutoff = 1.5, transcriptPointSize = 1.5, transcriptLabSize = 3.0, col=c(“grey30”, “forestgreen”, “royalblue”, “red2”), colAlpha = 1) 4、修改点的形状 shape点的形状,可以选择一个,也可以选择多个 选择一个形状 EnhancedVolcano(res2, lab = rownames(res2),x = ‘log2FoldChange’, y = ‘pvalue’,xlim = c(-8, 8),title = ‘N061011 versus N61311’, pCutoff = 10e-16, FCcutoff = 1.5, transcriptPointSize = 1.5, transcriptLabSize = 3.0,shape=4, col=c(“grey30”, “forestgreen”, “royalblue”, “red2”), colAlpha = 1) 选择多个形状 EnhancedVolcano(res2, lab = rownames(res2),x = ‘log2FoldChange’, y = ‘pvalue’,xlim = c(-8, 8),title = ‘N061011 versus N61311’, pCutoff = 10e-16, FCcutoff = 1.5, transcriptPointSize = 1.5, transcriptLabSize = 3.0,shape=c(1,4,23,25),col=c(“grey30”, “forestgreen”, “royalblue”, “red2”), colAlpha = 1) 5、添加额外的阈值线,自定义阈值线,可以自己查看文档 hlineType线条的类型(平行于x轴),vline—是平行于Y轴的 cutoffLineCol线条的颜色,cutoffLineWidth线条的粗细 EnhancedVolcano(res2,lab = rownames(res2), x = ‘log2FoldChange’,y = ‘pvalue’, xlim = c(-6, 6),title = ‘N061011 versus N61311’,pCutoff = 10e-12,FCcutoff = 1.5,transcriptPointSize = 1.5,transcriptLabSize = 3.0,colAlpha = 1, cutoffLineType = ‘blank’,cutoffLineCol = ‘black’, cutoffLineWidth = 0.8, hline = c(10e-12, 10e-36, 10e-60, 10e-84), hlineCol = c(‘grey0’, ‘grey25’,‘grey50’,‘grey75’), hlineType = ‘longdash’,hlineWidth = 0.8,gridlines.major = FALSE,gridlines.minor = FALSE) 6、调整图例 #legend图例内容,legendPosition图例的位置,legendLabSize文字的大小 legendIconSize标签的大小 EnhancedVolcano(res2,lab = rownames(res2),x = ‘log2FoldChange’,y = ‘pvalue’, xlim = c(-6, 6),pCutoff = 10e-12, FCcutoff = 1.5,cutoffLineType = ‘twodash’,cutoffLineWidth = 0.8,transcriptPointSize = 3.0,transcriptLabSize = 4.0, colAlpha = 1,legend=c(‘NS’,‘Log (base 2) fold-change’,‘P value’, ‘P value & Log (base 2) fold-change’), legendPosition = ‘right’,legendLabSize = 16,legendIconSize = 5.0) 详细的请查看说明文档

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/179441.html原文链接:https://javaforall.cn

0 人点赞