Title: | The Beta-Binomial Test for Count Data |
---|---|
Description: | The beta-binomial test is used for significance analysis of independent samples by Pham et al. (2010) <doi:10.1093/bioinformatics/btp677>. The inverted beta-binomial test is used for paired sample testing, e.g. pre-treatment and post-treatment data, by Pham and Jimenez (2012) <doi:10.1093/bioinformatics/bts394>. |
Authors: | Thang Pham [aut, cre, cph, ctb] |
Maintainer: | Thang Pham <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 1.3 |
Built: | 2024-10-31 22:11:05 UTC |
Source: | CRAN |
Performs the beta-binomial test for count data.
bb.test(x, tx, group, alternative = c("two.sided", "less", "greater"), n.threads = -1, verbose = TRUE)
bb.test(x, tx, group, alternative = c("two.sided", "less", "greater"), n.threads = -1, verbose = TRUE)
x |
A vector or matrix of counts. When |
tx |
A vector or matrix of the total sample counts. When |
group |
A vector of group indicators. |
alternative |
A character string specifying the alternative hypothesis: "two.sided" (default), "greater" or "less". |
n.threads |
The number of threads to be used. When |
verbose |
A logical value. If |
This test is designed for independent samples, two or more groups.
A list with a single component is returned
p.value |
The p-value of the test. |
Thang V. Pham
Pham TV, Piersma SR, Warmoes M, Jimenez CR (2010) On the beta binomial model for analysis of spectral count data in label-free tandem mass spectrometry-based proteomics. Bioinformatics, 26(3):363-369.
x <- c(1, 5, 1, 10, 9, 11, 2, 8) tx <- c(19609, 19053, 19235, 19374, 18868, 19018, 18844, 19271) group <- c(rep("cancer", 3), rep("normal", 5)) bb.test(x, tx, group) # p.value = 0.01568598
x <- c(1, 5, 1, 10, 9, 11, 2, 8) tx <- c(19609, 19053, 19235, 19374, 18868, 19018, 18844, 19271) group <- c(rep("cancer", 3), rep("normal", 5)) bb.test(x, tx, group) # p.value = 0.01568598
Calculates the fold changes between two numerical matrices row by row.
fold.change(d1, d2, BIG = 1e4)
fold.change(d1, d2, BIG = 1e4)
d1 |
The first data matrix. |
d2 |
The second data matrix. |
BIG |
A number representing a big value of the result, i.e. black-and-white regulation. |
The two matrices d1
and d2
must have the same number of rows.
A positive value means up-regulation where the average of d2
is higher than that of d1
. Conversely, a negative value means down-regulation where the the average of d1
is higher than that of d2
. If one group contains all zeros, a positive or negative BIG
value is returned.
A vector of fold changes is returned.
Thang V. Pham
Pham TV (2021). countdata: The Beta-Binomial Test for Count Data. R package version 1.1. https://CRAN.R-project.org/package=countdata
x <- rbind(c(1.5, 1.2, 10.2), c(9.1, 2.2, 8.1)) fold.change(x, 2 * x) # returns a column vector of 2 fold.change(x, 0.5 * x) # returns a column vector of -2
x <- rbind(c(1.5, 1.2, 10.2), c(9.1, 2.2, 8.1)) fold.change(x, 2 * x) # returns a column vector of 2 fold.change(x, 0.5 * x) # returns a column vector of -2
Performs the inverted beta-binomial test for paired count data.
ibb.test(x, tx, group, alternative = c("two.sided", "less", "greater"), n.threads = -1, BIG = 1e4, verbose = TRUE)
ibb.test(x, tx, group, alternative = c("two.sided", "less", "greater"), n.threads = -1, BIG = 1e4, verbose = TRUE)
x |
A vector or matrix of counts. When |
tx |
A vector or matrix of the total sample counts. When |
group |
A vector of group indicators. There should be two groups of equal size. The samples are matched by the order of appearance in each group. |
alternative |
A character string specifying the alternative hypothesis: "two.sided" (default), "greater" or "less". |
n.threads |
The number of threads to be used. When |
BIG |
A number representing a big value of the result, i.e. black-and-white regulation. |
verbose |
A logical value. If |
This test is designed for paired samples, for example data acquired before and after treatment.
A list of values is returned
p.value |
The p-value of the test. |
fc |
An estimation of the common fold change for all sample pairs. A positive value means up-regulation, i.e. the second group is higher, and a negative value down-regulation. A black-and-white regulation is denoted by the |
Thang V. Pham
Pham TV, Jimenez CR (2012) An accurate paired sample test for count data. Bioinformatics, 28(18):i596-i602.
x <- c(33, 32, 86, 51, 52, 149) tx <- c(7742608, 15581382, 20933491, 7126839, 13842297, 14760103) group <- c(rep("cancer", 3), rep("normal", 3)) ibb.test(x, tx, group) # p.value = 0.004103636 # fc = 2.137632
x <- c(33, 32, 86, 51, 52, 149) tx <- c(7742608, 15581382, 20933491, 7126839, 13842297, 14760103) group <- c(rep("cancer", 3), rep("normal", 3)) ibb.test(x, tx, group) # p.value = 0.004103636 # fc = 2.137632
Normalize a numerical matrix by scaling each column so that the scaled column sums are equal.
normalize(d)
normalize(d)
d |
A numerical matrix. |
The average of column sums is computed. A scaling factor is calculated for each colunm so that the scaled column sum is equal to the computed average value.
A matrix of the same size as d
is returned. The column sums of this matrix are equal.
Thang V. Pham
Pham TV (2021). countdata: The Beta-Binomial Test for Count Data. R package version 1.1. https://CRAN.R-project.org/package=countdata
d <- rbind(c(2.5, 11.2, 7.2), c(9.1, 2.2, 7.1)) colSums(d) # 11.6 13.4 14.3 colSums(normalize(d)) # 13.1 13.1 13.1
d <- rbind(c(2.5, 11.2, 7.2), c(9.1, 2.2, 7.1)) colSums(d) # 11.6 13.4 14.3 colSums(normalize(d)) # 13.1 13.1 13.1