Simbiology createSimFunction data access

I am using createSimFunction to run many scenarios. The results come out in an array of simData. How can I efficiently access one of the output observables (e.g. species of interest) from each of the simData results to plot the ranges or confidence intervals from these many scenarios?

 Accepted Answer

Jeremy Huard
Jeremy Huard on 21 Apr 2021
Edited: Jeremy Huard on 21 Apr 2021
Hi Mohammad,
the method selectbyname allows you to extract the data of a specific state.
Alternatively, you can use the attached function to generate a percentile plot for one of more states of your simData array:
sbioplotscan(simdataObj,"Name",["Receptor","Complex"],"Alpha",0.05)
or starting R2021a
sbioplotscan(simdataObj,Name=["Receptor","Complex"],Alpha=0.05)
For Alpha=0.05, the plot will display the median as well as a an area between the 2.5 and 97.5 percentiles.
Disclaimer: This function is a helper function I wrote for my personal use. It has not been thoroughly tested and is provided as is.
I hope this helps.
Best,
Jérémy

8 Comments

Thanks Jeremy, I have been using selectbyname but I have to transform it in a few lines and then do statistics on like below:
filter = simDataFunc.selectbyname('comp.D_nM')
[t, x, N] = filter.getdata()
cell2mat(x')
I can then look at median and percentiles.
Thank you for sending the plotting code. It is just plotting the median for me when I feed it the array of simdata that comes out of SimFunction and I am on R2021a. Any hypothesis what might be casuing this?
Hi Mohammad,
selectbyname can also return the data directly. So, you could replace the first two commands with:
[t, x, N] = selectbyname(simDataFunc, 'comp.D_nM');
Regarding the plotting code, do you get any error message when you run the function?
Have you tried to create this type of plot manually from the t and x arrays you get from selectbyname to compare?
Makes sense. Thank you.
Plot is just giving me a warning. If you could have a look that would be great. Here is the a sample data attached.
It looks like your data starts at time=1. My function was assuming that the simData has data for time=0.
I have uploaded an updated version of my function in my first post. Please use this version instead.
Did you expect your data to start at time =1? Did you resample the simulation results?
Awesome Jeremy. Thanks! Works great. I was playing with the simFunciton inputs to force all the runs to have the same output times and samples starting at 1 was an accidental choice there. Thanks for sharing the plot function.
It seems like it doesn't work when I have a species in multiple compartment and I specify the name with compartment name: (eg V_B.D_nM). Am I using it incorrectly or is this not built into this funiiton?
Is this coming as a standard function to simbiology/Matlab?
Is there a reason you are forcing alpha to be less than 0.1? Might be good to allow full flexibility of plotting percentiles for close to the whole range.
Hi Mohammad,
you should be able to use any species contained in your simData array. You can have a look at that list with:
simData(1).DataNames
You're right for alpha. Please feel free to adapt the code as you see fit. You can modify line 32 to be :
options.Alpha (1,:) double {mustBeInRange(options.Alpha,0,1)} = 0.05
Thanks Jeremy.
The problem with simData.DataNames is the following: you can have species with the same name in different compartments that will show up as duplicates in the DataNames. Assume you have comp1 and comp2. you can define the drug (D) in compa1 (comp1.D) and in comp2 (comp2.D). Now in the DataNames it shows up as 'D' and 'D'. not able to distinguish unless tracking down the parents. selectbyname works well as it can take 'comp1.D' as the input and distinguish which D we are looking for. I think sbioscanplot.m could also benefit from such a feature. I am getting around that by doing a selectbyname before feeding the data to the sbioscanplot os as not to have duplicates.
Also it would be nice to be able to specifiy DataName for the median line to facilitate legends later.
Thanks again for sharing the function. I have made some modifications to it for my personal use.
Cheers
Mohammad
Hi Mohammad,
I see what you mean now. You are right, DataNames are not necessarily unique. However, the DataInfo property contains information about the compartment that contains about the species. In my original code, I was only looking in DataNames. I have now updated the function and uploaded the updated version in my original answer.
Best,
Jérémy

Sign in to comment.

More Answers (1)

Mohammad,
The SimBiology Model Analyzer app introduced the percentile plot type in R2021b. You can use this plot type to visualize how summary statistics (percentiles, mean, standard deviation, min/max) for a set of timecourses (simulations from a scan or experimental data from imported datasets) change over time.
This new plot type is documented here:
Best,
Priya

Communities

More Answers in the  SimBiology Community

Categories

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!