VOOZH about

URL: https://qiita.com/yuifu/items/5c96ccb59fdfa6f915d1

⇱ 五角形の遺伝子を並べる #R - Qiita


👁 Image
2

Go to list of users who liked

1

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

五角形の遺伝子を並べる

2
Last updated at Posted at 2013-10-31

よく論文にある「複数の遺伝子が五角形として並べてある図」をRで描いてみます.

遺伝子のstartとendとstrandから,五角形を描くのに必要な座標を計算する関数
convertToOperon<-function(x1,x2,strand,heightOfOperon=1,ratioOfTriangle=0.3,y1=1){y2<-y1+heightOfOperony3<-y1+heightOfOperon/2if(strand==1){xAngle<-(1-ratioOfTriangle)*(x2-x1)+x1x<-c(x1,x1,xAngle,x2,xAngle)y<-c(y1,y2,y2,y3,y1)return(list(x,y))}else{xAngle<-ratioOfTriangle*(x2-x1)+x1x<-c(x1,xAngle,x2,x2,xAngle)y<-c(y3,y2,y2,y1,y1)return(list(x,y))}}
たくさんの遺伝子をまとめて描く関数
# 入力は,複数の遺伝子のstart, end, strand, 色を格納したデータフレーム(dat)と,どこから(start)どこまで(end)plotOperons<-function(dat,start,end,heightOfOperon=0.7,ratioOfTriangle=0.3,y1=1,lwd=2,xlab="[kb]"){genome<-c(start,end)height<-c(0,3)# Define plot spaceplot(genome,height,type="n",xlab=xlab,ylab="",axes=F)axis(1)# Draw horizontal linelines(c(start,end),c(y1+heightOfOperon/2,y1+heightOfOperon/2),lwd=lwd)if(is.factor(dat[,4])){dat[,4]<-as.character(dat[,4])}for(iin1:nrow(dat)){coo<-convertToOperon(dat[i,1],dat[i,2],dat[i,3],heightOfOperon=heightOfOperon,ratioOfTriangle=ratioOfTriangle,y1=y1)print(dat[i,4])polygon(coo[[1]],coo[[2]],col=dat[i,4],lwd=lwd)}}
入力データ
dat<-data.frame(start=c(5,50,70),end=c(30,60,90),strand=c(1,-1,1),color=c("orange","green","magenta"))
プロット
plotOperons(dat,0,100)

👁 図

追記

こんなのもあるそうです genoPlotR

2

Go to list of users who liked

1
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2

Go to list of users who liked

1