Browse code

3.99.8: unity build

ramon diaz-uriarte (at Phelsuma) authored on 15/09/2022 19:29:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,255 +0,0 @@
1
-//     Copyright 2013-2021 Ramon Diaz-Uriarte
2
-
3
-//     This program is free software: you can redistribute it and/or modify
4
-//     it under the terms of the GNU General Public License as published by
5
-//     the Free Software Foundation, either version 3 of the License, or
6
-//     (at your option) any later version.
7
-
8
-//     This program is distributed in the hope that it will be useful,
9
-//     but WITHOUT ANY WARRANTY; without even the implied warranty of
10
-//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
-//     GNU General Public License for more details.
12
-
13
-//     You should have received a copy of the GNU General Public License
14
-//     along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
-
16
-
17
-
18
-#ifndef _BNB_COMMON_H_
19
-#define _BNB_COMMON_H_
20
-
21
-#include <Rcpp.h>
22
-#include "common_classes.h"
23
-#include "debug_common.h"
24
-#include "new_restrict.h" // for the TypeModel enum
25
-
26
-
27
-inline void W_f_st(spParamsP& spP){
28
-  spP.W = spP.death + spP.birth + spP.mutation;
29
-}
30
-
31
-inline void R_f_st(spParamsP& spP) {
32
-  spP.R = sqrt( pow( spP.birth - spP.death, 2) +
33
-		( 2.0 * (spP.birth + spP.death) +
34
-		  spP.mutation) * spP.mutation );
35
-}
36
-
37
-
38
-inline double pE_f_st(double& pM, const spParamsP& spP){
39
-  double pE = (spP.death * (1.0 - pM ) )/(spP.W - spP.death - spP.birth * pM );
40
-  if( !std::isfinite(pE) ) {
41
-    DP2(spP.death);  DP2(spP.birth); DP2(pM); DP2(spP.W);
42
-    DP2(spP.mutation);
43
-    std::string error_message = R"(pE.f: pE not finite.
44
-      This is expected to happen when mutationPropGrowth = TRUE
45
-      and you have have an initMutant with death >> birth,
46
-      as that inevitably leads to net birth rate of 0
47
-      and mutation rate of 0)";
48
-    throw std::range_error(error_message);
49
-  }
50
-  return pE;
51
-}
52
-
53
-inline double pB_f_st(const double& pE,
54
-		      const spParamsP& spP) {
55
-  return (spP.birth * pE)/spP.death;
56
-}
57
-
58
-
59
-void print_mapTimes(std::multimap<double, int>& mapTimes);
60
-  
61
-void print_initMutant(const std::vector < std::vector<int> >& initMutant);
62
-
63
-void print_Genotype(const Genotype& ge);
64
-
65
-void mapTimes_updateP(std::multimap<double, int>& mapTimes,
66
-		      std::vector<spParamsP>& popParams,
67
-		      const int index,
68
-		      const double time);
69
-
70
-
71
-void getMinNextMutationTime4(int& nextMutant, double& minNextMutationTime,
72
-			     const std::multimap<double, int>& mapTimes);
73
-
74
-
75
-void fill_SStats(Rcpp::NumericMatrix& perSampleStats,
76
-		 const std::vector<double>& sampleTotPopSize,
77
-		 const std::vector<double>& sampleLargestPopSize,
78
-		 const std::vector<double>& sampleLargestPopProp,
79
-		 const std::vector<int>& sampleMaxNDr,
80
-		 const std::vector<int>& sampleNDrLargestPop);
81
-
82
-
83
-
84
-void print_spP(const spParamsP& spP);
85
-
86
-double pM_f_st(const double& t, const spParamsP& spP);
87
-
88
-double ti_nextTime_tmax_2_st(const spParamsP& spP,
89
-			     const double& currentTime,
90
-			     const double& tSample,
91
-			     int& ti_dbl_min,
92
-			     int& ti_e3);
93
-
94
-double Algo2_st(const spParamsP& spP,
95
-		const double& ti,
96
-		const int& mutationPropGrowth);
97
-
98
-double Algo3_st(const spParamsP& spP, const double& t);
99
-
100
-void precissionLoss();
101
-
102
-void init_tmpP(spParamsP& tmpParam);
103
-
104
-double returnMFE_new(double& en1,
105
-		     const TypeModel typeModel);
106
-
107
-
108
-void computeMcFarlandError_new(double& en1,
109
-			       double& en1sc,
110
-			       double& totPopSize_previous,
111
-			       double& DA_previous,
112
-			       const TypeModel typeModel,
113
-			       const double& totPopSize,
114
-			       const double& K);
115
-
116
-void updateRatesMcFarland(std::vector<spParamsP>& popParams,
117
-			  double& adjust_fitness_MF,
118
-			  const double& K,
119
-			  const double& totPopSize);
120
-
121
-void updateRatesMcFarlandLog(std::vector<spParamsP>& popParams,
122
-			     double& adjust_fitness_MF,
123
-			     const double& K,
124
-			     const double& totPopSize);
125
-
126
-void updateRatesFDFMcFarlandLog(std::vector<spParamsP>& popParams,
127
-				const std::vector<Genotype>& Genotypes,
128
-				const fitnessEffectsAll& fitnessEffects,
129
-				double& adjust_fitness_MF,
130
-				const double& K,
131
-				const double& totPopSize,
132
-				const double& currentTime);
133
-
134
-void updateRatesMcFarlandLog_D(std::vector<spParamsP>& popParams,
135
-			       double& adjust_fitness_MF,
136
-			       const double& K,
137
-			       const double& totPopSize);
138
-
139
-void updateRatesFDFMcFarlandLog_D(std::vector<spParamsP>& popParams,
140
-				  const std::vector<Genotype>& Genotypes,
141
-				  const fitnessEffectsAll& fitnessEffects,
142
-				  double& adjust_fitness_MF,
143
-				  const double& K,
144
-				  const double& totPopSize,
145
-				  const double& currentTime);
146
-
147
-
148
-void updateRatesFDFExp(std::vector<spParamsP>& popParams,
149
-		       const std::vector<Genotype>& Genotypes,
150
-		       const fitnessEffectsAll& fitnessEffects,
151
-		       const double& currentTime);
152
-
153
-void updateRatesFDFBozic(std::vector<spParamsP>& popParams,
154
-			 const std::vector<Genotype>& Genotypes,
155
-			 const fitnessEffectsAll& fitnessEffects,
156
-			 const double& currentTime);
157
-
158
-
159
-void updateRatesArbitrary(std::vector<spParamsP>& popParams,
160
-		       const std::vector<Genotype>& Genotypes,
161
-		       const fitnessEffectsAll& fitnessEffects,
162
-		       const double& currentTime);
163
-
164
-
165
-void updateRatesConstant(std::vector<spParamsP>& popParams,
166
-		       const std::vector<Genotype>& Genotypes,
167
-		       const fitnessEffectsAll& fitnessEffects,
168
-               const double& cte,
169
-           	   const double& sampleEvery,
170
-		       const double& currentTime);
171
-
172
-void updateBirthDeathRates(std::vector<spParamsP>& popParams,
173
-			   const std::vector<Genotype>& Genotypes,
174
-			   const fitnessEffectsAll& fitnessEffects,
175
-			   double& adjust_fitness_MF,
176
-			   const double& K,
177
-			   const double& totPopSize,
178
-			   const double& cteSize,
179
-			   const double& sampleEvery,
180
-			   const double& currentTime,
181
-			   const TypeModel typeModel);
182
-
183
-void detect_ti_duplicates(const std::multimap<double, int>& m,
184
-			  const double ti,
185
-			  const int spcies);
186
-
187
-
188
-
189
-void message1(const int verbosity, const std::string message,
190
-	      const int iteration, const double currentTime,
191
-	      const unsigned int numSpecies,
192
-	      const double totalPopulationSize,
193
-	      const double timeNextPopSample,
194
-	      const double minNextMutationTime);
195
-
196
-void messageNewSpecies(const int verbosity,
197
-		       const int iteration, 
198
-		       const unsigned int numSpecies,
199
-		       const int nextMutant);
200
-
201
-void vvmessageNewSpecies(const int verbosity,
202
-			 const unsigned int sp,
203
-			 const Genotype& newGenotype,
204
-			 const Genotype& parentGenotype,
205
-			 const spParamsP& tmpParam,
206
-			 const spParamsP& parentParam);
207
-
208
-void messageSampling(const int verbosity,
209
-		     const double tSample,
210
-		     const double finalTime,
211
-		     std::vector<spParamsP>& popParams);
212
-
213
-void messagePostSampling(const int verbosity,
214
-			 std::vector<spParamsP>& popParams,
215
-			 const double totPopSize);
216
-
217
-double setDummyMutationRate(std::vector<double> mu, const int verbosity);
218
-
219
-
220
-void initPops(
221
-	     unsigned int& numSpecies,
222
-	     double& totPopSize,
223
-	     int& outNS_i,
224
-	     double& lastStoredSample,
225
-	     std::vector<Genotype>& Genotypes,
226
-	     std::vector<spParamsP>& popParams,
227
-	     std::vector<Genotype>& genot_out,
228
-	     std::vector<double>& popSizes_out,
229
-	     std::vector<int>& index_out,
230
-	     std::vector<double>& time_out,
231
-	     std::vector<double>& sampleTotPopSize,
232
-	     std::vector<double>& sampleLargestPopSize,
233
-	     std::vector<int>& sampleMaxNDr,
234
-	     std::vector<int>& sampleNDrLargestPop,
235
-	     POM& pom,
236
-	     std::mt19937& ran_gen,
237
-	     const std::vector<std::vector<int> >& initMutant,
238
-	     const std::vector<double>& initSize,
239
-	     const fitnessEffectsAll& fitnessEffects,
240
-	     const std::vector<double>& mu,
241
-	     const fitnessEffectsAll& muEF,
242
-	     const std::vector<int>& full2mutator,
243
-	     const std::map<int, std::string>& intName,
244
-	     const fitness_as_genes& genesInFitness,	     
245
-	     const double& dummyMutationRate,
246
-	     const double& K,
247
-	     const double& death,
248
-	     const double& currentTime,	     
249
-	     const double& keepEvery,
250
-	     const int& mutationPropGrowth,
251
-	     const TypeModel typeModel,
252
-	     const int& verbosity
253
-	      );
254
-
255
-#endif
Browse code

