-
Notifications
You must be signed in to change notification settings - Fork 4
/
dayNightAnalysis.m
68 lines (61 loc) · 3.23 KB
/
dayNightAnalysis.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
%-------------------------------------------------------------------------------
% ---Day/night analysis
% Runs hctsa to understand differences in fly movement between
% day and night.
%-------------------------------------------------------------------------------
%% Label, normalize, and load data:
% Set how to normalize the data:
whatNormalization = 'mixedSigmoid'; % 'zscore', 'scaledRobustSigmoid'
% Label all time series by either 'day' or 'night':
TS_LabelGroups('raw',{'day','night'});
% Normalize the data, filtering out features with any special values:
TS_Normalize(whatNormalization,[0.5,1],[],true);
% Load data in as a structure:
unnormalizedData = load('HCTSA.mat');
% Load normalized data in a structure:
normalizedData = load('HCTSA_N.mat');
% Set classification parameters:
cfnParams = GiveMeDefaultClassificationParams(unnormalizedData,2);
cfnParams.whatClassifier = 'svm_linear';
%-------------------------------------------------------------------------------
% Optionally cluster and plot a colored data matrix:
doCluster = false
if doCluster
TS_Cluster();
% reload with cluster info:
normalizedData = load('HCTSA_N.mat');
end
TS_PlotDataMatrix(normalizedData,'colorGroups',false)
%-------------------------------------------------------------------------------
%% How accurately can day versus night be classified using all features:
numNulls = 0; % (don't do any comparison to shuffled-label nulls)
TS_Classify(normalizedData,cfnParams,numNulls);
%-------------------------------------------------------------------------------
%% Generate a low-dimensional feature-based representation of the dataset:
numAnnotate = 6; % number of time series to annotate to the plot
whatAlgorithm = 'tSNE';
userSelects = true; % whether the user can click on time series to manually annotate
timeSeriesLength = 600; % length of time-series segments to annotate
annotateParams = struct('n',numAnnotate,'textAnnotation','none',...
'userInput',userSelects,'maxL',timeSeriesLength);
TS_PlotLowDim(normalizedData,whatAlgorithm,true,annotateParams,cfnParams);
%-------------------------------------------------------------------------------
%% What individual features best discriminate day from night?
% Uses 'ustat' between day/night as a statistic to score individual features
% Produces 1) a pairwise correlation plot between the top features
% 2) class distributions of the top features, with their stats
% 3) a histogram of the accuracy of all features
numTopFeatures = 40; % number of features to include in the pairwise correlation plot
numFeaturesDistr = 32; % number of features to show class distributions for
whatStatistic = 'ustat'; % rank-sum test p-value
TS_TopFeatures(normalizedData,whatStatistic,struct(),...
'numTopFeatures',numTopFeatures,...
'numFeaturesDistr',numFeaturesDistr,...
'whatPlots',{'histogram','distributions','cluster'});
%-------------------------------------------------------------------------------
%% Investigate particular individual features in some more detail
annotateParams = struct('maxL',4320);
featureID = 1752;
TS_FeatureSummary(featureID,normalizedData,true,annotateParams)
featureID = 1099;
TS_FeatureSummary(featureID,unnormalizedData,true,annotateParams)