vly: vly

Description Usage Arguments Details Value Author(s) Examples

View source: R/functions.R

Description

Return co-ordinates of L-regions for cFDR method using kernel density method, with or without estimation of Pr(H0|Pj<pj).

Usage

1
2
3
vly(p, q, adj = T, indices = NULL, at = NULL, mode = 0,
  fold = NULL, p_threshold = 0, nt = 5000, nv = 1000,
  scale = c("p", "z"), closed = T, ...)

Arguments

p

principal p-values

q

conditional p-values

adj

adjust cFDR values and hence curves L using estimate of Pr(H0|Pj<pj)

indices

compute v(L) at indices of points. Overrides parameter at if set.

at

cfdr cutoff/cutoffs. Defaults to null

mode

set to 0 to leave all of 'indices' in, 1 (NOT CURRENTLY SUPPORTED) to remove each index only when computing L at that point, 2 to remove all of 'indices' from p,q

fold

If mode=2, only compute L-curves using points not in 'fold'.

p_threshold

if H0 is to be rejected automatically whenever p<p_threshold, include this in all regions L

nt

number of test points in x-direction, default 5000

nv

resolution for constructing L-curves, default 1000

scale

return curves on the p- or z- plane. Y values are equally spaced on the z-plane.

closed

determines whether curves are closed polygons encircling regions L (closed=T), or lines indicating the rightmost border of regions L

...

other parameters passed to function kde2d. Can be used to set a non-Gaussian kernel.

Details

Estimates empirical distribution of (P,Q) by fitting a kernel density estimate to observed values.

Value

list containing elements x, y. Assuming n curves are calculated and closed=T (where n=length(indices) or length(at)), x is a matrix of dimension n x (4+nv), y ix a vector of length (4+nv).

Author(s)

James Liley

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Generate standardised simulated dataset
set.seed(1); n=10000; n1p=100; n1pq=100; n1q=100
zp=c(rnorm(n1p,sd=3), rnorm(n1q,sd=1),rnorm(n1pq,sd=3), rnorm(n-n1p-n1q-n1pq,sd=1))
zq=c(rnorm(n1p,sd=1), rnorm(n1q,sd=3),rnorm(n1pq,sd=3), rnorm(n-n1p-n1q-n1pq,sd=1))
p=2*pnorm(-abs(zp)); q=2*pnorm(-abs(zq))
fold_id=(1:n) %% 3

# points to generate L-regions for
example_indices=c(4262, 268,83,8203) #c(164,23,74)

par(mfrow=c(1,2))

v1=vly(p,q,indices=example_indices,mode=0); 
plot(p,q,cex=0.5,col="gray",xlim=c(0,0.001),ylim=c(0,1), main="All points in"); 
for (i in 1:length(example_indices)) lines(v1$x[i,],v1$y); 
for (i in 1:length(example_indices)) points(p[example_indices[i]],q[example_indices[i]],pch=16,col="blue")

v2=vly(p,q,indices=example_indices,mode=2,fold=which(fold_id==1)); 
plot(p,q,cex=0.5,col="gray",xlim=c(0,0.001),ylim=c(0,1), main="Fold removed"); 
for (i in 1:length(example_indices)) lines(v2$x[i,],v2$y); 
for (i in 1:length(example_indices)) points(p[example_indices[i]],q[example_indices[i]],pch=16,col="blue")

jamesliley/cfdr documentation built on July 31, 2020, 9:42 a.m.