ʻOhana
Population structure, admixture history, and selection using learning methods.
neoscan/jade.main.cpp
1 /* -------------------------------------------------------------------------
2  Ohana
3  Copyright (c) 2015-2020 Jade Cheng (\___/)
4  Jade Cheng <info@jade-cheng.com> (='.'=)
5  ------------------------------------------------------------------------- */
6 
7 #include "jade.neoscan.hpp"
8 #include "jade.version.hpp"
9 
10 namespace
11 {
12  char const * const usage = R"(USAGE
13  neoscan [options] <g-matrix> <q-matrix> <f-matrix> <year-matrix>
14 
15 ARGUMENTS
16  g-matrix path to the [I x J] G matrix
17  q-matrix path to the [I x K] Q matrix
18  f-matrix path to the [K x J] F matrix
19  year-matrix path to the [I x 1] matrix for years
20 
21 OPTIONS
22  --help,-h shows this help message and exits
23 
24 DESCRIPTION
25  Performs a selection scan between ancient and modern data. The program can
26  take advantage of the dating for each individual ancient sample. The program
27  prints for each marker the delta when local optima is reached, the global
28  likelihood, the optimal local likelihood, and the likelihood ratio.
29 
30  The program requires a <year-matrix>, which contains for each individual a
31  row representing the number of years going backward in time. For instance,
32  modern samples would be zero, and a millennium would be a positive value,
33  e.g. 1000.
34 
35  [Notation]
36 
37  K := Number of Components
38  This value must be greater than or equal to one.
39 
40  I := Number of Individuals
41  This value must be greater than or equal to one.
42 
43  J := Number of Markers
44  This value must be greater than or equal to one.
45 
46  G := [I x J] Discrete or Likelihood Genotype Matrix
47  dgm consists of integer values ranging from 0 to 3, inclusive.
48  0 := major-major allele
49  1 := major-minor allele
50  2 := minor-minor allele
51  3 := missing allele information
52  lgm with three floating-point value matrices in the following order.
53  n x m matrix, values 0.0 to 1.0 for minor-minor
54  n x m matrix, values 0.0 to 1.0 for major-minor
55  n x m matrix, values 0.0 to 1.0 for major-major
56 
57  F := [K x J] Frequency Matrix
58  This matrix consists of floating-point values ranging from 0 to 1.
59 
60  Q := [I x K] Proportion Matrix
61  This matrix consists of floating-point values ranging from 0 to 1. Each
62  row sums to 1.0, and each row contains more than one distinct value.
63 
64  [Matrix File Format]
65 
66  A matrix file is an ASCII file in the following format. All values are
67  separated by white-space. The first value indicates the number of rows, the
68  second value indicates the number of columns, and then the remaining values
69  represent the values of the matrix in row-major order. For example, the
70  following represents a matrix with 2 rows and 4 columns:
71 
72  2 4
73  1.0 2.0 3.0 4.0
74  5.0 6.0 7.0 8.0
75 
76  In the case of the likelihood genotype matrix, three individual matrices
77  exist within the file representing minor-minor, major-minor, and major-major
78  allele frequencies. For example, the following represents a matrix with
79  2 rows (individuals) and 4 columns (markers):
80 
81  2 4
82  0.1 0.2 0.3 0.4
83  0.5 0.6 0.7 0.8
84  2 4
85  0.9 0.8 0.7 0.6
86  0.5 0.4 0.3 0.2
87  2 4
88  0.1 0.9 0.2 0.8
89  0.3 0.7 0.4 0.6
90 
91 EXAMPLE
92  $ neoscan g.dgm q.matrix f.matrix years.json
93  d global-lle local-lle lle-ratio
94  -1.00 +1.418028e+00 +1.418028e+00 +0.000000e+00
95  +0.00 +1.769128e+00 +1.769128e+00 +0.000000e+00
96  +1.00 +1.213023e+00 +1.213023e+00 +0.000000e+00
97 
98 BUGS
99  Report any bugs to Jade Cheng <info@jade-cheng.com>.
100 
101 Copyright (c) 2015-2020 Jade Cheng
102 )";
103 }
104 
105 ///
106 /// The main entry point of the program.
107 /// \param argc The argument count.
108 /// \param argv The argument values.
109 /// \return EXIT_SUCCESS or EXIT_FAILURE.
110 ///
111 int main(const int argc, const char * argv[])
112 {
113  try
114  {
115  jade::args args (argc, argv);
116 
117  if (args.read_flag("--help", "-h"))
118  {
119  std::cout << ::usage;
120  return EXIT_SUCCESS;
121  }
122 
123  if (args.read_flag("--version", "-v"))
124  {
125  jade::version::write("neoscan", std::cout);
126  return EXIT_SUCCESS;
127  }
128 
129  typedef double value_type;
130  typedef jade::basic_neoscan<value_type> neoscan_type;
131 
132  neoscan_type::run(args);
133 
134  return EXIT_SUCCESS;
135  }
136  catch (const std::exception & e)
137  {
138  std::cerr << e.what() << std::endl;
139  return EXIT_FAILURE;
140  }
141 }
jade::basic_neoscan
A template for a class implementing the neoscan algorithm. This algorithm scans for positive selectio...
Definition: jade.neoscan.hpp:22
jade::basic_args
A template for a class that helps process command-line arguments.
Definition: jade.args.hpp:19
jade::basic_version::write
static void write(char_type const *const title, ostream_type &out)
Writes the string displayed to the user.
Definition: jade.version.hpp:29