Description Usage Arguments Value See Also Examples
View source: R/permutation-testing.R
This tests a statistic for association between labels (for instance, cluster/clonal ID) and covariates (for instance, subject or treatment) by permuting the link between the two.
Each observation represents a cell.
statistic
is any function of labels
1 2 3 4 5 6 7 8 9 10 11 | cluster_permute_test(
ccdb,
cell_covariate_keys,
cell_label_key = ccdb$cluster_pk,
cell_stratify_keys,
statistic,
n_perm,
alternative = c("two.sided", "less", "greater"),
sanity_check_strata = TRUE,
...
)
|
ccdb |
|
cell_covariate_keys |
|
cell_label_key |
|
cell_stratify_keys |
optional |
statistic |
function of label (vector) and covariate (data.frame). Must return a scalar |
n_perm |
number of permutations to run |
alternative |
|
sanity_check_strata |
|
... |
passed to |
a list containing the observed value of the statistic, its expectation (under independence), a p-value, and the Monte Carlo standard error (of the expected value).
1 2 3 4 5 6 7 8 9 10 11 12 | library(dplyr)
# covariate should name one or more columns in `cell_tbl`
cluster_idx = c(1, 1, 1, 2, 2, 3, 3)
subject = c('A', 'A', 'B', 'B', 'B', 'C', 'C')
contig_tbl = tibble(contig_pk = seq_along(cluster_idx), cluster_idx, subject)
ccdb_test = ContigCellDB(contig_tbl = contig_tbl, contig_pk = 'contig_pk',
cell_pk = c('contig_pk', 'subject', 'cluster_idx'), cluster_pk = 'cluster_idx')
ccdb_test$cell_tbl
cluster_permute_test(ccdb_test, 'subject', 'cluster_idx',
statistic = purity, n_perm = 50)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.