您好,登录后才能下订单哦!
本篇内容主要讲解“怎么使用R语言的clusterProfiler对葡萄做GO富集”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么使用R语言的clusterProfiler对葡萄做GO富集”吧!
stringtie -e -B -p 8 -G merged.combined.gtf -o ballgown/L01/L01.gtf output_bam/L01.sorted.bam
library(ballgown)
library(genefilter)
library(dplyr)
pheno_data<-read.csv("pheno_data.txt",header=T)
grape_expr <- ballgown(dataDir = "ballgown",
samplePattern = "L0",
pData = pheno_data)
这一步可以拿到gene_id还有gene_name ,FPKM的表达量,cov对用的应该是reads count吧。
接下来是差异表达分析
代码是
grape_expr_filter<-subset(grape_expr,
"rowVars(texpr(grape_expr))>1",
genomesubset=T)
results_genes <- stattest(grape_expr_filter,
feature = "gene",
covariate = "time_point",
getFC = TRUE,
meas = "FPKM")
#results_genes <- arrange(results_genes,pval)
results_genes%>%
filter(abs(fc)>=2&pval<0.05) -> results_genes_diff
dim(results_genes_diff)
head(results_genes_diff)
现在有了基因id
接下来是使用clusterProfiler做go注释
这里参考 https://guangchuangyu.github.io/cn/2017/07/clusterprofiler-maize/#disqus_thread
首先把这个基因id对应着转换成 ENTREZID ,这里需要借助对应的gtf注释文件
这里只关注蛋白编码基因
grep 'gene_biotype "protein_coding"' 12X_genomic.gtf > 12X_protein_coding.gtf
#python
from gtfparse import read_gtf
known_proteincoding = read_gtf("12X_protein_coding.gtf")
known_proteincoding.to_csv("all_protein_coding.csv")
GO富集分析的R语言代码
require(AnnotationHub)
hub<-AnnotationHub() #这一步对网路有要求
# aa<-query(hub,'zea')
# aa$title
# query(hub,'Malus domestica')
bb<-query(hub,"Vitis vinifera")
#bb$title
grape<-hub[['AH85815']]
# length(keys(grape))
# columns(grape)
protein_coding_all<-read.csv("all_protein_coding.csv",header=T)
df<-merge(results_genes_diff,grape_expr_filter@expr$trans,by.x="id",by.y="gene_id")
df1<-merge(df,protein_coding_all,by.x="gene_name",by.y="gene_id")
dim(df1)
gene_ids<-
df1$db_xref[!duplicated(df1$db_xref)]
gene_ids<-stringr::str_replace(gene_ids,"GeneID:","")
library(clusterProfiler)
bitr(keys(grape)[2],'ENTREZID',c("REFSEQ","GO",
"ONTOLOGY","GENENAME",
"SYMBOL"),grape)
res = enrichGO(gene_ids,
OrgDb=grape, pvalueCutoff=0.05, qvalueCutoff=0.05)
help(package="clusterProfiler")
dotplot(res)
最后的结果是
到此,相信大家对“怎么使用R语言的clusterProfiler对葡萄做GO富集”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。