Skip to content

Commit

Permalink
Merge pull request #49 from KrishnaswamyLab/dev
Browse files Browse the repository at this point in the history
PHATE v0.2.9
  • Loading branch information
scottgigante authored Aug 13, 2018
2 parents 892cf33 + 08040dc commit c116e4d
Show file tree
Hide file tree
Showing 25 changed files with 159,667 additions and 153,932 deletions.
6 changes: 3 additions & 3 deletions Matlab/compute_alpha_kernel_sparse.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@

idx_thresh=find(below_thresh);

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

if ~isempty(idx_thresh2)
K2=exp(-(kdist2(idx_thresh2,:)./epsilon2(idx_thresh2)).^a);
K2=exp(-(kdist2(idx_thresh2,:)./repmat(epsilon2(idx_thresh2),1,size(kdist2,2))).^a);
K2(K2<=th)=0;
idx_notthresh=find(~below_thresh);
i2=repmat(idx_notthresh(idx_thresh2)',1,size(idx2,2));
Expand Down
6 changes: 3 additions & 3 deletions Matlab/compute_kernel_sparse.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function W = compute_kernel_sparse(data, varargin)
function [W,Wns] = compute_kernel_sparse(data, varargin)
% W = compute_kernel_sparse(data, varargin)
% computes kernel W
% varargin:
Expand Down Expand Up @@ -50,10 +50,10 @@
i = repmat((1:N)',1,size(idx,2));
i = i(:);
j = idx(:);
W = sparse(i, j, ones(size(j)));
Wns = sparse(i, j, ones(size(j)));

disp ' Symmetrize affinities'
W = W + W';
W = Wns + Wns';

disp ' Done computing kernel'

6 changes: 3 additions & 3 deletions Matlab/phate.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Y = phate(data, varargin)
function [Y, P, K] = phate(data, varargin)
% phate Run PHATE for visualizing noisy non-linear data in lower dimensions
% Y = phate(data) runs PHATE on data (rows: samples, columns: features)
% with default parameter settings and returns a 2 dimensional embedding.
Expand All @@ -20,7 +20,7 @@
% e.g. 10 or 15. Defaults to 5.
%
% 'a' - alpha of alpha decaying kernel. when a=[] knn (unweighted) kernel
% is used. Defaults to 15.
% is used. Defaults to 40.
%
% 't' - number of diffusion steps. Defaults to [] wich autmatically picks
% the optimal t.
Expand Down Expand Up @@ -85,7 +85,7 @@
distfun_mds = 'euclidean';
pot_method = 'log';
K = [];
a = 15;
a = 40;
Pnm = [];
t_max = 100;
pot_eps = 1e-7;
Expand Down
4 changes: 4 additions & 0 deletions Matlab/run_phate_DLA_tree.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
axis tight
xlabel 'PCA1'
ylabel 'PCA2'
drawnow

%% PHATE 2D
Y_PHATE_2D = phate(M, 't', 20, 'gamma', 0);
Expand All @@ -34,6 +35,7 @@
axis tight
xlabel 'PHATE1'
ylabel 'PHATE2'
drawnow

%% PHATE 3D
Y_PHATE_3D = phate(M, 'ndim', 3, 't', 20);
Expand All @@ -49,6 +51,7 @@
xlabel 'PHATE1'
ylabel 'PHATE2'
zlabel 'PHATE3'
drawnow

%% tSNE
tic;
Expand All @@ -64,6 +67,7 @@
axis tight
xlabel 'tSNE1'
ylabel 'tSNE2'
drawnow

%% plot combined
figure;
Expand Down
12 changes: 11 additions & 1 deletion Matlab/run_phate_EB.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
h = colorbar;
set(h,'xtick',1:5);
ylabel(h, 'time');
drawnow

%% PHATE 2D
Y_PHATE_2D = phate(data, 't', 20);
Expand All @@ -47,6 +48,7 @@
h = colorbar;
set(h,'xtick',1:5);
ylabel(h, 'time');
drawnow

%% PHATE 3D
Y_PHATE_3D = phate(data, 't', 20, 'ndim', 3);
Expand All @@ -62,11 +64,12 @@
xlabel 'PHATE1'
ylabel 'PHATE2'
zlabel 'PHATE3'
title 'PHATE'
title 'PHATE 3D'
h = colorbar;
set(h,'xtick',1:5);
ylabel(h, 'time');
view([-170 15]);
drawnow

%% tSNE -- slow!!!
% tic;
Expand Down Expand Up @@ -130,3 +133,10 @@
set(h,'xtick',1:5);
ylabel(h, 'time');








4 changes: 4 additions & 0 deletions Matlab/run_phate_mESC.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
title 'PCA'
h = colorbar;
ylabel(h, gene);
drawnow

%% PHATE 2D
Y_PHATE_2D = phate(M);
Expand All @@ -59,6 +60,7 @@
title 'PHATE 2D'
h = colorbar;
ylabel(h, gene);
drawnow

%% PHATE 3D
Y_PHATE_3D = phate(M, 'ndim', 3);
Expand All @@ -79,6 +81,7 @@
title 'PHATE 3D'
h = colorbar;
ylabel(h, gene);
drawnow

%% tSNE
tic;
Expand All @@ -99,6 +102,7 @@
title 'tSNE'
h = colorbar;
ylabel(h, gene);
drawnow


%% plot combined
Expand Down
4 changes: 4 additions & 0 deletions Matlab/run_phate_tree.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
axis tight
xlabel 'PCA1'
ylabel 'PCA2'
drawnow

%% PHATE 2D
Y_PHATE_2D = phate(M, 't', 32);
Expand All @@ -29,6 +30,7 @@
axis tight
xlabel 'PHATE1'
ylabel 'PHATE2'
drawnow

%% PHATE 3D
Y_PHATE_3D = phate(M, 'ndim', 3, 't', 32);
Expand All @@ -45,6 +47,7 @@
ylabel 'PHATE2'
zlabel 'PHATE3'
view([-15 20]);
drawnow

%% tSNE
tic;
Expand All @@ -60,6 +63,7 @@
axis tight
xlabel 'tSNE1'
ylabel 'tSNE2'
drawnow

%% plot combined
figure;
Expand Down
5 changes: 3 additions & 2 deletions Matlab/svdpca.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
function [pc,U,S] = svdpca(X, k, method)
function [pc,U,S,mu] = svdpca(X, k, method)

if ~exist('method','var')
method = 'svd';
end

X = bsxfun(@minus, X, mean(X));
mu = mean(X);
X = bsxfun(@minus, X, mu);

switch method
case 'svd'
Expand Down
4 changes: 3 additions & 1 deletion Python/phate/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def load_10X(data_dir, sparse=True, gene_labels='symbol'):
data : pandas.DataFrame shape=(n_cell, n_genes)
imported data matrix
"""

warnings.warn("phate.io is deprecated. Please use scprep.io instead. "
"Read more at http://scprep.readthedocs.io",
FutureWarning)
if gene_labels not in ['id', 'symbol', 'both']:
raise ValueError("gene_labels not in ['id', 'symbol', 'both']")

Expand Down
165 changes: 0 additions & 165 deletions Python/phate/logging.py

This file was deleted.

Loading

0 comments on commit c116e4d

Please sign in to comment.