Пример #1
0
def run(args):
    subnetworks_file = '%s/viz_files/%s' % (str(hotnet2.__file__).rsplit('/', 1)[0], VIZ_SUBNETWORKS)

    # create output directory if doesn't exist; warn if it exists and is not empty
    outdir = args.output_directory
    if not os.path.exists(outdir):
        os.makedirs(outdir)
    if len(os.listdir(outdir)) > 0:
        print("WARNING: Output directory is not empty. Any conflicting files will be overwritten. "
              "(Ctrl-c to cancel).")

    ks = set()
    output = dict(deltas=[], subnetworks=dict(), mutation_matrices=dict(), stats=dict())
    subnetworks = dict()
    for results_file in args.results_files:
        results = json.load(open(results_file))
        ccs = results['components']

        heat_file = json.load(open(results['parameters']['heat_file']))
        gene2heat = heat_file['heat']
        heat_parameters = heat_file['parameters']
        d_score = hnio.load_display_score_tsv(args.display_score_file) if args.display_score_file else None
        d_name = hnio.load_display_name_tsv(args.display_name_file) if args.display_name_file else dict()
        edges = hnio.load_ppi_edges(args.edge_file, hnio.load_index(results['parameters']['infmat_index_file']))
        delta = format(results['parameters']['delta'], 'g')
        output['deltas'].append(delta)
        subnetworks[delta] = ccs

        output["subnetworks"][delta] = []
        for cc in ccs:
            output['subnetworks'][delta].append(viz.get_component_json(cc, gene2heat, edges,
                                                                args.network_name, d_score, d_name))
            
        # make oncoprints if heat file was generated from mutation data
        if 'heat_fn' in heat_parameters and heat_parameters['heat_fn'] == 'load_mutation_heat':
            output['mutation_matrices'][delta] = list()
            samples = hnio.load_samples(heat_parameters['sample_file']) if heat_parameters['sample_file'] else None
            genes = hnio.load_genes(heat_parameters['gene_file']) if heat_parameters['gene_file'] else None
            snvs = hnio.load_snvs(heat_parameters['snv_file'], genes, samples) if heat_parameters['snv_file'] else []
            cnas = hnio.load_cnas(heat_parameters['cna_file'], genes, samples) if heat_parameters['cna_file'] else []

            for cc in ccs:
                output['mutation_matrices'][delta].append(viz.get_oncoprint_json(cc, snvs, cnas, d_name))

            if heat_parameters.get('sample_type_file'):
                with open(heat_parameters['sample_type_file']) as f:
                    output['sampleToTypes'] = dict(l.rstrip().split() for l in f if not l.startswith("#") )
                    output['typeToSamples'] = dict((t, []) for t in set(output['sampleToTypes'].values()))
                    for s, ty in output['sampleToTypes'].iteritems():
                        output['typeToSamples'][ty].append( s )
            else:
                output['sampleToTypes'] = dict( (s, "Cancer") for s in samples )
                output['typeToSamples'] = dict(Cancer=list(samples))

        output['stats'][delta] = results['statistics']
        for k in sorted(map(int, results['statistics'].keys())):
            ks.add(k)
            continue
            stats = results['statistics'][str(k)]
            output['stats'][delta].append( dict(k=k, expected=stats['expected'], observed=stats['observed'], pval=stats['pval']))

    output['ks'] = range(min(ks), max(ks)+1)
    with open('%s/subnetworks.json' % outdir, 'w') as out:
        json.dump(output, out, indent=4)

    shutil.copy(subnetworks_file, '%s/%s' % (outdir, VIZ_INDEX))
Пример #2
0
def run(args):
    # Load the network and heat files
    assert( len(args.network_files) == len(args.permuted_network_paths) )
    networks, graph_map = [], dict()
    for network_file, pnp in zip(args.network_files, args.permuted_network_paths):
        infmat, indexToGene, G, network_name = hnio.load_network(network_file, HN2_INFMAT_NAME)
        graph_map[network_name] = G
        networks.append( (infmat, indexToGene, G, network_name, pnp) )

    heats, json_heat_map, heat_map, mutation_map, heat_file_map = [], dict(), dict(), dict(), dict()
    for heat_file in args.heat_files:
        json_heat = os.path.splitext(heat_file.lower())[1] == '.json'
        heat, heat_name, mutations = hnio.load_heat_file(heat_file, json_heat)
        json_heat_map[heat_name] = json_heat
        heat_map[heat_name] = heat
        heat_file_map[heat_name] = heat_file
        mutation_map[heat_name] = mutations
        heats.append( (heat, heat_name) )

    # Run HotNet2 on each pair of network and heat files
    if args.verbose > 0:
        print('* Running HotNet2 in consensus mode...')

    single_runs, consensus, linkers, auto_deltas, consensus_stats = consensus_with_stats(args, networks, heats)

    # Output the single runs
    if args.verbose > 0:
        print('* Outputting results to file...')

    params = vars(args)
    result_dirs = []
    for (network_name, heat_name, run) in single_runs:
        # Set up the output directory and record for later
        output_dir = '%s/%s-%s' % (args.output_directory, network_name.lower(), heat_name.lower())
        result_dirs.append(output_dir)
        hnio.setup_output_dir(output_dir)

        # Output to file
        hnio.output_hotnet2_run(run, params, network_name, heat_map[heat_name], heat_name, heat_file_map[heat_name], json_heat_map[heat_name], output_dir)

        # create the hierarchy if necessary
        if args.output_hierarchy:
            hierarchy_out_dir = '{}/hierarchy/'.format(output_dir)
            if not os.path.isdir(hierarchy_out_dir): os.mkdir(hierarchy_out_dir)
            CD.createDendrogram( sim, list(index2gene.values()), hierarchy_out_dir, params, verbose=False)

    # Output the consensus
    hnio.output_consensus(consensus, linkers, auto_deltas, consensus_stats, params, args.output_directory)

    # Create the visualization(s). This has to be after the consensus procedure
    # is run because we want to default to the auto-selected deltas.
    if args.verbose > 0:
        print('* Generating and outputting visualization data...')

    d_score = hnio.load_display_score_tsv(args.display_score_file) if args.display_score_file else None
    d_name = hnio.load_display_name_tsv(args.display_name_file) if args.display_name_file else dict()
    for (network_name, heat_name, run), result_dir, auto_delta in zip(single_runs, result_dirs, auto_deltas):
        snvs, cnas, sampleToType = mutation_map[heat_name]
        G = graph_map[network_name]

        output = hnviz.generate_viz_json(run, G.edges(), network_name, heat_map[heat_name], snvs, cnas, sampleToType, d_score, d_name)

        with open('{}/viz-data.json'.format(result_dir), 'w') as OUT:
            output['params'] = dict(consensus=False, network_name=network_name, heat_name=heat_name, auto_delta=format(auto_delta, 'g'))
            json.dump( output, OUT )

    # Add the consensus visualization
    snvs, cnas, sampleToType = mutations
    consensus_ccs = [ d['core'] + d['expansion'] for d in consensus ]
    consensus_auto_delta = 0
    results = [[consensus_ccs, consensus_stats, consensus_auto_delta]]
    with open('{}/consensus/viz-data.json'.format(args.output_directory), 'w') as OUT:
        output = hnviz.generate_viz_json(results, G.edges(), network_name, heat, snvs, cnas, sampleToType, d_score, d_name)
        output['params'] = dict(consensus=True, auto_delta=format(consensus_auto_delta, 'g'))
        json.dump( output, OUT )
Пример #3
0
def run(args):
    # Load the network and heat files
    assert (len(args.network_files) == len(args.permuted_network_paths))
    networks, graph_map = [], dict()
    for network_file, pnp in zip(args.network_files,
                                 args.permuted_network_paths):
        infmat, indexToGene, G, network_name = hnio.load_network(
            network_file, HN2_INFMAT_NAME)
        graph_map[network_name] = G
        networks.append((infmat, indexToGene, G, network_name, pnp))

    heats, json_heat_map, heat_map, mutation_map, heat_file_map = [], dict(
    ), dict(), dict(), dict()
    for heat_file in args.heat_files:
        json_heat = os.path.splitext(heat_file.lower())[1] == '.json'
        heat, heat_name, mutations = hnio.load_heat_file(heat_file, json_heat)
        json_heat_map[heat_name] = json_heat
        heat_map[heat_name] = heat
        heat_file_map[heat_name] = heat_file
        mutation_map[heat_name] = mutations
        heats.append((heat, heat_name))

    # Run HotNet2 on each pair of network and heat files
    if args.verbose > 0:
        print '* Running HotNet2 in consensus mode...'

    single_runs, consensus, linkers, auto_deltas, consensus_stats = consensus_with_stats(
        args, networks, heats)

    # Output the single runs
    if args.verbose > 0:
        print '* Outputting results to file...'

    params = vars(args)
    result_dirs = []
    for (network_name, heat_name, run) in single_runs:
        # Set up the output directory and record for later
        output_dir = '%s/%s-%s' % (args.output_directory, network_name.lower(),
                                   heat_name.lower())
        result_dirs.append(output_dir)
        hnio.setup_output_dir(output_dir)

        # Output to file
        hnio.output_hotnet2_run(run, params, network_name, heat_map[heat_name],
                                heat_name, heat_file_map[heat_name],
                                json_heat_map[heat_name], output_dir)

        # create the hierarchy if necessary
        if args.output_hierarchy:
            hierarchy_out_dir = '{}/hierarchy/'.format(output_dir)
            if not os.path.isdir(hierarchy_out_dir):
                os.mkdir(hierarchy_out_dir)
            CD.createDendrogram(sim,
                                index2gene.values(),
                                hierarchy_out_dir,
                                params,
                                verbose=False)

    # Output the consensus
    hnio.output_consensus(consensus, linkers, auto_deltas, consensus_stats,
                          params, args.output_directory)

    # Create the visualization(s). This has to be after the consensus procedure
    # is run because we want to default to the auto-selected deltas.
    if args.verbose > 0:
        print '* Generating and outputting visualization data...'

    d_score = hnio.load_display_score_tsv(
        args.display_score_file) if args.display_score_file else None
    d_name = hnio.load_display_name_tsv(
        args.display_name_file) if args.display_name_file else dict()
    for (network_name, heat_name,
         run), result_dir, auto_delta in zip(single_runs, result_dirs,
                                             auto_deltas):
        snvs, cnas, sampleToType = mutation_map[heat_name]
        G = graph_map[network_name]

        output = hnviz.generate_viz_json(run, G.edges(), network_name,
                                         heat_map[heat_name], snvs, cnas,
                                         sampleToType, d_score, d_name)

        with open('{}/viz-data.json'.format(result_dir), 'w') as OUT:
            output['params'] = dict(consensus=False,
                                    network_name=network_name,
                                    heat_name=heat_name,
                                    auto_delta=format(auto_delta, 'g'))
            json.dump(output, OUT)

    # Add the consensus visualization
    snvs, cnas, sampleToType = mutations
    consensus_ccs = [d['core'] + d['expansion'] for d in consensus]
    consensus_auto_delta = 0
    results = [[consensus_ccs, consensus_stats, consensus_auto_delta]]
    with open('{}/consensus/viz-data.json'.format(args.output_directory),
              'w') as OUT:
        output = hnviz.generate_viz_json(results, G.edges(), network_name,
                                         heat, snvs, cnas, sampleToType,
                                         d_score, d_name)
        output['params'] = dict(consensus=True,
                                auto_delta=format(consensus_auto_delta, 'g'))
        json.dump(output, OUT)