3.99.1: interventions, death with fdf, user variables

ramon diaz-uriarte (at Phelsuma) authored on 25/06/2022 14:24:13
Showing 1 changed files
... ...
@@ -18,7 +18,7 @@
18 18
 #ifndef _BNB_COMMON_H_
19 19
 #define _BNB_COMMON_H_
20 20
 
21
-#include<Rcpp.h>
21
+#include <Rcpp.h>
22 22
 #include "common_classes.h"
23 23
 #include "debug_common.h"
24 24
 #include "new_restrict.h" // for the TypeModel enum
... ...
@@ -156,12 +156,27 @@ void updateRatesFDFBozic(std::vector<spParamsP>& popParams,
156 156
 			 const double& currentTime);
157 157
 
158 158
 
159
+void updateRatesArbitrary(std::vector<spParamsP>& popParams,
160
+		       const std::vector<Genotype>& Genotypes,
161
+		       const fitnessEffectsAll& fitnessEffects,
162
+		       const double& currentTime);
163
+
164
+
165
+void updateRatesConstant(std::vector<spParamsP>& popParams,
166
+		       const std::vector<Genotype>& Genotypes,
167
+		       const fitnessEffectsAll& fitnessEffects,
168
+               const double& cte,
169
+           	   const double& sampleEvery,
170
+		       const double& currentTime);
171
+
159 172
 void updateBirthDeathRates(std::vector<spParamsP>& popParams,
160 173
 			   const std::vector<Genotype>& Genotypes,
161 174
 			   const fitnessEffectsAll& fitnessEffects,
162 175
 			   double& adjust_fitness_MF,
163 176
 			   const double& K,
164 177
 			   const double& totPopSize,
178
+			   const double& cteSize,
179
+			   const double& sampleEvery,
165 180
 			   const double& currentTime,
166 181
 			   const TypeModel typeModel);
