Skip to content

Commit

Permalink
Merge pull request #59 from brianhie/matplotlib_backend
Browse files Browse the repository at this point in the history
remove changes to matplotlib defaults
  • Loading branch information
brianhie authored Mar 29, 2020
2 parents a437be5 + 6200ade commit f2435c4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
11 changes: 6 additions & 5 deletions bin/mouse_brain_sketched.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,28 @@

datasets = datasets_merged

labels = []
names = []
curr_label = 0
for i, a in enumerate(datasets_dimred):
labels += list(np.zeros(a.shape[0]) + curr_label)
names.append(data_names[i])
curr_label += 1
labels = np.array(labels, dtype=int)

mouse_brain_genes = [
'Gja1', 'Flt1', 'Gabra6', 'Syt1', 'Gabrb2', 'Gabra1',
'Meg3', 'Mbp', 'Rgs5',
]

# Downsample for visualization purposes
rand_idxs = []
labels = []
curr_label = 0
for i in range(len(data_names)):
ds = datasets_dimred[i]
rand_idx = np.random.choice(ds.shape[0], size=int(ds.shape[0]/10),
replace=False)
datasets_dimred[i] = ds[rand_idx, :]
datasets[i] = datasets[i][rand_idx, :]
labels += list(np.zeros(datasets_dimred[i].shape[0]) + curr_label)
curr_label += 1
labels = np.array(labels, dtype=int)

embedding = visualize(datasets_dimred,
labels, NAMESPACE + '_ds', names,
Expand Down
2 changes: 1 addition & 1 deletion scanorama/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .scanorama import *

__version__ = 1.5
__version__ = 1.5.1
13 changes: 5 additions & 8 deletions scanorama/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import errno
from fbpca import pca
import matplotlib as mpl
mpl.rcParams['figure.figsize'] = [10.0, 9.0]
mpl.use('Agg')
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
Expand All @@ -22,7 +19,7 @@ def dispersion(X):
dispersion[mean > 1e-10] = temp.A1
dispersion[mean <= 1e-10] = float('-inf')
return dispersion

def reduce_dimensionality(X, dim_red_k=100):
k = min((dim_red_k, X.shape[0], X.shape[1]))
U, s, Vt = pca(X, k=k) # Automatically centers.
Expand All @@ -48,16 +45,16 @@ def visualize_cluster(coords, cluster, cluster_labels,
c=colors[1], s=size)
plt.title(str(cluster_name))
plt.savefig(image_fname, dpi=500)

def visualize_expr(X, coords, genes, viz_gene, image_suffix='.svg',
new_fig=True, size=1, viz_prefix='ve'):
genes = [ gene.upper() for gene in genes ]
viz_gene = viz_gene.upper()

if not viz_gene.upper() in genes:
sys.stderr.write('Warning: Could not find gene {}\n'.format(viz_gene))
return

image_fname = '{}_{}{}'.format(
viz_prefix, viz_gene, image_suffix
)
Expand Down Expand Up @@ -111,7 +108,7 @@ def visualize_dropout(X, coords, image_suffix='.svg',
plt.scatter(coords[:, 0], coords[:, 1],
c=colors, cmap=cm.get_cmap('Reds'), s=size)
plt.savefig(image_fname, dpi=500)

def mkdir_p(path):
try:
os.makedirs(path)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

setup(
name='scanorama',
version='1.5',
version='1.5.1',
description='Panoramic stitching of heterogeneous single cell transcriptomic data',
url='https://github.com/brianhie/scanorama',
download_url='https://github.com/brianhie/scanorama/archive/v1.5.tar.gz',
download_url='https://github.com/brianhie/scanorama/archive/v1.5.1.tar.gz',
packages=find_packages(exclude=['bin', 'conf', 'data', 'target']),
install_requires=[
'annoy>=1.11.5',
Expand Down

0 comments on commit f2435c4

Please sign in to comment.