plot.fdr2d.result: Plotting the bivariate local false discovery results

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/localfdr2d.R

Description

These functions provide different ways of plotting the output fdr2d.

Usage

1
2
3
4
5
6
7
8
9
## S3 method for class 'fdr2d.result'
plot(x, levels, nr.plot = 20, add = FALSE, grid = FALSE, 
  pch = ".",xlab, ylab, vfont = c("sans serif", "plain"), lcol = "black", ...)

Tornadoplot(x, levels, nr.plot = 20, label = FALSE, constrain = FALSE, 
  pch = ".", xlab, ylab, vfont = c("sans serif", "plain"), lcol = "black", ...)
  
Volcanoplot(x, df, levels, nr.plot = 20, label = FALSE, constrain = FALSE, 
  pch = ".", xlab, ylab, vfont = c("sans serif", "plain"), lcol = "black", ...)	   

Arguments

x

an object created by fdr2d.

df

the appropriate degrees of freedom for a two-sample t-test with equal variances (in order to provide p-values for the volcano plot).

levels

vector of levels for drawing fdr isolines

nr.plot

number of equidistant breaks defining a two-dimensional grid for smoothing isolines, see Details.

add

logical value indicating whether to create a new plot, or to add to an existing plot.

grid

logical value indicating whether the original grid used for estimating the local fdr should be shown.

label

logical value indicating whether to draw labels on the isolines.

constrain

logical flag indicating whether transformed fdr values should be made monotnously decreasing with the absolute size of the first test statistic, see fdr2d.

pch, xlab, ylab

the usual graphical parameters

vfont

vector font specification for labelling the isolines, see contour.

lcol

colour used for drawing the isolines

...

extra graphical parameters passed to plot.default.

Details

The plot format is basically a scatter plot of the observed test statistics, overlayed with isolines showing the estimated fdr. The generic plot function displays the original test statistics that are used to estimate the fdr, i.e. the two-sample t-statistics and the logarithmized standard errors; the other plots use different, but mathematically equivalent test statistics:

By default, the estimated fdr isolines are smoothed and cropped to the convex hull of the observed test statistics by using akima. This is entirely a graphical pre-processing step which produces smoother isolines and enforces sanity at the edges of the observed distribution; it does not change the estimated fdr at all. This graphical smoothing is controlled via the argument nr.plot, which specifies the grid size, with lower values resulting in stronger smoothing. In order to suppress graphical smoothing, set nr.plot to zero.

Note that the test statistics and the fdr for the volcano- and tornado plots are not computed from scratch, but rather through transformation of the original results. Specifically, the isolines in these plots are also transformed; this has the unfortunate side effect that the labelling of isolines in these plots is not nearly as pretty as the standard provided by contour. This functionality is currently not available outside of contour, and our implementation in DrawContourlines frankly leaves a lot to be desired. We apologize for the inconvenience.

Value

The original x, invisibly.

Author(s)

A. Ploner

References

Ploner A, Calza S, Gusnanto A, Pawitan Y (2005) Multidimensional local false discovery rate for micorarray studies. Submitted Manuscript.

See Also

fdr2d, DrawContourlines

Examples

1
2
3
4
5
6
7
8
9
# Create res2d
example(fdr2d)

par(mfrow=c(2,2))
plot(res2d, main="Generic plotting")
Volcanoplot(res2d, df=length(grp)-2, main="Volcano plot", label=TRUE)
Tornadoplot(res2d, main="Tornado plot", label=TRUE)
# This is without graphical smoothing
plot(res2d, main="Generic plotting, raw", nr.plot=0)

Example output

fdr2d> # We simulate a small example with 5 percent regulated genes and
fdr2d> # a rather large effect size
fdr2d> set.seed(2000)

fdr2d> xdat = matrix(rnorm(50000), nrow=1000)

fdr2d> xdat[1:25, 1:25] = xdat[1:25, 1:25] - 1

fdr2d> xdat[26:50, 1:25] = xdat[26:50, 1:25] + 1

fdr2d> grp = rep(c("Sample A","Sample B"), c(25,25))

fdr2d> # A default run
fdr2d> res2d = fdr2d(xdat, grp)
Starting permutations...
	 1 
	 2 
	 3 
	 4 
	 5 
	 6 
	 7 
	 8 
	 9 
	 10 
	 11 
	 12 
	 13 
	 14 
	 15 
	 16 
	 17 
	 18 
	 19 
	 20 
	 21 
	 22 
	 23 
	 24 
	 25 
	 26 
	 27 
	 28 
	 29 
	 30 
	 31 
	 32 
	 33 
	 34 
	 35 
	 36 
	 37 
	 38 
	 39 
	 40 
	 41 
	 42 
	 43 
	 44 
	 45 
	 46 
	 47 
	 48 
	 49 
	 50 
	 51 
	 52 
	 53 
	 54 
	 55 
	 56 
	 57 
	 58 
	 59 
	 60 
	 61 
	 62 
	 63 
	 64 
	 65 
	 66 
	 67 
	 68 
	 69 
	 70 
	 71 
	 72 
	 73 
	 74 
	 75 
	 76 
	 77 
	 78 
	 79 
	 80 
	 81 
	 82 
	 83 
	 84 
	 85 
	 86 
	 87 
	 88 
	 89 
	 90 
	 91 
	 92 
	 93 
	 94 
	 95 
	 96 
	 97 
	 98 
	 99 
	 100 

