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:
| File | Contents |
|---|---|
<name>.csv | The data as a table |
<name>_truth.csv | Edge list with columns source, target, sign (labels, and +1/-1) |
<name>_adjacency.csv | The signed n x n matrix S, one header row of gene labels |
The data table layout:
| Data | Columns |
|---|---|
| Time series, one cell | t, then one column per state (sol.stateLabels) |
| Time series, several cells | cell, t, then the states; rows are ordered time within cell |
| Screen | perturbation (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:
"/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 0A 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
- The
_truth.csvand_adjacency.csvfiles, or the.matfile. - The
Seedvalues and toolbox version (ver("GRNLab")after installation, or theToolboxVersioninbuildfile.m). - For time series with several cells, the
cellcolumn tells consumers which rows belong together. - For screens,
screen.converged; non-converged rows are time averages and should be flagged or dropped.