167 182
 
... ...
@@ -232,7 +247,7 @@ void initPops(
232 247
 	     const double& death,
233 248
 	     const double& currentTime,	     
234 249
 	     const double& keepEvery,
235
-	     const int& mutationPropGrowth,	     
250
+	     const int& mutationPropGrowth,
236 251
 	     const TypeModel typeModel,
237 252
 	     const int& verbosity
238 253
 	      );
Browse code

v. 2.99.9: fixed one-gene cases, nem in Readme, typos; removin unused code and v.1 from long tests

ramon diaz-uriarte (at Phelsuma) authored on 22/04/2021 10:27:49
Showing 1 changed files
... ...
@@ -101,9 +101,6 @@ void precissionLoss();
101 101
 
102 102
 void init_tmpP(spParamsP& tmpParam);
103 103
 
104
-double returnMFE_new(double& en1,
105
-		     const std::string& typeFitness);
106
-
107 104
 double returnMFE_new(double& en1,
108 105
 		     const TypeModel typeModel);
109 106
 
... ...
@@ -116,14 +113,6 @@ void computeMcFarlandError_new(double& en1,
116 113
 			       const double& totPopSize,
117 114
 			       const double& K);
118 115
 
119
-void computeMcFarlandError_new(double& en1,
120
-			       double& en1sc,
121
-			       double& totPopSize_previous,
122
-			       double& DA_previous,
123
-			       const std::string& typeFitness,
124
-			       const double& totPopSize,
125
-			       const double& K);
126
-
127 116
 void updateRatesMcFarland(std::vector<spParamsP>& popParams,
128 117
 			  double& adjust_fitness_MF,
129 118
 			  const double& K,
Browse code

2.99.4

ramon diaz-uriarte (at Phelsuma) authored on 17/12/2020 15:07:07
Showing 1 changed files
... ...
@@ -23,27 +23,6 @@
23 23
 #include "debug_common.h"
24 24
 #include "new_restrict.h" // for the TypeModel enum
25 25
 
26
-// // Simple custom exception for exceptions that lead to re-runs.
27
-// class rerunExcept: public std::runtime_error {
28
-// public:
29
-//   rerunExcept(const std::string &s) :
30
-//     std::runtime_error(s) {}
31
-// };
32
-
33
-
34
-// struct spParamsP {
35
-//   double popSize;
36
-//   double birth;
37
-//   double death;
38
-//   double W;
39
-//   double R;
40
-//   double mutation;
41
-//   double timeLastUpdate;
42
-//   std::multimap<double, int>::iterator pv;
43
-//   double absfitness; //convenient for Beerenwinkel
44
-//   int numMutablePos; //for mutator if need update of mutation
45
-// };
46
-
47 26
 
48 27
 inline void W_f_st(spParamsP& spP){
49 28
   spP.W = spP.death + spP.birth + spP.mutation;
... ...
@@ -72,14 +51,21 @@ inline double pE_f_st(double& pM, const spParamsP& spP){
72 51
 }
73 52
 
74 53
 inline double pB_f_st(const double& pE,
75
-			     const spParamsP& spP) {
54
+		      const spParamsP& spP) {
76 55
   return (spP.birth * pE)/spP.death;
77 56
 }
78 57
 
58
+
59
+void print_mapTimes(std::multimap<double, int>& mapTimes);
60
+  
61
+void print_initMutant(const std::vector < std::vector<int> >& initMutant);
62
+
63
+void print_Genotype(const Genotype& ge);
64
+
79 65
 void mapTimes_updateP(std::multimap<double, int>& mapTimes,
80
-			     std::vector<spParamsP>& popParams,
81
-			     const int index,
82
-			     const double time);
66
+		      std::vector<spParamsP>& popParams,
67
+		      const int index,
68
+		      const double time);
83 69
 
84 70
 
85 71
 void getMinNextMutationTime4(int& nextMutant, double& minNextMutationTime,
... ...
@@ -87,15 +73,13 @@ void getMinNextMutationTime4(int& nextMutant, double& minNextMutationTime,
87 73
 
88 74
 
89 75
 void fill_SStats(Rcpp::NumericMatrix& perSampleStats,
90
-			       const std::vector<double>& sampleTotPopSize,
91
-			       const std::vector<double>& sampleLargestPopSize,
92
-			       const std::vector<double>& sampleLargestPopProp,
93
-			       const std::vector<int>& sampleMaxNDr,
76
+		 const std::vector<double>& sampleTotPopSize,
77
+		 const std::vector<double>& sampleLargestPopSize,
78
+		 const std::vector<double>& sampleLargestPopProp,
79
+		 const std::vector<int>& sampleMaxNDr,
94 80
 		 const std::vector<int>& sampleNDrLargestPop);
95 81
 
96
-void print_mapTimes(std::multimap<double, int>& mapTimes);
97
-  
98
-void print_initMutant(const std::vector < std::vector<int> >& initMutant);
82
+
99 83
 
100 84
 void print_spP(const spParamsP& spP);
101 85
 
... ...
@@ -117,31 +101,12 @@ void precissionLoss();
117 101
 
118 102
 void init_tmpP(spParamsP& tmpParam);
119 103
 
120
-// double returnMFE(double& e1,
121
-// 		 const std::string& typeFitness);
122
-
123
-// double returnMFE(double& e1,
124
-// 		 const TypeModel typeModel);
125
-
126 104
 double returnMFE_new(double& en1,
127 105
 		     const std::string& typeFitness);
128 106
 
129 107
 double returnMFE_new(double& en1,
130 108
 		     const TypeModel typeModel);
131 109
 
132
-// void computeMcFarlandError(double& e1,
133
-// 			   double& n_0,
134
-// 			   double& tps_0,
135
-// 			   const std::string& typeFitness,
136
-// 			   const double& totPopSize,
137
-// 			   const double& K);
138
-
139
-// void computeMcFarlandError(double& e1,
140
-// 			   double& n_0,
141
-// 			   double& tps_0,
142
-// 			   const TypeModel typeModel,
143
-// 			   const double& totPopSize,
144
-// 			   const double& K);
145 110
 
146 111
 void computeMcFarlandError_new(double& en1,
147 112
 			       double& en1sc,
... ...
@@ -160,65 +125,127 @@ void computeMcFarlandError_new(double& en1,
160 125
 			       const double& K);
161 126
 
162 127
 void updateRatesMcFarland(std::vector<spParamsP>& popParams,
163
-				 double& adjust_fitness_MF,
164
-				 const double& K,
128
+			  double& adjust_fitness_MF,
129
+			  const double& K,
165 130
 			  const double& totPopSize);
166 131
 
167 132
 void updateRatesMcFarlandLog(std::vector<spParamsP>& popParams,
168
-				    double& adjust_fitness_MF,
169
-				    const double& K,
133
+			     double& adjust_fitness_MF,
134
+			     const double& K,
170 135
 			     const double& totPopSize);
171 136
 
172 137
 void updateRatesFDFMcFarlandLog(std::vector<spParamsP>& popParams,
173
-  const std::vector<Genotype>& Genotypes,
174
-  const fitnessEffectsAll& fitnessEffects,
175
-  double& adjust_fitness_MF,
176
-  const double& K,
177
-  const double& totPopSize,
178
-  const double& currentTime);
138
+				const std::vector<Genotype>& Genotypes,
139
+				const fitnessEffectsAll& fitnessEffects,
140
+				double& adjust_fitness_MF,
141
+				const double& K,
142
+				const double& totPopSize,
143
+				const double& currentTime);
179 144
 
180 145
 void updateRatesMcFarlandLog_D(std::vector<spParamsP>& popParams,
181
-				    double& adjust_fitness_MF,
182
-				    const double& K,
183
-			     const double& totPopSize);
146
+			       double& adjust_fitness_MF,
147
+			       const double& K,
148
+			       const double& totPopSize);
184 149
 
185 150
 void updateRatesFDFMcFarlandLog_D(std::vector<spParamsP>& popParams,
186
-  const std::vector<Genotype>& Genotypes,
187
-  const fitnessEffectsAll& fitnessEffects,
188
-  double& adjust_fitness_MF,
189
-  const double& K,
190
-  const double& totPopSize,
191
-  const double& currentTime);
151
+				  const std::vector<Genotype>& Genotypes,
152
+				  const fitnessEffectsAll& fitnessEffects,
153
+				  double& adjust_fitness_MF,
154
+				  const double& K,
155
+				  const double& totPopSize,
156
+				  const double& currentTime);
192 157
 
193 158
 
194 159
 void updateRatesFDFExp(std::vector<spParamsP>& popParams,
195
-  const std::vector<Genotype>& Genotypes,
196
-  const fitnessEffectsAll& fitnessEffects,
197
-  const double& currentTime);
160
+		       const std::vector<Genotype>& Genotypes,
161
+		       const fitnessEffectsAll& fitnessEffects,
162
+		       const double& currentTime);
198 163
 
