-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Incorporated a few bug fixes; mainly
(1) Made bias correction code aware of updated output format (thanks, Ido & Jason). (2) Fixed bug in alignment-based Salmon where the alignment error model was incorrectly applied to orphaned reads in paired-end data.
- Loading branch information
Showing
14 changed files
with
513 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef COLLAPSED_GIBBS_SAMPLER_HPP | ||
#define COLLAPSED_GIBBS_SAMPLER_HPP | ||
|
||
#include <unordered_map> | ||
|
||
#include "tbb/atomic.h" | ||
#include "tbb/task_scheduler_init.h" | ||
|
||
#include "SalmonOpts.hpp" | ||
|
||
#include "cuckoohash_map.hh" | ||
#include "Eigen/Dense" | ||
|
||
class CollapsedGibbsSampler { | ||
public: | ||
using VecType = std::vector<double>; | ||
CollapsedGibbsSampler(); | ||
|
||
template <typename ExpT> | ||
bool sample(ExpT& readExp, | ||
SalmonOpts& sopt, | ||
uint32_t numSamples = 500); | ||
|
||
}; | ||
|
||
#endif // COLLAPSED_EM_OPTIMIZER_HPP | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#ifndef _MULTINOMIAL_SAMPLER_HPP_ | ||
#define _MULTINOMIAL_SAMPLER_HPP_ | ||
|
||
#include <random> | ||
#include <vector> | ||
|
||
class MultinomialSampler { | ||
public: | ||
MultinomialSampler(std::random_device& rd) : | ||
gen_(rd()), u01_(0.0, 1.0) {} | ||
|
||
void operator()( | ||
std::vector<int>::iterator sampleBegin, | ||
uint32_t n, | ||
uint32_t k, | ||
std::vector<double>::iterator probsBegin, | ||
bool clearCounts = true) { | ||
int i, j; | ||
double u, sum; | ||
std::vector<double> z(k+1, 0.0); | ||
|
||
if (clearCounts) { | ||
for (uint32_t i = 0; i < k; i++) { | ||
*(sampleBegin + i) = 0; | ||
} | ||
} | ||
|
||
z[0] = 0; | ||
for (i = 1; i <= k; i++) { | ||
sum = 0; | ||
for (j = 0; j < i; j++) sum+= *(probsBegin + j); | ||
z[i] = sum; | ||
} | ||
|
||
for (j = 0; j < n; j++) { | ||
u = u01_(gen_); | ||
|
||
for (i = 0; i < k; i++) { | ||
if ((z[i] < u) && (u <= z[i+1])) { | ||
(*(sampleBegin + i))++; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
private: | ||
std::mt19937 gen_; | ||
std::uniform_real_distribution<> u01_; | ||
}; | ||
|
||
#endif //_MULTINOMIAL_SAMPLER_HPP_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.