70 likes | 257 Views
Gene Ontology Enrichment Analysis code. By Thalia Lake. setwd ("/Users/ StarTCL /Documents/R") library(" org.Mm.eg.db ") library(" GOstats ") universe= read.csv (" universereal.txt",header = T,sep ='t') Touniverse = universe$To universestrings = as.character ( Touniverse )
E N D
Gene Ontology Enrichment Analysis code By Thalia Lake
setwd("/Users/StarTCL/Documents/R") • library("org.Mm.eg.db") • library("GOstats") • universe=read.csv("universereal.txt",header=T,sep='\t') • Touniverse=universe$To • universestrings=as.character(Touniverse) • checkGO=mget(universestrings,org.Mm.egGO,ifnotfound=NA) • hasGO=checkGO[!is.na(checkGO)] • geneid=names(hasGO) • MmCutoff=0.05 • setwd("clusters")
myFiles=list.files(pattern="EntrezCluster.*out$") • for(f in myFiles){ • cluster=read.table(f,header=T) • cluster=unlist(cluster) • cstrings=as.character(cluster) • checkGOc=mget(cstrings,org.Mm.egGO,ifnotfound=NA) • hasGOc=checkGOc[!is.na(checkGOc)] • geneidc=names(hasGOc) • settings=c("BP","MF","CC")
for(s in settings){ • params=new("GOHyperGParams", • geneIds=geneidc, • universeGeneIds=geneid, • annotation="org.Mm.eg.db", • ontology=s, • pvalueCutoff=MmCutoff, • conditional=FALSE, • testDirection="over")
paramsCond=new("GOHyperGParams", • geneIds=geneidc, • universeGeneIds=geneid, • annotation="org.Mm.eg.db", • ontology=s, • pvalueCutoff=MmCutoff, • conditional=TRUE, • testDirection="over")
MmOver=hyperGTest(params) • MmCondOver=hyperGTest(paramsCond) • MmOver • MmCondOver • df=summary(MmOver) • names(df) • outputfile=sprintf("%s_%s.html", f, s) • htmlReport(MmCondOver,file=outputfile) • df[df$OddsRatio>2, ] • }}
Example of output data • Gene to GO CC Conditional test for over-representation