||
#使用R语言,可以将LPSN网站(http://www.bacterio.net)上的感兴趣的细菌的属下的物种数统计出来并做图:
library(stringr)
#统计中华根瘤菌属(Sinorhizobium)
SinorhizobiumPage <- readLines("http://www.bacterio.net/sinorhizobium.html")
grep('Number of species', SinorhizobiumPage)
pat1 <- "(\d)+1"
(SinorhizobiumSpNum <- as.numeric(str_extract(SinorhizobiumPage[125], pat1)))
#统计剑菌属(Ensifer)
EnsiferPage <- readLines("http://www.bacterio.net/ensifer.html")
grep('Number of species', EnsiferPage)
EnsiferPage[125]
pat2 <- "(\d)+4"
(EnsiferSpNum <- as.numeric(str_extract(EnsiferPage[125], pat2)))
#统计根瘤菌属(Rhizobium)
RhizobiumPage <- readLines("http://www.bacterio.net/rhizobium.html")
grep('Number of species', RhizobiumPage)
pat3 <- "(\d)+2"
(RhizobiumSpNum <- as.numeric(str_extract(RhizobiumPage[125], pat3)))
#统计慢生根瘤菌属(Bradyrhizobium)
BradyrhizobiumPage <- readLines("http://www.bacterio.net/bradyrhizobium.html")
grep('Number of species', BradyrhizobiumPage)
pat4 <- "(\d)+6"
(BradyrhizobiumSpNum <- as.numeric(str_extract(BradyrhizobiumPage[125], pat4)))
rhizobiaNumbers <- data.frame(S=SinorhizobiumSpNum, E=EnsiferSpNum, R=RhizobiumSpNum,
B=BradyrhizobiumSpNum)
sino <- expression(italic(Sinorhizobium))
ensi <- expression(italic(Ensifer))
rhi <- expression(italic(Rhizobium))
brady <- expression(italic(Bradyrhizobium))
t.rhizobia <- t(rhizobiaNumbers)
t1.rhizobia <- as.data.frame(t.rhizobia)
barp <- barplot(t1.rhizobia$V1, names.arg=c(sino, ensi, rhi, brady),
xlab="属", ylab="种数", col=rainbow(4),
main="各属内根瘤菌的种数(截至到2014年4月20日)",
ylim=c(0, 80))
abline(h=0)
#经做图后如下:
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-22 13:55
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社