R/enrich.R
dag_enrich_on_offsprings_by_permutation.Rd
Enrichment analysis on offspring terms by permutation test
dag_enrich_on_offsprings_by_permutation(
dag,
value,
perm = 1000,
min_offspring = 10,
verbose = simona_opt$verbose
)
An ontology_DAG
object.
A numeric value. The value should correspond to terms in dag@terms
.
Number of permutations.
Minimal size of the offspring set.
Whether to print messages.
A data frame with the following columns:
term
: Term names.
stats
: The statistics of terms.
n_offspring
: Number of offspring terms of t
(including t
itself).
log2_fold_enrichment
: defined as log2(s/mean)
where mean
is calculated from random permutation.
z_score
: Defined as (s - mean)/sd
where mean
and sd
are calculated from random permutation.
p_value
: P-values from permutation test.
p_adjust
: Adjusted p-values from the BH method.
The number of rows in the data frame is the same as the number of terms in the DAG.
In the function dag_enrich_on_offsprings()
, the statistic for testing is the number of terms in each category. Here
this funtion makes the testing procedure more general
The function tests whether a term t
's offspring terms have an over-represented pattern on values in value
.
Denote T
as the set of t
's offspring terms plus t
itself, and v
as the numeric vector of value
, we first
calculate a score s
based on values in T
:
= mean_{terms in T}(v) s
To construct a random version of s
, we randomly sample n_T
terms from the DAG where n_T
is the size of set T
:
= mean_{n_T randomly sampled terms}(v) sr_i
where index i
represents the i^th sampling. If we sample k
times, the p-value is calculated as:
= sum_{i in 1..k}(I(sr_i > s))/k p
# \dontrun{
dag = create_ontology_DAG_from_GO_db()
#> relations: is_a, part_of
value = runif(dag_n_terms(dag)) # a set of random values
df = dag_enrich_on_offsprings_by_permutation(dag, value)
#> Error in dag_enrich_on_offsprings_by_permutation(dag, value): could not find function "dag_enrich_on_offsprings_by_permutation"
# }
1
#> [1] 1