将多个基因的cds用下面的网址获得结果
https://galaxy.pasteur.fr/?tool_id=toolshed.pasteur.fr%2Frepos%2Fkhillion%2Fcodonw%2Fcodonw%2F1.4.4&version=1.4.4&__identifer=zwhtdsoycw9
##选择Calculate Effective Number of Codons和Calculate GC of silent 3rd codon posit
结果如图,一共三列
image.png
修改为以下格式
image.png
这个结果用ggplot绘制保存为文件code.txt
ENC<-function(x){
return(2 + x + 29/(x^2+(1-x)^2))
}
x <- seq(0,1,by=0.005)
y <- ENC(x)
df1<-data.frame(A=x,B=y)
library(ggplot2)
df <- read_delim("/your-path/code.txt",
"\t", escape_double = FALSE, trim_ws = TRUE)
##只用前两列绘图
ggplot(df1,aes(x=A,y=B))+geom_line(size=1)+
geom_point(data=df,aes(x=GC3s,y=ENC))+xlim(0,1)+
ylim(0,70)+labs(x="GC3s",y="ENC")+theme_bw()
###到这一步有人遇到报错Error: `mapping` must be created by `aes(),具体是什么原因我不知道,对应着把geom_point(df,)改成geom_point(data=df)就不会有这个报错了。
image.png
##将第三列映射为颜色
ggplot(df1,aes(x=A,y=B))+geom_line(size=1)+
geom_point(data=df,aes(x=GC3s,y=ENC,color=gene))+xlim(0,1)+
ylim(0,70)+labs(x="GC3s",y="ENC")+theme_classic()+
theme(legend.position="none")
image.png
添加标签
ggplot(df1,aes(x=A,y=B))+geom_line(size=1)+
geom_point(data=df,aes(x=GC3s,y=ENC,color=gene))+xlim(0,1)+
ylim(0,70)+labs(x="GC3s",y="ENC")+theme_classic()+
geom_text(data=df,aes(x=GC3s,y=ENC,color=gene,label=gene))
theme(legend.position="none")
image.png
存在重叠看不起
这里使用ggrepel包中的geom_text_repel函数,只需要将geom_text换成geom_text_repel即可。
library(ggrepel)
ggplot(df1,aes(x=A,y=B))+geom_line(size=1)+
geom_point(data=df,aes(x=GC3s,y=ENC,color=gene))+xlim(0,1)+
ylim(0,70)+labs(x="GC3s",y="ENC")+theme_classic()+
geom_text_repel(data=df,aes(x=GC3s,y=ENC,color=gene,label=gene))
theme(legend.position="none")
image.png
###绘制GC3s图
ENC<-function(x){
return(2 + x + 29/(x^2+(1-x)^2))
}
x <- seq(0,1,by=0.005)
y <- ENC(x)
df1<-data.frame(A=x,B=y)
library(ggplot2)
df <- read_delim("~/yt/20230106_baimaike/0105_YC_hifi/mito_assemble_script/0314_comparate-mito/6-code/txt",
"\t", escape_double = FALSE, trim_ws = TRUE)
ggplot(df1,aes(x=A,y=B))+geom_line(size=1)+
geom_point(data=df,aes(x=GC3s,y=ENC))+xlim(0,1)+
ylim(0,70)+labs(x="GC3s",y="ENC")+theme_bw()
ggplot(df1,aes(x=A,y=B))+geom_line(size=1)+
geom_point(data=df,aes(x=GC3s,y=ENC,color=gene))+xlim(0,1)+
ylim(0,70)+labs(x="GC3s",y="ENC")+theme_classic()+
geom_text(data=df,aes(x=GC3s,y=ENC,color=gene,label=gene))
theme(legend.position="none")
ggplot(df1,aes(x=A,y=B))+geom_line(size=1)+
geom_point(data=df,aes(x=GC3s,y=ENC,color=gene))+xlim(0,1)+
ylim(0,70)+labs(x="GC3s",y="ENC")+theme_classic()+
geom_text_repel(data=df,aes(x=GC3s,y=ENC,color=gene,label=gene))
theme(legend.position="none")
ggplot(df1,aes(x=A,y=B))+geom_line(size=1)+
geom_point(data=df,aes(x=GC3s,y=ENC,color=gene))+xlim(0,1)+
ylim(0,70)+labs(x="GC3s",y="ENC")+theme_classic()+
geom_text_repel(data=df,aes(x=GC3s,y=ENC,color=gene,label=gene),fontface="bold", color="black")
theme(legend.position="none")
网友评论