# NOT RUN {
# THE CODE IN THIS EXAMPLE IS THE SAME AS THAT USED IN THE TUTORIAL, AND
# THUS YOU NEED TO DOWNLOAD THE TUTORIAL DATA SET AND SET FILEPATH
# CORRECTLY TO RUN THIS
##--Firstly, declare the parameters required for the 4 functions--
# Folder containing the simulation results or single CSV result file
FILEPATH<-"/home/kieran/Downloads/LHC_Spartan2/"
# Array of the parameters to be analysed
PARAMETERS<-c("thresholdBindProbability","chemoThreshold",
"chemoUpperLinearAdjust","chemoLowerLinearAdjust",
"maxVCAMeffectProbabilityCutoff","vcamSlope")
# The simulation output measures being examined
MEASURES<-c("Velocity","Displacement")
# What each measure represents. Used in graphing results
MEASURE_SCALE<-c("microns/min","microns")
# The number of parameter value sets created in latin-hypercube
# sampling
NUMSAMPLES <- 500
# Number of runs performed for each parameter value set
NUMRUNSPERSAMPLE<-500
# The output file containing the simulation results from that
# simulation run
RESULTFILENAME<-"trackedCells_Close.csv"
# Not used in this case, but this is useful in cases where
# two result files may exist (for example if tracking cells close to
# an area, and those further away two output files could be used).
# Here, results in a second file are processed if the first is blank
# or does not exist. Note no file extension if used.
ALTERNATIVEFILENAME<-NULL
# Use this if simulation results are in CSV format.
# The column within the csv results file where the results start.
# This is useful as it restricts what is read in to R, getting round
# potential errors where the first column contains an agent label
# (as R does not read in CSV files where the first column contains
# duplicates)
OUTPUTCOLSTART<-10
# Use this if simulation results are in CSV format.
# Last column of the output measure results
OUTPUTCOLEND<-11
# For each parameter value set being analysed, a file is created
# containing the median of each output measure, of each simulation run
# for that value. This sets the name of this file.
LHC_ALL_SIM_RESULTS_FILE<-"LHC_AllResults.csv"
# Location of a file containing the parameter value sets generated
# by the hypercube sampling (i.e. the file generated in the previous
# method of this tutorial.) However if providing a CSV file with all
# results, you do not need to provide this
LHC_PARAM_CSV_LOCATION<-"Tutorial_Parameters_for_Runs.csv"
# File name to give to the summary file that is produced showing the
# parameter value sets alongside the median results for each simulation
# output measure.
LHCSUMMARYFILENAME<-"LHC_Summary.csv"
# File name to give to the file showing the Partial Rank Correlation
# Coefficients for each parameter.
CORCOEFFSOUTPUTFILE<-"EgSet_corCoeffs.csv"
# Option to print the Partial Rank Correlation Coefficients
PRINTOPT<-"ALL"
# Timepoints being analysed. Must be NULL if no timepoints being analysed,
# or else be an array of timepoints. Scale sets the measure of these
# timepoints
TIMEPOINTS<-NULL; TIMEPOINTSCALE<-NULL
# Example Timepoints:
#TIMEPOINTS<-c(12,36,48,60); TIMEPOINTSCALE<-"Hours"
# Whether to display the p-values on the graph of PRCCS over time
# This can look unsightly if you have more than 3 output measures
# You would then be better producing these in a table. The p-values are placed in a CSV file
# produced by spartan
DISPLAYPVALS<-TRUE
# }
# NOT RUN {
# DONTRUN IS SET SO THIS IS NOT EXECUTED WHEN PACKAGE IS COMPILED - BUT THIS
# HAS BEEN TESTED WITH THE TUTORIAL DATA
##--- NOW RUN THE FOUR METHODS IN THIS ORDER ----
# A - FOR STOCHASTIC SIMS IN SET FOLDER STRUCTURE, GENERATE
# THE MEDIANS FOR EACH SET OF PARAMETER VALUES
# GENERATED BY THE HYPERCUBE
lhc_process_sample_run_subsets(FILEPATH,
LHC_PARAM_CSV_LOCATION,PARAMETERSNUMSAMPLES,
NUMRUNSPERSAMPLE,MEASURES,RESULTFILENAME,
ALTERNATIVEFILENAME,OUTPUTCOLSTART,OUTPUTCOLEND,
LHC_ALL_SIM_RESULTS_FILE,TIMEPOINTS=NULL,
TIMEPOINTSCALE=NULL)
# B - GENERATE THE SUMMARY FILE SHOWING THE PARAMETERS USED AND
# MEDIAN RESULTS FOR THE MEASURES OVER THE n RUNS
lhc_generateLHCSummary(FILEPATH,PARAMETERS,MEASURES,
LHC_ALL_SIM_RESULTS_FILE,LHCSUMMARYFILENAME,
LHC_PARAM_CSV_LOCATION=NULL,TIMEPOINTS=NULL,
TIMEPOINTSCALE=NULL)
# C- CALCULATE THE PARTIAL RANK CORRELATION COEFFICIENTS
lhc_generatePRCoEffs(FILEPATH,PARAMETERS,MEASURES,
LHCSUMMARYFILENAME,CORCOEFFSOUTPUTFILE,
TIMEPOINTS=NULL,TIMEPOINTSCALE=NULL)
# D - GRAPH THE CORRELATION COEFFICIENTS
lhc_plotCoEfficients<-function(FILEPATH, CORCOEFFSOUTPUTFILE,
MEASURES, PRINTOPT, TIMEPOINTS=NULL,
TIMEPOINTSCALE=NULL)
# E - GRAPH THE RESULTS FOR EACH PARAMETER MEASURE PAIRING
lhc_graphMeasuresForParameterChange(FILEPATH,PARAMETERS,
MEASURES,MEASURE_SCALE,CORCOEFFSOUTPUTFILE,
LHCSUMMARYFILENAME,TIMEPOINTS=NULL,
TIMEPOINTSCALE=NULL)
# F - IF USING RESULTS FILES FROM MULTIPLE TIMEPOINTS, YOU
# CAN PLOT THE PRCC FOR EACH TIMEPOINT, FOR ALL MEASURES,
# ON ONE PARAMETER GRAPH
plotPRCCSFromTimepointFiles(FILEPATH,PARAMETERS,MEASURES,
CORCOEFFSFILENAME,TIMEPOINTS,TIMEPOINTSCALE,
DISPLAYPVALS)
# G - Now to move the Median results for each parameter set
# into files containing results of all parameter sets.
# One file per timepoint. If we do this we make the output
# compatible with methods in the spartan toolkit
lhc_timepoint_files(FILEPATH,SPARTAN_PARAMETER_FILE,
RUN_SUMMARY_FILE_NAME,NUMSAMPLES,NUMRUNS,TIMEPOINTS)
# H - Now summarise all the PRCCS for all timepoints &
# parameters in one file - this will make graphing much easier
prccsEachTimepoint(FILEPATH, CORCOEFFSOUTPUTFILE,
TIMEPOINTS,MEASURES)
# I - Now graph each PRCC over time in comparison with the
# dummy parameter (something new to spartan does not do),
# to judge the impact of that parameter. These graphs are
# output as PDF's in the stated filepath
graphPRCC_Over_Time(FILEPATH,MEASURES,TIMEPOINTS)
# J - Count and graph the number of significant parameters
# for each measure
countSignificantParameters(FILEPATH,MEASURES,TIMEPOINTS)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab