|
ʻOhana
Population structure, admixture history, and selection using learning methods.
|
7 #ifndef JADE_SETTINGS_HPP__
8 #define JADE_SETTINGS_HPP__
10 #include "jade.agi_reader.hpp"
11 #include "jade.genotype_matrix_factory.hpp"
12 #include "jade.options.hpp"
19 template <
typename TValue>
64 const std::unique_ptr<genotype_matrix_type>
g_ptr (
66 const auto & g = *
g_ptr;
98 const auto agi_k = _agi->get_k();
103 <<
"inconsistent component sizes " << agi_k <<
" and "
104 << f_k <<
" in AGI file and F matrix.";
122 assert(
nullptr != _agi.get());
173 const auto nj1 =
static_cast<value_type>(J - 1);
174 const auto s = n1 / nj1 / n0_25;
180 for (
size_t rk = 0; rk < RK; rk++)
192 for (
size_t j = 0; j < J; j++)
194 for (
size_t row = 0; row < RK; row++)
196 const auto s_row = s * (rf(row, j) - rf_avg[row]);
197 for (
size_t col = 0; col <= row; col++)
198 c(row, col) += s_row * (rf(col, j) - rf_avg[col]);
222 const auto RK = K - 1;
226 for (
size_t rk = 0; rk < RK; rk++)
227 for (
size_t j = 0; j < J; j++)
228 rf(rk, j) = f(rk + 1, j) - f(0, j);
243 #endif // JADE_SETTINGS_HPP__
A template for a class that performs validation on various types of matrices.
void validate_empty() const
Throws an exception if there are more arguments to be processed.
static bool validate_c(const matrix_type &c)
Validates the C matrix and throws an exception if validation fails.
static genotype_matrix_type * create(const std::string &path)
Creates a genotype matrix based on values from a file. This function determines what kind of genotype...
const options_type & get_options() const
std::unique_ptr< genotype_matrix_type > g_ptr
The genotype matrix pointer type.
static bool validate_gf_sizes(const genotype_matrix_type &g, const matrix_type &f)
Validates the sizes of the G and F matrices and throws an exception if validation fails.
void resize(const size_t height, const size_t width)
Resizes the matrix to the specified dimensions. The values of the matrix are not reset.
static matrix_type create_c(const matrix_type &rf)
Creates the covariance matrix.
static matrix_type create_rf(const matrix_type &f)
Creates the rooted F matrix.
A template for an abstract class implementing operations for a genotype matrix.
TValue value_type
The value type.
A template for a class that reads an AGI (Admixture Graph Input) file. The file provides the followin...
const matrix_type & get_mu() const
basic_verification< value_type > verification_type
The verification type.
basic_options< value_type > options_type
The options type.
static bool validate_fc_sizes(const matrix_type &f, const matrix_type &c)
Validates the sizes of the F and C matrices and throws an exception if validation fails.
static bool validate_f(const matrix_type &f)
Validates the F matrix and throws an exception if validation fails.
void read(const std::string &path)
Reads the matrix values from the specified file.
bool is_tin_specified() const
bool is_ain_specified() const
size_t get_height() const
basic_agi_reader< value_type > agi_reader_type
The admixture graph input reader.
const agi_reader_type & get_agi() const
const std::string & get_ain() const
A template for a class that helps process command-line arguments.
basic_settings(args &a)
Initializes a new instance of the class based on the specified command-line arguments.
A template for a class that creates genotype matrices based on files and their file extensions.
bool is_cin_specified() const
basic_genotype_matrix_factory< value_type > genotype_matrix_factory_type
The genotype matrix factory type.
const matrix_type & get_rf() const
const std::string & get_cin() const
value_type get_row_sum(const size_t row) const
static bool validate_g(const genotype_matrix_type &g)
Validates the G matrix and throws an exception if validation fails.
void copy_lower_to_upper()
Copies the elements in the lower triangle of the square matrix to the corresponding upper triangle el...
A template for a class representing an exception thrown from this namespace.
basic_genotype_matrix< value_type > genotype_matrix_type
The genotype matrix type.
std::unique_ptr< agi_reader_type > agi_ptr_type
A pointer to an admixture graph input reader.
value_type get_f_epsilon() const
const matrix_type & get_c() const
basic_matrix< value_type > matrix_type
The matrix type.