compute.p.values: Compute Empirical p-values

Description Usage Arguments Details Value References Examples

View source: R/DetSel.R

Description

This command compute empirical p-values.

Usage

1
  compute.p.values(x.range,y.range,n.bins,m)

Arguments

x.range

the range of values in the x-axis, respectively, which takes the default values x.range = c(-1,1)

y.range

the range of values in the y-axis, respectively, which takes the default values y.range = c(-1,1)

n.bins

the size of the 2-dimensional array of n x n square cells used to bin the F_1 and F_2 estimates, which takes the default value n.bins = c(100,100)

m

the smoothing parameters of the ASH algorithm, which takes the default value m = c(2,2)

Details

compute.p.values(x.range,y.range,n.bins,m) produces an output file, named ‘P-values_i_j.dat’, with the P-value associated with each observation. To that end, the cumulative distribution function (CDF) is evaluated empirically from the joint distribution of all the pairwise observations (F_1,F_2) within the simulated dataset. Then, the empirical P-value for a given marker locus i is calculated as one minus the CDF evaluated at locus i. For multi-allelic markers, the joint distribution of all the pairwise observations (F_1,F_2) within the simulated dataset is computed from a 2-dimensional array, where the (F_1,F_2) pairs are binned, and then smoothed using the Average Shifted Histogram (ASH) algorithm (Scott 1992) as implemented in the "ash" R package. Because the distribution of (F_1,F_2) estimates for bi-allelic markers is discontinuous with many ties, the CDF is computed instead by enumerating all (F_1,F_2) pairs in the simulated data.

Value

The output files are saved in the working directory.

References

Scott, D. W. (1992) Multivariate density estimation: theory, practice, and visualization, John Wiley, New York.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## This is to generate an example file in the working directory.
make.example.files()

## This will read an input file named 'data.dat' that contains co-dominant markers,
## and a maximum allele frequency of 0.99 will be applied (i.e., by removing 
## marker loci in the observed and simulated datasets that have an allele with
## frequency larger than 0.99).
read.data(infile = 'data.dat',dominance = FALSE,maf = 0.99)

## The following command line executes the simulations:
run.detsel(example = TRUE)

## This compute empirical \emph{P}-values, assuming a range of values from -1 to 1
## in both dimensions, a grid of 50 x 50 bins, and a smoothing parameter m = 3
## in both dimensions.
compute.p.values(x.range = c(-1,1),y.range = c(-1,1),n.bins = c(50,50),m = c(3,3))

## This is to clean up the working directory.
remove.example.files()

Example output

[1] TRUE
Read 967 items
The data file data.dat contains 100 loci, with 2-5 alleles per locus, and 2 populations
The average values of population-specific measures of differentiation are:
----------------------------------------------
Pair		F_1			F_2
1-2		0.0847			0.054
----------------------------------------------
The program will now create 1 simulation files. Please wait, this can take some time...
Simulating data in output file: `Pair_1_2_50_50.dat`...
All the simulations have been completed.
The difference between observed and simulated values of population-specific measures of differentiation are:
-------------------------------------------------------------------------
Pair		F_1 (obs)	F_1 (sim)	F_2 (obs)	F_2 (sim)
Pair_1_2	0.08468		0.08221		0.05398		0.05336
-------------------------------------------------------------------------
Computing p-values. Please wait, this can take some time...
The p-values for each locus in population pair 1-2 are:
-------------------
    Locus      P-value
1       1  2.28003e-03
2       2  8.62436e-01
3       3  9.41367e-01
4       4  2.38057e-01
5       5  8.62436e-01
6       6  8.48481e-01
7       7  5.75242e-01
8       8  4.26309e-01
9       9  3.45494e-01
10     10  8.48481e-01
11     11  9.70565e-01
12     12  4.96856e-01
13     13  3.03687e-01
14     14  8.14226e-01
15     15  7.91609e-01
16     16  7.69765e-01
17     17  4.87926e-01
18     18  6.06311e-01
19     19  7.91479e-01
20     20  6.73716e-01
21     21  8.62436e-01
22     22  8.62436e-01
23     23  6.69686e-01
24     24  7.43397e-01
25     25  2.04455e-01
26     26  7.57298e-01
27     27  4.45516e-01
28     28  0.00000e+00
29     29  1.22689e-01
30     30  4.16806e-01
31     31  8.65356e-01
32     32  7.17112e-01
33     33  8.62436e-01
34     34  6.38958e-01
35     35  1.62445e-01
36     36  4.35837e-01
37     37  2.83931e-01
38     38  8.62436e-01
39     39  5.47798e-01
40     40  3.14233e-01
41     41  9.00706e-01
42     42  8.14226e-01
43     43  8.88106e-01
44     44  0.00000e+00
45     45  8.65068e-01
46     46  5.10808e-01
47     47  7.49136e-01
48     48  8.32038e-01
49     49  5.47798e-01
50     50  3.45494e-01
51     51  6.69686e-01
52     52  6.56119e-01
53     53  8.88106e-01
54     54  9.79976e-02
55     55  9.38388e-01
56     56  0.00000e+00
57     57  2.36165e-02
58     58  9.70565e-01
59     59  7.10336e-01
60     60  9.67022e-01
61     61  6.19352e-01
62     62  2.05534e-02
63     63  2.65552e-01
64     64  8.82540e-01
65     65  7.29645e-01
66     66  0.00000e+00
67     67  3.34841e-01
68     68  7.69765e-01
69     69  6.38958e-01
70     70  7.29645e-01
71     71  5.22876e-01
72     72  8.92420e-01
73     73  8.48481e-01
74     74  4.45516e-01
75     75  5.60599e-01
76     76  8.48481e-01
77     77  3.08051e-01
78     78  8.65356e-01
79     79  9.38388e-01
80     80  9.41367e-01
81     81  9.13864e-01
82     82  4.26309e-01
83     83  1.99762e-01
84     84  8.62436e-01
85     85  9.41367e-01
86     86  6.91531e-01
87     87  9.13864e-01
88     88  7.91479e-01
89     89  5.75242e-01
90     90  7.10336e-01
91     91  0.00000e+00
92     92  6.91531e-01
93     93  1.69613e-02
94     94  4.65838e-01
95     95  9.41367e-01
96     96  3.67965e-03
97     97 -2.22045e-16
98     98  9.00915e-03
99     99  2.66200e-03
100   100 -2.22045e-16
-------------------
The above results are saved in file: P-values_1_2.dat

DetSel documentation built on Feb. 17, 2020, 5:09 p.m.