Skip to content

Commit

Permalink
correction for huge data fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marekkokot committed Dec 3, 2024
1 parent f938b8e commit 8c0a23b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/common/version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#define SPLASH_VER "2.11.4"
#define SPLASH_VER "2.11.5"

inline void SPLASH_VER_PRINT(std::ostream& oss) {
oss << "splash version: " << SPLASH_VER << "\n";
Expand Down
40 changes: 14 additions & 26 deletions src/sig_anch/sig_anch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ bool load_tsv_stream(const string& fn, uint64_t file_id)
// ************************************************************************************
vector<pair<double, bool>> fdr_correction(const vector<double>& pvals, double alpha)
{
vector<pair<double, int>> pv_sorted;
vector<pair<double, int64_t>> pv_sorted;
vector<pair<double, bool>> pv_corr;

int size = (int)pvals.size();
int64_t size = (int64_t)pvals.size();

pv_corr.resize(size);

Expand All @@ -301,47 +301,35 @@ vector<pair<double, bool>> fdr_correction(const vector<double>& pvals, double al

pv_sorted.resize(size);

for (int i = 0; i < size; ++i)
for (int64_t i = 0; i < size; ++i)
pv_sorted[i] = make_pair(pvals[i], i);

stable_sort(pv_sorted.begin(), pv_sorted.end());

double cm = 0;
for (int i = 1; i <= size; ++i)
for (int64_t i = 1; i <= size; ++i)
cm += 1.0 / i;

// cout << "cm: " << cm << endl;

// Calculate pvals_corrected_raw
for (int i = 0; i < size; ++i)
// Calculate pvals_corrected_raw
for (int64_t i = 0; i < size; ++i)
{
pv_corr[i].first = pv_sorted[i].first * (size * cm) / (i + 1);
pv_corr[i].second = pv_corr[i].first <= alpha;
}

/* cout << "pvals_corrected_raw: ";
for (auto x : pv_corr)
cout << "[" << x.first << "," << x.second << "] ";
cout << endl;*/

// Calculate pvals_corrected
// Calculate pvals_corrected
double min_pv = 1.0;
for (int i = size - 1; i >= 0; --i)
for (int64_t i = size - 1; i >= 0; --i)
{
min_pv = min(min_pv, pv_corr[i].first);
pv_corr[i].first = min_pv;
}

/* cout << "pvals_corrected: ";
for (auto x : pv_corr)
cout << "[" << x.first << "," << x.second << "] ";
cout << endl;*/

vector<pair<double, bool>> pv_original_order;

pv_original_order.resize(size);

for (int i = 0; i < size; ++i)
for (int64_t i = 0; i < size; ++i)
pv_original_order[pv_sorted[i].second] = pv_corr[i];

return pv_original_order;
Expand Down Expand Up @@ -468,27 +456,27 @@ void correct_pvals()
// ************************************************************************************
void fdr_correction_stream(vector<double>& pvals, double alpha)
{
vector<pair<double, int>> pv_sorted;
vector<pair<double, int64_t>> pv_sorted;

int size = (int)pvals.size();
int64_t size = (int64_t)pvals.size();

if (size == 0)
return;

pv_sorted.resize(size);

for (int i = 0; i < size; ++i)
for (int64_t i = 0; i < size; ++i)
pv_sorted[i] = make_pair(pvals[i], i);

stable_sort(pv_sorted.begin(), pv_sorted.end());

double cm = 0;
for (int i = 1; i <= size; ++i)
for (int64_t i = 1; i <= size; ++i)
cm += 1.0 / i;

// Calculate pvals_corrected
double min_pv = 1.0;
for (int i = size - 1; i >= 0; --i)
for (int64_t i = size - 1; i >= 0; --i)
{
double pv = pv_sorted[i].first * (size * cm) / (i + 1);
min_pv = min(min_pv, pv);
Expand Down
2 changes: 1 addition & 1 deletion src/splash.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _split_lines(self, text, width):
# this is the RawTextHelpFormatter._split_lines
return argparse.HelpFormatter._split_lines(self, text, width)

SPLASH_VERSION="2.11.4"
SPLASH_VERSION="2.11.5"

parser = argparse.ArgumentParser(
prog = "splash",
Expand Down

0 comments on commit 8c0a23b

Please sign in to comment.