# Beta diversity within a group

Hi,

Anyone knows how i can calculate Beta diversity within the same group? For example i have 2 groups, one control and one of diabetes patients and i would like to know beta diversity within each group.

Hi @annsantos,

Like, you want to extract the within-group distances? The average within-group beta diversity? A PCoA of only those samples?

I would recommend that you use your full beta diversity table and then use `qiime diversity filter-distance-matrix` to select your samples. (You donâ€™t need to re-calculate). And then, you can do whatever you want to do with that.

Best,
Justine

2 Likes

Hi @jwdebelius,
Thank you for your reply. Yes, i want to know beta diversity of my control group and then of my diabetes patients . I donâ€™t want to compare my groups, i want to look each group individually .

What do you mean with â€śfull beta diversity tableâ€ť? How do i get that?

The â€śfull beta diversity tableâ€ť (or if Im more accurate, the full distance matrix) is the distance matrix that you calculate for all your samples. It saves you computational time if you calculate this once for all your samples and then filter it using the command I described above.

Best,
Justine

2 Likes

what youâ€™re saying is using this, for example ? â€ścore-metrics-results/bray_curtis_distance_matrix.qzaâ€ť

1 Like

There is a way to do inter- and intra- group beta-diversity in phyloseq. I think thereâ€™s been some code written on it. See this: https://github.com/joey711/phyloseq/issues/963

Ben

1 Like

Yes, thatâ€™s your distance matrix object. And then you can feed it into filter distance matrix and youâ€™ll get the distances for your groups. Its useful if you want to run a stratified analysis - check, for example, if thereâ€™s an effect of age on community structure.

Iâ€™m still pretty firmly in the camp that within-group beta diversity doesnâ€™t do you much without a point of comparison. So, like, is within 1 different from within another (although perhaps worth noting that there is some difference of opinion on where you can make this comparison.)

Best,
Justine

3 Likes

So, with qiime it is not possible to calculate beta diversity (within a group) without a point of comparison?

1 Like

Beta diversity, as an abstract concept, is the distance between two communities (samples). So, from the abstract standpoint, yes, QIIME calculates beta diversity agnostic to whatever sample labels we put on. Which is why you can calculate your distance matrix in core diversity and then do whatever you want with it.

My question is what your goal is with the within-group beta diversity. Do you want a PCoA? A stratified sensitivity analysis? A number to rule them all that says this is my beta diversity ? Because those are really different intra-group beta diversity things and figuring out what you mean here depends on what the best approach is.

One of the problems you run into is that beta diversity does best in a frame of reference. With geographical distance (my favorite analogy), you have a sense of what 3 km means in real and concrete terms. So, if all the landmarks in the city center are all no more than 3 km away from eachother, that boundary has real meaning. One of the issues with beta diversity from that perspective is that not only do the numbers not have units, they sometimes lack context.

And so, my question is what context you want to use for your within-group comparison and what answer you want out.

5 Likes

Yes, you are right. I was confused. What i wanted to do was to see beta diversity in my groups, so my point of comparison would be groups (control x diseased) . So, i think that i have to do something like this:

qiime diversity beta-group-significance
â€“i-distance-matrix core-metrics-results/Braycurtis_distance_matrix.qza
â€“o-visualization core-metrics-results/Braycurtis-group-significance.qzv

Right?

Thank you

1 Like

Yeah, I would use a permanova (as youâ€™ve shown) to test for significance.
And, figuring out this stuff and what you want test you want to show what you want to show? I spend hours trying to work through this stuff.

Best,
Justine

I am not sure if i understood what you mean but, basically, i wanted to see if my groups (control x diseased) had a different beta diversity and then, to see if the differences within goups were smaller then between groups.

I know, i am new with this stuff and sometimes i spend almost half aday to figure things out. I am so glad for this forum

2 Likes

``````qiime diversity beta-group-significance
â€“i-distance-matrix core-metrics-results/Braycurtis_distance_matrix.qza
â€“o-visualization core-metrics-results/Braycurtis-group-significance.qzv
``````

This will be a permdisp (just add the `--p-methods permdisp`) flag to your command and save as a different artifact

``````qiime diversity beta-group-significance
--i-distance-matrix core-metrics-results/Braycurtis_distance_matrix.qza \
--p-method permdisp
--o-visualization core-metrics-results/Braycurtis-group-significance-permdisp.qzv
``````

Best,
Justine

2 Likes

Right,

But, permdisp it is only used when p value is <0.05 in permanova right? To rule out differences due to a high degree of dispersion (within-group variance) in one of the groups of interest.?

That would be a good time to run permdisp. I tend to run them together, because it makes my life easier.

Best,
Justine

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.