ʻOhana
Population structure, admixture history, and selection using learning methods.
selscan/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.selscan.hpp"
8 #include "jade.version.hpp"
9 
10 namespace
11 {
12  char const * const usage = R"(USAGE
13  selscan [options] <g-matrix> <f-matrix> <c-matrix>
14 
15 ARGUMENTS
16  g-matrix path to the [I x J] G matrix
17  f-matrix path to the [K x J] F matrix
18  c-matrix path to the [K-1 x K-1] global C matrix
19 
20 OPTIONS
21  --c-scale,-cs indicates the next argument is the path to a [K-1 x K-1] C
22  matrix that provides scaling information; each step
23  linearly interpolates between the global C matrix and this
24  matrix
25  --f-epsilon,-fe indicates the next argument is the epsilon used to clamp
26  values of the allele frequency matrix between (0 + fe) and
27  (1 - fe); if unspecified, this value defaults to 1.0e-6;
28  the value must be greater than 0.0 and less than 0.1
29  --help,-h shows this help message and exits
30  --steps,-s (100) the number of steps to interpolate between C matrices
31 
32 DESCRIPTION
33  Performs a selection scan to identify covariance outliers and prints for each
34  marker the step number when local optima is reached, the global likelihood,
35  the optimal local likelihood, and the likelihood ratio. By default, the
36  program linearly interpolates between the global C matrix and 10 times its
37  values, but it is possible to specify a scaling matrix using the --c-scale
38  option.
39 
40  There are 'I' individuals, 'K' components, and 'J' markers. The sizes of
41  the matrices evaluated by this program are:
42 
43  G matrix [I x J] the path to a genotype matrix; the format of the file
44  is determined based on the extension,
45  .dgm (discrete genotype matrix) or
46  .lgm (likelihood genotype matrix)
47  F matrix [K x J] floating-point values ranging from 0.0 to 1.0
48  C matrix [K-1 x K-1] floating-point values; the matrix is symmetric and
49  positive semidefinite
50 
51  [Notation]
52 
53  K := Number of Components
54  This value must be greater than or equal to one.
55 
56  I := Number of Individuals
57  This value must be greater than or equal to one.
58 
59  J := Number of Markers
60  This value must be greater than or equal to one.
61 
62  G := [I x J] Discrete or Likelihood Genotype Matrix
63  dgm consists of integer values ranging from 0 to 3, inclusive.
64  0 := major-major allele
65  1 := major-minor allele
66  2 := minor-minor allele
67  3 := missing allele information
68  lgm with three floating-point value matrices in the following order.
69  n x m matrix, values 0.0 to 1.0 for minor-minor
70  n x m matrix, values 0.0 to 1.0 for major-minor
71  n x m matrix, values 0.0 to 1.0 for major-major
72 
73  F := [K x J] Frequency Matrix
74  This matrix consists of floating-point values ranging from 0 to 1.
75 
76  C := [K-1 x K-1] Rooted Covariance Matrix
77  This matrix consists of floating-point values. It is a symmetric and
78  positive semidefinite matrix.
79 
80 EXAMPLE
81  $ selscan g.dgm f.matrix c.matrix
82  step global-lle local-lle lle-ratio
83  0 +1.418028e+00 +1.418028e+00 +0.000000e+00
84  2 +1.769128e+00 +1.769128e+00 +0.000000e+00
85  0 +1.213023e+00 +1.213023e+00 +0.000000e+00
86 
87 BUGS
88  Report any bugs to Jade Cheng <info@jade-cheng.com>.
89 
90 Copyright (c) 2015-2020 Jade Cheng
91 )";
92 }
93 
94 ///
95 /// The main entry point of the program.
96 /// \param argc The argument count.
97 /// \param argv The argument values.
98 /// \return EXIT_SUCCESS or EXIT_FAILURE.
99 ///
100 int main(const int argc, const char * argv[])
101 {
102  try
103  {
104  jade::args args (argc, argv);
105 
106  if (args.read_flag("--help", "-h"))
107  {
108  std::cout << ::usage;
109  return EXIT_SUCCESS;
110  }
111 
112  if (args.read_flag("--version", "-v"))
113  {
114  jade::version::write("selscan", std::cout);
115  return EXIT_SUCCESS;
116  }
117 
118  typedef double value_type;
119  typedef jade::basic_selscan<value_type> selscan_type;
120 
121  selscan_type selscan (args);
122  selscan.execute();
123 
124  return EXIT_SUCCESS;
125  }
126  catch (const std::exception & e)
127  {
128  std::cerr << e.what() << std::endl;
129  return EXIT_FAILURE;
130  }
131 }
jade::basic_selscan
A template for a class implementing the selscan program.
Definition: jade.selscan.hpp:20
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