... | ... |
@@ -4,5 +4,22 @@ |
4 | 4 |
^\.astylerc$ |
5 | 5 |
^.*\.Rproj$ |
6 | 6 |
^\.Rproj\.user$ |
7 |
+ |
|
7 | 8 |
^inst/benchmarks/ |
8 |
-^inst/profiling/ |
|
9 | 9 |
\ No newline at end of file |
10 |
+^inst/profiling/ |
|
11 |
+^inst/vignettes/ |
|
12 |
+ |
|
13 |
+^src/Algorithms.o |
|
14 |
+^src/AtomicSupport.o |
|
15 |
+^src/Cogaps.o |
|
16 |
+^src/GibbsSampler.o |
|
17 |
+^src/Matrix.o |
|
18 |
+^src/Random.o |
|
19 |
+^src/RcppExports.o |
|
20 |
+^src/test-runner.o |
|
21 |
+^src/cpp_tests/testAlgorithms.o |
|
22 |
+^src/cpp_tests/testAtomicSupport.o |
|
23 |
+^src/cpp_tests/testGibbsSampler.o |
|
24 |
+^src/cpp_tests/testMatrix.o |
|
25 |
+^src/cpp_tests/testRandom.o |
|
26 |
+^src/cpp_tests/testSerialization.o |
|
10 | 27 |
\ No newline at end of file |
... | ... |
@@ -1,26 +1,10 @@ |
1 | 1 |
# options file for running astyle to "beautify" c++ code |
2 | 2 |
# run using `astyle --options=.astylerc src/*.{cc,cpp,h}` |
3 | 3 |
|
4 |
-# don't create suffixes |
|
5 |
-suffix=none |
|
6 |
- |
|
7 |
-# use the google style of braces |
|
8 |
-style=google |
|
9 |
- |
|
10 | 4 |
# use 4 spaces instead of tabs |
11 | 5 |
indent=spaces=4 |
12 | 6 |
convert-tabs |
13 | 7 |
|
14 |
-# indent 'class' and 'switch' blocks |
|
15 |
-indent-classes |
|
16 |
-indent-switches |
|
17 |
- |
|
18 |
-# empty lines around blocks, labels, class, closing headers, ... |
|
19 |
-break-blocks=all |
|
20 |
- |
|
21 |
-# spaces around operator |
|
22 |
-pad-oper |
|
23 |
- |
|
24 | 8 |
# remove spaces in and around parenthesis except in front of headers |
25 | 9 |
# Example: foo ( bar, baz ); -> foo(bar, baz); |
26 | 10 |
unpad-paren |
... | ... |
@@ -28,9 +12,6 @@ unpad-paren |
28 | 12 |
# insert a space after if, while, for, etc (exception to previous rule) |
29 | 13 |
pad-header |
30 | 14 |
|
31 |
-# delete empty lines not created by `break-blocks=all` |
|
32 |
-delete-empty-lines |
|
33 |
- |
|
34 | 15 |
# pointer and reference operators to name |
35 | 16 |
align-pointer=name |
36 | 17 |
|
... | ... |
@@ -41,9 +22,5 @@ add-brackets |
41 | 22 |
# use linux line-endings |
42 | 23 |
lineend=linux |
43 | 24 |
|
44 |
-# why not keep the date the same? |
|
45 |
-# although the date is modified by micro seconds to force compile |
|
46 |
-preserve-date |
|
47 |
- |
|
48 | 25 |
# restrict lines to 80 characters |
49 | 26 |
max-code-length=120 |
... | ... |
@@ -2,9 +2,8 @@ Package: CoGAPS |
2 | 2 |
Version: 2.99.0 |
3 | 3 |
Date: 2014-08-23 |
4 | 4 |
Title: Coordinated Gene Activity in Pattern Sets |
5 |
-Author: Wai-shing Lee, Conor Kelton, Ondrej Maxian, Jacob Carey, Genevieve |
|
6 |
- Stein-O'Brien, Michael Considine, John Stansfield, Shawn Sivy, Carlo Colantuoni, |
|
7 |
- Alexander Favorov, Mike Ochs, Elana Fertig |
|
5 |
+Author: Thomas Sherman, Wai-shing Lee, Conor Kelton, Ondrej Maxian, |
|
6 |
+ Jacob Carey, Genevieve Stein-O'Brien, Michael Considine, John Stansfield, Shawn Sivy, Carlo Colantuoni, Alexander Favorov, Mike Ochs, Elana Fertig |
|
8 | 7 |
Description: Coordinated Gene Activity in Pattern Sets (CoGAPS) |
9 | 8 |
implements a Bayesian MCMC matrix factorization algorithm, |
10 | 9 |
GAPS, and links it to gene set statistic methods to infer biological |
... | ... |
@@ -27,8 +26,6 @@ Imports: |
27 | 26 |
utils, |
28 | 27 |
doParallel, |
29 | 28 |
foreach, |
30 |
- iterators, |
|
31 |
- parallel, |
|
32 | 29 |
ggplot2, |
33 | 30 |
reshape2 |
34 | 31 |
Suggests: |
... | ... |
@@ -51,7 +51,6 @@ |
51 | 51 |
#'@param fixedPatterns matrix of fixed values in either A or P matrix |
52 | 52 |
#'@param whichMatrixFixed character to indicate whether A or P matrix |
53 | 53 |
#' contains the fixed patterns |
54 |
-#'@param checkpoint_file_name name of file to store checkpoint |
|
55 | 54 |
#'@param checkpoint_interval time (in seconds) between cogaps checkpoints |
56 | 55 |
#'@export |
57 | 56 |
|
... | ... |
@@ -142,7 +141,14 @@ gapsRun <- function(D, S, ABins = data.frame(), PBins = data.frame(), |
142 | 141 |
return(cogapResult); |
143 | 142 |
} |
144 | 143 |
|
144 |
+# TODO: remove dependency on D,S matrices |
|
145 |
+#' Restart Run from Checkpoint File |
|
145 | 146 |
#' @export |
147 |
+#' |
|
148 |
+#' @param D data matrix |
|
149 |
+#' @param S uncertainty matrix |
|
150 |
+#' @param path path to checkpoint file |
|
151 |
+#' @return list containing information about A and P matrix |
|
146 | 152 |
gapsRunFromCheckpoint <- function(D, S, path) |
147 | 153 |
{ |
148 | 154 |
# call to C++ Rcpp code |
149 | 155 |
deleted file mode 100644 |
... | ... |
@@ -1,28 +0,0 @@ |
1 |
-# get directory of script |
|
2 |
-initial.options <- commandArgs(trailingOnly = FALSE) |
|
3 |
-file.arg.name <- "--file=" |
|
4 |
-script.name <- sub(file.arg.name, "", initial.options[grep(file.arg.name, initial.options)]) |
|
5 |
-script.basename <- dirname(script.name) |
|
6 |
- |
|
7 |
-# load packages |
|
8 |
-library(microbenchmark) |
|
9 |
-library(CoGAPS) |
|
10 |
- |
|
11 |
-# load benchmarks |
|
12 |
-source(paste(sep="/", script.basename, "cogaps.R")) |
|
13 |
- |
|
14 |
-# display package version |
|
15 |
-print(packageVersion('CoGAPS')) |
|
16 |
- |
|
17 |
-# run benchmarks |
|
18 |
-data(GIST_TS_20084) |
|
19 |
-nIter <- 3000 |
|
20 |
-print(runCogapsBenchmark( |
|
21 |
- D=GIST.D[1:75,], |
|
22 |
- S=GIST.S[1:75,], |
|
23 |
- nEquil=nIter, |
|
24 |
- nSample=nIter, |
|
25 |
- nFactor=7, |
|
26 |
- seed=12345, |
|
27 |
- reps=10 |
|
28 |
-)) |
|
29 | 0 |
\ No newline at end of file |
30 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,13 +0,0 @@ |
1 |
-library(CoGAPS) |
|
2 |
-library(microbenchmark) |
|
3 |
- |
|
4 |
-runCogapsBenchmark <- function(D, S, nEquil, nSample, nFactor, seed, reps) |
|
5 |
-{ |
|
6 |
- return(microbenchmark(gapsRun(D, S, |
|
7 |
- nEquil=nEquil, |
|
8 |
- nSample=nSample, |
|
9 |
- nFactor=nFactor, |
|
10 |
- seed=seed, |
|
11 |
- messages=FALSE), |
|
12 |
- times=reps)) |
|
13 |
-} |
|
14 | 0 |
\ No newline at end of file |
... | ... |
@@ -71,8 +71,6 @@ domain for relative probabilities} |
71 | 71 |
contains the fixed patterns} |
72 | 72 |
|
73 | 73 |
\item{checkpoint_interval}{time (in seconds) between cogaps checkpoints} |
74 |
- |
|
75 |
-\item{checkpoint_file_name}{name of file to store checkpoint} |
|
76 | 74 |
} |
77 | 75 |
\description{ |
78 | 76 |
\code{gapsRun} calls the C++ MCMC code and performs Bayesian |
79 | 77 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,22 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/gapsRun.R |
|
3 |
+\name{gapsRunFromCheckpoint} |
|
4 |
+\alias{gapsRunFromCheckpoint} |
|
5 |
+\title{Restart Run from Checkpoint File} |
|
6 |
+\usage{ |
|
7 |
+gapsRunFromCheckpoint(D, S, path) |
|
8 |
+} |
|
9 |
+\arguments{ |
|
10 |
+\item{D}{data matrix} |
|
11 |
+ |
|
12 |
+\item{S}{uncertainty matrix} |
|
13 |
+ |
|
14 |
+\item{path}{path to checkpoint file} |
|
15 |
+} |
|
16 |
+\value{ |
|
17 |
+list containing information about A and P matrix |
|
18 |
+} |
|
19 |
+\description{ |
|
20 |
+Restart Run from Checkpoint File |
|
21 |
+} |
|
22 |
+ |
... | ... |
@@ -144,7 +144,7 @@ AtomicProposal AtomicSupport::makeProposal() const |
144 | 144 |
} |
145 | 145 |
|
146 | 146 |
float unif = gaps::random::uniform(); |
147 |
- if ((mNumAtoms < 2 && unif <= 0.6667) || unif <= 0.5) // birth/death |
|
147 |
+ if ((mNumAtoms < 2 && unif <= 0.6667f) || unif <= 0.5f) // birth/death |
|
148 | 148 |
{ |
149 | 149 |
if (mNumAtoms >= mMaxNumAtoms) |
150 | 150 |
{ |
... | ... |
@@ -8,7 +8,6 @@ |
8 | 8 |
#include <fstream> |
9 | 9 |
#include <vector> |
10 | 10 |
#include <stdint.h> |
11 |
-//#include <boost/serialization/map.hpp> |
|
12 | 11 |
|
13 | 12 |
struct AtomicProposal |
14 | 13 |
{ |
... | ... |
@@ -31,6 +30,18 @@ struct AtomicProposal |
31 | 30 |
{} |
32 | 31 |
}; |
33 | 32 |
|
33 |
+struct Atom |
|
34 |
+{ |
|
35 |
+ uint64_t pos; |
|
36 |
+ float mass; |
|
37 |
+}; |
|
38 |
+ |
|
39 |
+struct AtomNeighbors |
|
40 |
+{ |
|
41 |
+ Atom left; |
|
42 |
+ Atom right; |
|
43 |
+}; |
|
44 |
+ |
|
34 | 45 |
class AtomicSupport |
35 | 46 |
{ |
36 | 47 |
private: |
... | ... |
@@ -43,6 +54,8 @@ public: |
43 | 54 |
char mLabel; |
44 | 55 |
|
45 | 56 |
// storage of the atomic domain |
57 |
+ //std::vector<Atom> mAtoms; |
|
58 |
+ //std::map<uint64_t, uint64_t> mAtomPositions; |
|
46 | 59 |
std::map<uint64_t, float> mAtomicDomain; |
47 | 60 |
uint64_t mNumAtoms; |
48 | 61 |
uint64_t mMaxNumAtoms; |
... | ... |
@@ -62,6 +75,11 @@ public: |
62 | 75 |
// expected magnitude of each atom (must be > 0) |
63 | 76 |
float mLambda; |
64 | 77 |
|
78 |
+ // functions for dealing with atomic data structure |
|
79 |
+ //void addAtom(Atom atom); // O(logN) |
|
80 |
+ //void removeAtom(Atom atom); // O(logN) |
|
81 |
+ //AtomNeighbors getNeighbors(uint64_t pos); // O(logN) |
|
82 |
+ |
|
65 | 83 |
// convert atomic position to row/col of the matrix |
66 | 84 |
uint64_t getRow(uint64_t pos) const; |
67 | 85 |
uint64_t getCol(uint64_t pos) const; |
... | ... |
@@ -24,7 +24,7 @@ static bpt::ptime lastCheckpoint; |
24 | 24 |
static void createCheckpoint(GapsInternalState &state) |
25 | 25 |
{ |
26 | 26 |
state.numCheckpoints++; |
27 |
- std::cout << "creating gaps checkpoint..."; |
|
27 |
+ Rcpp::Rcout << "creating gaps checkpoint..."; |
|
28 | 28 |
bpt::ptime start = bpt::microsec_clock::local_time(); |
29 | 29 |
Archive ar("gaps_checkpoint_" + SSTR(state.numCheckpoints) + ".out", |
30 | 30 |
ARCHIVE_WRITE); |
... | ... |
@@ -39,7 +39,7 @@ static void createCheckpoint(GapsInternalState &state) |
39 | 39 |
ar.close(); |
40 | 40 |
bpt::time_duration diff = bpt::microsec_clock::local_time() - start; |
41 | 41 |
double elapsed = diff.total_milliseconds() / 1000.; |
42 |
- std::cout << " finished in " << elapsed << " seconds\n"; |
|
42 |
+ Rcpp::Rcout << " finished in " << elapsed << " seconds\n"; |
|
43 | 43 |
} |
44 | 44 |
|
45 | 45 |
static void runGibbsSampler(GapsInternalState &state, unsigned nIterTotal, |
... | ... |
@@ -92,7 +92,7 @@ Vector &chi2Vec, Vector &aAtomVec, Vector &pAtomVec) |
92 | 92 |
if ((state.iter + 1) % state.nOutputs == 0 && state.messages) |
93 | 93 |
{ |
94 | 94 |
std::string temp = state.phase == GAPS_CALIBRATION ? "Equil: " : "Samp: "; |
95 |
- std::cout << temp << state.iter + 1 << " of " << nIterTotal |
|
95 |
+ Rcpp::Rcout << temp << state.iter + 1 << " of " << nIterTotal |
|
96 | 96 |
<< ", Atoms:" << aAtomVec[state.iter] << "(" << pAtomVec[state.iter] |
97 | 97 |
<< ") Chi2 = " << state.sampler.chi2() << '\n'; |
98 | 98 |
} |
... | ... |
@@ -187,7 +187,7 @@ Rcpp::List cogapsFromCheckpoint(const std::string &fileName) |
187 | 187 |
ar >> magicNum; |
188 | 188 |
if (magicNum != ARCHIVE_MAGIC_NUM) |
189 | 189 |
{ |
190 |
- std::cout << "invalid checkpoint file" << std::endl; |
|
190 |
+ Rcpp::Rcout << "invalid checkpoint file" << std::endl; |
|
191 | 191 |
return Rcpp::List::create(); |
192 | 192 |
} |
193 | 193 |
|
... | ... |
@@ -7,20 +7,15 @@ |
7 | 7 |
#include <boost/random/normal_distribution.hpp> |
8 | 8 |
#include <boost/random/poisson_distribution.hpp> |
9 | 9 |
#include <boost/random/exponential_distribution.hpp> |
10 |
- |
|
11 | 10 |
#include <boost/random/mersenne_twister.hpp> |
12 | 11 |
|
13 |
-// need -O0 to run in valgrind, -O2 for performance |
|
14 |
-#pragma GCC push_options |
|
15 |
-#pragma GCC optimize ("O2") |
|
16 | 12 |
#include <boost/math/distributions/normal.hpp> |
17 | 13 |
#include <boost/math/distributions/exponential.hpp> |
18 | 14 |
#include <boost/math/distributions/gamma.hpp> |
19 |
-#pragma GCC pop_options |
|
20 | 15 |
|
21 | 16 |
#include <stdint.h> |
22 | 17 |
|
23 |
-#define Q_GAMMA_THRESHOLD 1E-6 |
|
18 |
+#define Q_GAMMA_THRESHOLD 0.000001f |
|
24 | 19 |
#define Q_GAMMA_MIN_VALUE 0.0 |
25 | 20 |
|
26 | 21 |
typedef boost::random::mt19937 RNGType; |
... | ... |
@@ -8,6 +8,8 @@ |
8 | 8 |
* Distributed under the Boost Software License, Version 1.0. (See accompanying |
9 | 9 |
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
10 | 10 |
*/ |
11 |
+#include <Rcpp.h> |
|
12 |
+ |
|
11 | 13 |
#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED |
12 | 14 |
#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED |
13 | 15 |
|
... | ... |
@@ -7705,10 +7707,10 @@ namespace Catch { |
7705 | 7707 |
|
7706 | 7708 |
#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions |
7707 | 7709 |
std::ostream& cout() { |
7708 |
- return std::cout; |
|
7710 |
+ return Rcpp::Rcout; |
|
7709 | 7711 |
} |
7710 | 7712 |
std::ostream& cerr() { |
7711 |
- return std::cerr; |
|
7713 |
+ return Rcpp::Rcerr; |
|
7712 | 7714 |
} |
7713 | 7715 |
std::ostream& clog() { |
7714 | 7716 |
return std::clog; |