Skip to content

Commit

Permalink
Merge pull request #1 from 444thLiao/master
Browse files Browse the repository at this point in the history
reorganized whole project and fullfill setup
  • Loading branch information
GPZ-Bioinfo authored Jul 10, 2018
2 parents 5572251 + 8218afe commit f14a1ad
Show file tree
Hide file tree
Showing 23 changed files with 56 additions and 24 deletions.
27 changes: 27 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from setuptools import setup, find_packages

setup(name='tmap',
version='1.0',
description='mapper ',
author='Haokui Zhou',
author_email='[email protected]',
license='GNU',
url='https://github.com/GPZ-Bioinfo/tmap',
packages=find_packages(),
package_data={'': ['test_data/*.csv',
'test_data/*.tsv',
'example/*'],
},
install_requires=['statsmodels>=0.9.0',
'tqdm',
'scikit-learn>=0.19.1',
'matplotlib>=2.2.2',
'networkx==1.11',
'pandas>=0.23.0',
'numpy>=1.10.4',
'scipy',

],
zip_safe=False,
extras_require={'alldeps': ('numpy>=1.10.4', 'scipy',)}
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tda/filter.py → tmap/tda/filter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import numpy as np
from sklearn import decomposition, manifold
from tda.metric import Metric
from tmap.tda.metric import Metric


_METRIC_BUILT_IN = ["braycurtis", "canberra", "chebyshev", "cityblock", "correlation", "cosine", "dice", "euclidean",
Expand Down
3 changes: 1 addition & 2 deletions tda/mapper.py → tmap/tda/mapper.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
from tda.cover import Cover
import numpy as np
import pandas as pd
import itertools
from sklearn import cluster, preprocessing
from sklearn import cluster


class Mapper(object):
Expand Down
File renamed without changes.
10 changes: 8 additions & 2 deletions tda/plot.py → tmap/tda/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def __init__(self, target, dtype="numerical", target_by="sample"):
if target_by not in ["sample", "node"]:
raise ValueError("target values must be by 'sample' or 'node'")
# target values should be numbers, check and encode categorical labels
if ((type(target[0][0]) != int) and (type(target[0][0]) != float)):
if ((type(target[0][0]) != int)
and (type(target[0][0]) != float)
and (not isinstance(target[0][0],np.number))
):
self.label_encoder = LabelEncoder()
self.target = self.label_encoder.fit_transform(target)
else:
Expand Down Expand Up @@ -165,7 +168,10 @@ def show(data, graph, color=None, fig_size=(10, 10), node_size=10, edge_width=2,
if color.dtype == "categorical":
for label in set([it[0] for it in color.labels]):
if color.label_encoder:
label_color = legend_lookup[color.label_encoder.fit_transform(label)]
try:
label_color = legend_lookup[color.label_encoder.fit_transform(label)]
except:
import pdb;pdb.set_trace()
else:
label_color = legend_lookup[label]
ax.plot([], [], 'o', color=label_color, label=label, markersize=10)
Expand Down
File renamed without changes.
Empty file added tmap/test/__init__.py
Empty file.
File renamed without changes.
20 changes: 10 additions & 10 deletions test/test_FGFP.py → tmap/test/test_FGFP.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from sklearn.preprocessing import MinMaxScaler, LabelEncoder, Imputer
import os
from sklearn.preprocessing import MinMaxScaler
from sklearn.cluster import DBSCAN
import numpy as np
from tda import mapper, filter
from tda.cover import Cover
from tda.plot import show, Color
from tda.metric import Metric
from tda.utils import optimize_dbscan_eps
from netx.SAFE import SAFE_batch, get_SAFE_summary, SAFE_single
from test import load_data
from tmap.tda import mapper, filter
from tmap.tda.cover import Cover
from tmap.tda.plot import show, Color
from tmap.tda.metric import Metric
from tmap.tda.utils import optimize_dbscan_eps
from tmap.netx.SAFE import SAFE_batch, get_SAFE_summary
from tmap.test import load_data


# load taxa abundance data, sample metadata and precomputed distance matrix
Expand Down Expand Up @@ -52,4 +52,4 @@

safe_summary = get_SAFE_summary(graph=graph, meta_data=X, safe_scores=safe_scores,
n_iter_value=n_iter, p_value=0.01)
safe_summary.to_csv('../example/FGFP_SAFE_ranking_genus_1000.csv', index=True)
safe_summary.to_csv(os.path.join(os.path.dirname(__file__),'../example/FGFP_SAFE_ranking_genus_1000.csv'), index=True)
6 changes: 3 additions & 3 deletions test/test_circles.py → tmap/test/test_circles.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from sklearn import datasets
from sklearn.cluster import DBSCAN
from tda import mapper, filter
from tda.cover import Cover
from tda.plot import show, Color
from tmap.tda import mapper, filter
from tmap.tda.cover import Cover
from tmap.tda.plot import show, Color


X, y = datasets.make_circles(n_samples=5000, noise=0.05, factor=0.3)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions test/test_digits.py → tmap/test/test_digits.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from sklearn import datasets
from sklearn.preprocessing import MinMaxScaler
from tda import mapper, filter
from tda.cover import Cover
from tmap.tda import mapper, filter
from tmap.tda.cover import Cover
from sklearn.cluster import DBSCAN
from tda.plot import Color, show
from tmap.tda.plot import Color, show


digits = datasets.load_digits()
Expand Down
6 changes: 3 additions & 3 deletions test/test_iris.py → tmap/test/test_iris.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from sklearn.preprocessing import MinMaxScaler, StandardScaler
from sklearn import datasets
from sklearn.cluster import DBSCAN
from tda import mapper, filter
from tda.cover import Cover
from tda.plot import show, Color
from tmap.tda import mapper, filter
from tmap.tda.cover import Cover
from tmap.tda.plot import show, Color


iris = datasets.load_iris()
Expand Down

0 comments on commit f14a1ad

Please sign in to comment.