A bit weird to answer my own question, but for who's interested I can show the 'hard' way using biomaRt
and then use goseq
with gene2cat
defined.
So first you need biomaRt to get annotation of the genes. I have ensembl genes from mm10.
library(biomaRt)
table <- read.table(file, header = T, stringsAsFactors = F)
ensembl <- useMart("ENSEMBL_MART_ENSEMBL")
ensembl <- useDataset("mmusculus_gene_ensembl", mart = ensembl)
allGenes <- table$Geneid
GOs <- getBM(attributes=c('ensembl_gene_id', 'go_id', 'name_1006', 'go_linkage_type', 'namespace_1003'),
filters = 'ensembl_gene_id',
values = allGenes,
mart = ensembl)
dim(GOs)
[1] 477082 5
table(GOs$go_linkage_type)
EXP IBA IC IDA IEA IEP IGI IMP IPI ISA ISM ISO ISS NAS ND RCA TAS
36931 36 27918 525 34038 210114 630 6891 30219 6205 4234 20 77365 24673 609 12821 99 3754
# I only want BP and no IEA evidence code
GOs_no_IEA <- GOs[GOs$go_linkage_type != "IEA" & GOs$namespace_1003 == "biological_process",]
dim(GOs_no_IEA)
[1] 111944 5
Then you can continue with goseq.
library(goseq)
All <- read.table(input_All, sep = "\t", header = T)
All_genes <- as.character(All$Geneid)
TopTable <- read.table(input, sep = "\t", header = T)
sig_genes <- as.character(TopTable$Ensembl)
# Make gene vector
gene.vector <- as.integer(All_genes %in% sig_genes)
names(gene.vector) <- All_genes
gene.lengths <- All$Length
pwf <- nullp(gene.vector, "mm10", "ensGene", bias.data = gene.lengths)
head(pwf)
GO.wall <- goseq(pwf, "mm10", "ensGene", gene2cat = GOs_no_IEA[, c(1:2)], use_genes_without_cat = F, test.cats = "GO:BP")
elim
function? That reduces the number of significant GO terms, but won't eliminate false positive genes (targets) for further research. $\endgroup$