text: user939: When using GOseq analysis on RNA-seq data, I often find many 'false positives'. What I mean with that is that some genes in certain categories are not really involved in the process, but are only involved due to 'Electronic Annotation' (IEA). Most of the genes are IEA. A list of all evidence codes is here.
  Is it possible to (easily) do GOseq analysis without this evidence group?
  I mean, I know how to do it the hard way (make a custom GO-genes annotation in e.g., biomaRt removing all IEA evidence code genes, and perform GOseq with custom genome). But is there also a easy way in GOseq available? 
  
  user939: 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")
  
  
original_text: 939: <p>When using GOseq analysis on RNA-seq data, I often find many 'false positives'. What I mean with that is that some genes in certain categories are not really involved in the process, but are only involved due to 'Electronic Annotation' (IEA). Most of the genes are IEA. A list of all evidence codes is <a href="http://www.geneontology.org/page/guide-go-evidence-codes" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Is it possible to (easily) do GOseq analysis without this evidence group?</p>
  
  <p>I mean, I know how to do it the hard way (make a custom GO-genes annotation in e.g., biomaRt removing all IEA evidence code genes, and perform GOseq with custom genome). But is there also a easy way in GOseq available? </p>
   939: <p>A bit weird to answer my own question, but for who's interested I can show the 'hard' way using <code>biomaRt</code> and then use <code>goseq</code> with <code>gene2cat</code> defined.</p>
  
  <p>So first you need biomaRt to get annotation of the genes. I have ensembl genes from mm10.</p>
  
  <pre><code>library(biomaRt)
  
  table &lt;- read.table(file, header = T, stringsAsFactors = F)
  
  ensembl &lt;- useMart("ENSEMBL_MART_ENSEMBL")
  
  ensembl &lt;- useDataset("mmusculus_gene_ensembl", mart = ensembl)
  
  allGenes &lt;- table$Geneid
  
  GOs &lt;- 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 &lt;- GOs[GOs$go_linkage_type != "IEA" &amp; GOs$namespace_1003 == "biological_process",]
  
  dim(GOs_no_IEA)
  [1] 111944      5
  </code></pre>
  
  <p>Then you can continue with goseq.</p>
  
  <pre><code>library(goseq)
  
  All &lt;- read.table(input_All, sep = "\t", header = T)
  
  All_genes &lt;- as.character(All$Geneid)
  
  TopTable &lt;- read.table(input, sep = "\t", header = T)
  
  sig_genes &lt;- as.character(TopTable$Ensembl)
  
  # Make gene vector
  
  gene.vector &lt;- as.integer(All_genes %in% sig_genes)
  
  names(gene.vector) &lt;- All_genes
  
  gene.lengths &lt;- All$Length
  
  pwf &lt;- nullp(gene.vector, "mm10", "ensGene", bias.data = gene.lengths)
  head(pwf)
  
  GO.wall &lt;- goseq(pwf, "mm10", "ensGene", gene2cat = GOs_no_IEA[, c(1:2)], use_genes_without_cat = F, test.cats = "GO:BP")
  </code></pre>
  