... | ... |
@@ -1,14 +1,14 @@ |
1 |
+// Copyright [2014] <Fred Hutchinson Cancer Research Center> |
|
1 | 2 |
// [[Rcpp::interfaces(r)]] |
2 | 3 |
|
3 | 4 |
#include <Rcpp.h> |
4 | 5 |
using namespace Rcpp; |
5 | 6 |
|
6 | 7 |
template <typename T> |
7 |
-T my_abs( const T& x){ |
|
8 |
- return ::abs(x) ; |
|
8 |
+T my_abs(const T& x) { |
|
9 |
+ return ::abs(x); |
|
9 | 10 |
} |
10 | 11 |
|
11 |
- |
|
12 | 12 |
#define rownames(x) as<CharacterVector>(VECTOR_ELT(x.attr("dimnames"), 0)) |
13 | 13 |
#define colnames(x) as<CharacterVector>(VECTOR_ELT(x.attr("dimnames"), 1)) |
14 | 14 |
|
... | ... |
@@ -28,7 +28,6 @@ T my_abs( const T& x){ |
28 | 28 |
|
29 | 29 |
// [[Rcpp::export(.CellCounts)]] |
30 | 30 |
IntegerMatrix CellCounts(List x, List combos) { |
31 |
- |
|
32 | 31 |
int x_n = x.size(); |
33 | 32 |
int combos_n = combos.size(); |
34 | 33 |
IntegerMatrix output(x_n, combos_n); |
... | ... |
@@ -38,22 +37,20 @@ IntegerMatrix CellCounts(List x, List combos) { |
38 | 37 |
LogicalMatrix mat = as<LogicalMatrix>(x[i]); |
39 | 38 |
int nrows = mat.nrow(); |
40 | 39 |
for (int k = 0; k < combos_n; ++k) { |
41 |
- |
|
42 | 40 |
int num = 0; |
43 | 41 |
IntegerVector c_combo = as<IntegerVector>(combos[k]); |
44 | 42 |
int n_c = c_combo.size(); |
45 |
- IntegerVector c_combo_abs = sapply(c_combo,my_abs<int>); |
|
43 |
+ IntegerVector c_combo_abs = sapply(c_combo, my_abs<int>); |
|
46 | 44 |
|
47 | 45 |
for (int j = 0; j < nrows; ++j) { |
48 |
- |
|
49 | 46 |
LogicalMatrix::Row row = mat(j, _); |
50 | 47 |
|
51 |
-// checking algorithm: |
|
52 |
-// we loop through each entry in 'c_combo' => p |
|
53 |
-// we check the element in 'row' at 'abs(c_combo[p])' |
|
54 |
-// if 'abs(c_combo[p])' is > 0 and row[ c_combo[p] ] is true; continue |
|
55 |
-// if 'abs(c_combo[p])' is <= 0 and row[ c_combo[p] ] is false; continue |
|
56 |
-// else, 'false_case' |
|
48 |
+ // checking algorithm: |
|
49 |
+ // we loop through each entry in 'c_combo' => p |
|
50 |
+ // we check the element in 'row' at 'abs(c_combo[p])' |
|
51 |
+ // if 'abs(c_combo[p])' is > 0 and row[ c_combo[p] ] is true; continue |
|
52 |
+ // if 'abs(c_combo[p])' is <= 0 and row[ c_combo[p] ] is false; continue |
|
53 |
+ // else, 'false_case' |
|
57 | 54 |
|
58 | 55 |
#define c (c_combo[p]) |
59 | 56 |
#define abs_c (c_combo_abs[p]) |
... | ... |
@@ -86,8 +83,8 @@ IntegerMatrix CellCounts(List x, List combos) { |
86 | 83 |
} |
87 | 84 |
|
88 | 85 |
if (!Rf_isNull(combos.attr("names"))) { |
89 |
- SET_VECTOR_ELT( |
|
90 |
- output.attr("dimnames"), 1, Rf_duplicate(combos.attr("names"))); |
|
86 |
+ SET_VECTOR_ELT(output.attr("dimnames"), 1, |
|
87 |
+ Rf_duplicate(combos.attr("names"))); |
|
91 | 88 |
} |
92 | 89 |
|
93 | 90 |
return output; |
... | ... |
@@ -1,13 +1,12 @@ |
1 |
+// Copyright [2014] <Fred Hutchinson Cancer Research Center> |
|
1 | 2 |
// [[Rcpp::interfaces(r)]] |
2 | 3 |
|
3 | 4 |
#include <Rcpp.h> |
4 | 5 |
using namespace Rcpp; |
5 |
- |
|
6 | 6 |
extern "C" SEXP mat2vec(SEXP); |
7 | 7 |
|
8 | 8 |
// [[Rcpp::export]] |
9 | 9 |
IntegerMatrix CellCounts_character(List data, List combinations) { |
10 |
- |
|
11 | 10 |
Function list2env("list2env"); |
12 | 11 |
|
13 | 12 |
int m = data.size(); // rows |
... | ... |
@@ -16,7 +15,6 @@ IntegerMatrix CellCounts_character(List data, List combinations) { |
16 | 15 |
|
17 | 16 |
// loop over data |
18 | 17 |
for (int i = 0; i < m; ++i) { |
19 |
- |
|
20 | 18 |
SEXP m = PROTECT(mat2vec(as<LogicalMatrix>(data[i]))); |
21 | 19 |
Environment env = list2env(m); |
22 | 20 |
|
... | ... |
@@ -1,3 +1,5 @@ |
1 |
+// Copyright [2014] <Fred Hutchinson Cancer Research Center> |
|
2 |
+ |
|
1 | 3 |
// Generated by using Rcpp::compileAttributes() -> do not edit by hand |
2 | 4 |
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 |
3 | 5 |
|
... | ... |
@@ -8,24 +10,25 @@ using namespace Rcpp; |
8 | 10 |
// CellCounts |
9 | 11 |
IntegerMatrix CellCounts(List x, List combos); |
10 | 12 |
RcppExport SEXP _COMPASS_CellCounts(SEXP xSEXP, SEXP combosSEXP) { |
11 |
-BEGIN_RCPP |
|
12 |
- Rcpp::RObject rcpp_result_gen; |
|
13 |
- Rcpp::RNGScope rcpp_rngScope_gen; |
|
14 |
- Rcpp::traits::input_parameter< List >::type x(xSEXP); |
|
15 |
- Rcpp::traits::input_parameter< List >::type combos(combosSEXP); |
|
16 |
- rcpp_result_gen = Rcpp::wrap(CellCounts(x, combos)); |
|
17 |
- return rcpp_result_gen; |
|
18 |
-END_RCPP |
|
13 |
+ BEGIN_RCPP |
|
14 |
+ Rcpp::RObject rcpp_result_gen; |
|
15 |
+ Rcpp::RNGScope rcpp_rngScope_gen; |
|
16 |
+ Rcpp::traits::input_parameter<List>::type x(xSEXP); |
|
17 |
+ Rcpp::traits::input_parameter<List>::type combos(combosSEXP); |
|
18 |
+ rcpp_result_gen = Rcpp::wrap(CellCounts(x, combos)); |
|
19 |
+ return rcpp_result_gen; |
|
20 |
+ END_RCPP |
|
19 | 21 |
} |
20 | 22 |
// CellCounts_character |
21 | 23 |
IntegerMatrix CellCounts_character(List data, List combinations); |
22 |
-RcppExport SEXP _COMPASS_CellCounts_character(SEXP dataSEXP, SEXP combinationsSEXP) { |
|
23 |
-BEGIN_RCPP |
|
24 |
- Rcpp::RObject rcpp_result_gen; |
|
25 |
- Rcpp::RNGScope rcpp_rngScope_gen; |
|
26 |
- Rcpp::traits::input_parameter< List >::type data(dataSEXP); |
|
27 |
- Rcpp::traits::input_parameter< List >::type combinations(combinationsSEXP); |
|
28 |
- rcpp_result_gen = Rcpp::wrap(CellCounts_character(data, combinations)); |
|
29 |
- return rcpp_result_gen; |
|
30 |
-END_RCPP |
|
24 |
+RcppExport SEXP _COMPASS_CellCounts_character(SEXP dataSEXP, |
|
25 |
+ SEXP combinationsSEXP) { |
|
26 |
+ BEGIN_RCPP |
|
27 |
+ Rcpp::RObject rcpp_result_gen; |
|
28 |
+ Rcpp::RNGScope rcpp_rngScope_gen; |
|
29 |
+ Rcpp::traits::input_parameter<List>::type data(dataSEXP); |
|
30 |
+ Rcpp::traits::input_parameter<List>::type combinations(combinationsSEXP); |
|
31 |
+ rcpp_result_gen = Rcpp::wrap(CellCounts_character(data, combinations)); |
|
32 |
+ return rcpp_result_gen; |
|
33 |
+ END_RCPP |
|
31 | 34 |
} |
... | ... |
@@ -1,24 +1,19 @@ |
1 |
+// Copyright [2014] <Fred Hutchinson Cancer Research Center> |
|
2 |
+ |
|
1 | 3 |
#include <Rcpp.h> |
2 | 4 |
using namespace Rcpp; |
3 | 5 |
|
4 | 6 |
// [[register]] |
5 |
-RcppExport SEXP samplePuPs(SEXP alphau, |
|
6 |
- SEXP alphas, |
|
7 |
- SEXP gammat, |
|
8 |
- SEXP T, |
|
9 |
- SEXP K, |
|
10 |
- SEXP nsi, |
|
11 |
- SEXP nui, |
|
12 |
- SEXP d, |
|
13 |
- SEXP M) { |
|
7 |
+RcppExport SEXP samplePuPs(SEXP alphau, SEXP alphas, SEXP gammat, SEXP T, |
|
8 |
+ SEXP K, SEXP nsi, SEXP nui, SEXP d, SEXP M) { |
|
14 | 9 |
BEGIN_RCPP |
15 | 10 |
|
16 |
- IntegerVector xnsi(nsi); // n_s[i,] |
|
17 |
- IntegerVector xnui(nui); // n_u[i,] |
|
18 |
- NumericMatrix xalphau(alphau); // posterior samples for alpha_u |
|
19 |
- NumericMatrix xalphas(alphas); // posterior samples for alpha_s |
|
20 |
- IntegerMatrix xgammat(gammat); // posterior samples for gamma_i |
|
21 |
- IntegerMatrix xd(d); // cytokine combination indicator matrix |
|
11 |
+ IntegerVector xnsi(nsi); // n_s[i,] |
|
12 |
+ IntegerVector xnui(nui); // n_u[i,] |
|
13 |
+ NumericMatrix xalphau(alphau); // posterior samples for alpha_u |
|
14 |
+ NumericMatrix xalphas(alphas); // posterior samples for alpha_s |
|
15 |
+ IntegerMatrix xgammat(gammat); // posterior samples for gamma_i |
|
16 |
+ IntegerMatrix xd(d); // cytokine combination indicator matrix |
|
22 | 17 |
|
23 | 18 |
// int xM = as<int>(M); // # markers |
24 | 19 |
int xT = as<int>(T); // # MCMC iterations used |
... | ... |
@@ -94,7 +89,6 @@ RcppExport SEXP samplePuPs(SEXP alphau, |
94 | 89 |
std::vector<double> as(sum); |
95 | 90 |
sass = 0.; |
96 | 91 |
for (int j = 0; j < sum; j++) { |
97 |
- |
|
98 | 92 |
as[j] = alpha_s[place1[j]]; |
99 | 93 |
sass += as[j]; |
100 | 94 |
} |
... | ... |
@@ -119,8 +113,8 @@ RcppExport SEXP samplePuPs(SEXP alphau, |
119 | 113 |
p_s = p_s[seq(0, p_s.size() - 2)]; |
120 | 114 |
p_u = p_u[seq(0, p_u.size() - 2)]; |
121 | 115 |
|
122 |
- return List::create( |
|
123 |
- _["p_s"] = p_s, _["p_u"] = p_u, _["diff"] = DIFF, _["logd"] = LogD); |
|
116 |
+ return List::create(_["p_s"] = p_s, _["p_u"] = p_u, _["diff"] = DIFF, |
|
117 |
+ _["logd"] = LogD); |
|
124 | 118 |
|
125 | 119 |
END_RCPP |
126 | 120 |
} |
... | ... |
@@ -1,18 +1,12 @@ |
1 |
+// Copyright [2014] <Fred Hutchinson Cancer Research Center> |
|
1 | 2 |
#include <Rcpp.h> |
2 | 3 |
|
3 | 4 |
extern "C" double digamma(double); |
4 | 5 |
|
5 | 6 |
// [[register]] |
6 |
-RcppExport SEXP updatealphas_Exp(SEXP alphast, |
|
7 |
- SEXP n_s, |
|
8 |
- SEXP K, |
|
9 |
- SEXP I, |
|
10 |
- SEXP lambda_s, |
|
11 |
- SEXP gammat, |
|
12 |
- SEXP var_1, |
|
13 |
- SEXP var_2, |
|
14 |
- SEXP p_var, |
|
15 |
- SEXP ttt) { |
|
7 |
+RcppExport SEXP updatealphas_Exp(SEXP alphast, SEXP n_s, SEXP K, SEXP I, |
|
8 |
+ SEXP lambda_s, SEXP gammat, SEXP var_1, |
|
9 |
+ SEXP var_2, SEXP p_var, SEXP ttt) { |
|
16 | 10 |
BEGIN_RCPP |
17 | 11 |
Rcpp::NumericVector xalphast(alphast); |
18 | 12 |
|
... | ... |
@@ -1,16 +1,11 @@ |
1 |
+// Copyright [2014] <Fred Hutchinson Cancer Research Center> |
|
1 | 2 |
#include <Rcpp.h> |
2 | 3 |
extern "C" double digamma(double); |
3 | 4 |
|
4 | 5 |
// [[register]] |
5 |
-RcppExport SEXP updatealphau_noPu_Exp(SEXP alphaut, |
|
6 |
- SEXP n_s, |
|
7 |
- SEXP n_u, |
|
8 |
- SEXP I, |
|
9 |
- SEXP K, |
|
10 |
- SEXP lambda_u, |
|
11 |
- SEXP var_p, |
|
12 |
- SEXP ttt, |
|
13 |
- SEXP gammat) { |
|
6 |
+RcppExport SEXP updatealphau_noPu_Exp(SEXP alphaut, SEXP n_s, SEXP n_u, SEXP I, |
|
7 |
+ SEXP K, SEXP lambda_u, SEXP var_p, |
|
8 |
+ SEXP ttt, SEXP gammat) { |
|
14 | 9 |
BEGIN_RCPP |
15 | 10 |
Rcpp::IntegerMatrix xgammat(gammat); |
16 | 11 |
Rcpp::NumericVector xalphaut(alphaut); |
... | ... |
@@ -1,25 +1,14 @@ |
1 |
-#include <Rcpp.h> |
|
1 |
+// Copyright [2014] <Fred Hutchinson Cancer Research Center> |
|
2 | 2 |
|
3 | 3 |
#include <R_ext/Utils.h> |
4 |
+#include <Rcpp.h> |
|
4 | 5 |
#include <stdlib.h> |
5 | 6 |
|
6 | 7 |
// [[register]] |
7 |
-RcppExport SEXP updategammak_noPu(SEXP n_s, |
|
8 |
- SEXP n_u, |
|
9 |
- SEXP gammat, |
|
10 |
- SEXP I, |
|
11 |
- SEXP K, |
|
12 |
- SEXP SS, |
|
13 |
- SEXP alphau, |
|
14 |
- SEXP alphas, |
|
15 |
- SEXP alpha, |
|
16 |
- SEXP mk, |
|
17 |
- SEXP Istar, |
|
18 |
- SEXP mKstar, |
|
19 |
- SEXP pp, |
|
20 |
- SEXP pb1, |
|
21 |
- SEXP pb2, |
|
22 |
- SEXP indi) { |
|
8 |
+RcppExport SEXP updategammak_noPu(SEXP n_s, SEXP n_u, SEXP gammat, SEXP I, |
|
9 |
+ SEXP K, SEXP SS, SEXP alphau, SEXP alphas, |
|
10 |
+ SEXP alpha, SEXP mk, SEXP Istar, SEXP mKstar, |
|
11 |
+ SEXP pp, SEXP pb1, SEXP pb2, SEXP indi) { |
|
23 | 12 |
BEGIN_RCPP |
24 | 13 |
|
25 | 14 |
Rcpp::IntegerMatrix xn_s(n_s); |
... | ... |
@@ -358,11 +347,10 @@ RcppExport SEXP updategammak_noPu(SEXP n_s, |
358 | 347 |
} |
359 | 348 |
} |
360 | 349 |
|
361 |
- return Rcpp::List::create(Rcpp::Named("gamma_tt") = gamma_tt, |
|
362 |
- Rcpp::Named("Ag") = xAg, |
|
363 |
- Rcpp::Named("mKstar") = xmKstar, |
|
364 |
- Rcpp::Named("xmk") = xmk, |
|
365 |
- Rcpp::Named("xIstar") = xIstar); |
|
350 |
+ return Rcpp::List::create( |
|
351 |
+ Rcpp::Named("gamma_tt") = gamma_tt, Rcpp::Named("Ag") = xAg, |
|
352 |
+ Rcpp::Named("mKstar") = xmKstar, Rcpp::Named("xmk") = xmk, |
|
353 |
+ Rcpp::Named("xIstar") = xIstar); |
|
366 | 354 |
|
367 | 355 |
END_RCPP |
368 | 356 |
} |