First, 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 fetal/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 = KGExplorer::filter_ontology(KGExplorer::get_ontology("cl"), keep_descendants =
    "cell"),
  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,
  ...
)

Arguments

results

The cell type-phenotype enrichment results generated by gen_results and merged together with merge_results

hpo

Human Phenotype Ontology object, loaded from get_ontology.

cl

Cell Ontology (CL) object from KGExplorer::get_ontology("cl").

gpt_annot

A data.table of GPT annotations.

fetal_keywords

A character vector of keywords to identify fetal cell types.

celltype_col

The column name of the cell type.

top_n_phenotypes

Number of top and bottom phenotypes to return.

top_n_hpo

Number of top and bottom phenotypes to run enrichment analyses on.

top_n_cl

Number of top and bottom cell types to run enrichment analyses on.

q_threshold

The q value threshold to subset the results by.

prune

Prune redundant ancestral terms from the enrichment results using prune_ancestors.

...

Arguments passed on to simona::dag_enrich_on_offsprings

dag

An ontology_DAG object.

terms

A vector of term names.

min_hits

Minimal number of terms in an offspring set.

min_offspring

Minimal size of the offspring set.

Value

Named list of enrichment results.

Examples

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: v2024-12-12
#> 383 phenotypes do not have matching HPO IDs.
#> Reading in GPT annotations for 16,753 phenotypes.
#> Mapping cell types to cell ontology terms.
#> Adding stage information.
#> Translating ontology terms to ids.
#> Loading cached ontology: /github/home/.cache/R/KGExplorer/cl.rds
#> Keeping descendants of 1 term(s).
#> 2,801 terms remain after filtering.
#> Pruning ancestors.
#> 2 / 10 terms were kept after pruning.
#> Pruning ancestors.
#> 2 / 9 terms were kept after pruning.
#> Pruning ancestors.
#> 1 / 1 terms were kept after pruning.
#> Pruning ancestors.
#> 0 / 0 terms were kept after pruning.