-
Notifications
You must be signed in to change notification settings - Fork 4
/
flyInTubeAnalysis.m
69 lines (61 loc) · 2.7 KB
/
flyInTubeAnalysis.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
57
58
59
60
61
62
63
64
65
66
67
68
69
%-------------------------------------------------------------------------------
% Time-series similarity matrix
%-------------------------------------------------------------------------------
TS_Normalize('scaledRobustSigmoid',[0.5,1]);
% Pairwise distances:
Dij = TS_PairwiseDist('ts','norm','euclidean');
% Order by individual, which have a unique experiment and ROI ID combination:
load('HCTSA_N.mat','TimeSeries');
[expID,recordingSegment] = getExperimentID(TimeSeries);
[expID,ix] = sort(expID);
recordingSegment = recordingSegment(ix);
% Re-sort by recording segment:
uExpID = unique(expID);
ix2 = 1:length(TimeSeries);
for i = 1:length(uExpID)
tmp = ix2(expID==i);
[~,ix_tmp] = sort(recordingSegment(expID==i));
ix2(expID==i) = tmp(ix_tmp);
end
ixTot = ix(ix2);
Dij = squareform(Dij);
Dij_sorted = Dij(ixTot,ixTot);
unitRescale = @(x) (x-min(x))/(max(x)-min(x));
BF_PlotCorrMat([repmat(unitRescale(expID),1,100)*max(Dij(:)),Dij],'auto',true);
%-------------------------------------------------------------------------------
% Individual classification
%-------------------------------------------------------------------------------
regIDs = TS_LabelGroups({'reg2','reg4','reg6','reg8','reg10','reg11','reg13','reg15','reg17','reg19'},'raw',0)';
load('HCTSA.mat','TimeSeries');
[expIDs,recordingSegment] = getExperimentID(TimeSeries);
combID = 100*expIDs+regIDs; % 14 exps and 10 regs
[~,~,indLabels] = unique(combID);
% Make a cell version of group indices (to use cell2struct)
theGroupsCell = cell(1,length(TimeSeries));
for i = 1:length(theGroupsCell)
theGroupsCell{i} = indLabels(i);
end
groupNames = cell(max(indLabels),1);
for j = 1:max(indLabels)
groupNames{j} = num2str(j);
end
LabelBy(theGroupsCell,groupNames,TimeSeries,'HCTSA.mat');
TS_Normalize('scaledRobustSigmoid',[0.5,1]);
%-------------------------------------------------------------------------------
% Classification of region (tube ID) -- shouldn't be much of a signal
%-------------------------------------------------------------------------------
TS_LabelGroups('raw',{'reg2','reg4','reg6','reg8','reg10','reg11','reg13','reg15','reg17','reg19'});
normHow = 'zscore'; % 'none', 'scaledRobustSigmoid', 'zscore'
TS_Normalize(normHow,[0.5,1],[],1);
TS_Classify('norm')
TS_PlotLowDim('norm','tSNE');
TS_Normalize('none',[0.5,1],[],1);
TS_TopFeatures('norm','ustat','numFeaturesDistr',40)
%-------------------------------------------------------------------------------
% Effect of day number?
%-------------------------------------------------------------------------------
TS_LabelGroups('raw',{'day1','day2','day3','day4','day5'});
TS_Normalize('scaledRobustSigmoid',[0.5,1]);
TS_Classify('norm')
TS_PlotLowDim('norm','tSNE');
TS_TopFeatures('norm','ustat')