Skip to content

Commit 8639b7e

Browse files
last error main commit
1 parent 9ff8854 commit 8639b7e

File tree

6 files changed

+580
-99708
lines changed

6 files changed

+580
-99708
lines changed

plankton/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# from plankton import *
22
# from stats import *
3-
3+
import plankton

plankton/graph.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import pandas as pd
1515
from scipy.stats import binom
16+
from sklearn.decomposition import PCA
1617

1718
from sklearn.neighbors import NearestNeighbors
1819

@@ -235,7 +236,7 @@ def kernel(x): return np.exp(-x**2/(2*bandwidth**2))
235236
] += kernel(self.distances[:, i])
236237
return counts
237238

238-
def run_umap(self, bandwidth=1, kernel=None, metric='euclidean', zero_weight=1.0, *args, **kwargs):
239+
def run_umap(self, bandwidth=1, kernel=None, metric='euclidean', zero_weight=1.0, cutoff = 30, *args, **kwargs):
239240
"""run_umap: Creates a UMAP representation of recurring local contexts in the source data.
240241
241242
:param bandwidth: Bandwidth of the default Gaussian kernel used to build local environment models, defaults to 1
@@ -252,9 +253,15 @@ def run_umap(self, bandwidth=1, kernel=None, metric='euclidean', zero_weight=1.0
252253
assert (all(counts.sum(1)) > 0)
253254
counts[np.arange(len(self.sdata)),
254255
self.sdata.gene_ids] += zero_weight-1
255-
256+
257+
pca=PCA()
258+
facs = pca.fit_transform(counts)
259+
260+
facs_ = facs[:,:cutoff]
261+
facs_[:,-1]=facs[:,cutoff:].sum(1)
262+
256263
umap = UMAP(metric=metric, *args, **kwargs)
257-
self._umap = umap.fit_transform(counts)
264+
self._umap = umap.fit_transform(facs_)
258265

259266
def plot_umap(self, color_prop='genes', text_prop=None,
260267
text_color_prop=None, c=None, color=None, color_dict=None, text_distance=1,
@@ -526,10 +533,10 @@ def map_and_umap(self, color_prop=None, scalebar=True, cmap='jet',
526533

527534
ax1 = plt.subplot2grid((3, 2), (0, 0), 2, 1)
528535

529-
sc2, _, _ = self.sdata.scatter(axd=ax1,scalebar=scalebar, ** kwargs)
536+
sc2, _, _ = self.sdata.scatter(axd=ax1,scalebar=scalebar,cmap=cmap, ** kwargs)
530537

531538
ax2 = plt.subplot2grid((3, 2), (0, 1), 2, 1)
532-
self.sdata.graph.plot_umap(**kwargs)
539+
self.sdata.graph.plot_umap(cmap=cmap,**kwargs)
533540

534541

535542

plankton/plankton.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,11 @@
2323
import matplotlib.patheffects as PathEffects
2424
from matplotlib import pyplot as plt
2525

26-
# from typing import Union
27-
# from cgitb import text
28-
# from enum import unique
29-
# from hashlib import new
30-
# from msilib import add_data
31-
# from turtle import color
3226

3327
import warnings
3428
warnings.simplefilter(action='ignore', category=UserWarning)
3529

3630

37-
# from sklearn.manifold import TSNE
3831

3932
plt.style.use('dark_background')
4033
matplotlib.rcParams['figure.figsize'] = (15, 15)

0 commit comments

Comments
 (0)