-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsne_on_human_genes_selection_3D.m
56 lines (46 loc) · 1.45 KB
/
tsne_on_human_genes_selection_3D.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%% Perform Barnes-Hut t-SNE on human gene data
clear variables
close all
addpath('../bh-tsne');
ids = {'9861','10021','12876','14380','15496','15697'};
nbrains = length(ids);
for bnr = 1:nbrains
%% Load data (currently for a single brain)
id = ids{bnr};
datadir = ['/home/mvandegiessen/data/tSNE_ABA/rawData_25Feb2014/normalized_microarray_donor' id '/'];
expressionlevels = load([datadir 'MicroarrayExpression']);
% Load gene selection
indexdata = load([datadir 'probe2gene_index']);
allgindices = 1:size(expressionlevels.MicroarrayExpression,1);
selgenes = allgindices(indexdata.probe2gene_index>0);
ngenes = length(selgenes);
% Load gene coordinates
coordsdata = load([datadir 'sample']);
coords = [coordsdata.sample.mni_x,coordsdata.sample.mni_y,coordsdata.sample.mni_z];
%% Perform t-SNE
% Data subselection
X = expressionlevels.MicroarrayExpression';
X = X(:,selgenes);
% Perform t-SNE
perplexity = 30;
theta = 0.7;
initial_dims = min(1000,size(X,2));
mappedX = fast_tsne(X,3,initial_dims,perplexity,theta);
%% Save mapped data
save(['MappedGenesSelection3D' id],'X','mappedX','selgenes','coords',...
'initial_dims','perplexity','theta');
%% Visualize mapped data
% Colorspace
crange = max(coords)-min(coords);
mincoords = min(coords);
nsamples = size(X,1);
%
figure(1)
clf
hold on
for snr = 1:nsamples
c = (coords(snr,:)-mincoords)./crange;
plot3(mappedX(snr,1),mappedX(snr,2),mappedX(snr,3),'.','Color',c);
end
% saveas(1,'MappedGenesSelection');
end