sign_test: Sign test

Description Usage Arguments Value Examples

View source: R/annots.r

Description

Performs sign test of a score for all annotation terms in a set of genes that occurr a minimum number of times.

Usage

1
sign_test(dat, alternative = "two.sided", min_size = 3)

Arguments

dat

A data.frame or tibble. It must contain one row per gene and columns 'gene_id', 'terms', and 'score'. Column 'terms' must be of type character and each entry must be a comma-separated character string of all the terms that annotate the corresponding gene.

alternative

The alternative hypothesis to test. Either 'greater', 'less' or 'two.sided'. It corresponds to option 'alternative' in binom.test or ks.test which is used to determine if the number of positive scores for a given term is more than expected given the overall number of positive scores. Genes with score == 0 are removed prior to any analysis.

min_size

The minimum number of genes in the group for the test to be performed. Basically if the number of genes that appear in 'scores' is less than 'min_size', the test won't be performed.

Value

A tibble with elements: term (the annotation term ID), n_scucesses (the number of positive scores in that term), expected (the expected number of positive scores given the number of genes in the term and the overall probability of a positive score), n_trials (the number of genes annotated with the corresponding term), p_success (the overall proability of a positive score among all genes in dat) , and p.value (the p-value of the test). The tibble is sorted by increasing p-value.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Make some fake data
dat <- tibble::tibble(gene_id = paste('gene', 1:10, sep = ''),
                      terms = c('term1,term2,term3',
                                NA,
                                'term2,term3,term4',
                                'term3',
                                'term4,term5',
                                'term6',
                                'term6',
                                'term6,term2',
                                'term6,term7',
                                'term6,term2'),
                      score = -5:4)
dat

# Test
sign_test(dat, min_size = 2)

surh/HMVAR documentation built on Aug. 18, 2021, 1:21 a.m.