Sagar Adhurya
Sagar Adhurya

Reputation: 3

How to add cluster border in the component plot generated by SOM toolbox in Matlab?

I have trained a SOM model using som_make function in Matlab. I have classified the SOM codes using hierarchical clustering. According to this, I can make cluster plot using the code:som_cplane(sM, clusterIndices); where sM is the trained map and clusterIndices is the variable containing cluster information of the SOM. Here is the full code:

data = readtable('data.csv');

% Display the first few rows of the table
selected_columns = {'Species', 'MBL', 'BEL', 'VEP', 'RES', 'BLS', 'TL'};
data = data(:, selected_columns); % select some particular columns
data1 = table2array(data(:, 2:end)); % convert to matrix or double type
sD = som_data_struct(data1, 'name', 'fish', 'comp_names', {'MBL', 'BEL', 'VEP', 'RES', 'BLS', 'TL'});
sD.labels = data(:, 1); % set labels
sD = som_normalize(sD, 'var'); % normalize
sM = som_make(sD); % train

Z = linkage(sM.codebook, 'ward', 'euclidean');
numClusters = 6;
clusterIndices = cluster(Z, 'maxclust', numClusters);
som_cplane(sM,clusterIndices); %cluster map

Now if I can get component plot using the code:

som_show(sM,'comp',1:6, 'norm', 'd');

I want to add cluster border around each cluster in these component plot to make it more clear. I can perform similar job in R using the command add.cluster.boundaries(sM, clusterIndices). But, how can I achieve similar thing in Matlab? I will remain thankful to anyone if he/she can write code regarding this. I am a biologist and just beginner in programming.

I have tried the component plot as shown below: Component plot

However, I want to make it like this: component plot with cluster border

Upvotes: 0

Views: 20

Answers (0)

Related Questions