fdr2d> res2d[1:20,]
       tstat     logse    fdr.local
1  -3.113975 -1.317751 0.2107689450
2  -4.868530 -1.423606 0.0124838710
3  -4.487968 -1.316576 0.0374126780
4  -3.891546 -1.282619 0.0543524911
5  -2.323968 -1.302204 0.7080678883
6  -2.491116 -1.157857 0.7460020233
7  -2.896670 -1.169804 0.3756223654
8  -4.254195 -1.290534 0.0332573755
9  -3.490224 -1.334211 0.1736562385
10 -3.465717 -1.328086 0.1528700464
11 -2.642704 -1.407889 0.5238031060
12 -1.532776 -1.217003 0.8184856281
13 -3.805811 -1.373781 0.1298236681
14 -4.138912 -1.361446 0.0536263057
15 -4.999346 -1.340191 0.0120454097
16 -3.724595 -1.201502 0.0956079406
17 -4.853666 -1.180403 0.0003179785
18 -2.607185 -1.235779 0.4654395719
19 -3.639713 -1.275850 0.1302013668
20 -4.881803 -1.340349 0.0127744426

fdr2d> # Looking at the results
fdr2d> summary(res2d)
$Statistic
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
-5.247257 -0.647769 -0.003438  0.015693  0.736234  5.125711 

$fdr
         fdr
statistic (0,0.05] (0.05,0.1] (0.1,0.2] (0.2,1] (1,Inf]
     t<0         8          5         4     475       4
     t>=0       10          3         4     482       5

$p0
$p0$Value
[1] 0.8382156

$p0$Estimated
[1] TRUE



fdr2d> plot(res2d)

fdr2d> res2d[res2d$fdr<0.05, ]
       tstat     logse    fdr.local
2  -4.868530 -1.423606 1.248387e-02
3  -4.487968 -1.316576 3.741268e-02
8  -4.254195 -1.290534 3.325738e-02
15 -4.999346 -1.340191 1.204541e-02
17 -4.853666 -1.180403 3.179785e-04
20 -4.881803 -1.340349 1.277444e-02
21 -4.273400 -1.134357 2.606529e-02
22 -5.247257 -1.143727 1.601348e-04
23 -4.550108 -1.159578 5.881470e-03
24 -5.002789 -1.299289 2.626309e-03
30  4.274270 -1.211328 2.714740e-03
31  3.687758 -1.223230 3.844077e-02
35  3.774064 -1.087781 3.072547e-02
37  4.810875 -1.337504 6.771634e-06
38  5.125711 -1.279623 6.771634e-06
39  4.883544 -1.324364 6.771634e-06
41  4.404355 -1.367099 3.016086e-02
46  3.476958 -1.184922 4.998823e-02

fdr2d> # Extra information
fdr2d> class(res2d)
[1] "fdr2d.result" "fdr.result"   "data.frame"  

fdr2d> attr(res2d,"param")
$p0
[1] 0.8382156

$p0.est
[1] TRUE

$fdr
                cut.stat.y
cut.stat.x       [-1.68,-1.63] (-1.63,-1.57] (-1.57,-1.52] (-1.52,-1.46]
  [-5.93,-5.14]   1.016497e-05  6.789719e-05  0.0004291401  0.0001170128
  (-5.14,-4.35]   7.127111e-05  8.583627e-04  0.0500607462  0.0011605028
  (-4.35,-3.56]   4.980187e-04  7.543943e-02  0.5392176225  0.1626796607
  (-3.56,-2.77]   1.009121e-03  1.518015e-01  0.6685138474  0.4618647699
  (-2.77,-1.98]   1.556639e-01  1.422781e+00  0.6685138474  0.4618647699
  (-1.98,-1.19]   2.933443e-01  2.979744e+00  0.6685138474  0.7749257661
  (-1.19,-0.395]  4.427931e+00  5.617510e+00  0.8719620723  0.8335001136
  (-0.395,0.395]  9.417282e+00  1.027663e+00  0.5774517378  0.5424582979
  (0.395,1.19]    4.056640e+00  1.027663e+00  0.5774517378  0.5424582979
  (1.19,1.98]     2.765121e-01  2.343601e-01  0.5774517378  0.5424582979
  (1.98,2.77]     2.765121e-01  2.343601e-01  0.5774517378  0.5424582979
  (2.77,3.56]     1.435008e-01  1.405925e-01  0.0640265198  0.4498870094
  (3.56,4.35]     5.138012e-04  9.223914e-04  0.0640265198  0.0308634697
  (4.35,5.14]     3.394681e-05  7.467544e-05  0.0004851369  0.0008886767
                cut.stat.y
