JSON config

The JSON configuration file, together with Snakemake’s command line tool, serve as the interface for the user. Below we describe the main structure of a config file, where we for reference show (in Listing 4 with additional comments) the content of config/paper_pc_vs_dualpc.json , which is a comparison study between the PC algorithm [1] (pcalg_pc) and the Dual PC algorithm [2] (dualpc). The results of this study can be found in PC vs. dual PC.

At the highest level there are two main sections, benchmark_setup (Line 2) and resources (Line 37). The modules used in benchmark_setup are specified in resources and referenced by their corresponding IDs.

resources

The resources section contains the subsections graph (Line 47), parameters (Line 61), data (Line 37), and structure_learning_algorithms (Line 70), which contain the modules used in the study. Each module in turn has a list of JSON objects, where each of the objects defines a specific parameter setting. The objects are identified by unique IDs (see Lines 41, 50, 64, 73, and 87). The parametrisations for the modules can typically be either single values (see e.g. Line 73) or lists (see e.g. Line 79). In the case of lists, the module runs for each of the values in the list.

benchmark_setup

The benchmark_setup section specifies the data models (data, Line 3) and evaluation methods (evaluation, Line 11) a user wishes to consider for analysis.

  • The data section should contain a list, where each item defines a certain data setup. For each seed number \(i\) in the range specified by seed_range (Line 8), a triple (\(G_i, \Theta_i, \mathbf Y_i\)) is generated, where \(G_i\) is obtained as specified by graph_id (Line 5). Conditional on \(G_i\), the model parameters \(\Theta_i\) are obtained according to parameters_id (Line 6). The data matrix \(\mathbf Y_i = (Y^j)_{j=1}^n\) is sampled conditional on \((G_i,\Theta_i)\) as specified by data_id (Line 7).

  • The evaluation section contains the evaluation methods used for the analysis. Descriptions of the available evaluation methods can be found in Evaluation.

Listing 4 Comparison between PC vs. dual PC.
  1{
  2    "benchmark_setup": {
  3        "data": [ // the data setups
  4            {
  5                "graph_id": "avneigs4_p80", // see line 50
  6                "parameters_id": "SEM", // see line 64
  7                "data_id": "standardized", // see line 41
  8                "seed_range": [1, 10]
  9            }
 10        ],
 11        "evaluation": { // the evaluation modules
 12            "benchmarks": {
 13                "filename_prefix": "paper_pc_vs_dualpc/",
 14                "show_seed": true,
 15                "errorbar": true,
 16                "errorbarh": false,
 17                "scatter": true,
 18                "path": true,
 19                "text": false,
 20                "ids": [
 21                    "pc-gaussCItest", // see line 87
 22                    "dualpc" // see line 73
 23                ]
 24            },
 25            "graph_true_plots": true,
 26            "graph_true_stats": true,
 27            "ggally_ggpairs": false,
 28            "graph_plots": [
 29                "pc-gaussCItest",
 30                "dualpc"
 31            ],
 32            "mcmc_traj_plots": [],
 33            "mcmc_heatmaps": [],
 34            "mcmc_autocorr_plots": []
 35        }
 36    },
 37    "resources": {
 38        "data": { // the data modules
 39            "iid": [
 40                {
 41                    "id": "standardized",
 42                    "standardized": true,
 43                    "n": 300
 44                }
 45            ]
 46        },
 47        "graph": { // the graph modules
 48            "pcalg_randdag": [
 49                {
 50                    "id": "avneigs4_p80",
 51                    "max_parents": 5,
 52                    "n": 80,
 53                    "d": 4,
 54                    "par1": null,
 55                    "par2": null,
 56                    "method": "er",
 57                    "DAG": true
 58                }
 59            ]
 60        },
 61        "parameters": { // the parameters modules
 62            "sem_params": [
 63                {
 64                    "id": "SEM",
 65                    "min": 0.25,
 66                    "max": 1
 67                }
 68            ]
 69        },
 70        "structure_learning_algorithms": { // the structure learning modules
 71            "dualpc": [
 72                {
 73                    "id": "dualpc",
 74                    "alpha": [
 75                        0.001,
 76                        0.05,
 77                        0.1
 78                    ],
 79                    "skeleton": false,
 80                    "pattern_graph": false,
 81                    "max_ord": null,
 82                    "timeout": null
 83                }
 84            ],
 85            "pcalg_pc": [
 86                {
 87                    "id": "pc-gaussCItest",
 88                    "alpha": [
 89                        0.001,
 90                        0.05,
 91                        0.1
 92                    ],
 93                    "NAdelete": true,
 94                    "mmax": "Inf",
 95                    "u2pd": "relaxed",
 96                    "skelmethod": "stable",
 97                    "conservative": false,
 98                    "majrule": false,
 99                    "solveconfl": false,
100                    "numCores": 1,
101                    "verbose": false,
102                    "indepTest": "gaussCItest",
103                    "timeout": null
104                }
105            ]
106        }
107    }
108}

Example data scenarios

Apart from the modules used in Listing 4, Benchpress also provides the special modules fixed_graph, fixed_params, and fixed_data, which allow the user to provide files in their analysis. These modules are not part of the resources section of the JSON file and are referenced by IDs, instead, files are simply referenced by their names. The file formats are described in File formats.

The different sources of data, obtained by combining the fixed files and the ordinary modules, can be summarised in five scenarios shown in the table below. Scenario I is the typical scenario for data analysts, where the user provides one or more datasets by hand. Scenario II is similar to Scenario I, with the difference that the user also provides the true graph underlying the data. This situation arises e.g. when replicating a simulation study from the literature, where both the true graph and the dataset are given. Scenarios III-V are pure benchmarking scenarios, where either all of the graphs, parameters and data are generated (V) or the graphs and possibly parameters are specified by the user (III, IV).

Graph

Parameters

Data

I

Fixed

II

Fixed

Fixed

III

Fixed

Fixed

Generated

IV

Fixed

Generated

Generated

V

Generated

Generated

Generated

The following subsections show some template data examples in the benchmark_setup section that correspond to the scenarios I-IV.

I) Data analysis (fixed data)

In the example below, my_data_file.csv should be a file in resources/data/mydatasets.

{
    "graph_id": null,
    "parameters_id": null,
    "data_id": "my_data_file.csv",
    "seed_range": null
}

In the example below, my_data_folder should be a subfolder of resources/data/mydatasets containing data files.

{
    "graph_id": null,
    "parameters_id": null,
    "data_id": "my_data_folder",
    "seed_range": null
}

II) Data analysis with validation

{
    "graph_id": "my_graph_file.csv",
    "parameters_id": null,
    "data_id": "my_data_file.csv",
    "seed_range": null
}

III) Fixed graph

{
    "graph_id": "my_graph_file.csv",
    "parameters_id": "my_params_id",
    "data_id": "my_data_id",
    "seed_range": [
        1,
        3
    ]
}

IV) Fixed graph and parameters

{
    "graph_id": "my_graph_file.csv",
    "parameters_id": "my_params_file.rds",
    "data_id": "my_data_id",
    "seed_range": [1, 10]
}

V) Fully generated

{
    "graph_id": "my_graph_id",
    "parameters_id": "my_params_id",
    "data_id": "my_data_id",
    "seed_range": [1, 10]
}

References