Function hpo::stats::hypergeom::gene_enrichment
source · pub fn gene_enrichment<'a, T, U>(
background: T,
set: U
) -> Vec<Enrichment<GeneId>>
Expand description
Calculates the hypergeometric enrichment of genes within the set
compared to the background
§Examples
use hpo::Ontology;
use hpo::{HpoSet, term::HpoGroup};
use hpo::stats::hypergeom::gene_enrichment;
let ontology = Ontology::from_binary("tests/example.hpo").unwrap();
let gene = ontology.gene_by_name("EZH2").unwrap();
let gene_hpo_set = gene.to_hpo_set(&ontology);
let mut enrichments = gene_enrichment(&ontology, &gene_hpo_set);
// the results are not sorted by default
enrichments.sort_by(|a, b| {
a.pvalue().partial_cmp(&b.pvalue()).unwrap()
});
assert!(enrichments.first().unwrap().pvalue() < enrichments.last().unwrap().pvalue());
assert!(enrichments.first().unwrap().enrichment() > enrichments.last().unwrap().enrichment());