cluster_data function

Cluster data using hierarchical clustering or use provided clustering.