Skip to content

5 · Check and run

Run the following commands in the terminal, from the project folder:

cd ~/Documents/my-cohort          # Windows: cd $HOME\Documents\my-cohort

Check the files

layerbn check --figure

This command reads settings.yml, variables.xlsx and the data without fitting a model. It reports any inconsistencies and describes how to correct them. If the files are valid, the output looks like this:

Project      Example cohort study
Variables    16 in 5 layers

Layers, in causal order (an arc may only run to the same layer or to a layer further down):
  1. Background
       Age (years); Sex; Education
  2. Lifestyle
       Smoking; Alcohol
  ...
Settings and design table are valid.

Data file my_cohort.csv: 812 participants, all 16 variables found.

If there is a problem, the message states where it is:

Error: variables.xlsx, sheet 'variables': variable 'SBP' is in layer 'Clinicals', which is
not on the 'layers' sheet. Did you mean 'Clinical'?

Correct the file, save it and run layerbn check --figure again. Repeat this until the output states that the files are valid. Each message is described on the Error messages page.

With --figure, the command also draws the layers to results/figures/design.png:

The design figure

Design figure. Arcs point downward, from a layer to the same layer or a later layer. If a variable is in the wrong layer, change its layer or the order of the layers, and run the check again.

Run the analysis

layerbn run --fast

Uses 20 resamples. Use this to check that the analysis works and to review the output. The report is labelled as a trial run. Do not report its results.

layerbn run

Uses the number of resamples set in settings.yml. The terminal shows the progress and an estimate of the remaining time. With 200 resamples and 20 variables, a run takes from several minutes to half an hour.

When the run is finished, open the report:

open results/report.html
start results\report.html

Output folder

results/
├── report.html        all results in one page; open this file first
├── figures/           each figure as PNG and as PDF with editable text
├── tables/            each table as CSV, and all tables in tables.xlsx
├── networks/          each network as .bifxml, and the interactive explorer (.html)
└── inputs/            copies of settings.yml and variables.xlsx, and a record of the data file

A new run overwrites results/

To keep earlier results, copy or rename the folder before the next run, or specify another output folder: layerbn run --output results_2026-12-01.

Reducing the run time

Most of the run time is spent on the bootstrap, and it increases with the number of resamples. Use --fast while you set up the analysis. learning: search: greedy is faster but searches less thoroughly. Fewer variables, groups and parents also reduce the run time.

Using another data file without editing settings.yml

Use layerbn run --data path/to/other_file.csv. This also keeps the location of the data out of a file that you may share.

Next: report