ecdf_lr_test_clon_excl_avg_rate: Compare observed likelihood ratio test statistic to its ecdf...

Description Usage Arguments Details Value Author(s) Examples

View source: R/stats_functions.R

Description

Compare the likelihood ratio test statistic to its ecdf under the null for two mutated genes/pathways in clones of patients.

Usage

1
2
ecdf_lr_test_clon_excl_avg_rate(entA, entB, clone_tbl, avg_rates_m, ecdf_list,
  alternative)

Arguments

entA

One gene/pathway of the pair.

entB

The other gene/pathway of the pair.

clone_tbl

The clone tibble as generated with create_tbl_tree_collection from several trees of the tree inference, i.e. it also contains a column 'tree_id'.

avg_rates_m

The average rates of clonal exclusivity for each patient. The name of each rate is the respective patient_id.

ecdf_list

The list of ECDF's of the test statistic under the null distribution. Can be generated with generate_ecdf_test_stat. It is important that the rates that are used for that are the same as the avg_rates_m here.

alternative

The character indicating whether pairs should only be tested if delta > 0 or if all pairs should be tested. Can be one of "greater" or "two.sided".

Details

Tests whether the observed number of clonal exclusivities of mutated entities (genes or pathways) A and B in clones of patients is significantly different from what would be expected given the average clonal exclusivity rates. The observed test statistic is compared to the ecdf of the test statistic under the null hypothesis.

Value

Returns list(p_val, num_patients, mle_delta, test_statistic), i.e. a list with the p-value, the number of patients in which both of the genes/pathways were mutated, the maximum likelihood estimate of the delta, and the test statistic.

Author(s)

Ariane L. Moore

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
clone_tbl <- dplyr::tibble("file_name"=
           rep(c(rep(c("fn1", "fn2"), each=3)), 2),
          "patient_id"=rep(c(rep(c("pat1", "pat2"), each=3)), 2),
          "altered_entity"=c(rep(c("geneA", "geneB", "geneC"), 4)),
          "clone1"=c(0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0),
          "clone2"=c(1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1),
          "tree_id"=c(rep(5, 6), rep(10, 6)))
clone_tbl_pat1 <- dplyr::filter(clone_tbl, patient_id == "pat1")
clone_tbl_pat2 <- dplyr::filter(clone_tbl, patient_id == "pat2")
rates_exmpl_1 <- compute_rates_clon_excl(clone_tbl_pat1)
rates_exmpl_2 <- compute_rates_clon_excl(clone_tbl_pat2)
avg_rates_m <- apply(cbind(rates_exmpl_1, rates_exmpl_2), 2, mean)
names(avg_rates_m) <- c(names(rates_exmpl_1)[1], 
    names(rates_exmpl_2)[1])
values_clon_excl_num_trees_pat1 <- get_hist_clon_excl(clone_tbl_pat1)
values_clon_excl_num_trees_pat2 <- get_hist_clon_excl(clone_tbl_pat2)
list_of_num_trees_all_pats <- 
 list(pat1=values_clon_excl_num_trees_pat1[[1]], 
      pat2=values_clon_excl_num_trees_pat2[[1]])
list_of_clon_excl_all_pats <- 
  list(pat1=values_clon_excl_num_trees_pat1[[2]],
       pat2=values_clon_excl_num_trees_pat2[[2]])
num_pat_pair_max <- 2
num_pairs_sim <- 10
ecdf_list <- generate_ecdf_test_stat(avg_rates_m, 
                               list_of_num_trees_all_pats, 
                               list_of_clon_excl_all_pats, 
                               num_pat_pair_max, 
                               num_pairs_sim)
ecdf_lr_test_clon_excl_avg_rate("geneA", "geneB", clone_tbl, 
                                  avg_rates_m,
                                  ecdf_list, "greater")

GeneAccord documentation built on Nov. 8, 2020, 8:04 p.m.