Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python2andpython3 #331

Merged
merged 1 commit into from
May 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist
.idea*
.idea/*
*DS_store
.cache

virtualenv

Expand All @@ -14,5 +15,9 @@ virtualenv
.ipynb_checkpoints
_build

# data
data
# Shalek and Satija data
nature12172-s1
#nature12172-s1
__*
examples/__*
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: python
python:
- '2.7'
- '3.5'
sudo: false
before_install:
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
Expand Down Expand Up @@ -34,7 +35,7 @@ script:
- MASTER=master
- if [[ $TRAVIS_BRANCH == v*.*.* ]] ; then export DEPLOY_HTML_DIR=docs ; fi
- if [[ $TRAVIS_BRANCH == "$MASTER" ]] ; then export DEPLOY_HTML_DIR=docs-dev ; fi
- if [[ $TRAVIS_BRANCH == v*.*.* ]] || [[ $TRAVIS_BRANCH == "$MASTER" ]] ; then sudo apt-get install pandoc; conda install --yes --file doc/conda_requirements.txt ; conda install --yes ipython-notebook=2; pip install -r doc/requirements.txt; pip install . ; cd doc ; make setup_gh_pages ; make generate ; make deploy ; fi
- if [[ $TRAVIS_BRANCH == v*.*.* ]] || [[ $TRAVIS_BRANCH == "$MASTER" ]] ; then sudo apt-get install pandoc; conda install --yes --file doc/conda_requirements.txt ; pip install -r doc/requirements.txt; pip install . ; cd doc ; make setup_gh_pages ; make generate ; make deploy ; fi
after_script:
- coveralls
notifications:
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[![Stories in Ready](https://badge.waffle.io/yeolab/flotilla.png?label=ready&title=Ready)](https://waffle.io/yeolab/flotilla)
[![Build Status](https://travis-ci.org/YeoLab/flotilla.svg?branch=master)](https://travis-ci.org/YeoLab/flotilla)[![Coverage Status](https://img.shields.io/coveralls/YeoLab/flotilla.svg?style=flat)](https://coveralls.io/r/YeoLab/flotilla?branch=master)[![License](https://img.shields.io/pypi/l/flotilla.svg?style=flat)](https://pypi.python.org/pypi/flotilla/)[![Downloads](https://img.shields.io/pypi/dm/flotilla.svg?style=flat)](https://pypi.python.org/pypi/flotilla/)[![Latest Version](https://img.shields.io/pypi/v/flotilla.svg?style=flat)](https://pypi.python.org/pypi/flotilla/)[![DOI](https://img.shields.io/badge/DOI-10.5281%20%2F%20zenodo.12230-blue.svg)](http://dx.doi.org/10.5281/zenodo.12230)
[![Build Status](https://travis-ci.org/YeoLab/flotilla.svg?branch=master)](https://travis-ci.org/YeoLab/flotilla)
[![Coverage Status](https://img.shields.io/coveralls/YeoLab/flotilla.svg?style=flat)](https://coveralls.io/r/YeoLab/flotilla?branch=master)
[![License](https://img.shields.io/pypi/l/flotilla.svg?style=flat)](https://pypi.python.org/pypi/flotilla/)
[![Downloads](https://img.shields.io/pypi/dm/flotilla.svg?style=flat)](https://pypi.python.org/pypi/flotilla/)
[![Latest Version](https://img.shields.io/pypi/v/flotilla.svg?style=flat)](https://pypi.python.org/pypi/flotilla/)
[![DOI](https://img.shields.io/badge/DOI-10.5281%20%2F%20zenodo.12230-blue.svg)](http://dx.doi.org/10.5281/zenodo.12230)
[![Binder](http://mybinder.org/badge.svg)](http://mybinder.org/repo/YeoLab/flotilla)

flotilla
========
Expand Down Expand Up @@ -151,7 +157,11 @@ Problems? Questions?

We invite your input! Please leave any feedback on our [issues page](https://github.com/YeoLab/flotilla/issues).

![NumFOCUS logo](http://numfocus.org/theme/img/numfocus_logo.png)
![NumFOCUS logo](https://www.continuum.io/sites/default/files/numfocus_logo.png)

Proudly sponsored by a NumFOCUS John Hunter Technical Fellowship to Olga
Botvinnik.




3 changes: 3 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ Frigate





python3 unicode compatibility in flotilla/test/data_model/test_data_model_gene_ontology.py
3 changes: 2 additions & 1 deletion doc/conda_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
runipy
numpydoc
sphinx
fabric
fabric
jupyter
1 change: 0 additions & 1 deletion doc/releases/v0.2.7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ Miscellaneous
~~~~~~~~~~~~~

- Fixed tutorial building on the documentation page

9 changes: 9 additions & 0 deletions doc/releases/v0.3.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
v0.3.1 (May 17th, 2016)
-----------------------

This is a patch release, with non-breaking changes from v0.3.0.

Miscellaneous
~~~~~~~~~~~~~

- Refactored for compatibility with both py2.7 and 3.5
3 changes: 2 additions & 1 deletion doc/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ What's new in the package

A catalog of new features, improvements, and bug-fixes in each release.

.. include:: releases/v0.2.8.txt
.. include:: releases/v0.3.1.txt
.. include:: releases/v0.3.0.txt
.. include:: releases/v0.2.7.txt
.. include:: releases/v0.2.6.txt
.. include:: releases/v0.2.5.txt
Expand Down
12 changes: 12 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: flotilla
dependencies:
- jupyter
- pymongo
- scikit-learn
- seaborn
- semantic_version
- statsmodels
- xlrd
- pip:
- brewer2mpl
- husl
28 changes: 19 additions & 9 deletions flotilla/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@

from __future__ import absolute_import, division, print_function
from __future__ import unicode_literals

import os

from .data_model import ExpressionData, SplicingData, MetaData, \
MappingStatsData, GeneOntologyData
from .data_model import (ExpressionData, SplicingData, MetaData,
MappingStatsData, GeneOntologyData)
from .compute.predict import PredictorConfigManager, PredictorDataSetManager
from .datapackage import make_study_datapackage, FLOTILLA_DOWNLOAD_DIR
from .study import Study


__all__ = ['Study', 'PredictorConfigManager', 'PredictorDataSetManager',
__all__ = ['Study',
'PredictorConfigManager', 'PredictorDataSetManager',
'make_study_datapackage', 'FLOTILLA_DOWNLOAD_DIR',
'compute', 'data_model', 'visualize', 'Study', 'ExpressionData',
'SplicingData', 'MetaData', 'MappingStatsData',
'datapackage', 'GeneOntologyData', 'go', 'util']
'compute', 'data_model', 'visualize',
'Study',
'ExpressionData', 'SplicingData', 'MetaData', 'MappingStatsData',
'GeneOntologyData',
'datapackage', 'go', 'util']


__version__ = 'v0.3.0'
__version__ = 'v0.3.1'

# 18 cells, multiindex on the splicing data features, features already renamed
# in the matrices

# 18 cells, multiindex on the splicing data features,
# features already renamed in the matrices
_shalek2013 = 'https://raw.githubusercontent.com/YeoLab/shalek2013/master/' \
'datapackage.json'

# 250 cells, ensembl and miso ids on index, need renaming, lots of celltypes
_test_data = 'https://raw.githubusercontent.com/YeoLab/flotilla_test_data/' \
'master/datapackage.json'

_brainspan = 'https://s3-us-west-2.amazonaws.com/flotilla/' \
'brainspan_batch_corrected_for_amazon_s3/datapackage.json'

Expand Down
4 changes: 4 additions & 0 deletions flotilla/compute/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
"""
compute tools
"""

__author__ = 'olga'
8 changes: 6 additions & 2 deletions flotilla/compute/decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Perform various dimensionality reduction algorithms on data
"""

from __future__ import (absolute_import, division,
print_function, unicode_literals)

import sys

from sklearn import decomposition
Expand Down Expand Up @@ -95,7 +98,7 @@ def fit(self, X):
return self

def transform(self, X):
"""Transform a matrix into the compoment space
"""Transform a matrix into the component space

Parameters
----------
Expand Down Expand Up @@ -146,7 +149,8 @@ def fit_transform(self, X):


class DataFramePCA(DataFrameReducerBase, decomposition.PCA):
"""Perform Principal Components Analaysis on a DataFrame"""
"""Perform Principal Components Analaysis on a DataFrame
"""
pass


Expand Down
9 changes: 8 additions & 1 deletion flotilla/compute/expression.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
from __future__ import division
"""
compute / expression
"""

# from __future__ import division
from __future__ import (absolute_import, division,
print_function, unicode_literals)

import itertools
import math
import sys
Expand Down
7 changes: 7 additions & 0 deletions flotilla/compute/generic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
generic
"""

from __future__ import (absolute_import, division,
print_function, unicode_literals)

import sys

import numpy as np
Expand Down
3 changes: 3 additions & 0 deletions flotilla/compute/infotheory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Information-theoretic calculations
"""

from __future__ import (absolute_import, division,
print_function, unicode_literals)

import numpy as np
import pandas as pd
from sklearn import cross_validation
Expand Down
3 changes: 3 additions & 0 deletions flotilla/compute/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
:py:mod:flotilla.visualize.network
"""

from __future__ import (absolute_import, division,
print_function, unicode_literals)

import networkx as nx
import numpy as np
import pandas as pd
Expand Down
8 changes: 4 additions & 4 deletions flotilla/compute/outlier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""
Detect outlier samples in data
"""
import sys

from __future__ import (absolute_import, division,
print_function, unicode_literals)

import sklearn
import pandas as pd
Expand Down Expand Up @@ -37,9 +39,7 @@ def __init__(self, X, method=None, nu=0.1, kernel='rbf', gamma=0.1,
random_state=0, **kwargs):
if method is None:
method = sklearn.svm.OneClassSVM

sys.stdout.write('SVM Kernel is: {}\n'.format(kernel))

print('SVM Kernel is:', kernel)
kwargs.update(dict(nu=nu, kernel=kernel, gamma=gamma,
random_state=random_state))
self.kwargs = kwargs
Expand Down
4 changes: 4 additions & 0 deletions flotilla/compute/predict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
Compute predictors on data, e.g. classify or regress on features/samples
"""

from __future__ import (absolute_import, division,
print_function, unicode_literals)

import sys
import warnings
from collections import defaultdict
Expand Down
3 changes: 3 additions & 0 deletions flotilla/compute/splicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Calculate splicing-specific operations
"""

from __future__ import (absolute_import, division,
print_function, unicode_literals)

import numpy as np


Expand Down
4 changes: 4 additions & 0 deletions flotilla/data_model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
data model
"""

from .expression import ExpressionData
from .gene_ontology import GeneOntologyData
from .metadata import MetaData
Expand Down
24 changes: 16 additions & 8 deletions flotilla/data_model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Base data class for all data types. All data types in flotilla inherit from
this, or a child object (like ExpressionData).
"""

from __future__ import (absolute_import, division,
print_function, unicode_literals)
from six import text_type

import sys

import matplotlib.pyplot as plt
Expand All @@ -15,11 +20,13 @@
from ..compute.infotheory import binify, cross_phenotype_jsd, jsd_df_to_2d
from ..compute.predict import PredictorConfigManager, \
PredictorDataSetManager, CLASSIFIER
from ..compute.outlier import OutlierDetection

from ..visualize.decomposition import DecompositionViz
from ..visualize.generic import violinplot, simple_twoway_scatter
from ..visualize.network import NetworkerViz
from ..visualize.predict import ClassifierViz
from ..compute.outlier import OutlierDetection


MINIMUM_FEATURE_SUBSET = 20

Expand Down Expand Up @@ -1020,8 +1027,9 @@ def _violinplot(self, feature_id, sample_ids=None,
# feature_id, renamed = feature_id
# else:
# renamed = self.feature_renamer(feature_id)
title = '{}\n{}'.format(renamed, '\n'.join(
feature_id.split('@')))
# TODO check switch to unicode
# title = b'{}\n{}'.format(renamed, b'\n'.join(feature_id.split(b'@')))
title = renamed + u"\n" + u"\n".join(feature_id.split(u'@'))

violinplot(singles, groupby=phenotype_groupby, color_ordered=color,
pooled=pooled, order=phenotype_order,
Expand Down Expand Up @@ -1129,9 +1137,10 @@ def plot_two_features(self, feature1, feature2, groupby=None,
"""
feature1s = self.maybe_renamed_to_feature_id(feature1)
feature2s = self.maybe_renamed_to_feature_id(feature2)
if isinstance(feature1s, str):

if isinstance(feature1s, text_type):
feature1s = [feature1s]
if isinstance(feature2s, str):
if isinstance(feature2s, text_type):
feature2s = [feature2s]

for f1 in feature1s:
Expand All @@ -1157,8 +1166,7 @@ def plot_two_features(self, feature1, feature2, groupby=None,
@staticmethod
def _figsizer(shape, multiplier=0.25):
"""Scale a heatmap figure based on the dataframe shape"""
return tuple(reversed(map(lambda x: min(x * multiplier, 40),
shape)))
return tuple(reversed([min(x * multiplier, 40) for x in shape]))

def plot_clustermap(self, sample_ids=None, feature_ids=None, data=None,
feature_colors=None, sample_id_to_color=None,
Expand Down Expand Up @@ -1285,7 +1293,7 @@ def subsets_from_metadata(metadata, minimum, subset_type, ignore=None):
continue
name = '{}: {}'.format(col, group)
subsets[name] = grouped.groups[group]
for sample_subset in subsets.keys():
for sample_subset in subsets.copy().keys():
name = 'not ({})'.format(sample_subset)
if 'False' in name or 'True' in name:
continue
Expand Down
4 changes: 4 additions & 0 deletions flotilla/data_model/expression.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
Data types related to gene expression, e.g. from RNA-Seq or microarrays.
"""

from __future__ import (absolute_import, division,
print_function, unicode_literals)

import sys

import numpy as np
Expand Down
Loading