R语言:gggenes在基因组中画基因箭头图

Python022

R语言:gggenes在基因组中画基因箭头图,第1张

Github: gggens

CRAN: gggenes: Draw Gene Arrow Maps in 'ggplot2'

Author: Introduction to ‘gggenes’

注意:

R version >= 3.6

gggenes依赖的ggfittext需要R 3.6以上,导致我用R 3.4.1安装gggenes失败。后来改用R 3.6.1成功安装。

Linux conda安装R 3.6:

1. 基因组-基因-方向

1. 基础绘图

5. 控制箭头方向

6. 标记亚基因位置

R绘制带箭头坐标轴,两个参数需要提前设置

第一,xpd=NA,否则绘制箭头只会显示一半

xpd参数说明:A logical value or NA. If FALSE, all plotting is clipped to the plot region, if TRUE, all plotting is clipped to the figure region, and if NA, all plotting is clipped to the device region. 

第二,横纵坐标由于默认是多增加4%的区间,因此要么设置xaxs=“i" 和 yaxs ="i",让坐标轴交于结束位置

或者直接用par()['usr'][[1]] 找出绘制的起点和终点

在R语言中,这两个参数的取值包括 5种,其中"r"是默认值,就是我们上边讲到的添加4%的一个距离,"i" 代表的行为是原始数据的最小值到最大值是多少,对应的坐标轴的起始和终止位置就是多少

举例:par(xpd=NA)

plot(c(1:10),c(1:10),type="l",bty="l",xlab="X",ylab="Y")

ord<-par("usr")

arrows(x0 = ord[1],y0=ord[3],x1=ord[2]*1.05,y1=ord[3])

arrows(x0 = ord[1],y0=ord[3],x1=ord[1],y1=ord[4]*1.05)

绘制