Created
November 1, 2017 20:57
-
-
Save slavailn/dcff753cc32fd9e053590308c831b057 to your computer and use it in GitHub Desktop.
Run topGO on non-model organism
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(ggplot2) | |
library(reshape2) | |
library(topGO) | |
library(plyr) | |
# Read in some table with gene ids, for example expressions | |
coreGenes <- read.table(<some_table_gene_ids>) | |
# Get gene mappings to GO terms | |
# This table has to look like this: | |
# FN03409 GO:0009514,GO:0004451,GO:0046872,GO:0006097,GO:0006099, | |
# FN23295 GO:0009507,GO:0022626,GO:0009514,GO:0005739, | |
# FN06463 GO:0009514,GO:0004474,GO:0006097,GO:0006099, | |
# FN16456 GO:0048046,GO:0009507,GO:0009570,GO:0005829,GO:0016020,GO:0005777, | |
# FN00210 GO:0005576,GO:0003993,GO:0046872, | |
# FN00543 GO:0005788,GO:0003756,GO:0045454, | |
# FN26703 GO:0005829,GO:0016020,GO:0005730,GO:0005634,GO:0005524,GO:0004612, | |
# FN16210 GO:0005829,GO:0016020,GO:0005739,GO:0005634,GO:0005886,GO:0009506, | |
# FN20048 GO:0009507,GO:0016020,GO:0005777,GO:0009536,GO:0004069,GO:0080130, | |
# FN26629 GO:0022625,GO:0003723,GO:0003735,GO:0000027,GO:0006412, | |
geneID2GO <- readMappings("gene2GO.txt") | |
geneNames <- names(geneID2GO) | |
# Get the list of genes of interest | |
myInterestingGenes <- coreGenes$id | |
geneList <- factor(as.integer(geneNames %in% myInterestingGenes)) | |
names(geneList) <- geneNames | |
head(geneList) | |
GOdata <- new("topGOdata", ontology = "BP", allGenes = geneList, | |
annot = annFUN.gene2GO, gene2GO = geneID2GO) | |
# Run topGO with elimination test | |
resultTopGO.elim <- runTest(GOdata, algorithm = "elim", statistic = "Fisher" ) | |
allRes <- GenTable(GOdata, elimKS = resultTopGO.elim, | |
orderBy = "elimKS", | |
topNodes = 356) | |
write.table(allRes, file = "topGO_results.txt", sep = "\t", quote = F, col.names = T, row.names = F) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment