11# -*- coding: utf-8 -*-
22
3- """Command line interface for DiffuPy ."""
3+ """Command line interface for diffuPy ."""
44
55import json
66import logging
1212import click
1313from diffupy .process_network import get_kernel_from_network_path
1414
15- from .constants import OUTPUT , METHODS , EMOJI , RAW
15+ from .constants import OUTPUT , METHODS , EMOJI , RAW , CSV , JSON
1616from .diffuse import diffuse as run_diffusion
1717from .kernels import regularised_laplacian_kernel
1818from .process_input import process_map_and_format_input_data_for_diff
@@ -78,14 +78,14 @@ def kernel(
7878
7979@main .command ()
8080@click .option (
81- '-n ' , '--network ' ,
82- help = 'Path to the network graph or kernel ' ,
81+ '-i ' , '--input ' ,
82+ help = 'Input data ' ,
8383 required = True ,
8484 type = click .Path (exists = True , dir_okay = False )
8585)
8686@click .option (
87- '-i ' , '--data ' ,
88- help = 'Input data ' ,
87+ '-n ' , '--network ' ,
88+ help = 'Path to the network graph or kernel ' ,
8989 required = True ,
9090 type = click .Path (exists = True , dir_okay = False )
9191)
@@ -131,24 +131,32 @@ def kernel(
131131 default = 0.05 ,
132132 show_default = True ,
133133)
134+ @click .option (
135+ '-f' , '--output_format' ,
136+ help = 'Statistical significance (p-value).' ,
137+ type = float ,
138+ default = CSV ,
139+ show_default = True ,
140+ )
134141def diffuse (
135- input_data : str ,
142+ input : str ,
136143 network : str ,
137144 output : str = sys .stdout ,
138145 method : str = RAW ,
139146 binarize : bool = True ,
140147 threshold : float = None ,
141148 absolute_value : bool = True ,
142149 p_value : float = 0.05 ,
150+ output_format : str = CSV
143151):
144152 """Run a diffusion method over a network or pre-generated kernel."""
145153 click .secho (f'{ EMOJI } Loading graph from { network } { EMOJI } ' )
146154
147155 kernel = get_kernel_from_network_path (network )
148156
149- click .secho (f'Codifying data from { input_data } .' )
157+ click .secho (f'Processing data input from { input } .' )
150158
151- input_scores_dict = process_map_and_format_input_data_for_diff (input_data ,
159+ input_scores_dict = process_map_and_format_input_data_for_diff (input ,
152160 kernel ,
153161 method ,
154162 binarize ,
@@ -157,24 +165,21 @@ def diffuse(
157165 threshold ,
158166 )
159167
160-
161- click .secho (f'Running the diffusion algorithm.' )
168+ click .secho (f'Computing the diffusion algorithm.' )
162169
163170 results = run_diffusion (
164- label_dict ,
171+ input_scores_dict ,
165172 method ,
166173 k = kernel
167174 )
168175
169- # results = run_diffusion(
170- # label_dict,
171- # method,
172- # graph,
173- # )
176+ if output_format is CSV :
177+ results .to_csv (output )
174178
175- # json.dump(results, output, indent=2)
179+ elif output_format is JSON :
180+ json .dump (results , output , indent = 2 )
176181
177- click .secho (f'Finished! ' )
182+ click .secho (f'{ EMOJI } Diffusion performed with success. Output located at { output } { EMOJI } ' )
178183
179184
180185if __name__ == '__main__' :
0 commit comments