199 164
 void updateRatesFDFBozic(std::vector<spParamsP>& popParams,
200
-  const std::vector<Genotype>& Genotypes,
201
-  const fitnessEffectsAll& fitnessEffects,
202
-  const double& currentTime);
165
+			 const std::vector<Genotype>& Genotypes,
166
+			 const fitnessEffectsAll& fitnessEffects,
167
+			 const double& currentTime);
203 168
 
204
-void updateRatesMcFarland0(std::vector<spParamsP>& popParams,
205
-				  double& adjust_fitness_MF,
206
-				  const double& K,
207
-				  const double& totPopSize,
208
-				  const int& mutationPropGrowth,
209
-			   const double& mu);
210
-
211
-void updateRatesBeeren(std::vector<spParamsP>& popParams,
212
-			      double& adjust_fitness_B,
213
-			      const double& initSize,
214
-			      const double& currentTime,
215
-			      const double& alpha,
216
-			      const double& totPopSize,
217
-			      const int& mutationPropGrowth,
218
-		       const double& mu);
169
+
170
+void updateBirthDeathRates(std::vector<spParamsP>& popParams,
171
+			   const std::vector<Genotype>& Genotypes,
172
+			   const fitnessEffectsAll& fitnessEffects,
173
+			   double& adjust_fitness_MF,
174
+			   const double& K,
175
+			   const double& totPopSize,
176
+			   const double& currentTime,
177
+			   const TypeModel typeModel);
219 178
 
