Skip to content

Commit c116e4d

Browse files
authored
Merge pull request #49 from KrishnaswamyLab/dev
PHATE v0.2.9
2 parents 892cf33 + 08040dc commit c116e4d

25 files changed

+159667
-153932
lines changed

Matlab/compute_alpha_kernel_sparse.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969

7070
idx_thresh=find(below_thresh);
7171

72-
if ~isempty(idx_thresh)
73-
K=exp(-(kdist(idx_thresh,:)./epsilon(idx_thresh)).^a);
72+
if ~isempty(idx_thresh)
73+
K=exp(-(kdist(idx_thresh,:)./repmat(epsilon(idx_thresh),1,size(kdist,2))).^a);
7474
K(K<=th)=0;
7575
K=K(:);
7676
i = repmat(idx_thresh',1,size(idx,2));
@@ -94,7 +94,7 @@
9494
idx_thresh2=find(below_thresh2);
9595

9696
if ~isempty(idx_thresh2)
97-
K2=exp(-(kdist2(idx_thresh2,:)./epsilon2(idx_thresh2)).^a);
97+
K2=exp(-(kdist2(idx_thresh2,:)./repmat(epsilon2(idx_thresh2),1,size(kdist2,2))).^a);
9898
K2(K2<=th)=0;
9999
idx_notthresh=find(~below_thresh);
100100
i2=repmat(idx_notthresh(idx_thresh2)',1,size(idx2,2));

Matlab/compute_kernel_sparse.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function W = compute_kernel_sparse(data, varargin)
1+
function [W,Wns] = compute_kernel_sparse(data, varargin)
22
% W = compute_kernel_sparse(data, varargin)
33
% computes kernel W
44
% varargin:
@@ -50,10 +50,10 @@
5050
i = repmat((1:N)',1,size(idx,2));
5151
i = i(:);
5252
j = idx(:);
53-
W = sparse(i, j, ones(size(j)));
53+
Wns = sparse(i, j, ones(size(j)));
5454

5555
disp ' Symmetrize affinities'
56-
W = W + W';
56+
W = Wns + Wns';
5757

5858
disp ' Done computing kernel'
5959

Matlab/phate.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function Y = phate(data, varargin)
1+
function [Y, P, K] = phate(data, varargin)
22
% phate Run PHATE for visualizing noisy non-linear data in lower dimensions
33
% Y = phate(data) runs PHATE on data (rows: samples, columns: features)
44
% with default parameter settings and returns a 2 dimensional embedding.
@@ -20,7 +20,7 @@
2020
% e.g. 10 or 15. Defaults to 5.
2121
%
2222
% 'a' - alpha of alpha decaying kernel. when a=[] knn (unweighted) kernel
23-
% is used. Defaults to 15.
23+
% is used. Defaults to 40.
2424
%
2525
% 't' - number of diffusion steps. Defaults to [] wich autmatically picks
2626
% the optimal t.
@@ -85,7 +85,7 @@
8585
distfun_mds = 'euclidean';
8686
pot_method = 'log';
8787
K = [];
88-
a = 15;
88+
a = 40;
8989
Pnm = [];
9090
t_max = 100;
9191
pot_eps = 1e-7;

Matlab/run_phate_DLA_tree.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
axis tight
2222
xlabel 'PCA1'
2323
ylabel 'PCA2'
24+
drawnow
2425

2526
%% PHATE 2D
2627
Y_PHATE_2D = phate(M, 't', 20, 'gamma', 0);
@@ -34,6 +35,7 @@
3435
axis tight
3536
xlabel 'PHATE1'
3637
ylabel 'PHATE2'
38+
drawnow
3739

3840
%% PHATE 3D
3941
Y_PHATE_3D = phate(M, 'ndim', 3, 't', 20);
@@ -49,6 +51,7 @@
4951
xlabel 'PHATE1'
5052
ylabel 'PHATE2'
5153
zlabel 'PHATE3'
54+
drawnow
5255

5356
%% tSNE
5457
tic;
@@ -64,6 +67,7 @@
6467
axis tight
6568
xlabel 'tSNE1'
6669
ylabel 'tSNE2'
70+
drawnow
6771

6872
%% plot combined
6973
figure;

Matlab/run_phate_EB.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
h = colorbar;
3131
set(h,'xtick',1:5);
3232
ylabel(h, 'time');
33+
drawnow
3334

3435
%% PHATE 2D
3536
Y_PHATE_2D = phate(data, 't', 20);
@@ -47,6 +48,7 @@
4748
h = colorbar;
4849
set(h,'xtick',1:5);
4950
ylabel(h, 'time');
51+
drawnow
5052

5153
%% PHATE 3D
5254
Y_PHATE_3D = phate(data, 't', 20, 'ndim', 3);
@@ -62,11 +64,12 @@
6264
xlabel 'PHATE1'
6365
ylabel 'PHATE2'
6466
zlabel 'PHATE3'
65-
title 'PHATE'
67+
title 'PHATE 3D'
6668
h = colorbar;
6769
set(h,'xtick',1:5);
6870
ylabel(h, 'time');
6971
view([-170 15]);
72+
drawnow
7073

7174
%% tSNE -- slow!!!
7275
% tic;
@@ -130,3 +133,10 @@
130133
set(h,'xtick',1:5);
131134
ylabel(h, 'time');
132135

136+
137+
138+
139+
140+
141+
142+

Matlab/run_phate_mESC.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
title 'PCA'
4242
h = colorbar;
4343
ylabel(h, gene);
44+
drawnow
4445

4546
%% PHATE 2D
4647
Y_PHATE_2D = phate(M);
@@ -59,6 +60,7 @@
5960
title 'PHATE 2D'
6061
h = colorbar;
6162
ylabel(h, gene);
63+
drawnow
6264

6365
%% PHATE 3D
6466
Y_PHATE_3D = phate(M, 'ndim', 3);
@@ -79,6 +81,7 @@
7981
title 'PHATE 3D'
8082
h = colorbar;
8183
ylabel(h, gene);
84+
drawnow
8285

8386
%% tSNE
8487
tic;
@@ -99,6 +102,7 @@
99102
title 'tSNE'
100103
h = colorbar;
101104
ylabel(h, gene);
105+
drawnow
102106

103107

104108
%% plot combined

Matlab/run_phate_tree.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
axis tight
1717
xlabel 'PCA1'
1818
ylabel 'PCA2'
19+
drawnow
1920

2021
%% PHATE 2D
2122
Y_PHATE_2D = phate(M, 't', 32);
@@ -29,6 +30,7 @@
2930
axis tight
3031
xlabel 'PHATE1'
3132
ylabel 'PHATE2'
33+
drawnow
3234

3335
%% PHATE 3D
3436
Y_PHATE_3D = phate(M, 'ndim', 3, 't', 32);
@@ -45,6 +47,7 @@
4547
ylabel 'PHATE2'
4648
zlabel 'PHATE3'
4749
view([-15 20]);
50+
drawnow
4851

4952
%% tSNE
5053
tic;
@@ -60,6 +63,7 @@
6063
axis tight
6164
xlabel 'tSNE1'
6265
ylabel 'tSNE2'
66+
drawnow
6367

6468
%% plot combined
6569
figure;

Matlab/svdpca.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
function [pc,U,S] = svdpca(X, k, method)
1+
function [pc,U,S,mu] = svdpca(X, k, method)
22

33
if ~exist('method','var')
44
method = 'svd';
55
end
66

7-
X = bsxfun(@minus, X, mean(X));
7+
mu = mean(X);
8+
X = bsxfun(@minus, X, mu);
89

910
switch method
1011
case 'svd'

Python/phate/io.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def load_10X(data_dir, sparse=True, gene_labels='symbol'):
5858
data : pandas.DataFrame shape=(n_cell, n_genes)
5959
imported data matrix
6060
"""
61-
61+
warnings.warn("phate.io is deprecated. Please use scprep.io instead. "
62+
"Read more at http://scprep.readthedocs.io",
63+
FutureWarning)
6264
if gene_labels not in ['id', 'symbol', 'both']:
6365
raise ValueError("gene_labels not in ['id', 'symbol', 'both']")
6466

Python/phate/logging.py

Lines changed: 0 additions & 165 deletions
This file was deleted.

0 commit comments

Comments
 (0)