cut.stat.x       (-1.46,-1.41] (-1.41,-1.35] (-1.35,-1.3] (-1.3,-1.24]
  [-5.93,-5.14]   0.0007091151  0.0319622586 0.0006728586 6.486309e-05
  (-5.14,-4.35]   0.0085408955  0.0319622586 0.0066790854 5.031757e-04
  (-4.35,-3.56]   0.2038617163  0.0319622586 0.1225750400 1.200084e-02
  (-3.56,-2.77]   0.4088414902  0.5658742386 0.1547746626 3.107612e-01
  (-2.77,-1.98]   0.4088414902  0.6789512837 0.7783547602 6.046599e-01
  (-1.98,-1.19]   0.6289316657  0.6789512837 0.7783547602 7.341049e-01
  (-1.19,-0.395]  0.7974134691  0.6789512837 0.7783547602 8.973134e-01
  (-0.395,0.395]  1.0000000000  0.8591118067 0.7839871593 7.379130e-01
  (0.395,1.19]    0.7116472313  0.8503171998 0.7839871593 7.379130e-01
  (1.19,1.98]     0.7116472313  0.8503171998 0.7224511199 6.723660e-01
  (1.98,2.77]     0.7116472313  0.8503171998 0.6276135600 4.128811e-01
  (2.77,3.56]     0.5577543946  0.8503171998 0.4513440323 7.928577e-02
  (3.56,4.35]     0.3338496078  0.0514955487 0.1269185903 7.928577e-02
  (4.35,5.14]     0.0749274908  0.0009334974 0.0005368182 4.863211e-04
                cut.stat.y
cut.stat.x       (-1.24,-1.19] (-1.19,-1.13] (-1.13,-1.08] (-1.08,-1.02]
  [-5.93,-5.14]   2.662789e-05  2.669564e-05  2.869114e-05  1.010564e-05
  (-5.14,-4.35]   3.461522e-04  3.776071e-04  4.393928e-04  7.268734e-05
  (-4.35,-3.56]   1.551672e-02  2.214101e-02  6.698968e-02  9.250566e-04
  (-3.56,-2.77]   3.451949e-01  1.350248e-01  7.071912e-01  1.499118e-01
  (-2.77,-1.98]   4.746000e-01  8.474774e-01  9.033145e-01  3.233492e-01
  (-1.98,-1.19]   8.203263e-01  9.197094e-01  9.033145e-01  3.233492e-01
  (-1.19,-0.395]  8.203263e-01  9.197094e-01  9.033145e-01  8.335412e-01
  (-0.395,0.395]  8.542737e-01  8.608025e-01  8.329860e-01  8.924202e-01
  (0.395,1.19]    8.542737e-01  8.608025e-01  8.329860e-01  8.924202e-01
  (1.19,1.98]     8.117328e-01  6.365743e-01  5.685784e-01  8.924202e-01
  (1.98,2.77]     3.208918e-01  3.586726e-01  3.659326e-01  8.924202e-01
  (2.77,3.56]     8.626137e-02  7.812575e-02  1.352357e-01  1.362331e-01
  (3.56,4.35]     4.794024e-03  6.268985e-04  4.991264e-04  4.905773e-04
  (4.35,5.14]     2.023619e-04  4.775147e-05  3.339304e-05  3.228750e-05
                cut.stat.y
cut.stat.x       (-1.02,-0.969] (-0.969,-0.914]
  [-5.93,-5.14]    6.164728e-06    3.381046e-06
  (-5.14,-4.35]    3.279677e-05    9.489522e-06
  (-4.35,-3.56]    4.716101e-04    7.538774e-05
  (-3.56,-2.77]    7.605143e-02    9.572560e-04
  (-2.77,-1.98]    1.007017e+00    1.587987e-01
  (-1.98,-1.19]    1.073935e+00    6.614802e-01
  (-1.19,-0.395]   1.073935e+00    6.614802e-01
  (-0.395,0.395]   6.212182e+00    7.268667e+00
  (0.395,1.19]     6.212182e+00    2.759033e+00
  (1.19,1.98]      1.397037e+00    1.601527e-01
  (1.98,2.77]      1.505924e-01    1.009852e-03
  (2.77,3.56]      7.196805e-02    4.946541e-04
  (3.56,4.35]      4.459883e-04    5.195335e-05
  (4.35,5.14]      2.832573e-05    6.771634e-06

$xbreaks
 [1] -5.9263662 -5.1361841 -4.3460019 -3.5558197 -2.7656376 -1.9754554
 [7] -1.1852732 -0.3950911  0.3950911  1.1852732  1.9754554  2.7656376
[13]  3.5558197  4.3460019  5.1361841

$ybreaks
 [1] -1.6821150 -1.6272404 -1.5723657 -1.5174911 -1.4626165 -1.4077419
 [7] -1.3528672 -1.2979926 -1.2431180 -1.1882434 -1.1333687 -1.0784941
[13] -1.0236195 -0.9687448 -0.9138702

OCplus documentation built on Nov. 8, 2020, 5:20 p.m.