Skip to content

Commit

Permalink
Small changes in CLI to increase overall consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
bramvds committed Aug 2, 2018
1 parent 227af82 commit 26cd309
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/pyscenic/cli/pyscenic.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,21 @@ def get_name(fname):
}


def _load_expression_matrix(args):
ext = os.path.splitext(args.expression_mtx_fname.name)[1]
if ext not in FILE_EXTENSION2SEPARATOR:
LOGGER.error("Unknown file format \"{}\"".format(args.expression_mtx_fname.name))
sys.exit(1)
ex_mtx = pd.read_csv(args.expression_mtx_fname, sep=FILE_EXTENSION2SEPARATOR[ext], header=0, index_col=0)
if args.transpose == 'yes':
ex_mtx = ex_mtx.T
return ex_mtx


def _df2modules(args):
ext = os.path.splitext(args.module_fname.name)[1]
adjacencies = pd.read_csv(args.module_fname.name, sep=FILE_EXTENSION2SEPARATOR[ext])
ex_mtx = pd.read_csv(args.expression_mtx_fname, sep='\t', header=0, index_col=0)
ex_mtx = _load_expression_matrix(args)
return modules_from_adjacencies(adjacencies, ex_mtx,
thresholds=args.thresholds,
top_n_targets=args.top_n_targets,
Expand All @@ -81,17 +92,6 @@ def _df2regulons(fname):
return df2regs(df)


def _load_expression_matrix(args):
ext = os.path.splitext(args.expression_mtx_fname.name)[1]
if ext not in FILE_EXTENSION2SEPARATOR:
LOGGER.error("Unknown file format \"{}\"".format(args.expression_mtx_fname.name))
sys.exit(1)
ex_mtx = pd.read_csv(args.expression_mtx_fname, sep=FILE_EXTENSION2SEPARATOR[ext], header=0, index_col=0)
if args.transpose == 'yes':
ex_mtx = ex_mtx.T
return ex_mtx


def find_adjacencies_command(args):
"""
Infer co-expression modules.
Expand Down Expand Up @@ -287,7 +287,7 @@ def create_argument_parser():
parser_ctx.add_argument('-o', '--output',
type=argparse.FileType('w'), default=sys.stdout,
help='Output file/stream, i.e. a table of enriched motifs and target genes (CSV).')
parser_ctx.add_argument('-t', '--output_type',
parser_ctx.add_argument('--output_type',
choices=['json', 'csv'], default='csv',
help='Type of output file/stream to generate (csv or json). Output as CSV gives the list of enriched motifs while the JSON option provides the regulon names with their associated target genes.')
parser_ctx.add_argument('-n', '--no_pruning', action='store_const', const = 'yes',
Expand All @@ -301,6 +301,8 @@ def create_argument_parser():
help='The mode to be used for computing (default: dask_multiprocessing).')
parser_ctx.add_argument('-a', '--all_modules', action='store_const', const = 'no',
help='Included positive and negative regulons in the analysis (default: no, i.e. only positive).')
parser_ctx.add_argument('-t', '--transpose', action='store_const', const = 'yes',
help='Transpose the expression matrix (rows=genes x columns=cells).')
add_recovery_parameters(parser_ctx)
add_annotation_parameters(parser_ctx)
add_computation_parameters(parser_ctx)
Expand Down

0 comments on commit 26cd309

Please sign in to comment.