Skip to content

Commit

Permalink
[Fix] Permutation number was not initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
choishingwan committed Oct 9, 2019
1 parent 10ff53c commit f900601
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 49 deletions.
4 changes: 2 additions & 2 deletions inc/commander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#include <windows.h>
#endif

const std::string version = "2.2.10";
const std::string date = "2019-10-08";
const std::string version = "2.2.10.b";
const std::string date = "2019-10-09";
class Commander
{
public:
Expand Down
9 changes: 9 additions & 0 deletions inc/genotype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ class Genotype
{
std::fill(m_in_regression.begin(), m_in_regression.end(), 0);
}
void reset_std_flag()
{
std::fill(m_exclude_from_std.begin(), m_exclude_from_std.end(), 0);
}
void exclude_from_std(const size_t idx)
{
SET_BIT(idx, m_exclude_from_std.data());
}
/*!
* \brief Function to prepare the object for PRSice. Will sort the
* m_existed_snp vector according to their p-value.
Expand Down Expand Up @@ -481,6 +489,7 @@ class Genotype
std::vector<uintptr_t> m_founder_include2;
std::vector<uintptr_t> m_sample_include;
std::vector<uintptr_t> m_sample_include2;
std::vector<uintptr_t> m_exclude_from_std;
std::vector<uintptr_t> m_in_regression;
std::vector<uintptr_t> m_haploid_mask;
std::vector<size_t> m_sort_by_p_index;
Expand Down
14 changes: 6 additions & 8 deletions inc/prsice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ class PRSice
long long m_max_fid_length = 3;
long long m_max_iid_length = 3;
int m_best_index = -1;
size_t m_num_perm = 0;
bool m_perform_prset = false;
bool m_quick_best = true;
bool m_printed_warning = false;
const std::string m_prefix;
Expand All @@ -342,7 +340,8 @@ class PRSice
* regression flag for each sample
* \param target is the target genotype object
*/
void update_sample_included(const std::string& delim, Genotype& target);
void update_sample_included(const std::string& delim, const bool binary,
Genotype& target);
/*!
* \brief gen_pheno_vec is the function responsible for generating the
* phenotype vector
Expand Down Expand Up @@ -450,7 +449,7 @@ class PRSice
const Eigen::ColPivHouseholderQR<Eigen::MatrixXd>& PQR,
const Eigen::ColPivHouseholderQR<Eigen::MatrixXd>::PermutationType&
Pmat,
const Eigen::MatrixXd& Rinv, const Eigen::Index& rank,
const Eigen::MatrixXd& Rinv,
std::map<size_t, std::vector<size_t>>& set_index,
std::vector<double>& obs_t_value,
std::vector<std::atomic<size_t>>& set_perm_res, const bool is_binary);
Expand All @@ -463,8 +462,7 @@ class PRSice
const Eigen::ColPivHouseholderQR<Eigen::MatrixXd>& PQR,
const Eigen::ColPivHouseholderQR<Eigen::MatrixXd>::PermutationType&
Pmat,
const Eigen::MatrixXd& Rinv, const Eigen::Index& rank,
std::vector<double>& obs_t_value,
const Eigen::MatrixXd& Rinv, std::vector<double>& obs_t_value,
std::vector<std::atomic<size_t>>& set_perm_res, const bool is_binary);
/*!
* \brief The "producer" for generating the permuted phenotypes
Expand All @@ -487,7 +485,7 @@ class PRSice
const Eigen::ColPivHouseholderQR<Eigen::MatrixXd>& PQR,
const Eigen::ColPivHouseholderQR<Eigen::MatrixXd>::PermutationType&
Pmat,
const Eigen::MatrixXd& R, const Eigen::Index& rank, bool run_glm);
const Eigen::MatrixXd& R, bool run_glm);
/*!
* \brief Funtion to perform single threaded permutation
* \param decomposed is the pre-decomposed independent matrix. If run glm is
Expand All @@ -502,7 +500,7 @@ class PRSice
const Eigen::ColPivHouseholderQR<Eigen::MatrixXd>& PQR,
const Eigen::ColPivHouseholderQR<Eigen::MatrixXd>::PermutationType&
Pmat,
const Eigen::MatrixXd& R, const Eigen::Index& rank, const bool run_glm);
const Eigen::MatrixXd& R, const bool run_glm);

void parse_pheno(const bool binary, const std::string& pheno,
std::vector<double>& pheno_store, double& first_pheno,
Expand Down
8 changes: 5 additions & 3 deletions src/genotype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,10 @@ void Genotype::load_samples(bool verbose)
+ misc::to_string(m_num_female)
+ " female(s)) observed\n";
message.append(misc::to_string(m_founder_ct) + " founder(s) included");

const uintptr_t unfiltered_sample_ctl =
BITCT_TO_WORDCT(m_unfiltered_sample_ct);
m_exclude_from_std.resize(unfiltered_sample_ctl, 0);
if (verbose) m_reporter->report(message);
m_sample_selection_list.clear();
}
Expand Down Expand Up @@ -1474,9 +1478,7 @@ void Genotype::standardize_prs()
size_t num_prs = m_prs_info.size();
for (size_t i = 0; i < num_prs; ++i)
{
if (!IS_SET(m_sample_include, i)
|| (m_prs_calculation.scoring_method == SCORING::CONTROL_STD
&& m_sample_id[i].pheno != "0"))
if (!IS_SET(m_sample_include, i) || IS_SET(m_exclude_from_std, i))
continue;
if (m_prs_info[i].num_snp == 0) { rs.push(0.0); }
else
Expand Down
Loading

0 comments on commit f900601

Please sign in to comment.