220 179
 void detect_ti_duplicates(const std::multimap<double, int>& m,
221 180
 			  const double ti,
222 181
 			  const int spcies);
223 182
 
183
+
184
+
185
+void message1(const int verbosity, const std::string message,
186
+	      const int iteration, const double currentTime,
187
+	      const unsigned int numSpecies,
188
+	      const double totalPopulationSize,
189
+	      const double timeNextPopSample,
190
+	      const double minNextMutationTime);
191
+
192
+void messageNewSpecies(const int verbosity,
193
+		       const int iteration, 
194
+		       const unsigned int numSpecies,
195
+		       const int nextMutant);
196
+
197
+void vvmessageNewSpecies(const int verbosity,
198
+			 const unsigned int sp,
199
+			 const Genotype& newGenotype,
200
+			 const Genotype& parentGenotype,
201
+			 const spParamsP& tmpParam,
202
+			 const spParamsP& parentParam);
203
+
204
+void messageSampling(const int verbosity,
205
+		     const double tSample,
206
+		     const double finalTime,
207
+		     std::vector<spParamsP>& popParams);
208
+
209
+void messagePostSampling(const int verbosity,
210
+			 std::vector<spParamsP>& popParams,
211
+			 const double totPopSize);
212
+
213
+double setDummyMutationRate(std::vector<double> mu, const int verbosity);
214
+
215
+
216
+void initPops(
217
+	     unsigned int& numSpecies,
218
+	     double& totPopSize,
219
+	     int& outNS_i,
220
+	     double& lastStoredSample,
221
+	     std::vector<Genotype>& Genotypes,
222
+	     std::vector<spParamsP>& popParams,
223
+	     std::vector<Genotype>& genot_out,
224
+	     std::vector<double>& popSizes_out,
225
+	     std::vector<int>& index_out,
226
+	     std::vector<double>& time_out,
227
+	     std::vector<double>& sampleTotPopSize,
228
+	     std::vector<double>& sampleLargestPopSize,
229
+	     std::vector<int>& sampleMaxNDr,
230
+	     std::vector<int>& sampleNDrLargestPop,
231
+	     POM& pom,
232
+	     std::mt19937& ran_gen,
233
+	     const std::vector<std::vector<int> >& initMutant,
234
+	     const std::vector<double>& initSize,
235
+	     const fitnessEffectsAll& fitnessEffects,
236
+	     const std::vector<double>& mu,
237
+	     const fitnessEffectsAll& muEF,
238
+	     const std::vector<int>& full2mutator,
239
+	     const std::map<int, std::string>& intName,
240
+	     const fitness_as_genes& genesInFitness,	     
241
+	     const double& dummyMutationRate,
242
+	     const double& K,
243
+	     const double& death,
244
+	     const double& currentTime,	     
245
+	     const double& keepEvery,
246
+	     const int& mutationPropGrowth,	     
247
+	     const TypeModel typeModel,
248
+	     const int& verbosity
249
+	      );
250
+
224 251
 #endif
