Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
jpm-behavior/variable_hclust.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 lines (42 sloc)
1.75 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [] = variable_hclust(dirstring, labels, c, Xc, pc, beh_type) | |
% This function performs Ward Hierarchical cluastering on the data | |
% and takes as paramters: | |
% dirstring: string indicating the directory | |
% labels: in the order that they are in the dataset | |
% c: clock to help save out this figure's unique string | |
% Xc: the cleaned predictor variable matrix for the population | |
% pc: the (numeric) IDs for each person | |
% beh_type: the type of behavior (AGG, SIB, or BOTH) | |
% Figure setup - 1/3 of screen size | |
set(0,'DefaultTextInterpreter','none') | |
screen_size = get(0, 'Screensize'); | |
screen_size(4) = screen_size(4) / 3; | |
FigH = figure('Position', screen_size); | |
e1 = load(strcat(dirstring,'/',beh_type,'people2.mat')); | |
e1 = e1.eligible_people; | |
e2 = load(strcat(dirstring,'/',beh_type,'people2_highacc.mat')); | |
e2 = e2.high_accs; | |
% Run the clustering for only the high-accuracy individuals | |
data = Xc(ismember(pc,e1),:);%(e2)),:); | |
% Z-score this subpopulation | |
X0 = zscore(data); | |
% Get linkage matrix and plot dendrogram | |
Z = linkage(X0','ward'); | |
[H, p, outperm] = dendrogram(Z,0); | |
% Set axis labels and parameters | |
ax = gca; | |
ax.XAxis.TickLength = [0 0]; | |
ax.FontSize= 12; | |
title(strcat(" Ward Variable Hierarchical Clustering of data,", ... | |
" >80% BCR for ",beh_type)) | |
ylabel('Distance') | |
set(gca,'TickLabelInterpreter', 'none'); | |
% Set the x labels to the permutation from the clustering | |
xticklabels(labels(outperm)) | |
xtickangle(45) | |
% Save out figure | |
fig = 0; | |
set( findall(fig, '-property', 'fontname'), 'fontname',... | |
'Palatino Linotype') | |
saveas(FigH, strcat(dirstring,'/',beh_type,c,'_hclust.png'),'png'); | |
end | |