| Title: | Computes Local False Discovery Rates |
|---|---|
| Description: | Computation of local false discovery rates. |
| Authors: | Bradley Efron [aut], Brit Turnbull [aut], Balasubramanian Narasimhan [aut, cre], Korbinian Strimmer [ctb] |
| Maintainer: | Balasubramanian Narasimhan <[email protected]> |
| License: | GPL-2 |
| Version: | 1.1-9 |
| Built: | 2026-10-16 21:48:29 UTC |
| Source: | https://github.com/bnaras/locfdr |
The data comprises 7680 z-values, each relating to a two-sample
t-test. The test compares gene expression values for 4 HIV patients
with values for 4 normal subjects; the t-score 'T[i]' for gene i has
been transformed to a normal scale, 'z[i] = qnorm(pt(T[i], df=6))',
so that the ‘z[i]'’s theoretically would have a standard
distribution under the null hypothesis.
hivdatahivdata
A numeric vector containing 7680 z-values.
van't Wout, et al., Cellular gene expression upon human immunodeficiency virus type 1 infection of CD4+-T-Cell lines, Journal of Virology 77, 1392-1402.
data(hivdata) hist(hivdata, breaks = 100)data(hivdata) hist(hivdata, breaks = 100)
A simulated dataset that involves 2000 "genes", each of which has
yielded a test statistic "zex", with
(independently for ). Of the 2000
values, 1800 (90%) are zero (null cases) and the
remaining 200 (10%) are drawn from a distribution
(non-null cases).
lfdrsimlfdrsim
A data frame with 2000 rows and 2 columns:
the true score for each gene
the observed z-value
data(lfdrsim) hist(lfdrsim$zex, breaks = 80)data(lfdrsim) hist(lfdrsim$zex, breaks = 80)
Computes influence functions and covariance matrices for local false discovery rate estimates under the MLE null.
loccov(N, N0, p0, d, s, x, X, f, JV, Y, i0, H, h, sw)loccov(N, N0, p0, d, s, x, X, f, JV, Y, i0, H, h, sw)
N |
Total number of cases. |
N0 |
Number of cases in the estimation interval. |
p0 |
Estimated proportion of null cases. |
d |
Estimated null mean (delta). |
s |
Estimated null standard deviation (sigma). |
x |
Vector of bin midpoints. |
X |
Design matrix for the density fit. |
f |
Fitted density values at bin midpoints. |
JV |
Jacobian-variance product from MLE. |
Y |
Two-vector of sufficient statistics from the MLE interval. |
i0 |
Indices of bins in the central matching region. |
H |
Vector of truncated normal moments. |
h |
Derivative terms from truncated normal. |
sw |
Switch: 2 returns parameter derivatives with respect to bin counts; 3 returns influence function of log(fdr); otherwise returns covariance matrix of log(fdr). |
Depends on 'sw': derivative matrix (sw=2), influence function matrix (sw=3), or covariance matrix (otherwise).
Computes covariance and influence functions for local false discovery rate estimates under the central matching or theoretical null.
loccov2(X, X0, i0, f, ests, N)loccov2(X, X0, i0, f, ests, N)
X |
Design matrix for the mixture density fit. |
X0 |
Design matrix for the null density fit. |
i0 |
Indices of bins in the central matching region. |
f |
Fitted mixture density values at bin midpoints. |
ests |
Three-vector of null parameter estimates 'c(delta, sigma, p0)'. |
N |
Total number of cases. |
A list with components:
Influence function matrix for log(fdr).
Parameter derivative matrix (3 x K).
Standard deviations of parameter estimates.
Covariance matrix of log(fdr) estimates.
Compute local false discovery rates, following the definitions and description in references listed below.
locfdr( zz, bre = 120, df = 7, pct = 0, pct0 = 1/4, nulltype = 1, type = 0, plot = 1, mult, mlests, main = " ", sw = 0 )locfdr( zz, bre = 120, df = 7, pct = 0, pct0 = 1/4, nulltype = 1, type = 0, plot = 1, mult, mlests, main = " ", sw = 0 )
zz |
A vector of summary statistics, one for each case under
simultaneous consideration. The calculations assume a large number
of cases, say 'length(zz)' exceeding 200. Results may be improved
by transforming zz so that its elements are theoretically distributed
as |
bre |
Number of breaks in the discretization of the z-score axis, or a vector of breakpoints fully describing the discretization. If 'length(zz)' is small, such as when the number of cases is less than about 1000, set bre to a number lower than the default of 120. |
df |
Degrees of freedom for fitting the estimated density |
pct |
Excluded tail proportions of zz's when fitting |
pct0 |
Proportion of the zz distribution used in fitting the null
density |
nulltype |
Type of null hypothesis assumed in estimating
|
type |
Type of fitting used for |
plot |
Plots desired. 0 gives no plots. 1 gives single plot
showing the histogram of zz and fitted densities |
mult |
Optional scalar multiple (or vector of multiples) of the sample size for calculation of the corresponding hypothetical Efdr value(s). |
mlests |
Optional vector of initial values for
|
main |
Main heading for the histogram plot when 'plot>0'. |
sw |
Determines the type of output desired. 2 gives a list consisting of the last 5 values listed under Value below. 3 gives the square matrix of dimension bre-1 representing the influence function of log(fdr). Any other value of sw returns a list consisting of the first 7 (8 if mult is supplied) values listed below. |
Depending on the value of 'sw':
For 'sw' other than 2 or 3, a list with components:
the estimated local false discovery rate for each case, using the selected type and nulltype.
a matrix of estimated parameters delta, sigma, and p0, along with their standard errors, for all three null types.
the expected false discovery rate for the non-null cases.
a 99x2 matrix giving the estimated cdf of fdr under
the non-null distribution .
a matrix of estimates at the bin midpoints.
the interval where fdr < 0.2.
the function call.
if the argument mult was supplied, vector of Efdr ratios for sample size multiples.
For 'sw=2', a list with components 'pds', 'x', 'f', 'pds.', 'stdev'.
For 'sw=3', the influence function matrix of log(fdr).
Bradley Efron, Brit B. Turnbull, and Balasubramanian Narasimhan
Efron, B. (2004) "Large-scale simultaneous hypothesis testing: the choice of a null hypothesis", Jour Amer Stat Assoc, 99, pp. 96–104.
Efron, B. (2006) "Size, Power, and False Discovery Rates".
Efron, B. (2007) "Correlation and Large-Scale Simultaneous Significance Testing", Jour Amer Stat Assoc, 102, pp. 93–103.
## HIV data example data(hivdata) w <- locfdr(hivdata)## HIV data example data(hivdata) w <- locfdr(hivdata)
Uses z-values in a specified interval to find maximum likelihood estimates for the null distribution parameters p0, delta0, and sigma0.
locmle(z, xlim, Jmle = 35, d = 0, s = 1, ep = 1/1e+05, sw = 0, Cov.in)locmle(z, xlim, Jmle = 35, d = 0, s = 1, ep = 1/1e+05, sw = 0, Cov.in)
z |
Vector of summary statistics (z-values). |
xlim |
Two-vector 'c(center, half-width)' defining the interval '[center - half-width, center + half-width]' used for estimation. If missing, computed automatically from 'z'. |
Jmle |
Number of iterations for the MLE algorithm. |
d |
Initial value for delta (null mean). |
s |
Initial value for sigma (null standard deviation). |
ep |
Convergence tolerance. |
sw |
If 1, returns correlation matrix along with MLE. |
Cov.in |
Optional list with components 'x', 'X', 'f', 'sw' for covariance and influence function calculations. |
If 'sw' is not 1 and 'Cov.in' is not supplied, a named vector of length 6: 'del0', 'sig0', 'p0', 'sd.del0', 'sd.sig0', 'sd.p0'.
If 'sw=1', a list with 'mle' (the estimates) and 'Cor' (correlation matrix).
If 'Cov.in' is supplied, a list with 'mle' and either 'Cov.lfdr', 'pds.', or 'Ilfdr' depending on 'Cov.in$sw'.