-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGO.R
69 lines (61 loc) · 1.62 KB
/
GO.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#DME MIR TARGETS GO ANALYSIS####
home= '~/GitHub/'
rootdir = paste(home, "integrative-transcriptomics", sep="")
setwd(rootdir)
## >>unbiased GO analysis - all results####
library(topGO)
get.GO <- function(scores, ensgs, quant = .9){
geneID2GO <- readRDS(file = "./working_data/geneID2GO_all.rds")
#ontology
ontology <- "BP"
# #description
# description <- "miR targets in LA-N-2 during CNTF differentiation (all conditions), miRExpress and bowtie/bwa intersect"
#allGenes list
allGenes <- scores
names(allGenes) <- ensgs
#geneSelection function
hist(allGenes)
quantile(allGenes, seq(0, 1, .01))
x <- quantile(allGenes, seq(0, 1, quant))
topGenes <- function(allScore) {
return(allScore >= x)
}
#prune GO terms
nodeSize <- 10
GOdata <- new(
"topGOdata",
# description = description,
ontology = ontology,
allGenes = allGenes,
geneSel = topGenes,
annot = annFUN.gene2GO,
nodeSize = nodeSize,
gene2GO = geneID2GO
)
## >fisher test ####
test.stat <-
new("classicCount", testStatistic = GOFisherTest, name = "Fisher test")
resultFisher <- getSigGroups(GOdata, test.stat)
resultFisher
# >weight test ####
test.stat <-
new(
"weightCount",
testStatistic = GOFisherTest,
name = "Fisher test",
sigRatio = "ratio"
)
resultWeight <- getSigGroups(GOdata, test.stat)
resultWeight
## >total ####
allRes <- GenTable(
GOdata,
classic = resultFisher,
weight = resultWeight,
orderBy = "weight",
ranksOf = "classic",
topNodes = 100
)
res <- allRes[allRes$weight < .05, ]
return(list(res, GOdata))
}