MATLAB · chapter 9 of 13

Exporting data and reproducing it

grn.export

files = grn.export(data, filename) writes a solution or a screen. The format follows the extension.

.mat

The whole struct is saved as the variable data. It contains the model with every parameter, so load gives you back everything needed to regenerate or extend the dataset.

.csv

Three files are written and their names returned:

FileContents
<name>.csvThe data as a table
<name>_truth.csvEdge list with columns source, target, sign (labels, and +1/-1)
<name>_adjacency.csvThe signed n x n matrix S, one header row of gene labels

The data table layout:

DataColumns
Time series, one cellt, then one column per state (sol.stateLabels)
Time series, several cellscell, t, then the states; rows are ordered time within cell
Screenperturbation (wildtype or the perturbed gene), then the states

For two-stage models the state columns are <gene>_mRNA and <gene>_protein.

files = grn.export(sol, "run1.csv");
tbl = readtable(files(1));
edges = readtable(files(2), TextType = "string");
S = readmatrix(files(3));

For a three-gene, two-cell time series:

Output
    "/private/var/folders/4p/lyl8zns92f533lvhlldbpm0w0000gq/T/abc.csv"
    "/private/var/folders/4p/lyl8zns92f533lvhlldbpm0w0000gq/T/abc_truth.csv"
    "/private/var/folders/4p/lyl8zns92f533lvhlldbpm0w0000gq/T/abc_adjacency.csv"

    <strong>cell</strong>     <strong>t</strong>       <strong>A</strong>         <strong>B</strong>          <strong>C</strong>   
    <strong>____</strong>    <strong>___</strong>    <strong>______</strong>    <strong>______</strong>    <strong>_______</strong>

     1        0    2.8837    2.2741    0.28156
     1      0.1    3.0322    2.2653    0.31994
     1      0.2    3.1516    2.2722    0.35601
     1      0.3    3.2436    2.2885    0.38958

    <strong>source</strong>    <strong>target</strong>    <strong>sign</strong>
    <strong>______</strong>    <strong>______</strong>    <strong>____</strong>

     "C"       "A"       -1 
     "A"       "B"        1 
     "B"       "C"       -1 

    <strong>A</strong>    <strong>B</strong>     <strong>C</strong> 
    <strong>_</strong>    <strong>__</strong>    <strong>__</strong>

    0     0    -1
    1     0     0
    0    -1     0

A complete recipe

Because every option is recorded, the following regenerates a dataset exactly:

data = load("run1.mat").data;
o = data.options;
sol = grn.simulate(data.model, Duration = o.Duration, SampleDt = o.SampleDt, ...
    Transient = o.Transient, Cells = o.Cells, RandomIC = o.RandomIC, ...
    InitialCondition = data.ic, Noise = o.Noise, NoiseStrength = o.NoiseStrength, ...
    Dt = o.Dt, NoiseSigma = o.NoiseSigma, Seed = o.Seed, Stimulus = data.stimulus);
isequal(sol.x, data.x)      % true

Passing InitialCondition = data.ic (the dim x cells initial conditions actually used) reproduces random initial conditions without redrawing them; leaving it out and keeping RandomIC and Seed gives the same result too.

What to ship with a benchmark