Пример #4
0
def run(args):
    subnetworks_file = '%s/viz_files/%s' % (str(hotnet2.__file__).rsplit('/', 1)[0], VIZ_SUBNETWORKS)

    # create output directory if doesn't exist; warn if it exists and is not empty
    outdir = args.output_directory
    if not os.path.exists(outdir):
        os.makedirs(outdir)
    if len(os.listdir(outdir)) > 0:
        print("WARNING: Output directory is not empty. Any conflicting files will be overwritten. "
              "(Ctrl-c to cancel).")

    ks = set()
    output = dict(deltas=[], subnetworks=dict(), mutation_matrices=dict(), stats=dict())
    predictions = set()
    multipleHeatFiles = False
    for results_file in args.results_files:
        with open(results_file, 'r') as IN:
            results = json.load(IN)
            ccs = results['components']

        heat_file = json.load(open(results['parameters']['heat_file']))
        gene2heat = heat_file['heat']
        heat_parameters = heat_file['parameters']
        d_score = hnio.load_display_score_tsv(args.display_score_file) if args.display_score_file else None
        d_name = hnio.load_display_name_tsv(args.display_name_file) if args.display_name_file else dict()
        edges = hnio.load_ppi_edges(args.edge_file, hnio.load_index(results['parameters']['infmat_index_file']))
        delta = format(results['parameters']['delta'], 'g')
        output['deltas'].append(delta)

        output["subnetworks"][delta] = []
        predictions |= set( g for cc in ccs for g in cc )
        for cc in ccs:
            output['subnetworks'][delta].append(viz.get_component_json(cc, gene2heat, edges,
                                                                args.network_name, d_score, d_name))
        # Record the heat scores
        if 'geneToHeat' in output:
            if any( output['geneToHeat'][g] != h for g, h in gene2heat.iteritems() ) or len(gene2heat.keys()) != len(output['geneToHeat'].keys()):
                multipleHeatFiles = True
        output['geneToHeat'] = gene2heat

        # make oncoprints if heat file was generated from mutation data
        if 'heat_fn' in heat_parameters and heat_parameters['heat_fn'] == 'load_mutation_heat':
            output['mutation_matrices'][delta] = list()
            samples = hnio.load_samples(heat_parameters['sample_file']) if heat_parameters['sample_file'] else None
            genes = hnio.load_genes(heat_parameters['gene_file']) if heat_parameters['gene_file'] else None
            snvs = hnio.load_snvs(heat_parameters['snv_file'], genes, samples) if heat_parameters['snv_file'] else []
            cnas = hnio.load_cnas(heat_parameters['cna_file'], genes, samples) if heat_parameters['cna_file'] else []

            # Get the samples and genes from the mutations directly if they weren't provided
            if not samples:
                samples = set( m.sample for m in snvs ) | set( m.sample for m in cnas )
            if not genes:
                genes = set( m.gene for m in snvs) | set( m.gene for m in cnas )

            for cc in ccs:
                output['mutation_matrices'][delta].append(viz.get_oncoprint_json(cc, snvs, cnas, d_name))

            if heat_parameters.get('sample_type_file'):
                with open(heat_parameters['sample_type_file']) as f:
                    output['sampleToTypes'] = dict(l.rstrip().split() for l in f if not l.startswith("#") )
                    output['typeToSamples'] = dict((t, []) for t in set(output['sampleToTypes'].values()))
                    for s, ty in output['sampleToTypes'].iteritems():
                        output['typeToSamples'][ty].append( s )
            else:
                if not samples:
                    samples = set( m.sample for m in snvs ) | set( m.sample for m in cnas )
                output['sampleToTypes'] = dict( (s, "Cancer") for s in samples )
                output['typeToSamples'] = dict(Cancer=list(samples))

        output['stats'][delta] = results['statistics']
        ks |= set(map(int, results['statistics'].keys()))

    # Print a warning if there were multiple heat files referenced by
    # the results files
    if multipleHeatFiles:
        sys.stderr.write('Warning: results files used multiple heat files. Only the last heat file will be used to tabulate scores.\n')

    # Output to file
    output['predictions'] = sorted(predictions) # list of nodes found in any run
    output['ks'] = range(min(ks), max(ks)+1)
    with open('%s/subnetworks.json' % outdir, 'w') as out:
        json.dump(output, out, indent=4)

    shutil.copy(subnetworks_file, '%s/%s' % (outdir, VIZ_INDEX))