Browse code

version 2.99.1: frequency-dependent fitness functionality

ramon diaz-uriarte (at Phelsuma) authored on 10/12/2020 11:41:53
Showing 1 changed files
... ...
@@ -1,4 +1,4 @@
1
-//     Copyright 2013, 2014, 2015 Ramon Diaz-Uriarte
1
+//     Copyright 2013-2021 Ramon Diaz-Uriarte
2 2
 
3 3
 //     This program is free software: you can redistribute it and/or modify
4 4
 //     it under the terms of the GNU General Public License as published by
... ...
@@ -21,7 +21,7 @@
21 21
 #include<Rcpp.h>
22 22
 #include "common_classes.h"
23 23
 #include "debug_common.h"
24
-// #include "new_restrict.h" // for the TypeModel enum
24
+#include "new_restrict.h" // for the TypeModel enum
25 25
 
26 26
 // // Simple custom exception for exceptions that lead to re-runs.
27 27
 // class rerunExcept: public std::runtime_error {
... ...
@@ -37,7 +37,7 @@
37 37
 //   double death;
38 38
 //   double W;
39 39
 //   double R;
40
-//   double mutation; 
40
+//   double mutation;
41 41
 //   double timeLastUpdate;
42 42
 //   std::multimap<double, int>::iterator pv;
43 43
 //   double absfitness; //convenient for Beerenwinkel
... ...
@@ -50,8 +50,8 @@ inline void W_f_st(spParamsP& spP){
50 50
 }
51 51
 
