> m <- read.table("cog.class.annot.txt",header = T,sep = "\t")
> head(m)
Code Functional.Categories Gene.Number
1 A RNA processing and modification 90
2 B Chromatin structure and dynamics 245
3 C Energy production and conversion 523
4 D Cell cycle control, cell division, chromosome partitioning 1034
5 E Amino acid transport and metabolism 793
6 F Nucleotide transport and metabolism 209
> layout(matrix(c(1,2),nrow = 1),widths = c(20,13))# layout布局,1行2列#
> layout.show(2)#查看
> par(mar=c(3,4,4,1)+0.1)
> class <- c("J","A","K","L","B","D","Y","V","T","M","N","Z","W","U","O","C","G","E","F","H","I","P","Q","R","S");
> class
[1] "J" "A" "K" "L" "B" "D" "Y" "V" "T" "M" "N" "Z" "W" "U" "O" "C" "G" "E" "F" "H"
[21] "I" "P" "Q" "R" "S"
> t <- factor(as.character(m$Code),levels = class)
> m[order(t),]
Code Functional.Categories Gene.Number
10 J Translation, ribosomal structure and biogenesis 1424
1 A RNA processing and modification 90
11 K Transcription 1367
12 L Replication, recombination and repair 1576
2 B Chromatin structure and dynamics 245
4 D Cell cycle control, cell division, chromosome partitioning 1034
24 Y Nuclear structure 5
22 V Defense mechanisms 197
20 T Signal transduction mechanisms 891
13 M Cell wall/membrane/envelope biogenesis 949
14 N Cell motility 352
25 Z Cytoskeleton 417
23 W Extracellular structures 38
21 U Intracellular trafficking, secretion, and vesicular transport 731
15 O Posttranslational modification, protein turnover, chaperones 1242
3 C Energy production and conversion 523
7 G Carbohydrate transport and metabolism 1124
5 E Amino acid transport and metabolism 793
6 F Nucleotide transport and metabolism 209
8 H Coenzyme transport and metabolism 195
9 I Lipid transport and metabolism 579
16 P Inorganic ion transport and metabolism 580
17 Q Secondary metabolites biosynthesis, transport and catabolism 641
18 R General function prediction only 3283
19 S Function unknown 1121
> m <- m[order(t),]
> head(m)
Code Functional.Categories Gene.Number
10 J Translation, ribosomal structure and biogenesis 1424
1 A RNA processing and modification 90
11 K Transcription 1367
12 L Replication, recombination and repair 1576
2 B Chromatin structure and dynamics 245
4 D Cell cycle control, cell division, chromosome partitioning 1034
> barplot(m$Gene.Number,space = F,col = rainbow(25),ylab = "Number of Genes",names.arg = m$Code)
> l <- c(0,5,15,23,25)
> l
[1] 0 5 15 23 25
> id <- c("INFORMATION STORAGE AND PROCESSING","CELLULAR PROCESSES AND SIGNALING","METABOLISM","POORLY CHARACTERIZED")
> id
[1] "INFORMATION STORAGE AND PROCESSING" "CELLULAR PROCESSES AND SIGNALING"
[3] "METABOLISM" "POORLY CHARACTERIZED"
> abline(v=l[c(-1,-5)])
> for (i in 2:length(l)) {
text( (l[i-1]+l[i])/2, max(m[,3])*1.1,id[i-1],cex = 0.8,xpd=T)
}
> par(mar= c(2,0,2,1)+0.1)
> plot(0,0,type = "n",xlim = c(0,1),ylim = c(0,26),bty="n",axes = F,xlab = "",ylab = "")
> for(i in 1:length(class)){
text(0,26-i+0.5,paste(m$Code[i],m$Functional.Categories[i]),pos=4,cex=1,pty=T)
}
> title(main = "COG function classfication")
数据,链接:https://pan.baidu.com/s/1RoT4TxuZ4dKBDw6-kcbnIw
提取码:675p
《R语言与生物信息绘图》课程笔记