From 19b4d909beb68390b83e8e39df771d78156c2231 Mon Sep 17 00:00:00 2001 From: Cedric Arisdakessian Date: Thu, 20 Feb 2020 12:51:38 -1000 Subject: [PATCH] split parser; clened main script; added entrypoint set to deepImpute --- .bumpversion.cfg | 2 +- .gitignore | 1 + Dockerfile | 3 +- README.md | 45 +++-- deepimpute/deepImpute.py | 133 +++------------ deepimpute/parser.py | 96 +++++++++++ examples/notebook_example.ipynb | 286 +------------------------------- makefile | 7 +- setup.py | 3 +- tests/deepImpute_test.py | 31 +++- 10 files changed, 188 insertions(+), 419 deletions(-) create mode 100644 deepimpute/parser.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 4255e50..1594310 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -2,5 +2,5 @@ files = ./setup.py commit = True tag = True -current_version = 0.0.1 +current_version = 1.1 diff --git a/.gitignore b/.gitignore index 5436e71..84351b4 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *#* *.egg-info* +dist *.pyc .coverage .vscode diff --git a/Dockerfile b/Dockerfile index 995f8af..de8528b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,5 +4,4 @@ MAINTAINER Breck Yunits RUN apt-get update && apt-get install -y git -RUN git clone https://github.com/lanagarmire/deepimpute && cd deepimpute && pip install --user . - +RUN git clone https://github.com/lanagarmire/deepimpute && cd deepimpute && pip install --user . \ No newline at end of file diff --git a/README.md b/README.md index b78ac08..b367012 100755 --- a/README.md +++ b/README.md @@ -14,7 +14,14 @@ These instructions will get you a copy of the project up and running on your loc ### Installing -To install DeepImpute, you only need to download the git repository at https://github.com/lanagarmire/deepimpute and install it using pip: +You can install DeepImpute's latest release using pip with the following command: + +```bash +pip install deepimpute +``` + +To install the latest GitHub version, you can also clone this directory and +install it: ```bash git clone https://github.com/lanagarmire/deepimpute @@ -29,14 +36,15 @@ DeepImpute can be used either on the command line or as a Python package. Command line: ``` -usage: deepImpute.py [-h] [-o O] [--cores CORES] [--cell-axis {rows,columns}] - [--limit LIMIT] [--minVMR MINVMR] [--subset SUBSET] - [--learning-rate LEARNING_RATE] [--batch-size BATCH_SIZE] - [--max-epochs MAX_EPOCHS] - [--hidden-neurons HIDDEN_NEURONS] - [--dropout-rate DROPOUT_RATE] - [--output-neurons OUTPUT_NEURONS] - inputFile +usage: deepImpute [-h] [-o OUTPUT] [--cores CORES] + [--cell-axis {rows,columns}] [--limit LIMIT] + [--minVMR MINVMR] [--subset SUBSET] + [--learning-rate LEARNING_RATE] [--batch-size BATCH_SIZE] + [--max-epochs MAX_EPOCHS] [--hidden-neurons HIDDEN_NEURONS] + [--dropout-rate DROPOUT_RATE] + [--output-neurons OUTPUT_NEURONS] [--n_pred N_PRED] + [--policy POLICY] + inputFile scRNA-seq data imputation using DeepImpute. @@ -45,7 +53,8 @@ positional arguments: optional arguments: -h, --help show this help message and exit - -o O Path to output data counts. Default: ./ + -o OUTPUT, --output OUTPUT + Path to output data counts. Default: ./imputed.csv --cores CORES Number of cores. Default: all available cores --cell-axis {rows,columns} Cell dimension in the matrix. Default: rows @@ -68,16 +77,26 @@ optional arguments: Dropout rate for the hidden dropout layer (0" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Using 80% of the data\n", "multinet.fit(data,cell_subset=0.5)" diff --git a/makefile b/makefile index ded255c..44cd74c 100644 --- a/makefile +++ b/makefile @@ -26,6 +26,7 @@ coverage: coverage${PYTHON_VERSION} html echo "Results in: file://${CURDIR}/htmlcov/index.html" -test-mp-hang-bug: - # This triggers TensorFlow issue #8220 - python${PYTHON_VERSION} -m unittest discover -s deepimpute -p '*_test.py' +publish: + pip install . + python setup.py sdist + twine upload dist/* diff --git a/setup.py b/setup.py index 50927a1..7f98958 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -VERSION = "1.0.0" +VERSION = "1.1" setup( name="deepimpute", @@ -12,6 +12,7 @@ author="Cedric Aridakessian", author_email="carisdak@hawaii.edu", url="", + entry_points={'console_scripts': ['deepImpute=deepimpute.deepImpute:deepImpute']}, license="MIT", packages=find_packages(exclude=["examples", "tests"]), include_package_data=True, diff --git a/tests/deepImpute_test.py b/tests/deepImpute_test.py index 48ce95a..f86c1ee 100644 --- a/tests/deepImpute_test.py +++ b/tests/deepImpute_test.py @@ -1,20 +1,35 @@ import unittest +from unittest import mock +import argparse import test_data from deepimpute.deepImpute import deepImpute - -# test sending data transposed - +args = { + 'inputFile': test_data.PATH+"csv", + 'cell_axis': "rows", + 'cores': 1, + 'learning_rate': 1e-4, + 'batch_size': 64, + 'max_epochs': 300, + 'output_neurons': 512, + 'hidden_neurons': 300, + "dropout_rate": 0.2, + "subset": 1, + "limit": 1000, + "minVMR": 0.5, + "n_pred": None, + "policy": "restore", + "output": None +} class TestDeepImpute(unittest.TestCase): """ """ - def test_all(self): - _ = deepImpute(test_data.rawData, NN_lim=1000) - - def test_minExpressionLevel(self): - _ = deepImpute(test_data.rawData, ncores=4, minVMR=1) + @mock.patch('argparse.ArgumentParser.parse_args', + return_value=argparse.Namespace(**args)) + def test_all(self, mock_args): + _ = deepImpute() if __name__ == "__main__": unittest.main()