52 52
 inline void R_f_st(spParamsP& spP) {
53
-  spP.R = sqrt( pow( spP.birth - spP.death, 2) + 
54
-		( 2.0 * (spP.birth + spP.death) + 
53
+  spP.R = sqrt( pow( spP.birth - spP.death, 2) +
54
+		( 2.0 * (spP.birth + spP.death) +
55 55
 		  spP.mutation) * spP.mutation );
56 56
 }
57 57
 
... ...
@@ -62,7 +62,7 @@ inline double pE_f_st(double& pM, const spParamsP& spP){
62 62
     DP2(spP.death);  DP2(spP.birth); DP2(pM); DP2(spP.W);
63 63
     DP2(spP.mutation);
64 64
     std::string error_message = R"(pE.f: pE not finite.
65
-      This is expected to happen when mutationPropGrowth = TRUE 
65
+      This is expected to happen when mutationPropGrowth = TRUE
66 66
       and you have have an initMutant with death >> birth,
67 67
       as that inevitably leads to net birth rate of 0
68 68
       and mutation rate of 0)";
... ...
@@ -73,7 +73,7 @@ inline double pE_f_st(double& pM, const spParamsP& spP){
73 73
 
74 74
 inline double pB_f_st(const double& pE,
75 75
 			     const spParamsP& spP) {
76
-  return (spP.birth * pE)/spP.death; 
76
+  return (spP.birth * pE)/spP.death;
77 77
 }
78 78
 
79 79
 void mapTimes_updateP(std::multimap<double, int>& mapTimes,
... ...
@@ -93,6 +93,9 @@ void fill_SStats(Rcpp::NumericMatrix& perSampleStats,
93 93
 			       const std::vector<int>& sampleMaxNDr,
94 94
 		 const std::vector<int>& sampleNDrLargestPop);
95 95
 
96
+void print_mapTimes(std::multimap<double, int>& mapTimes);
97
+  
98
+void print_initMutant(const std::vector < std::vector<int> >& initMutant);
96 99
 
97 100
 void print_spP(const spParamsP& spP);
98 101
 
... ...
@@ -166,6 +169,37 @@ void updateRatesMcFarlandLog(std::vector<spParamsP>& popParams,
166 169
 				    const double& K,
167 170
 			     const double& totPopSize);
168 171
 
172
+void updateRatesFDFMcFarlandLog(std::vector<spParamsP>& popParams,
173
+  const std::vector<Genotype>& Genotypes,
174
+  const fitnessEffectsAll& fitnessEffects,
175
+  double& adjust_fitness_MF,
176
+  const double& K,
177
+  const double& totPopSize,
178
+  const double& currentTime);
179
+
180
+void updateRatesMcFarlandLog_D(std::vector<spParamsP>& popParams,
181
+				    double& adjust_fitness_MF,
182
+				    const double& K,
183
+			     const double& totPopSize);
184
+
185
+void updateRatesFDFMcFarlandLog_D(std::vector<spParamsP>& popParams,
186
+  const std::vector<Genotype>& Genotypes,
187
+  const fitnessEffectsAll& fitnessEffects,
188
+  double& adjust_fitness_MF,
189
+  const double& K,
190
+  const double& totPopSize,
191
+  const double& currentTime);
192
+
193
+
194
+void updateRatesFDFExp(std::vector<spParamsP>& popParams,
195
+  const std::vector<Genotype>& Genotypes,
196
+  const fitnessEffectsAll& fitnessEffects,
197
+  const double& currentTime);
198
+
199
+void updateRatesFDFBozic(std::vector<spParamsP>& popParams,
200
+  const std::vector<Genotype>& Genotypes,
201
+  const fitnessEffectsAll& fitnessEffects,
202
+  const double& currentTime);
169 203
 
170 204
 void updateRatesMcFarland0(std::vector<spParamsP>& popParams,
171 205
 				  double& adjust_fitness_MF,
... ...
@@ -188,4 +222,3 @@ void detect_ti_duplicates(const std::multimap<double, int>& m,
188 222
 			  const int spcies);
189 223
 
190 224
 #endif
191
-
Browse code

v. 2.9.2 - LOD: using only the strict Szendro et al. meaning. - POM: computed in C++. - Using fitness landscape directly when given as input (no conversion to epistasis)

ramon diaz-uriarte (at Phelsuma) authored on 24/11/2017 12:41:48
Showing 1 changed files
... ...
@@ -186,5 +186,6 @@ void updateRatesBeeren(std::vector<spParamsP>& popParams,
186 186
 void detect_ti_duplicates(const std::multimap<double, int>& m,
187 187
 			  const double ti,
188 188
 			  const int spcies);
189
+
189 190
 #endif
190 191
 
Browse code

version 2.7.2 Changes in version 2.7.2 (2017-09-27): - genot_to_adj_mat in C++. - fast_peaks (for no backmutation cases). - Better explanation and testing of peaks and valleys. - Clarified simOGraph transitive reduction. - Better handling of ti corner cases. - Magellan reading fuctions adapted to output of newer (as of 2017-07) version of Magellan. - sorting gene names in allGenotypes_to_matrix. - sampledGenotypes: genotype names with sorted gene names.

ramon diaz-uriarte (at Phelsuma) authored on 27/09/2017 10:23:50
Showing 1 changed files
... ...
@@ -183,6 +183,8 @@ void updateRatesBeeren(std::vector<spParamsP>& popParams,
183 183
 			      const int& mutationPropGrowth,
184 184
 		       const double& mu);
185 185
 
186
-
186
+void detect_ti_duplicates(const std::multimap<double, int>& m,
187
+			  const double ti,
188
+			  const int spcies);
187 189
 #endif
188 190
 
Browse code

v.2.5.2 - Lots and lots of addition to vignette including benchmarks. - Diversity of sampled genotypes. - Genotyping error can be added in samplePop. - LOD and POM (lines of descent, path of maximum, sensu Szendro et al.). - simOGraph can also out rT data frames. - Better (and better explained) estimates of simulation error for McFL.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/OncoSimulR@124982 bc3139a8-67e5-0310-9ffc-ced21a209358

Ramon Diaz-Uriarte authored on 10/12/2016 16:05:05
Showing 1 changed files
... ...
@@ -114,33 +114,47 @@ void precissionLoss();
114 114
 
115 115
 void init_tmpP(spParamsP& tmpParam);
116 116
 
117
-double returnMFE(double& e1,
118
-		 // const double& K,
119
-		 const std::string& typeFitness);
120
-
121
-double returnMFE(double& e1,
122
-		 // const double& K,
123
-		 const TypeModel typeModel);
124
-
125
-void computeMcFarlandError(double& e1,
126
-			   double& n_0,
127
-			   double& n_1,
128
-			   double& tps_0,
129
-			   double& tps_1,
130
-			   const std::string& typeFitness,
131
-			   const double& totPopSize,
132
-			   const double& K);
133
-
134
-void computeMcFarlandError(double& e1,
135
-			   double& n_0,
136
-			   double& n_1,
137
-			   double& tps_0,
138
-			   double& tps_1,
139
-			   const TypeModel typeModel,
140
-			   const double& totPopSize,
141
-			   const double& K);
142
-
143
-
117
+// double returnMFE(double& e1,
118
+// 		 const std::string& typeFitness);
119
+
120
+// double returnMFE(double& e1,
121
+// 		 const TypeModel typeModel);
122
+
123
+double returnMFE_new(double& en1,
124
+		     const std::string& typeFitness);
125
+
126
+double returnMFE_new(double& en1,
127
+		     const TypeModel typeModel);
128
+
129
+// void computeMcFarlandError(double& e1,
130
+// 			   double& n_0,
131
+// 			   double& tps_0,
132
+// 			   const std::string& typeFitness,
133
+// 			   const double& totPopSize,
134
+// 			   const double& K);
135
+
136
+// void computeMcFarlandError(double& e1,
137
+// 			   double& n_0,
138
+// 			   double& tps_0,
139
+// 			   const TypeModel typeModel,
140
+// 			   const double& totPopSize,
141
+// 			   const double& K);
142
+
143
+void computeMcFarlandError_new(double& en1,
144
+			       double& en1sc,
145
+			       double& totPopSize_previous,
146
+			       double& DA_previous,
147
+			       const TypeModel typeModel,
148
+			       const double& totPopSize,
149
+			       const double& K);
150
+
151
+void computeMcFarlandError_new(double& en1,
152
+			       double& en1sc,
153
+			       double& totPopSize_previous,
154
+			       double& DA_previous,
155
+			       const std::string& typeFitness,
156
+			       const double& totPopSize,
157
+			       const double& K);
144 158
 
145 159
 void updateRatesMcFarland(std::vector<spParamsP>& popParams,
146 160
 				 double& adjust_fitness_MF,
Browse code

v. 2.3.3.\n mutator, fitness landscapes, rfitness, and many other changes

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/OncoSimulR@118909 bc3139a8-67e5-0310-9ffc-ced21a209358

Ramon Diaz-Uriarte authored on 23/06/2016 16:43:51
Showing 1 changed files
... ...
@@ -19,29 +19,30 @@
19 19
 #define _BNB_COMMON_H_
20 20
 
21 21
 #include<Rcpp.h>
22
-#include"debug_common.h"
23
-#include "new_restrict.h" // for the TypeModel enum
24
-
25
-// Simple custom exception for exceptions that lead to re-runs.
26
-class rerunExcept: public std::runtime_error {
27
-public:
28
-  rerunExcept(const std::string &s) :
29
-    std::runtime_error(s) {}
30
-};
31
-
32
-
33
-struct spParamsP {
34
-  double popSize;
35
-  double birth;
36
-  double death;
37
-  double W;
38
-  double R;
39
-  double mutation; 
40
-  double timeLastUpdate;
41
-  std::multimap<double, int>::iterator pv;
42
-  double absfitness; //convenient for Beerenwinkel
43
-  int numMutablePos; //for mutator if need update of mutation
44
-};
22
+#include "common_classes.h"
23
+#include "debug_common.h"
24
+// #include "new_restrict.h" // for the TypeModel enum
25
+
26
+// // Simple custom exception for exceptions that lead to re-runs.
27
+// class rerunExcept: public std::runtime_error {
28
+// public:
29
+//   rerunExcept(const std::string &s) :
30
+//     std::runtime_error(s) {}
31
+// };
32
+
33
+
34
+// struct spParamsP {
35
+//   double popSize;
36
+//   double birth;
37
+//   double death;
38
+//   double W;
39
+//   double R;
40
+//   double mutation; 
41
+//   double timeLastUpdate;
42
+//   std::multimap<double, int>::iterator pv;
43
+//   double absfitness; //convenient for Beerenwinkel
44
+//   int numMutablePos; //for mutator if need update of mutation
45
+// };
45 46
 
46 47
 
47 48
 inline void W_f_st(spParamsP& spP){
... ...
@@ -58,7 +59,14 @@ inline void R_f_st(spParamsP& spP) {
58 59
 inline double pE_f_st(double& pM, const spParamsP& spP){
59 60
   double pE = (spP.death * (1.0 - pM ) )/(spP.W - spP.death - spP.birth * pM );
60 61
   if( !std::isfinite(pE) ) {
61
-    throw std::range_error("pE.f: pE not finite");
62
+    DP2(spP.death);  DP2(spP.birth); DP2(pM); DP2(spP.W);
63
+    DP2(spP.mutation);
64
+    std::string error_message = R"(pE.f: pE not finite.
65
+      This is expected to happen when mutationPropGrowth = TRUE 
66
+      and you have have an initMutant with death >> birth,
67
+      as that inevitably leads to net birth rate of 0
68
+      and mutation rate of 0)";
69
+    throw std::range_error(error_message);
62 70
   }
63 71
   return pE;
64 72
 }
... ...
@@ -97,7 +105,8 @@ double ti_nextTime_tmax_2_st(const spParamsP& spP,
97 105
 			     int& ti_e3);
98 106
 
99 107
 double Algo2_st(const spParamsP& spP,
100
-		const double& ti);
108
+		const double& ti,
109
+		const int& mutationPropGrowth);
101 110
 
102 111
 double Algo3_st(const spParamsP& spP, const double& t);
103 112
 
... ...
@@ -106,11 +115,11 @@ void precissionLoss();
106 115
 void init_tmpP(spParamsP& tmpParam);
107 116
 
108 117
 double returnMFE(double& e1,
109
-		 const double& K,
118
+		 // const double& K,
110 119
 		 const std::string& typeFitness);
111 120
 
112 121
 double returnMFE(double& e1,
113
-		 const double& K,
122
+		 // const double& K,
114 123
 		 const TypeModel typeModel);
115 124
 
116 125
 void computeMcFarlandError(double& e1,
Browse code

v-2.1.1: stacked and area plots, genotype plots, and mut.prop.growth

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/OncoSimulR@114315 bc3139a8-67e5-0310-9ffc-ced21a209358

Ramon Diaz-Uriarte authored on 07/03/2016 13:48:31
Showing 1 changed files
... ...
@@ -148,7 +148,7 @@ void updateRatesMcFarland0(std::vector<spParamsP>& popParams,
148 148
 				  double& adjust_fitness_MF,
149 149
 				  const double& K,
150