These are methods for turning a qvalue object, from the qvalue package for
false discovery rate control, into a tidy data frame. augment
returns a data.frame of the original p-values combined with the computed
q-values and local false discovery rates, tidy constructs a table
showing how the estimate of pi0 (the proportion of true nulls) depends
on the choice of the tuning parameter lambda, and glance returns a
data.frame with only the chosen pi0 value.
Usage
## S3 method for class 'qvalue'
tidy(x, ...)
## S3 method for class 'qvalue'
augment(x, data, ...)
## S3 method for class 'qvalue'
glance(x, ...)
Arguments
x
qvalue object
...
extra arguments (not used)
data
Original data
Value
All tidying methods return a data.frame without rownames.
The structure depends on the method chosen.
tidy returns one row for each choice of the tuning
parameter lambda that was considered (argument lambda to qvalue),
containing
lambda
the tuning parameter
pi0
corresponding estimate of pi0
smoothed
whether the estimate has been spline-smoothed)
If pi0.method="smooth", the pi0 estimates and smoothed values both
appear in the table. If pi0.method="bootstrap", smoothed
is FALSE for all entries.
augment returns a data.frame with
p.value
the original p-values given to qvalue
q.value
the computed q-values
lfdr
the local false discovery rate
glance returns a one-row data.frame containing
pi0
the estimated pi0 (proportion of nulls)
lambda
lambda used to compute pi0. Note that if pi0 is 1,
this may be NA since it can be ambiguous which lambda was used
Examples
library(ggplot2)
if (require("qvalue")) {
set.seed(2014)
# generate p-values from many one sample t-tests: half of them null
oracle <- rep(c(0, .5), each=1000)
pvals <- sapply(oracle, function(mu) t.test(rnorm(15, mu))$p.value)
qplot(pvals)
q <- qvalue(pvals)
tidy(q)
head(augment(q))
glance(q)
# use augmented data to compare p-values to q-values
ggplot(augment(q), aes(p.value, q.value)) + geom_point()
# use tidy see how pi0 estimate changes with lambda, comparing
# to smoothed version
g <- ggplot(tidy(q), aes(lambda, pi0, color=smoothed)) + geom_line()
g
# show the chosen value
g + geom_hline(yintercept=q$pi0, lty=2)
}
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(biobroom)
Loading required package: broom
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/biobroom/qvalue_tidiers.Rd_%03d_medium.png", width=480, height=480)
> ### Name: qvalue_tidiers
> ### Title: Tidying methods for a qvalue object
> ### Aliases: augment.qvalue glance.qvalue qvalue_tidiers tidy.qvalue
>
> ### ** Examples
>
>
> library(ggplot2)
> if (require("qvalue")) {
+ set.seed(2014)
+
+ # generate p-values from many one sample t-tests: half of them null
+ oracle <- rep(c(0, .5), each=1000)
+ pvals <- sapply(oracle, function(mu) t.test(rnorm(15, mu))$p.value)
+ qplot(pvals)
+
+ q <- qvalue(pvals)
+
+ tidy(q)
+ head(augment(q))
+ glance(q)
+
+ # use augmented data to compare p-values to q-values
+ ggplot(augment(q), aes(p.value, q.value)) + geom_point()
+
+ # use tidy see how pi0 estimate changes with lambda, comparing
+ # to smoothed version
+ g <- ggplot(tidy(q), aes(lambda, pi0, color=smoothed)) + geom_line()
+ g
+
+ # show the chosen value
+ g + geom_hline(yintercept=q$pi0, lty=2)
+ }
Loading required package: qvalue
>
>
>
>
>
> dev.off()
null device
1
>