Skip to content

Commit d827c17

Browse files
committed
Added option for noise to exptSynth
1 parent 185e4dc commit d827c17

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

exptSynth.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,12 @@ def generateDoseExperiment( fname, stimVec, refMol, refVals, settleTime, baselin
421421
jsonDict["Modifications"]["parameterChange"].extend( baselineList )
422422
with open( fname, "w" ) as fd:
423423
json.dump( jsonDict, fd, indent = 4 )
424-
424+
425+
426+
def addNoise( readouts, noise ):
427+
logNoise = np.log( noise )
428+
for key, val in readouts.items():
429+
readouts[key] = np.exp( np.log( val ) + np.random.normal(0.0, logNoise) )
425430

426431
def main():
427432
global plotDt
@@ -433,6 +438,7 @@ def main():
433438
parser.add_argument( "-b", "--buffer", nargs = '+', metavar = "molName conc", help = "Optional: mol conc [mol conc]... List of buffered molecules with their concentration.")
434439
parser.add_argument( "-r", "--readouts", type = str, nargs = '+', metavar = "molName", help = "Optional: Readout molecules to monitor, as a list of space-separated names.", default = [] )
435440
parser.add_argument( "-m", "--model", type = str, help = "Optional: Filepath for chemical kinetic model in HillTau or SBML format. If model is not provided the synthetic file just has zeros for predicted output." )
441+
parser.add_argument( "-n", "--noise", type = float, help = "Optional: Noise (as lognorm ratio) for each output point. Default = none." )
436442
parser.add_argument( "-t", "--tau", type = float, help = "Optional: tau for reaction settling, overrides estimate from model if available. Default = 300 seconds." )
437443
parser.add_argument( '-f', '--findSimFile', type = str, help='Optional: Base name of FindSim output file, which will be of form <file>_TS_<output>_vs__<input>.json for TimeSeries outputs, and <file>_DR_<output>_vs_<input>.json for the dose-responses. Default = "synth"', default = "synth", metavar = "experiment_file_name" )
438444
parser.add_argument( '-d', '--dir', type = str, help='Optional: Directory in which to put the output files. If it does not exist it is created. Default is current directory', metavar = "output_directory" )
@@ -531,6 +537,10 @@ def main():
531537
referenceOutputs = runHillTau( htmodel, stimVec, rlist, bufList)
532538
htmodel.dt = settleTime
533539
doserOutputs = runHillTau( htmodel, doseVec, rlist, bufList )
540+
if args.noise:
541+
assert( args.noise >= 1.0 )
542+
addNoise( referenceOutputs, args.noise )
543+
addNoise( doserOutputs, args.noise )
534544
else:
535545
referenceOutputs = { rr:np.zeros(1+int(tau*3/plotDt)) for rr in rlist }
536546
doserOutputs = { rr:np.zeros(len(stimRange)) for rr in rlist }

0 commit comments

Comments
 (0)