From 1227b3a18343f0582744da5c8cfef11c51df8d27 Mon Sep 17 00:00:00 2001 From: Antonio Camargo Date: Tue, 23 Jul 2019 23:26:16 -0300 Subject: [PATCH] Add Excel support and bump to 0.6.0 --- README.md | 3 ++- docs/cli.md | 3 ++- setup.py | 8 ++++---- tspex/cli.py | 7 +++++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 465559f..bd6116d 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ usage: tspex [-h] [-l] [-d] [-t THRESHOLD] input_file output_file method Compute gene tissue-specificity from an expression matrix and save the output. positional arguments: - input_file Expression matrix file in the TSV or CSV formats. + input_file Expression matrix file in the TSV, CSV or Excel + formats. output_file Output TSV file containing tissue-specificity values. method Tissue-specificity metric. Allowed values are: "counts", "tau", "gini", "simpson", diff --git a/docs/cli.md b/docs/cli.md index 60cdab1..a4e7557 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -13,7 +13,8 @@ usage: tspex [-h] [-l] [-d] [-t THRESHOLD] input_file output_file method Compute gene tissue-specificity from an expression matrix and save the output. positional arguments: - input_file Expression matrix file in the TSV or CSV formats. + input_file Expression matrix file in the TSV, CSV or Excel + formats. output_file Output TSV file containing tissue-specificity values. method Tissue-specificity metric. Allowed values are: "counts", "tau", "gini", "simpson", diff --git a/setup.py b/setup.py index 5e71ebc..77b42a2 100644 --- a/setup.py +++ b/setup.py @@ -25,15 +25,15 @@ setup( name='tspex', - version='0.5.1', + version='0.6.0', packages=find_packages(), license='GNU General Public License v3.0', description='A Python package for calculating tissue-specificity metrics for gene expression.', long_description=open('README.md').read(), long_description_content_type='text/markdown', - install_requires=['matplotlib >= 2.2', 'numpy', 'pandas >= 0.23'], - python_requires= '>=3', - entry_points = { + install_requires=['matplotlib >= 2.2', 'numpy', 'pandas >= 0.23', 'xlrd >= 1.1.0'], + python_requires='>=3', + entry_points={ 'console_scripts': ['tspex=tspex.cli:main'], }, url='https://apcamargo.github.io/tspex/', diff --git a/tspex/cli.py b/tspex/cli.py index c7a03fb..faedb23 100644 --- a/tspex/cli.py +++ b/tspex/cli.py @@ -32,7 +32,10 @@ def tspex_cli(input_file, output_file, method, log, disable_transformation, threshold): """Compute gene tissue-specificity from a expression matrix file and save an output file.""" transform = not disable_transformation - expression_matrix = pd.read_csv(input_file, index_col=0, header=0, sep=None, engine='python') + if input_file.rsplit('.', 1)[1].lower() in ['xls', 'xlsx']: + expression_matrix = pd.read_excel(input_file, index_col=0, header=0) + else: + expression_matrix = pd.read_csv(input_file, index_col=0, header=0, sep=None, engine='python') tissue_specificity = tspex.TissueSpecificity( expression_matrix, method, log, transform=transform, threshold=threshold) tissue_specificity.tissue_specificity.to_csv(output_file, sep='\t') @@ -45,7 +48,7 @@ def main(): description='Compute gene tissue-specificity from an expression matrix and save the output.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('input_file', - help='Expression matrix file in the TSV or CSV formats.') + help='Expression matrix file in the TSV, CSV or Excel formats.') parser.add_argument('output_file', help='Output TSV file containing tissue-specificity values.') parser.add_argument(