0

I am trying to assess how long a change in stream communities persists following invasive species removals. Community was assessed in a series of streams before and at several time points after the removal. I would like to calculate dissimilarity between the community immediately before and at each time point following removal (i.e. between pre and post 1, pre and post 2, pre and post 3, etc.), then analyze these values across time to determine how long it takes for streams communities to return to pre-removal conditions. Differences in stream parameters are expected to influence the process, so I need to do this by stream. I'm picturing a plot with time on the x axis, dissimilarity on the y axis, and a different function for each stream. Is there a way to pull just these dissimilarity values out of a bray curtis matrix?

This is my first question, I apologize for any missing information or lack of clarity.

  • Can you inform what have you done? Also a quick search on Google returns this - http://cc.oulu.fi/~jarioksa/softhelp/vegan/html/vegdist.html Is it what you want? – Jaehyeon Kim Dec 08 '18 at 00:35
  • I've already run vegdist on the data to get the Bray Curtis values and the answer below solved my problem of how to get particular values out. I'm just not sure how to identify which dissimilarity values within the matrix to know which ones to pull. – Avery Scherer Dec 10 '18 at 15:43

1 Answers1

1

If you convert the output from vegdist() to a matrix then you can easily pull out the dissimilarities between pairs of samples, using rownames or indices of the matrix to extract what you want.

To convert to a matrix use

distmat <- as.matrix(bc_obj)

where bc_obj is the object returned from vegdist() containing the Bray Curtis distances.

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453
  • Thanks, that was super helpful. However, since the labels aren't included in the matrix, I'm having trouble identifying which values I want to pull. Do you have any references on how the matrix gets constructed (i.e. which combinations of date and site are compared for the dissimilarity between 1 and 3) or know how to label the matrix itself? – Avery Scherer Dec 10 '18 at 15:42
  • @AveryScherer If you have rownames on the data frame passed to `vegdist()` they should be preserved and present when you convert to a matrix. – Gavin Simpson Dec 10 '18 at 16:56