in reply to Pair-Wise Clustering

I would like for the data to be in this data structure...

That doesn't explain what kind of structure you want. Create sample data structure you want, and print it with Dumper, example

#!/usr/bin/perl -- use strict; use warnings; use Data::Dumper; my( @cluster_60 ) = ( { 3 => 4 }, { 2 => 8 }, {}, {}, { 1 => 5 }, ); $cluster_60[2]{hot} = 'dog'; print Dumper( \@cluster_60); __END__ $VAR1 = [ { '3' => 4 }, { '2' => 8 }, { 'hot' => 'dog' }, {}, { '1' => 5 } ];
Data Types and Variables, References quick reference

Replies are listed 'Best First'.
Re^2: Pair-Wise Clustering
by cutcopy11 (Initiate) on Oct 01, 2009 at 01:13 UTC

    I need to write a code that determines the clusters from the table. From the table above, I would get four clusters. Cluster#1 would have 5 elements. Cluster#2 would have 3 elements. Cluster 3 and 4 would have 1 element each. I would like to stores these elements of each cluster in the form below

     $cluster_60[element]{cluster#}

    After after adding all the elements to each cluster, then the following could be obtained

     $cluster_60[0]{3} = 9

    I need some sort of hierarchial/single-linkage algorithm, but I can't find exactly what I need.

      Your word explanations aren't sinking into my brain. Is the perl data structure I showed the one you want or not?

        Yes, I believe that is the correct data structure. I have used this data structure to count occurrences of dna motifs at various positions. Say, I wanted to count and store the total occurences of A, C, G, T in 1000 nucleotide sequences that are 10 nucleotides long at each position. If you wanted a hash of arrays with the keys being A,C,G,T and the elements being positions 1 through 10, then

        $position[10]{A}

        would equal the frequency of A at position 10 if you define position 1 as element 1. ... anyway, yes, this is the data structure that I want to store the clusters in, but I still need to figure out how to write a code to determine those clusters. I am still working on it. I think that I might have figured it out, though it is quite crude.