User Tools

Site Tools


en:mix:doubs-cluster

FIXME: has multiple issues - first combines hier and nonhier cluster analysis, second the k-means clustering has obviously trouble. FIX!

Use the Doubs river fish dataset.

  1. Import the data into R (import species matrix DoubsSpe.txt and spatial matrix DoubsSpa.txt. Spatial matrix contains x and y geographical coordinates of each sample). The names of variables in R will be doubs.spe for species matrix and doubs.spa for spatial matrix.
  2. Remove empty sample number 8 from both datasets (it contains no species).
  3. Calculate hierarchical cluster analysis of species data. Use Euclidean distance and Ward method.
  4. Draw the resulting dendrogram, in which you display boxes around 4 groups. Rectangle for each group will have different color!
  5. Calculate non-hierarchical cluster analysis of species data. Use Bray-Curtis distance and k means method to define 4 clusters.
  6. Draw the figure with spatial distribution of the samples (use the dataset with spatial data), where each sample will have different symbol and color according to the result of hierarchical cluster analysis (Euclidean distance and Ward clustering algorithm).
  7. Draw the same diagram, but use the results of k-means clustering.

For hints click here ☛

For hints click here ☛

  1. read.delim
  2. doubs.spe[-8,] will produce dataframe without the row number 8 - but you need to assign it to some variable and do the same with doubs.spa variable
  3. hclust, dist
  4. plot, rect.hclust (argument border, which means the color of the rectangle, will be vector of four numbers or color names
  5. kmeans, vegdist
  6. cutree, plot, where x and y variables, respectively, will be the first and second column from the object doubs.spa. Type of the symbol is modified by the argument pch, color by col. Result of cutree (vector of assignment of each sample into cluster) will be assigned to pch and col argument! If you use type = “b” '' argument in ''plot function, the sample points will be connected by line.
  7. the same as previous, just no cutree - the assignment of samples into cluster is in k means method stored in variable cluster, which is a part of the output object (list) calculated by kmeans function.

Solution

en/mix/doubs-cluster.txt · Last modified: by David Zelený

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki