Bio-Community
view release on metacpan or search on metacpan
lib/Bio/Community/Meta/Beta.pm view on Meta::CPAN
}
if ($j > $min_permuted) {
# Member rank in second community conflicts with minimum permutation
# assumption. Increase minimum permutation.
$min_permuted = $j;
}
# Finish if the permutation limit has been reached without conflicts
last if $i >= $min_permuted;
}
if (defined $min_permuted) {
if ($min_permuted == 1) {
$min_permuted--;
}
$min_permuted = $min_permuted / $community1->get_richness * 100;
}
return $min_permuted;
}
method _maxiphi ($meta) {
# Given S, the fraction shared, and P, the fraction permuted, calculate the
# MaxiPhi beta diversity M as:
# M = 1 - S*(2-P)/2
#
# M ranges from 0 (low beta diversity, similar communities), to 1 (high beta
# diversity, dissimilar communities). The weight of the percent permuted
# parameter is proportional to the percent shared. At 0% shared, the fraction
# permuted has no weight in the index, while at 100% shared, the fraction
# permuted and fraction shared have the same weight.
#
# For example:
# for 100 % shared, 0 % permuted -> M = 0
# for 100 % shared, 100 % permuted -> M = 0.5
# for 0 % shared, 0 % permuted -> M = 1
# for 0 % shared, 100 % permuted -> M = 1
# Calculate the fraction shared
my $s = $self->_shared($meta) / 100;
# Calculate the fraction permuted
my $p = $self->_permuted($meta);
if (not defined $p) {
$p = 100; # but any value between 0 and 100 would work as well
}
$p /= 100;
# Calculate the Maxiphi index
my $m = 1 - $s * (2-$p) / 2;
return $m;
}
method _unifrac ($meta, $tree) {
#### TODO: unifrac
$self->throw_not_implemented;
}
#######
# TODO:
# Many more beta diversity indices to calculate:
# Unifrac
# ...
#######
__PACKAGE__->meta->make_immutable;
1;
( run in 0.998 second using v1.01-cache-2.11-cpan-39bf76dae61 )