R/run_congenital_enrichment.R
run_congenital_enrichment.RdFirst, this function computes the mean difference in association p-values
between a given phenotype and the congenital and non-congenital versions
of a cell type (the fetal_nonfetal_pdiff column).
It then sorts the results from the largest to the smallest difference.
Here, a positive difference indicates that the phenotype is more associated
with the foetal/embryonic version of the cell type, while a negative difference
indicates that the phenotype is more associated with the adult version.
Next, it runs enrichment analyses for the top and bottom N phenotypes
using the dag_enrich_on_offsprings function.
Finally, it run enrichment analyses for the top and bottom N cell types.
run_congenital_enrichment(
results,
hpo = HPOExplorer::get_hpo(),
cl = get_cl(),
gpt_annot = HPOExplorer::gpt_annot_codify(),
fetal_keywords = c("fetal", "fetus", "primordial", "hESC", "embryonic"),
celltype_col = "author_celltype",
top_n_phenotypes = 10,
top_n_hpo = 50,
top_n_cl = top_n_hpo,
q_threshold = 0.05,
prune = TRUE,
...
)The cell type-phenotype enrichment results generated by gen_results and merged together with merge_results
Human Phenotype Ontology object, loaded from get_ontology.
Cell Ontology (CL) object from
KGExplorer::get_ontology("cl").
A data.table of GPT annotations.
A character vector of keywords to identify fetal cell types.
The column name of the cell type.
Number of top and bottom phenotypes to return.
Number of top and bottom phenotypes to run enrichment analyses on.
Number of top and bottom cell types to run enrichment analyses on.
The q value threshold to subset the results by.
Prune redundant ancestral terms from the enrichment results using prune_ancestors.
Arguments passed on to simona::dag_enrich_on_offsprings
dagAn ontology_DAG object.
termsA vector of term names.
min_hitsMinimal number of terms in an offspring set.
min_offspringMinimal size of the offspring set.
Named list of enrichment results.
results <- load_example_results()[ctd=="HumanCellLandscape"]
out <- run_congenital_enrichment(results=results)
#> Translating ontology terms to ids.
#> Reading cached RDS file: phenotype_to_genes.txt
#> + Version: v2025-05-06
#> 151 phenotypes do not have matching HPO IDs.
#> Reading in GPT annotations for 16,982 phenotypes.
#> Mapping cell types to cell ontology terms.
#> Adding stage information.
#> Translating ontology terms to ids.
#> Using cached ontology file (1/1):
#> /github/home/.cache/R/KGExplorer/ontologies/github/cl_v2023-09-21.rds
#> Keeping descendants of 2 term(s).
#> 2,711 terms remain after filtering.
#> Pruning ancestors.
#> 10 / 10 terms were kept after pruning.
#> Pruning ancestors.
#> 9 / 9 terms were kept after pruning.
#> Pruning ancestors.
#> 1 / 1 terms were kept after pruning.
#> Pruning ancestors.
#> 0 / 0 terms were kept after pruning.