Diff of /geneGO2.R [000000] .. [81de4e]

Switch to unified view

a b/geneGO2.R
1
library(topGO)
2
library(limma)
3
library(edgeR)
4
library(org.Hs.eg.db)
5
6
data = read.table("lung.txt", header = T, sep = "\t")
7
data2 = data[data$X != "SLC35E2",]
8
rownames(data2) = data2[,1]
9
data = data2[,-1]
10
condition = factor(rep(c("T1", "T2"), c(576, 552)))
11
design = model.matrix(~condition)
12
13
dge = DGEList(counts=as.matrix(data), group = condition)
14
dge = calcNormFactors(dge, method = "TMM") #webtool'da var. RLE dediği deseq, TMM dediği TMM, none dediği none
15
v = voom(dge,design,plot=F) 
16
fit = lmFit(v,design)
17
fit = eBayes(fit)
18
res = topTable(fit,coef=ncol(design),number = dim(data)[1])
19
geneList = res$adj.P.Val #voomNSC tarafından seçilen genler
20
names(geneList) = rownames(res) #voomNSC tarafından seçilen genler
21
biomarkers = rownames(res[10:50,]) #voomNSC tarafından seçilen genler
22
#truefalse = is.element(names(geneList),biomarkers)
23
#selection = function(x) TRUE 
24
25
#allGO2genes = annFUN.org(whichOnto='BP', feasibleGenes = NULL,
26
#                         mapping="org.Hs.eg.db", ID = "genename")
27
28
#GOdata = new("topGOdata", description = "Simple session", ontology = "BP",
29
# allGenes = geneList, geneSel = topDiffGenes, nodeSize = 10,
30
# annot = annFUN.db, affyLib = affyLib)
31
truefalse = function(allScore) {  
32
  truefalse = is.element(names(geneList),biomarkers)
33
  return(truefalse)
34
}
35
36
allGO2genes = annFUN.org(whichOnto='BP', feasibleGenes = NULL,
37
                         mapping="org.Hs.eg.db", ID = "symbol")
38
GOdata =  new('topGOdata', ontology = 'BP', allGenes = geneList, 
39
              annot = annFUN.GO2genes, GO2genes = allGO2genes, 
40
              geneSel = truefalse, nodeSize=10)
41
42
results.ks = runTest(GOdata, algorithm = "classic", statistic = "ks")
43
results.ks
44
allRes = GenTable(GOdata, KS = results.ks, orderBy = "KS", topNodes = 20)
45
allRes[,c('GO.ID','Term','KS')]
46
showSigOfNodes(GOdata, score(results.ks), firstSigNodes = 5, useInfo = 'all')
47