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

Commit

Permalink
Merge pull request #32 from ManuSetty/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ManuSetty authored Sep 6, 2016
2 parents e5c3fe3 + 7d04edc commit c04fbaa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


setup(name='wishbone',
version='0.4',
version='0.4.1',
description='Wishbone algorithm for identifying bifurcating trajectories from single-cell data',
author='Manu Setty',
author_email='[email protected]',
Expand All @@ -24,7 +24,7 @@
'numpy>=1.10.0',
'pandas>=0.18.0',
'scipy>=0.14.0',
'tsne==0.1.3',
'bhtsne',
'matplotlib',
'seaborn',
'sklearn',
Expand Down
2 changes: 1 addition & 1 deletion src/wishbone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from . import wishbone_gui
from . import autocomplete_entry

__version__ = "0.4"
__version__ = "0.4.1"
19 changes: 11 additions & 8 deletions src/wishbone/wb.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
warnings.simplefilter('ignore') # catch experimental ipython widget warning
import seaborn as sns

from tsne import bh_sne
import bhtsne
from scipy.sparse import csr_matrix, find
from scipy.sparse.linalg import eigs
from numpy.linalg import norm
Expand Down Expand Up @@ -134,8 +134,9 @@ def load(cls, fin):
"""
with open(fin, 'rb') as f:
data = pickle.load(f)
scdata = cls(data['_data'], data['_metadata'])
scdata = cls(data['_data'], data['_data_type'], data['_metadata'])
del data['_data']
del data['_data_type']
del data['_metadata']
for k, v in data.items():
setattr(scdata, k[1:], v)
Expand Down Expand Up @@ -290,7 +291,7 @@ def from_fcs(cls, fcs_file, cofactor=5,
data = data[data_channels]

# Transform if necessary
if cofactor is not None or cofactor > 0:
if cofactor is not None and cofactor > 0:
data = np.arcsinh(np.divide( data, cofactor ))

# Create and return scdata object
Expand Down Expand Up @@ -411,12 +412,14 @@ def run_tsne(self, n_components=15, perplexity=30):
index=self.data.index)

# Reduce perplexity if necessary
data = data.astype(np.float64)
perplexity_limit = 15
if data.shape[0] < 100 and perplexity > perplexity_limit:
print('Reducing perplexity to %d since there are <100 cells in the dataset. ' % perplexity_limit)
perplexity = perplexity_limit
self.tsne = pd.DataFrame(bh_sne(data, perplexity=perplexity),
index=self.data.index, columns=['x', 'y'])
self.tsne = pd.DataFrame(bhtsne.tsne(data, perplexity=perplexity),
index=self.data.index, columns=['x', 'y'])


def plot_tsne(self, fig=None, ax=None, title='tSNE projection'):
"""Plot tSNE projections of the data
Expand Down Expand Up @@ -780,8 +783,8 @@ def plot_gene_component_correlations(

@staticmethod
def _gmt_options():
mouse_options = os.listdir(os.path.expanduser('~/.seqc/tools/mouse'))
human_options = os.listdir(os.path.expanduser('~/.seqc/tools/human'))
mouse_options = os.listdir(os.path.expanduser('~/.wishbone/tools/mouse'))
human_options = os.listdir(os.path.expanduser('~/.wishbone/tools/human'))
print('Available GSEA .gmt files:\n\nmouse:\n{m}\n\nhuman:\n{h}\n'.format(
m='\n'.join(mouse_options),
h='\n'.join(human_options)))
Expand Down Expand Up @@ -861,7 +864,7 @@ def run_gsea(self, output_stem, gmt_file=None,
else:
if not len(gmt_file) == 2:
raise ValueError('gmt_file should be a tuple of (organism, filename).')
gmt_file = os.path.expanduser('~/.seqc/tools/{}/{}').format(*gmt_file)
gmt_file = os.path.expanduser('~/.wishbone/tools/{}/{}').format(*gmt_file)

if components is None:
components = self.diffusion_map_correlations.columns
Expand Down

0 comments on commit c04fbaa

Please sign in to comment.