Mercurial > repos > miller-lab > genome_diversity
annotate genome_diversity/src/Fst_ave.c @ 22:95a05c1ef5d5
update to devshed revision aaece207bd01
author | Richard Burhans <burhans@bx.psu.edu> |
---|---|
date | Mon, 11 Mar 2013 11:28:06 -0400 |
parents | fa34d259eb8f |
children | 248b06e86022 |
rev | line source |
---|---|
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
1 /* Fst_ave -- determine four FST values between two specified populations, |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
2 * and optionally between several pairs of random populations |
0 | 3 * |
4 * argv{1] = a Galaxy SNP table. For each of several individuals, the table | |
5 * has four columns (#A, #B, genotype, quality). | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
6 * argv[2] = 1 if FST is estimated from SAMtools genotypes; 0 means use |
0 | 7 * read-coverage data. |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
8 * argv[3] = lower bound, for individual quality value if argv[2] = 1, |
0 | 9 * or for total number of reads per population if argv[2] = 0. |
10 * SNPs not satisfying these lower bounds are ignored. | |
11 * argv[4] = 1 to discard SNPs that appear fixed in the two populations | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
12 * argv[5] = k says report the maximum and average FST over k randomly |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
13 * chosen splits into two populations of two original sizes |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
14 * argv[6], argv[7], ..., have the form "13:1", "13:2" or "13:0", meaning |
0 | 15 * that the 13th and 14th columns (base 1) give the allele counts |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
16 * (and column 15 gives the genotype) for an individual that is in |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
17 * population 1, in population 2, or in neither population. |
0 | 18 |
19 What it does on Galaxy | |
20 | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
21 The user specifies a SNP table and two "populations" of individuals, both previously defined using the Galaxy tool to specify individuals from a SNP table. No individual can be in both populations. Other choices are as follows. |
0 | 22 |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
23 Data source. The allele frequencies of a SNP in the two populations can be estimated either by the total number of reads of each allele, or by adding the frequencies inferred from genotypes of individuals in the populations. |
0 | 24 |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
25 After specifying the data source, the user sets lower bounds on amount of data required at a SNP. For estimating the FST using read counts, the bound is the minimum count of reads of the two alleles in a population. For estimations based on genotype, the bound is the minimum reported genotype quality per individual. SMPs not meeting these lower bounds are ignored. |
0 | 26 |
27 The user specifies whether SNPs where both populations appear to be fixed for the same allele should be retained or discarded. | |
28 | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
29 Finally, the user decides whether to use randomizations. If so, then the user specifies how many randomly generated population pairs (retaining the numbers of individuals of the originals) to generate, as well as the "population" of additional individuals (not in the first two populations) that can be used in the randomization process. |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
30 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
31 The program prints the following measures of FST for the two populations. |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
32 1. The formulation by Sewall Wright (average over FSTs for all SNPs). |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
33 2. The Weir-Cockerham estimator (average over FSTs for all SNPs). |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
34 3. The Reich-Patterson estimator (average over FSTs for all SNPs). |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
35 4. The population-based Reich-Patterson estimator. |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
36 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
37 If randomizations were requested, it prints a summary for each of the four definitions of FST that includes the maximum and average value, and the highest-scoring population pair (if any scored higher than the two user-specified populations). |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
38 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
39 References: |
0 | 40 |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
41 Sewall Wright (1951) The genetical structure of populations. Ann Eugen 15:323-354. |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
42 |
19 | 43 B. S. Weir and C. Clark Cockerham (1984) Estimating F-statistics for the analysis of population structure. Evolution 38:1358-1370. |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
44 |
19 | 45 Weir, B.S. 1996. Population substructure. Genetic data analysis II, pp. 161-173. Sinauer Associates, Sunderland, MA. |
0 | 46 |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
47 David Reich, Kumarasamy Thangaraj, Nick Patterson, Alkes L. Price, and Lalji Singh (2009) Reconstructing Indian population history. Nature 461:489-494, especially Supplement 2. |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
48 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
49 Their effectiveness for computing FSTs when there are many SNPs but few individuals is discussed in the followoing paper. |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
50 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
51 Eva-Maria Willing, Christine Dreyer, Cock van Oosterhout (2012) Estimates of genetic differentiation measured by FST do not necessarily require large sample sizes when using many SNP markers. PLoS One 7:e42649. |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
52 |
0 | 53 */ |
54 | |
55 #include "lib.h" | |
56 #include "Fst_lib.h" | |
57 | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
58 // maximum length of a line from the table |
0 | 59 #define MOST 5000 |
60 | |
61 // information about the specified individuals | |
62 // x is an array of nI values 0, 1, or 2; | |
63 // shuffling x creates random "populations" | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
64 int col[MOST], x[MOST]; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
65 int nI, lower_bound, discard, genotypes, nsnp, nfail; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
66 double F_wright, F_weir, F_reich, N_reich, D_reich; |
0 | 67 |
68 // each SNP has an array of counts | |
69 struct count { | |
70 int A, B; | |
71 }; | |
72 | |
73 // linked list summarizes the Galaxy table | |
74 struct snp { | |
75 struct count *c; | |
76 struct snp *next; | |
77 } *start, *last; | |
78 | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
79 /* For each of wright, weir and reich, we observe allele counts A1 and A2 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
80 * for one allele in the two populations, and B1 and B2 for the other allele. |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
81 */ |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
82 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
83 // given the two populations specified by x[], compute four corresponding FSTs |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
84 void pop_Fst() { |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
85 double N, D; |
0 | 86 struct snp *s; |
87 int i, A1, B1, A2, B2, too_few; | |
88 | |
89 | |
90 // scan the SNPs | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
91 F_wright = F_weir = F_reich = N_reich = D_reich = 0.0; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
92 nsnp = nfail = 0; |
0 | 93 for (s = start; s != NULL; s = s->next) { |
94 // get counts for the two populations at this SNP | |
95 for (A1 = B1 = A2 = B2 = i = 0; i < nI; ++i) { | |
96 if (s->c[i].A < 0) // no genotypes | |
97 continue; | |
98 if (x[i] == 1) { | |
99 A1 += s->c[i].A; | |
100 B1 += s->c[i].B; | |
101 } else if (x[i] == 2) { | |
102 A2 += s->c[i].A; | |
103 B2 += s->c[i].B; | |
104 } | |
105 } | |
106 if (discard && ((A1 == 0 && A2 == 0) || (B1 == 0 && B2 == 0))) | |
107 continue; // fixed in these two populations | |
108 too_few = (genotypes ? 1 : lower_bound); | |
109 if (A1+B1 >= too_few && A2+B2 >= too_few) { | |
110 ++nsnp; | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
111 wright(A1, A2, B1, B2, &N, &D); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
112 if (D != 0.0) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
113 F_wright += N/D; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
114 else |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
115 ++nfail; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
116 weir(A1, A2, B1, B2, &N, &D); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
117 if (D != 0.0) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
118 F_weir += N/D; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
119 else |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
120 ++nfail; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
121 reich(A1, A2, B1, B2, &N, &D); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
122 N_reich += N; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
123 D_reich += D; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
124 if (D != 0.0) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
125 F_reich += N/D; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
126 else |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
127 ++nfail; |
0 | 128 } |
129 } | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
130 F_wright /= nsnp; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
131 F_weir /= nsnp; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
132 N_reich /= nsnp; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
133 D_reich /= nsnp; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
134 F_reich /= nsnp; |
0 | 135 } |
136 | |
137 /* shuffle the values x[0], x[1], ... , x[nI-1]; | |
138 * Uses Algorithm P in page 125 of "The Art of Computer Programming (Vol II) | |
139 * Seminumerical Programming", by Donald Knuth, Addison-Wesley, 1971. | |
140 */ | |
141 void shuffle() { | |
142 int i, j, temp; | |
143 | |
144 for (i = nI - 1; i > 0; --i) { | |
145 // swap what's in location i with location j, where 0 <= j <= i | |
146 j = random() % (i+1); | |
147 temp = x[i]; | |
148 x[i] = x[j]; | |
149 x[j] = temp; | |
150 } | |
151 } | |
152 | |
153 int main(int argc, char **argv) { | |
154 FILE *fp; | |
155 char *p, *z = "\t\n", buf[MOST]; | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
156 int X[MOST], nshuff, n, i, j, k, saw[3], larger0, larger1, larger2, |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
157 larger3, best_x0[MOST], best_x1[MOST], best_x2[MOST], best_x3[MOST]; |
0 | 158 struct snp *new; |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
159 double F, F0, F1, F2, F3, tot_F0, tot_F1, tot_F2, tot_F3, |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
160 largest_F0, largest_F1, largest_F2, largest_F3; |
0 | 161 |
162 if (argc < 7) | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
163 fatal("args: table data-source lower_bound discard? #shuffles n:1 m:2 ..."); |
0 | 164 |
165 // handle command-line arguments | |
166 genotypes = atoi(argv[2]); | |
167 lower_bound = atoi(argv[3]); | |
168 if (!genotypes && lower_bound <= 0) | |
169 fatal("minimum coverage should exceed 0"); | |
170 discard = atoi(argv[4]); | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
171 nshuff = atoi(argv[5]); |
0 | 172 saw[0] = saw[1] = saw[2] = 0; |
173 // populations 1 and 2 must be disjoint | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
174 for (i = 6; i < argc; ++i) { |
0 | 175 if (sscanf(argv[i], "%d:%d", &j, &k) != 2) |
176 fatalf("not like 13:2 : %s", argv[i]); | |
177 if (k < 0 || k > 2) | |
178 fatalf("not population 0, 1 or 2: %s", argv[i]); | |
179 saw[k] = 1; | |
180 // seen this individual (i.e., column) before?? | |
181 for (n = 0; n < nI && col[n] != j; ++n) | |
182 ; | |
183 if (n < nI) { // OK if one of the populations is 0 | |
184 if (k > 0) { | |
185 if (x[n] > 0 && x[n] != k) | |
186 fatalf("column %d is in both populations", j); | |
187 x[n] = k; | |
188 } | |
189 } else { | |
190 col[nI] = j; | |
191 x[nI] = k; | |
192 ++nI; | |
193 } | |
194 } | |
195 if (saw[1] == 0) | |
196 fatal("population 1 is empty"); | |
197 if (saw[2] == 0) | |
198 fatal("population 2 is empty"); | |
199 | |
200 // read the table of SNPs and store the essential allele counts | |
201 fp = ckopen(argv[1], "r"); | |
202 while (fgets(buf, MOST, fp)) { | |
203 if (buf[0] == '#') | |
204 continue; | |
205 new = ckalloc(sizeof(*new)); | |
206 new->next = NULL; | |
207 new->c = ckalloc(nI*sizeof(struct count)); | |
208 // set X[i] = atoi(i-th word of buf), i is base 1 | |
209 for (i = 1, p = strtok(buf, z); p != NULL; | |
210 ++i, p = strtok(NULL, z)) | |
211 X[i] = atoi(p); | |
212 for (i = 0; i < nI; ++i) { | |
213 n = col[i]; | |
214 if (genotypes) { | |
215 k = X[n+2]; | |
216 if (k == -1 || X[n+3] < lower_bound) | |
217 new->c[i].A = new->c[i].B = -1; | |
218 else { | |
219 new->c[i].A = k; | |
220 new->c[i].B = 2 - k; | |
221 } | |
222 } else { | |
223 new->c[i].A = X[n]; | |
224 new->c[i].B = X[n+1]; | |
225 } | |
226 } | |
227 if (start == NULL) | |
228 start = new; | |
229 else | |
230 last->next = new; | |
231 last = new; | |
232 } | |
233 fclose(fp); | |
234 | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
235 pop_Fst(); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
236 printf("Using %d SNPs, we compute:\n", nsnp); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
237 printf("Average Reich-Patterson FST is %5.5f.\n", F2 = F_reich); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
238 printf("The population-based Reich-Patterson Fst is %5.5f.\n", |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
239 F3 = N_reich/D_reich); |
22
95a05c1ef5d5
update to devshed revision aaece207bd01
Richard Burhans <burhans@bx.psu.edu>
parents:
19
diff
changeset
|
240 printf("Average Wright FST is %5.5f.\n", F0 = F_wright); |
95a05c1ef5d5
update to devshed revision aaece207bd01
Richard Burhans <burhans@bx.psu.edu>
parents:
19
diff
changeset
|
241 printf("Average Weir-Cockerham FST is %5.5f.\n", F1 = F_weir); |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
242 if (nfail > 0) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
243 printf("WARNING: %d of %d FSTs could not be computed\n", |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
244 nfail, 3*nsnp); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
245 if (nshuff == 0) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
246 return 0; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
247 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
248 // do the following only if randomization is requested |
0 | 249 for (j = 0; j < nI; ++j) |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
250 best_x0[j] = best_x1[j] = best_x2[j] = best_x3[j] = x[j]; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
251 tot_F0 = tot_F1 = tot_F2 = tot_F3 = |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
252 largest_F0 = largest_F1 = largest_F2 = largest_F3 = 0.0; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
253 larger0 = larger1 = larger2 = larger3 = 0; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
254 for (i = 0; i < nshuff; ++i) { |
0 | 255 shuffle(); |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
256 pop_Fst(); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
257 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
258 // Wright |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
259 if ((F = F_wright) > F0) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
260 ++larger0; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
261 if (F > largest_F0) { |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
262 largest_F0 = F; |
0 | 263 for (j = 0; j < nI; ++j) |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
264 best_x0[j] = x[j]; |
0 | 265 } |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
266 tot_F0 += F; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
267 /* |
0 | 268 if (all) // make this optional? |
269 printf("%d: %f\n", i+1, F); | |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
270 */ |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
271 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
272 // Weir |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
273 if ((F = F_weir) > F1) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
274 ++larger1; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
275 if (F > largest_F1) { |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
276 largest_F1 = F; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
277 for (j = 0; j < nI; ++j) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
278 best_x1[j] = x[j]; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
279 } |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
280 tot_F1 += F; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
281 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
282 // Riech average |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
283 if ((F = F_reich) > F2) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
284 ++larger2; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
285 if (F > largest_F2) { |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
286 largest_F2 = F; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
287 for (j = 0; j < nI; ++j) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
288 best_x2[j] = x[j]; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
289 } |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
290 tot_F2 += F; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
291 |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
292 // Reich population |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
293 if ((F = (N_reich/D_reich)) > F3) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
294 ++larger3; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
295 if (F > largest_F3) { |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
296 largest_F3 = F; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
297 for (j = 0; j < nI; ++j) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
298 best_x3[j] = x[j]; |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
299 } |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
300 tot_F3 += F; |
0 | 301 } |
18
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
302 printf("\nOf %d random groupings:\n", nshuff); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
303 printf("%d had a larger average Wright FST (max %5.5f, mean %5.5f)\n", |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
304 larger0, largest_F0, tot_F0/nshuff); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
305 if (largest_F0 > F0) { |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
306 printf("first columns for the best two populations:\n"); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
307 for (i = 0; i < nI; ++i) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
308 if (best_x0[i] == 1) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
309 printf("%d ", col[i]); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
310 printf("and\n"); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
311 for (i = 0; i < nI; ++i) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
312 if (best_x0[i] == 2) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
313 printf("%d ", col[i]); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
314 putchar('\n'); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
315 putchar('\n'); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
316 } |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
317 printf("%d had a larger average Weir-Cockerham FST (max %5.5f, mean %5.5f)\n", |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
318 larger1, largest_F1, tot_F1/nshuff); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
319 if (largest_F1 > F1) { |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
320 printf("first columns for the best two populations:\n"); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
321 for (i = 0; i < nI; ++i) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
322 if (best_x1[i] == 1) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
323 printf("%d ", col[i]); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
324 printf("and\n"); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
325 for (i = 0; i < nI; ++i) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
326 if (best_x1[i] == 2) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
327 printf("%d ", col[i]); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
328 putchar('\n'); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
329 putchar('\n'); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
330 } |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
331 printf("%d had a larger average Reich-Patterson FST (max %5.5f, mean %5.5f)\n", |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
332 larger2, largest_F2, tot_F2/nshuff); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
333 if (largest_F2 > F2) { |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
334 printf("first columns for the best two populations:\n"); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
335 for (i = 0; i < nI; ++i) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
336 if (best_x2[i] == 1) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
337 printf("%d ", col[i]); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
338 printf("and\n"); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
339 for (i = 0; i < nI; ++i) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
340 if (best_x2[i] == 2) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
341 printf("%d ", col[i]); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
342 putchar('\n'); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
343 putchar('\n'); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
344 } |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
345 printf("%d had a larger Reich-Patterson population FST (max %5.5f, mean %5.5f)\n", |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
346 larger3, largest_F3, tot_F3/nshuff); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
347 if (largest_F3 > F3) { |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
348 printf("first columns for the best two populations:\n"); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
349 for (i = 0; i < nI; ++i) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
350 if (best_x3[i] == 1) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
351 printf("%d ", col[i]); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
352 printf("and\n"); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
353 for (i = 0; i < nI; ++i) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
354 if (best_x3[i] == 2) |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
355 printf("%d ", col[i]); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
356 putchar('\n'); |
f04f40a36cc8
Latest changes from Belinda and Cathy. Webb's updates to the Fst tools.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
357 putchar('\n'); |
0 | 358 } |
359 | |
360 return 0; | |
361 } |