前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >散点图和直方图

散点图和直方图

作者头像
生信喵实验柴
发布2022-10-25 19:54:42
5610
发布2022-10-25 19:54:42
举报
文章被收录于专栏:生信喵实验柴生信喵实验柴

一、散点图

代码语言:javascript
复制
m <- read.table("prok_representative.csv",sep = ",",header = T);  
x <- m[,2]
y <- m[,4]  
plot(x,y,pch=16,xlab="Genome Size",ylab="Genes");  
fit <- lm(y~x);  
abline( fit,col="blue",lwd=1.8 );  
rr <- round( summary(fit)$adj.r.squared,2);  
intercept <- round( summary(fit)$coefficients[1],2);  
slope <- round( summary(fit)$coefficients[2],2);  
eq <- bquote( atop( "y = " * .(slope) * " x + " * .(intercept), R^2 == .(rr) ) );  
text(12,6e3,eq);

基因组大小与基因数目相关性散点图

二、基因长度分布直方图

代码语言:javascript
复制
#基因长度分布图
x <- read.table("H37Rv.gff",sep = "\t",header = F,skip = 7,quote = "")  
x <- x[x$V3=="gene",]  
# x <- x %>% dplyr::filter(V3 == 'gene')
x <- abs(x$V5-x$V4)+1  
# x <- x %>% dplyr::mutate(gene_len=abs(V5-V4)+1)
# head(x$gene_len)
length(x)  
range(x)  
hist(x)  
hist(x,breaks = 80)  
?hist
hist(x,breaks = 'Sturges') 
hist(x,breaks = c(0,500,1000,1500,2000,2500,15000))  
hist(x,breaks = 80,freq = F)  
hist(x,breaks = 80,density = T)  
hist(rivers,density = T,breaks = 10)  
?hist  
pdf(file = 'hist.pdf')
h <- hist(x,nclass=80,col="pink",xlab="Gene Length (bp)",main="Histogram of Gene Length");  
rug(x);
xfit<-seq(min(x),max(x),length=100);
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x));
yfit <- yfit*diff(h$mids[1:2])*length(x);
lines(xfit, yfit, col="blue", lwd=2);
dev.off()

基因长度分布直方图

写在最后:有时间我们会努力更新的。大家互动交流可以前去论坛,地址在下面,复制去浏览器即可访问,弥补下公众号没有留言功能的缺憾。原地址暂未启用(bioinfoer.com)。

代码语言:javascript
复制
sx.voiceclouds.cn

有些板块也可以预设为大家日常趣事的分享等,欢迎大家来提建议。

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-09-18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 生信喵实验柴 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档