#!/usr/perl/perl580/bin/perl use Algorithm::Cluster; open (DATA, "$ARGV[0]"); my $firstline = ; # Skip the title line ## while(my $line = ) { chomp $line; @field = split /\t/, $line; $patient_id[$i] = shift @field; $patient_class[$i] = shift @field; $j = 0; $patient_data[$i] = [ @field ]; #this is the where the data will be stored; the "[]" around #the array indicates the creationof a matrix to perl. print ("Patient $patient_id[$i] is $patient_class[$i]\n"); $i++; } ## The code below is useful to check if the matrix in line 23 is correct; ## it's needed only in new datasets to check if the work is right. #$i = 0; #for $i (0..$#patient_data) { # for $j (0..$#{$patient_data[$i]}) { # print ("\t Element $i $j is $patient_data[$i][$j]\n"); # } #} ## The hash generated below is the input to the subroutine ## treecluster; for more information about the meaning of ## the paramenters please read http://bonsai.ims.u-tokyo.ac.jp/~mdehoon/software/cluster/cluster.pdf my %params = ( transpose => 0, dist => 'e', data => \@patient_data, mask => '', weight => '', niter => 10, ); my ($clusterid); my ($i); $clusterid = Algorithm::Cluster::somcluster(%params); $i=0; foreach(@{$clusterid}) { printf("Patient %2d assigned to cell (%2d,%2d)\n",$i++,$_->[0],$_->[1]); }