Skip to content
This repository has been archived by the owner on Oct 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #90 from NeuroDataDesign/development
Browse files Browse the repository at this point in the history
v0.0.4
  • Loading branch information
tpsatish95 authored Dec 10, 2018
2 parents 66f447d + 7ab3688 commit ecc7547
Show file tree
Hide file tree
Showing 118 changed files with 4,955 additions and 664 deletions.
30 changes: 17 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,38 @@ RUN ln -s /usr/bin/python3.6 /usr/local/bin/python
# cd .. && \
# rm -rf *

# change working directory
# make a directory for mounting local files into docker
RUN mkdir /root/workspace/
WORKDIR /root/workspace/

# add vim in docker
RUN apt-get install -y vim

# change working directory
RUN mkdir /root/code/
WORKDIR /root/code/

# clone the mgcpy code into the container
ARG SOURCE_BRANCH=master
RUN git clone -b ${SOURCE_BRANCH} https://github.com/NeuroDataDesign/mgcpy.git .

# install python requirements
COPY requirements.txt /root/workspace/requirements.txt
RUN pip install -r requirements.txt
RUN pip install jupyter
RUN pip install matplotlib
RUN pip install pycodestyle

# copy the mgcpy code into the container
COPY . /root/workspace/
RUN pip install matplotlib seaborn pandas jupyter pycodestyle

# setup pep8 guidelines (restricts push when pep8 is violated)
RUN rm ./.git/hooks/pre-commit
RUN rm -f ./.git/hooks/pre-commit
RUN chmod 777 install-hooks.sh
RUN ./install-hooks.sh

# install mgcpy
RUN python setup.py build_ext --inplace

# add mgcpy to PYTHONPATH for dev purposes
RUN echo "export PYTHONPATH='${PYTHONPATH}:/root/workspace'" >> ~/.bashrc
RUN echo "export PYTHONPATH='${PYTHONPATH}:/root/code'" >> ~/.bashrc

# test if mgcpy is correctly installed
# clean dir and test if mgcpy is correctly installed
RUN py3clean .
RUN pytest
RUN python -c "import mgcpy"

# launch terminal
CMD ["/bin/bash"]
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

`mgcpy` is a Python package containing tools for multiscale graph correlation and other statistical tests, that is capable of dealing with high dimensional and multivariate data.

**Documentation:** https://mgcpy.readthedocs.io/en/latest/

## Installation Guide:

### Install from PyPi
Expand All @@ -29,10 +31,27 @@ python3 setup.py install
- `python3 setup.py build_ext --inplace # for cython`, if you want to test in-place, first execute this

## Setting up the development environment:
- Install [docker](https://docs.docker.com/install/)
- Build the docker image, `docker build -t mgcpy-dev:latest .`
- This takes 10 to 15 mins to build
- Launch the container to go into mgcpy's dev env, `docker run -it --rm --name mgcpy-dev-env mgcpy-dev`
- To build image and run from scratch:
- Install [docker](https://docs.docker.com/install/)
- Build the docker image, `docker build -t mgcpy:latest .`
- This takes 20-30 mins to build
- Launch the container to go into mgcpy's dev env, `docker run -it --rm --name mgcpy-env mgcpy:latest`
- Pull image from Dockerhub and run:
- `docker pull tpsatish95/mgcpy:latest` or `docker pull tpsatish95/mgcpy:development`
- `docker run -it --rm -p 8888:8888 --name mgcpy-env tpsatish95/mgcpy:latest`


- To run demo notebooks (from within Docker):
- `cd demos`
- `jupyter notebook --ip 0.0.0.0 --no-browser --allow-root`
- Then copy the url it generates, it looks something like this: `http://(0de284ecf0cd or 127.0.0.1):8888/?token=e5a2541812d85e20026b1d04983dc8380055f2d16c28a6ad`
- Edit this: `(0de284ecf0cd or 127.0.0.1)` to: `127.0.0.1`, in the above link and open it in your browser
- Then open `mgc.ipynb`

- To mount/load local files into docker container:
- Do `docker run -it --rm -v <local_dir_path>:/root/workspace/ -p 8888:8888 --name mgcpy-env tpsatish95/mgcpy:latest`, replace `<local_dir_path>` with your local dir path.
- Do `cd ../workspace` when you are inside the container to view the mounted files. The **mgcpy** package code will be in `/root/code` directory.


## MGC Algorithm's Flow
![MGCPY Flow](MGCPY.png)
Expand Down
70 changes: 70 additions & 0 deletions demos/MDMR.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"module_path = \"C:\\\\Users\\\\sunda\\\\Desktop\\\\AAA FA18 JHU\\\\NDD1\\\\gitscr\\\\mgcpy\"\n",
"if module_path not in sys.path:\n",
" sys.path.append(module_path)\n",
" \n",
"import numpy as np\n",
"from mgcpy.independence_tests.mdmr.mdmr import MDMR\n",
"from mgcpy.independence_tests.mdmr.mdmrfunctions import compute_distance_matrix"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[25.03876688]\n"
]
}
],
"source": [
"X = np.genfromtxt('../mgcpy/independence_tests/unit_tests/mdmr/data/X_mdmr.csv', delimiter=\",\")\n",
"Y = np.genfromtxt('../mgcpy/independence_tests/unit_tests/mdmr/data/Y_mdmr.csv', delimiter=\",\")\n",
"\n",
"mdmr = MDMR(compute_distance_matrix)\n",
"a, _ = mdmr.test_statistic(X, Y)\n",
"print(a)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
443 changes: 0 additions & 443 deletions demos/mcorr_dcorr_mantel.ipynb

This file was deleted.

Loading

0 comments on commit ecc7547

Please sign in to comment.