Пример #5
0
def run(args):
    subnetworks_file = '%s/viz_files/%s' % (str(hotnet2.__file__).rsplit(
        '/', 1)[0], VIZ_SUBNETWORKS)

    # create output directory if doesn't exist; warn if it exists and is not empty
    outdir = args.output_directory
    if not os.path.exists(outdir):
        os.makedirs(outdir)
    if len(os.listdir(outdir)) > 0:
        print(
            "WARNING: Output directory is not empty. Any conflicting files will be overwritten. "
            "(Ctrl-c to cancel).")

    ks = set()
    output = dict(deltas=[],
                  subnetworks=dict(),
                  mutation_matrices=dict(),
                  stats=dict())
    subnetworks = dict()
    for results_file in args.results_files:
        results = json.load(open(results_file))
        ccs = results['components']

        heat_file = json.load(open(results['parameters']['heat_file']))
        gene2heat = heat_file['heat']
        heat_parameters = heat_file['parameters']
        d_score = hnio.load_display_score_tsv(
            args.display_score_file) if args.display_score_file else None
        d_name = hnio.load_display_name_tsv(
            args.display_name_file) if args.display_name_file else dict()
        edges = hnio.load_ppi_edges(
            args.edge_file,
            hnio.load_index(results['parameters']['infmat_index_file']))
        delta = format(results['parameters']['delta'], 'g')
        output['deltas'].append(delta)
        subnetworks[delta] = ccs

        output["subnetworks"][delta] = []
        for cc in ccs:
            output['subnetworks'][delta].append(
                viz.get_component_json(cc, gene2heat, edges, args.network_name,
                                       d_score, d_name))

        # make oncoprints if heat file was generated from mutation data
        if 'heat_fn' in heat_parameters and heat_parameters[
                'heat_fn'] == 'load_mutation_heat':
            output['mutation_matrices'][delta] = list()
            samples = hnio.load_samples(
                heat_parameters['sample_file']
            ) if heat_parameters['sample_file'] else None
            genes = hnio.load_genes(heat_parameters['gene_file']
                                    ) if heat_parameters['gene_file'] else None
            snvs = hnio.load_snvs(
                heat_parameters['snv_file'], genes,
                samples) if heat_parameters['snv_file'] else []
            cnas = hnio.load_cnas(
                heat_parameters['cna_file'], genes,
                samples) if heat_parameters['cna_file'] else []

            # Get the samples and genes from the mutations directly if they weren't provided
            if not samples:
                samples = set(m.sample for m in snvs) | set(m.sample
                                                            for m in cnas)
            if not genes:
                genes = set(m.gene for m in snvs) | set(m.gene for m in cnas)

            for cc in ccs:
                output['mutation_matrices'][delta].append(
                    viz.get_oncoprint_json(cc, snvs, cnas, d_name))

            if heat_parameters.get('sample_type_file'):
                with open(heat_parameters['sample_type_file']) as f:
                    output['sampleToTypes'] = dict(l.rstrip().split()
                                                   for l in f
                                                   if not l.startswith("#"))
                    output['typeToSamples'] = dict(
                        (t, []) for t in set(output['sampleToTypes'].values()))
                    for s, ty in output['sampleToTypes'].iteritems():
                        output['typeToSamples'][ty].append(s)
            else:
                output['sampleToTypes'] = dict((s, "Cancer") for s in samples)
                output['typeToSamples'] = dict(Cancer=list(samples))

        output['stats'][delta] = results['statistics']
        ks |= set(map(int, results['statistics'].keys()))

    output['ks'] = range(min(ks), max(ks) + 1)
    with open('%s/subnetworks.json' % outdir, 'w') as out:
        json.dump(output, out, indent=4)

    shutil.copy(subnetworks_file, '%s/%s' % (outdir, VIZ_INDEX))
Пример #6
0
def run(args):
    # Load the network and heat files
    assert (len(args.network_files) == len(args.permuted_network_paths))
    networks, graph_map = [], dict()
    for network_file, pnp in zip(args.network_files,
                                 args.permuted_network_paths):
        infmat, indexToGene, G, network_name = hnio.load_network(
            network_file, HN2_INFMAT_NAME)
        graph_map[network_name] = G
        networks.append((infmat, indexToGene, G, network_name, pnp))
    """Change from here"""
    #print type(G)
    """End here """

    heats, json_heat_map, heat_map, mutation_map, heat_file_map = [], dict(
    ), dict(), dict(), dict()
    for heat_file in args.heat_files:
        json_heat = os.path.splitext(heat_file.lower())[1] == '.json'
        heat, heat_name, mutations = hnio.load_heat_file(heat_file, json_heat)
        json_heat_map[heat_name] = json_heat
        heat_map[heat_name] = heat
        heat_file_map[heat_name] = heat_file
        mutation_map[heat_name] = mutations
        heats.append((heat, heat_name))

    # Run HotNet2 on each pair of network and heat files
    if args.verbose > 0:
        print '* Running HotNet2 in consensus mode...'

    single_runs, single_My_results, consensus, linkers, auto_deltas, consensus_stats = consensus_with_stats(
        args, networks, heats)

    #print single_sig_Count_delta
    #print single_sig_Conp_delta
    #print signle_Subnet_sig_delta

    # Output the single runs
    if args.verbose > 0:
        print '* Outputting results to file...'

    params = vars(args)
    result_dirs = []
    for (network_name, heat_name, run) in single_runs:
        # Set up the output directory and record for later
        output_dir = '%s/%s-%s' % (args.output_directory, network_name.lower(),
                                   heat_name.lower())
        result_dirs.append(output_dir)
        hnio.setup_output_dir(output_dir)

        # Output to file
        hnio.output_hotnet2_run(run, params, network_name, heat_map[heat_name],
                                heat_name, heat_file_map[heat_name],
                                json_heat_map[heat_name], output_dir)

        # create the hierarchy if necessary
        if args.output_hierarchy:
            hierarchy_out_dir = '{}/hierarchy/'.format(output_dir)
            if not os.path.isdir(hierarchy_out_dir):
                os.mkdir(hierarchy_out_dir)
            CD.createDendrogram(sim,
                                index2gene.values(),
                                hierarchy_out_dir,
                                params,
                                verbose=False)
    """change my code here"""
    # Set up the output directory and record for later

    #for (network_name, heat_name, subnetScore) in single_subnet_score_delta:
    #output_dir = '%s/%s-%s' % (args.output_directory, network_name.lower(), heat_name.lower())
    #       result_dirs.append(output_dir)
    #       hnio.setup_output_dir(output_dir)

    #       my.output_subnetscore_deltas(subnetScore,output_dir)

    for (network_name, heat_name, Myresults) in single_My_results:

        output_dir = '%s/%s-%s' % (args.output_directory, network_name.lower(),
                                   heat_name.lower())
        result_dirs.append(output_dir)
        hnio.setup_output_dir(output_dir)
        #(permuted_sub_score, subnet_geneScore, Alpha_sig, Subnetscore_sig, Conponet_sig, count, sig_conponet, degree, permuted_degree,cent_weighted_score, degree_weighted_score,delta)
        my.output_Myresults(Myresults, output_dir)

    ###### permuted results store
    """end here"""

    # Output the consensus
    hnio.output_consensus(consensus, linkers, auto_deltas, consensus_stats,
                          params, args.output_directory)
    """changing here, I calculate the genes score"""
    #####calculate all the gene score for gene list
    #genelist, scoreVec = my.score_vec(infmat,indexToGene, heat)
    #gene_socre = np.column_stack((genelist, scoreVec))
    #subnet_geneScore = my.Matchscore_fun(genelist,scoreVec,consensus)
    ####output the subnetwork with score only
    #my.output_scoreSubnet(subnet_geneScore,args.output_directory)
    ####output the result
    #hnio.output_scoreVec(scoreVec, genelist,args.output_directory)
    """end here """

    # Create the visualization(s). This has to be after the consensus procedure
    # is run because we want to default to the auto-selected deltas.
    if args.verbose > 0:
        print '* Generating and outputting visualization data...'

    d_score = hnio.load_display_score_tsv(
        args.display_score_file) if args.display_score_file else None
    d_name = hnio.load_display_name_tsv(
        args.display_name_file) if args.display_name_file else dict()
    for (network_name, heat_name,
         run), result_dir, auto_delta in zip(single_runs, result_dirs,
                                             auto_deltas):
        snvs, cnas, sampleToType = mutation_map[heat_name]
        G = graph_map[network_name]

        output = hnviz.generate_viz_json(run, G.edges(), network_name,
                                         heat_map[heat_name], snvs, cnas,
                                         sampleToType, d_score, d_name)

        with open('{}/viz-data.json'.format(result_dir), 'w') as OUT:
            output['params'] = dict(consensus=False,
                                    network_name=network_name,
                                    heat_name=heat_name,
                                    auto_delta=format(auto_delta, 'g'))
            json.dump(output, OUT)

    # Add the consensus visualization
    snvs, cnas, sampleToType = mutations
    consensus_ccs = [d['core'] + d['expansion'] for d in consensus]
    consensus_auto_delta = 0
    results = [[consensus_ccs, consensus_stats, consensus_auto_delta]]
    with open('{}/consensus/viz-data.json'.format(args.output_directory),
              'w') as OUT:
        output = hnviz.generate_viz_json(results, G.edges(), network_name,
                                         heat, snvs, cnas, sampleToType,
                                         d_score, d_name)
        output['params'] = dict(consensus=True,
                                auto_delta=format(consensus_auto_delta, 'g'))
        json.dump(output, OUT)