Skip to content

Instantly share code, notes, and snippets.

@PoisonAlien
Created November 10, 2021 11:49
Show Gist options
  • Save PoisonAlien/a904629260b21dce85d6629e67b0a8ef to your computer and use it in GitHub Desktop.
Save PoisonAlien/a904629260b21dce85d6629e67b0a8ef to your computer and use it in GitHub Desktop.
#Wrapper around goseq
#'@param assayedGenes total gene IDs that were measured
#'@param deGenes DE gene IDs
#'@param source_id Can be `ensGene` or `geneSymbol`
#'@param hyperGeo Dfault TRUE. Set to FALSE for rna-seq data
goseq_wrapper = function(assayedGenes, deGenes, source_id = "ensGene", hyperGeo = TRUE){
gene_vector = as.integer(assayedGenes %in% deGenes)
names(gene_vector)= assayedGenes
pwf = suppressWarnings(suppressMessages(goseq::nullp(DEgenes = gene_vector, genome = "hg19", id = source_id, plot.fit = FALSE)))
if(hyperGeo){
GO = suppressWarnings(suppressMessages(goseq::goseq(pwf = pwf, genome = "hg19", id = source_id, test.cats = c("GO:BP", "GO:MF"), method = "Hypergeometric")))
}else{
GO = suppressWarnings(suppressMessages(goseq::goseq(pwf = pwf, genome = "hg19", id = source_id, test.cats = c("GO:BP", "GO:MF"))))
}
data.table::setDT(GO)
GO[,fdr := p.adjust(GO$over_represented_pvalue)]
GO
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment