Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/KrishnaswamyLab/PHATE into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdijk committed Jun 7, 2018
2 parents 2f9b9e6 + 78b8da4 commit 7a4ecd0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 84 deletions.
1 change: 1 addition & 0 deletions Python/phate/phate.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ def fit(self, X):
precomputed = "distance"
else:
precomputed = "affinity"
log_info("Using precomputed {} matrix...".format(precomputed))
n_pca = None
else:
precomputed = None
Expand Down
18 changes: 15 additions & 3 deletions Python/phate/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ def library_size_normalize(data, verbose=False):
if verbose:
print("Normalizing library sizes for %s cells" % (data.shape[0]))

# pandas support
columns, index = None, None
try:
if isinstance(data, pd.SparseDataFrame):
data = data.to_coo()
elif pd.api.types.is_sparse(data):
if isinstance(data, pd.SparseDataFrame) or \
pd.api.types.is_sparse(data):
columns, index = data.columns, data.index
data = data.to_coo()
elif isinstance(data, pd.DataFrame):
columns, index = data.columns, data.index
except NameError:
pass
except AttributeError as e:
Expand Down Expand Up @@ -76,4 +80,12 @@ def library_size_normalize(data, verbose=False):
# axis = 1 independently normalizes each sample

data_norm = data_norm * median_transcript_count
if columns is not None:
# pandas dataframe
if sparse.issparse(data_norm):
data_norm = pd.SparseDataFrame(data_norm, default_fill_value=0)
else:
data_norm = pd.DataFrame(data_norm)
data_norm.columns = columns
data_norm.index = index
return data_norm
2 changes: 1 addition & 1 deletion phateR
80 changes: 0 additions & 80 deletions test/phate_test_tree.py

This file was deleted.

0 comments on commit 7a4ecd0

Please sign in to comment.