« blib/lib/Bio/Community/Tools/IdConverter.pm
↑ Summary
blib/lib/Bio/Community/Tools/Accumulator.pm »
| 1 | # BioPerl module for Bio::Community::Tools::Summarizer | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Copyright 2011-2014 Florent Angly <florent.angly@gmail.com> | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | Bio::Community::Tools::Summarizer - Create a summary of communities | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | use Bio::Community::Tools::Summarizer; | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Given a metacommunity, merge community members with the same taxonomy, then | ||||||||||||||||||||||||||||
| 19 | # group members at the second level of their taxonomy (i.e. phylum level when | ||||||||||||||||||||||||||||
| 20 | # using the Greengenes taxonomy), then group members at less than 1% relative | ||||||||||||||||||||||||||||
| 21 | # abundance into a single group called 'Other': | ||||||||||||||||||||||||||||
| 22 | my $summarizer = Bio::Community::Tools::Summarizer->new( | ||||||||||||||||||||||||||||
| 23 | -metacommunity => $meta, | ||||||||||||||||||||||||||||
| 24 | -merge_dups => 1, | ||||||||||||||||||||||||||||
| 25 | -by_tax_level => 2, | ||||||||||||||||||||||||||||
| 26 | -by_rel_ab => ['<', 1], | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | my $summarized_meta = $summarizer->get_summary; | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | Summarize communities in a metacommunity by grouping members based on their | ||||||||||||||||||||||||||||
| 33 | taxonomic affiliation first, then by collapsing or removing members with a | ||||||||||||||||||||||||||||
| 34 | relative abundance above or below a specified threshold. Summarizing communities | ||||||||||||||||||||||||||||
| 35 | should be the last step of any community analysis, because it compresses | ||||||||||||||||||||||||||||
| 36 | communities (members, weights, taxonomy, etc.) in a way that cannot be undone. | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | Florent Angly L<florent.angly@gmail.com> | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =head1 SUPPORT AND BUGS | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | User feedback is an integral part of the evolution of this and other Bioperl | ||||||||||||||||||||||||||||
| 45 | modules. Please direct usage questions or support issues to the mailing list, | ||||||||||||||||||||||||||||
| 46 | L<bioperl-l@bioperl.org>, rather than to the module maintainer directly. Many | ||||||||||||||||||||||||||||
| 47 | experienced and reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||
| 48 | address it. Please include a thorough description of the problem with code and | ||||||||||||||||||||||||||||
| 49 | data examples if at all possible. | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | If you have found a bug, please report it on the BioPerl bug tracking system | ||||||||||||||||||||||||||||
| 52 | to help us keep track the bugs and their resolution: | ||||||||||||||||||||||||||||
| 53 | L<https://redmine.open-bio.org/projects/bioperl/> | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | Copyright 2011-2014 by Florent Angly <florent.angly@gmail.com> | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 60 | it under the same terms as Perl itself, either Perl version 5.10.1 or, | ||||||||||||||||||||||||||||
| 61 | at your option, any later version of Perl 5 you may have available. | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head1 APPENDIX | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | The rest of the documentation details each of the object | ||||||||||||||||||||||||||||
| 66 | methods. Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head2 new | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Function: Create a new Bio::Community::Tool::Summarizer object | ||||||||||||||||||||||||||||
| 71 | Usage : my $summarizer = Bio::Community::Tools::Summarizer->new( | ||||||||||||||||||||||||||||
| 72 | -metacommunity => $meta, | ||||||||||||||||||||||||||||
| 73 | ); | ||||||||||||||||||||||||||||
| 74 | Args : -metacommunity : See metacommunity(). | ||||||||||||||||||||||||||||
| 75 | -merge_dups : See merge_dups(). | ||||||||||||||||||||||||||||
| 76 | -identify_dups_by: See identify_dups_by(). | ||||||||||||||||||||||||||||
| 77 | -by_tax_level : See by_tax_level(). | ||||||||||||||||||||||||||||
| 78 | -by_rel_ab : See by_rel_ab(). | ||||||||||||||||||||||||||||
| 79 | Returns : a Bio::Community::Tools::Summarizer object | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =cut | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | package Bio::Community::Tools::Summarizer; | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 87 | 1 | ▶ | use MooseX::NonMoose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 88 | 1 | ▶ | use MooseX::StrictConstructor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 89 | 1 | ▶ | use Method::Signatures; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 90 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 91 | 1 | ▶ | use Bio::Community::IO; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 92 | 1 | ▶ | use Bio::Community::Meta; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 93 | use Bio::Community::TaxonomyUtils | ||||||||||||||||||||||||||||
| 94 | 1 | ▶ | qw(get_taxon_lineage get_lineage_string clean_lineage_arr); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 1 | ▶ | use POSIX; # defines DBL_EPSILON to something like 2.22044604925031e-16 | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 97 | 1 | ▶ | use constant EPSILON => 10 * DBL_EPSILON; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 1 | extends 'Bio::Root::Root'; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =head2 metacommunity | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | Function: Get/set communities, given as metacommunity, to summarize. | ||||||||||||||||||||||||||||
| 106 | Usage : my $meta = $summarizer->metacommunity; | ||||||||||||||||||||||||||||
| 107 | Args : A Bio::Community::Meta object | ||||||||||||||||||||||||||||
| 108 | Returns : A Bio::Community::Meta object | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =cut | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 1 | has metacommunity => ( | |||||||||||||||||||||||||||
| 113 | is => 'rw', | ||||||||||||||||||||||||||||
| 114 | isa => 'Maybe[Bio::Community::Meta]', | ||||||||||||||||||||||||||||
| 115 | required => 0, | ||||||||||||||||||||||||||||
| 116 | lazy => 1, | ||||||||||||||||||||||||||||
| 117 | default => undef, | ||||||||||||||||||||||||||||
| 118 | init_arg => '-metacommunity', | ||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =head2 merge_dups | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | Function: Merge duplicate community members into a single one. For example, if | ||||||||||||||||||||||||||||
| 125 | your community contained several members with a taxonomic lineage of | ||||||||||||||||||||||||||||
| 126 | 'Archaea;Euryarchaeota;Halobacteria', all would be merged into a new | ||||||||||||||||||||||||||||
| 127 | member with the same taxonomy and the sum of the counts. See the | ||||||||||||||||||||||||||||
| 128 | identify_dups_by() method to specify what constitutes duplicates. | ||||||||||||||||||||||||||||
| 129 | Note that merging duplicates takes place before grouping by taxonomy | ||||||||||||||||||||||||||||
| 130 | level, by_tax_level(). | ||||||||||||||||||||||||||||
| 131 | Usage : $summarizer->merge_dups(1); | ||||||||||||||||||||||||||||
| 132 | Args : 0 (no) or 1 (yes). Default: 1 | ||||||||||||||||||||||||||||
| 133 | Returns : a positive integer | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =cut | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 1 | has merge_dups => ( | |||||||||||||||||||||||||||
| 138 | is => 'rw', | ||||||||||||||||||||||||||||
| 139 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 140 | required => 0, | ||||||||||||||||||||||||||||
| 141 | lazy => 1, | ||||||||||||||||||||||||||||
| 142 | default => 1, | ||||||||||||||||||||||||||||
| 143 | init_arg => '-merge_dups', | ||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | =head2 identify_dups_by | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | Function: Define what constitute duplicates, i.e. members that have the same | ||||||||||||||||||||||||||||
| 150 | desc() or the same taxon(). | ||||||||||||||||||||||||||||
| 151 | Usage : $summarizer->identify_dups_by('taxon'); | ||||||||||||||||||||||||||||
| 152 | Args : 'desc' or 'taxon'. Default: 'desc' | ||||||||||||||||||||||||||||
| 153 | Returns : 'desc' or 'taxon' | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =cut | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 1 | has identify_dups_by => ( | |||||||||||||||||||||||||||
| 158 | is => 'rw', | ||||||||||||||||||||||||||||
| 159 | isa => 'IdentifyDupsByType', | ||||||||||||||||||||||||||||
| 160 | required => 0, | ||||||||||||||||||||||||||||
| 161 | lazy => 1, | ||||||||||||||||||||||||||||
| 162 | default => 'desc', | ||||||||||||||||||||||||||||
| 163 | init_arg => '-identify_dups_by', | ||||||||||||||||||||||||||||
| 164 | ); | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =head2 by_tax_level | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | Function: Get/set the taxonomic level at which to group community members. When | ||||||||||||||||||||||||||||
| 170 | community members have taxonomic information attached, add the | ||||||||||||||||||||||||||||
| 171 | relative abundance of all members belonging to the same taxonomic | ||||||||||||||||||||||||||||
| 172 | level. The taxonomic level depends on which taxonomy is used. For the | ||||||||||||||||||||||||||||
| 173 | Greengenes taxonomy, level 1 represents kingdom, level 2 represents | ||||||||||||||||||||||||||||
| 174 | phylum, and so on, until level 7, representing the species level. | ||||||||||||||||||||||||||||
| 175 | Members without taxonomic information are grouped together in a Member | ||||||||||||||||||||||||||||
| 176 | with the description 'Unknown taxonomy'. | ||||||||||||||||||||||||||||
| 177 | Note that summarizing by taxonomy level takes place before grouping by | ||||||||||||||||||||||||||||
| 178 | relative abundance, by_rel_ab(). Also, since each community member | ||||||||||||||||||||||||||||
| 179 | represents the combination of multiple members, they have to be given | ||||||||||||||||||||||||||||
| 180 | a new weight, that is specific to the community they belong to. | ||||||||||||||||||||||||||||
| 181 | Usage : $summarizer->by_tax_level(2); | ||||||||||||||||||||||||||||
| 182 | Args : a positive integer | ||||||||||||||||||||||||||||
| 183 | Returns : a positive integer | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =cut | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 1 | has by_tax_level => ( | |||||||||||||||||||||||||||
| 188 | is => 'rw', | ||||||||||||||||||||||||||||
| 189 | isa => 'Maybe[StrictlyPositiveInt]', | ||||||||||||||||||||||||||||
| 190 | required => 0, | ||||||||||||||||||||||||||||
| 191 | lazy => 1, | ||||||||||||||||||||||||||||
| 192 | default => undef, | ||||||||||||||||||||||||||||
| 193 | init_arg => '-by_tax_level', | ||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =head2 by_rel_ab | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | Function: Get/set the relative abundance threshold to group members together. | ||||||||||||||||||||||||||||
| 200 | Example: You provide a metacommunity containing multiple communities | ||||||||||||||||||||||||||||
| 201 | and you specify to group members with a relative abundance less than | ||||||||||||||||||||||||||||
| 202 | 1%. If the abundance of member A is less than 1% in all the | ||||||||||||||||||||||||||||
| 203 | communities, it is removed from the communities and added as a new | ||||||||||||||||||||||||||||
| 204 | member with the desciption 'Other < 1%' along with all other members | ||||||||||||||||||||||||||||
| 205 | that are less than 1% in all the communities. | ||||||||||||||||||||||||||||
| 206 | Note that when community members are weighted, the 'Other' group also | ||||||||||||||||||||||||||||
| 207 | has to be weighted differently for each community. | ||||||||||||||||||||||||||||
| 208 | Usage : $summarizer->by_rel_ab('<', 1); | ||||||||||||||||||||||||||||
| 209 | Args : * the type of numeric comparison, '<', '<=', '>=', '>' | ||||||||||||||||||||||||||||
| 210 | * the relative abundance threshold (in %) | ||||||||||||||||||||||||||||
| 211 | Returns : * the type of numeric comparison, '<', '<=', '>=', '>' | ||||||||||||||||||||||||||||
| 212 | * the relative abundance threshold (in %) | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | =cut | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 1 | has by_rel_ab => ( | |||||||||||||||||||||||||||
| 217 | is => 'rw', | ||||||||||||||||||||||||||||
| 218 | isa => 'Maybe[ArrayRef]', # how to specify ArrayRef[Str, Num]? | ||||||||||||||||||||||||||||
| 219 | required => 0, | ||||||||||||||||||||||||||||
| 220 | lazy => 1, | ||||||||||||||||||||||||||||
| 221 | default => undef, | ||||||||||||||||||||||||||||
| 222 | init_arg => '-by_rel_ab', | ||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | =head2 get_summary | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | Function: Summarize the communities and return an arrayref of fresh communities. | ||||||||||||||||||||||||||||
| 229 | Usage : my $summary = $summarizer->get_summary; | ||||||||||||||||||||||||||||
| 230 | Args : None | ||||||||||||||||||||||||||||
| 231 | Returns : A Bio::Community::Meta object | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | =cut | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 1 | ▶ | method get_summary () { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
get_summary: called CC=7 SCAR=31.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | # Sanity check | ||||||||||||||||||||||||||||
| 237 | 1 | my $meta = $self->metacommunity; | |||||||||||||||||||||||||||
| 238 | 1 | ▶ | if ( (not $meta) || ($meta->get_communities_count == 0) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $meta or $meta->get_communities_count == 0
MC/DC0%0/2
not $meta or $meta->get_communities_count == 0
not $meta
$meta->get_communities_count == 0
Truth table33%1/3
not(A) or B
A= not $metaB= $meta->get_communities_count == 0
| |||||||||||||||||||||||||||||
| 239 | 1 | $self->throw('Should have a metacommunity containing at least one community'); | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | 0 | my $summary = $meta; | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | # Then merge duplicates | ||||||||||||||||||||||||||||
| 245 | 0 | my $merge_dups = $self->merge_dups(); | |||||||||||||||||||||||||||
| 246 | 0 | ▶ | if ($merge_dups) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 0 | $summary = $self->_merge_duplicates($summary, $merge_dups); | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | # Then summarize by taxonomy | ||||||||||||||||||||||||||||
| 251 | 0 | my $tax_level = $self->by_tax_level(); | |||||||||||||||||||||||||||
| 252 | 0 | ▶ | if (defined $tax_level) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | $summary = $self->_group_by_taxonomic_level($summary, $tax_level); | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | # Finally, group members by abundance | ||||||||||||||||||||||||||||
| 257 | 0 | my $rel_ab_params = $self->by_rel_ab; | |||||||||||||||||||||||||||
| 258 | 0 | ▶ | if (defined $rel_ab_params) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 0 | $summary = $self->_group_by_relative_abundance($summary, $rel_ab_params); | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | return $summary; | |||||||||||||||||||||||||||
| 263 | }; | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 1 | ▶ | method _merge_duplicates ( $meta, $merge_dups ) { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=4.9
Subroutine
_merge_duplicates: not called CC=12 SCAR=49.5
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 267 | # Create fresh community objects to hold the summary | ||||||||||||||||||||||||||||
| 268 | 0 | my $summary = $self->_new_summary($meta); | |||||||||||||||||||||||||||
| 269 | 0 | ▶ | my $use_desc = $self->identify_dups_by eq 'desc' ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 0 | my $taxa_counts = {}; | |||||||||||||||||||||||||||
| 271 | 0 | my $taxa_objs = {}; | |||||||||||||||||||||||||||
| 272 | 0 | for my $member ( @{$meta->get_all_members} ) { | |||||||||||||||||||||||||||
| 273 | 0 | ▶ | my $taxon = $use_desc ? $member->desc : $member->taxon; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if ($taxon) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | # Member has taxonomic information | ||||||||||||||||||||||||||||
| 276 | 0 | ▶ | my $lineage_str = $use_desc ? $taxon : get_lineage_string(get_taxon_lineage($taxon)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | # Save taxon object | ||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if (not exists $taxa_objs->{$lineage_str}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | 0 | $taxa_objs->{$lineage_str} = $taxon; | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | # For each community, add member counts and weighted counts to the taxonomic group | ||||||||||||||||||||||||||||
| 284 | 0 | my $i = -1; | |||||||||||||||||||||||||||
| 285 | 0 | ▶ | while (my $community = $meta->next_community) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | 0 | $i++; | |||||||||||||||||||||||||||
| 287 | 0 | my $count = $community->get_count($member); | |||||||||||||||||||||||||||
| 288 | 0 | my $wcount = $count / Bio::Community::_prod($member->weights); | |||||||||||||||||||||||||||
| 289 | 0 | $taxa_counts->{$lineage_str}->{$i}->[0] += $count; | |||||||||||||||||||||||||||
| 290 | 0 | $taxa_counts->{$lineage_str}->{$i}->[1] += $wcount; | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | } else { | ||||||||||||||||||||||||||||
| 294 | # Member has no taxonomic assignment. Add member as-is in the summary. | ||||||||||||||||||||||||||||
| 295 | 0 | my $i = -1; | |||||||||||||||||||||||||||
| 296 | 0 | ▶ | while (my $community = $meta->next_community) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 297 | 0 | $i++; | |||||||||||||||||||||||||||
| 298 | 0 | my $count = $community->get_count($member); | |||||||||||||||||||||||||||
| 299 | 0 | my $summary = $summary->get_community_by_name($community->name); | |||||||||||||||||||||||||||
| 300 | 0 | $summary->add_member($member, $count); | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | # Add taxonomic groups to all communities | ||||||||||||||||||||||||||||
| 307 | 0 | $self->_add_groups($taxa_objs, $taxa_counts, $summary, $use_desc); | |||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 0 | return $summary; | |||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 1 | ▶ | method _group_by_taxonomic_level ( $meta, $tax_level ) { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=4.9
Subroutine
_group_by_taxonomic_level: not called CC=14 SCAR=52.7
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | # Create fresh community objects to hold the summary | ||||||||||||||||||||||||||||
| 316 | 0 | my $summary = $self->_new_summary($meta); | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | my $taxa_counts = {}; | |||||||||||||||||||||||||||
| 319 | 0 | my $taxa_objs = {}; | |||||||||||||||||||||||||||
| 320 | 0 | for my $member ( @{$meta->get_all_members} ) { | |||||||||||||||||||||||||||
| 321 | 0 | my $taxon = $member->taxon; | |||||||||||||||||||||||||||
| 322 | 0 | ▶ | if ($taxon) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 323 | # Member has taxonomic information | ||||||||||||||||||||||||||||
| 324 | 0 | my $lineage_arr = get_taxon_lineage($taxon); | |||||||||||||||||||||||||||
| 325 | 0 | ▶ | my $end_idx = $tax_level-1 > $#$lineage_arr ? $#$lineage_arr : $tax_level-1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 326 | 0 | $lineage_arr = [ @{$lineage_arr}[0 .. $end_idx] ]; | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | # Need to clean lineage again to prevent this from happening: | ||||||||||||||||||||||||||||
| 329 | # o__Rickettsiales;f__;g__Candidatus P. -> o__Rickettsiales;f__ | ||||||||||||||||||||||||||||
| 330 | 0 | $lineage_arr = clean_lineage_arr($lineage_arr); | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | ▶ | if ( scalar @$lineage_arr > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | # Could find Bio::Taxon at requested taxonomic level | ||||||||||||||||||||||||||||
| 334 | 0 | my $lineage_str = get_lineage_string($lineage_arr); | |||||||||||||||||||||||||||
| 335 | 0 | $taxon = $lineage_arr->[-1]; | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | # Save taxon object | ||||||||||||||||||||||||||||
| 338 | 0 | ▶ | if (not exists $taxa_objs->{$lineage_str}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 0 | $taxa_objs->{$lineage_str} = $taxon; | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | # For each community, add member counts and weighted counts to the taxonomic group | ||||||||||||||||||||||||||||
| 343 | 0 | my $i = -1; | |||||||||||||||||||||||||||
| 344 | 0 | ▶ | while (my $community = $meta->next_community) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 345 | 0 | $i++; | |||||||||||||||||||||||||||
| 346 | 0 | my $count = $community->get_count($member); | |||||||||||||||||||||||||||
| 347 | 0 | my $wcount = $count / Bio::Community::_prod($member->weights); | |||||||||||||||||||||||||||
| 348 | 0 | $taxa_counts->{$lineage_str}->{$i}->[0] += $count; | |||||||||||||||||||||||||||
| 349 | 0 | $taxa_counts->{$lineage_str}->{$i}->[1] += $wcount; | |||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | } else { | ||||||||||||||||||||||||||||
| 353 | # Member had taxonomic information at a higher level than requested. | ||||||||||||||||||||||||||||
| 354 | # Add member as-is in the summary. | ||||||||||||||||||||||||||||
| 355 | 0 | my $i = -1; | |||||||||||||||||||||||||||
| 356 | 0 | ▶ | while (my $community = $meta->next_community) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 357 | 0 | $i++; | |||||||||||||||||||||||||||
| 358 | 0 | my $count = $community->get_count($member); | |||||||||||||||||||||||||||
| 359 | 0 | my $summary = $summary->get_community_by_name($community->name); | |||||||||||||||||||||||||||
| 360 | 0 | $summary->add_member($member, $count); | |||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 0 | ▶ | if (not $taxon) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | # Member had no taxonomic info. Add it in a separate group. | ||||||||||||||||||||||||||||
| 367 | 0 | my $lineage_str = 'Unknown taxonomy'; | |||||||||||||||||||||||||||
| 368 | 0 | ▶ | if (not exists $taxa_objs->{$lineage_str}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | 0 | $taxa_objs->{$lineage_str} = undef; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | 0 | my $i = -1; | |||||||||||||||||||||||||||
| 372 | 0 | ▶ | while (my $community = $meta->next_community) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 373 | 0 | $i++; | |||||||||||||||||||||||||||
| 374 | 0 | my $count = $community->get_count($member); | |||||||||||||||||||||||||||
| 375 | 0 | my $wcount = $count / Bio::Community::_prod($member->weights); | |||||||||||||||||||||||||||
| 376 | 0 | $taxa_counts->{$lineage_str}->{$i}->[0] += $count; | |||||||||||||||||||||||||||
| 377 | 0 | $taxa_counts->{$lineage_str}->{$i}->[1] += $wcount; | |||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | # Add taxonomic groups to all communities | ||||||||||||||||||||||||||||
| 384 | 0 | $self->_add_groups($taxa_objs, $taxa_counts, $summary); | |||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 0 | return $summary; | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | 1 | ▶ | method _group_by_relative_abundance ( $meta, $params ) { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=4.9
Subroutine
_group_by_relative_abundance: not called CC=17 SCAR=56.5
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | # Get grouping parameters | ||||||||||||||||||||||||||||
| 393 | 0 | ▶ | my $thresh = $params->[1] || $self->throw("No grouping threshold was provided."); | ||||||||||||||||||||||||||
|
Condition0%0/3
$params->[1] || $self->throw('No grouping threshold was provided.')
MC/DC0%0/2
$params->[1] || $self->throw('No grouping threshold was provided.')
$params->[1]
$self->throw('No grouping threshold was provided.')
Truth table0%0/3
A || B
A= $params->[1]B= $self->throw('No grouping threshold was provided.')
| |||||||||||||||||||||||||||||
| 394 | 0 | ▶ | my $operator = $params->[0] || $self->throw("No comparison operator was provided."); | ||||||||||||||||||||||||||
|
Condition0%0/3
$params->[0] || $self->throw('No comparison operator was provided.')
MC/DC0%0/2
$params->[0] || $self->throw('No comparison operator was provided.')
$params->[0]
$self->throw('No comparison operator was provided.')
Truth table0%0/3
A || B
A= $params->[0]B= $self->throw('No comparison operator was provided.')
| |||||||||||||||||||||||||||||
| 395 | 0 | my $cmp; | |||||||||||||||||||||||||||
| 396 | 0 | ▶ | if ($operator eq '<' ) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 397 | 0 | ▶ | $cmp = sub { $_[0] < $_[1] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 398 | } elsif ($operator eq '<=' ) { | ||||||||||||||||||||||||||||
| 399 | 0 | ▶ | $cmp = sub { $_[0] - $_[1] < EPSILON }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 400 | } elsif ($operator eq '>=' ) { | ||||||||||||||||||||||||||||
| 401 | 0 | ▶ | $cmp = sub { $_[1] - $_[0] < EPSILON }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 402 | } elsif ($operator eq '>' ) { | ||||||||||||||||||||||||||||
| 403 | 0 | ▶ | $cmp = sub { $_[1] < $_[0] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 404 | } else { | ||||||||||||||||||||||||||||
| 405 | 0 | $self->throw("Invalid comparison operator provided, '$operator'."); | |||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | # Create fresh community objects to hold the summary | ||||||||||||||||||||||||||||
| 409 | 0 | my $summary = $self->_new_summary($meta); | |||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | 0 | my $taxa_counts = {}; | |||||||||||||||||||||||||||
| 412 | 0 | my $desc = "Other $operator $thresh %"; | |||||||||||||||||||||||||||
| 413 | 0 | my $taxa_objs = { $desc => undef }; | |||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | 0 | for my $member ( @{$meta->get_all_members} ) { | |||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | # Determine if this member should be grouped | ||||||||||||||||||||||||||||
| 418 | 0 | my $member_to_group = 1; | |||||||||||||||||||||||||||
| 419 | 0 | my $rel_abs; | |||||||||||||||||||||||||||
| 420 | 0 | ▶ | while (my $community = $meta->next_community) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 421 | 0 | push @$rel_abs, $community->get_rel_ab($member); | |||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||
| 423 | 0 | for my $rel_ab (@$rel_abs) { | |||||||||||||||||||||||||||
| 424 | 0 | ▶ | if ( not &$cmp($rel_ab, $thresh) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 425 | 0 | $member_to_group = 0; # This member needs no grouping | |||||||||||||||||||||||||||
| 426 | 0 | last; | |||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 431 | 0 | ▶ | while (my $community = $meta->next_community) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 432 | 0 | my $rel_ab = $rel_abs->[$i]; | |||||||||||||||||||||||||||
| 433 | 0 | my $count = $community->get_count($member); | |||||||||||||||||||||||||||
| 434 | 0 | ▶ | if ($count > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 435 | 0 | ▶ | if ($member_to_group) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 436 | # Will group member | ||||||||||||||||||||||||||||
| 437 | 0 | $taxa_counts->{$desc}->{$i}->[0] += $count; # count | |||||||||||||||||||||||||||
| 438 | 0 | $taxa_counts->{$desc}->{$i}->[1] += $count / Bio::Community::_prod($member->weights); # weighted count | |||||||||||||||||||||||||||
| 439 | } else { | ||||||||||||||||||||||||||||
| 440 | # Add member as-is, ungrouped | ||||||||||||||||||||||||||||
| 441 | 0 | $summary->get_community_by_name($community->name)->add_member($member, $count); | |||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||
| 444 | 0 | $i++; | |||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | # Add taxonomic groups to all communities | ||||||||||||||||||||||||||||
| 450 | 0 | $self->_add_groups($taxa_objs, $taxa_counts, $summary); | |||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | 0 | return $summary; | |||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | 1 | ▶ | method _calc_weights ($count, $weighted_count) { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=4.9
Subroutine
_calc_weights: not called CC=5 SCAR=31.2
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 457 | # Given a count and a weighted count, calcualte | ||||||||||||||||||||||||||||
| 458 | 0 | ▶ | my $weight = ($count > 0) ? ($count / $weighted_count) : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 459 | 0 | return [ $weight ]; | |||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | 1 | ▶ | method _add_groups ($taxa_objs, $taxa_counts, $summary, $use_desc = 0) { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=5.5
Subroutine
_add_groups: not called CC=12 SCAR=49.4
Branch: 5 branches
| |||||||||||||||||||||||||||||
| 463 | # Add groups to the summary metacommunity provided | ||||||||||||||||||||||||||||
| 464 | 0 | ▶ | while (my ($lineage_str, $taxon) = each %$taxa_objs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 465 | # Make a group template | ||||||||||||||||||||||||||||
| 466 | 0 | my $group_template = Bio::Community::Member->new( ); | |||||||||||||||||||||||||||
| 467 | 0 | ▶ | if ($use_desc) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 468 | 0 | $group_template->desc($taxon); | |||||||||||||||||||||||||||
| 469 | #### TODO: Need to make taxonomy. Ideally instead of re-making it, it should not be lost. | ||||||||||||||||||||||||||||
| 470 | #use Bio::Community::TaxonomyUtils qw(split_lineage_string); | ||||||||||||||||||||||||||||
| 471 | #my @names = @{split_lineage_string($lineage_str)}; | ||||||||||||||||||||||||||||
| 472 | #my $taxonomy = $tax_obj->db_handle; | ||||||||||||||||||||||||||||
| 473 | #my $tax_obj = $self->taxonomy->get_taxon( -names => \@names ); | ||||||||||||||||||||||||||||
| 474 | #$group_template->taxon($tax_obj); | ||||||||||||||||||||||||||||
| 475 | } else { | ||||||||||||||||||||||||||||
| 476 | 0 | $group_template->desc($lineage_str); | |||||||||||||||||||||||||||
| 477 | 0 | ▶ | if ($taxon) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 478 | 0 | $group_template->taxon($taxon); | |||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||
| 481 | # Make a group based on the template and add it to each community | ||||||||||||||||||||||||||||
| 482 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 483 | 0 | ▶ | while (my $summary = $summary->next_community) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 484 | 0 | ▶ | my $count_info = $taxa_counts->{$lineage_str}->{$i} || next; | ||||||||||||||||||||||||||
|
Condition0%0/2
$taxa_counts->{$lineage_str}{$i} || (next)
MC/DC0%0/1
$taxa_counts->{$lineage_str}{$i} || (next)
$taxa_counts->{$lineage_str}{$i}
Truth table0%0/2
A
A= $taxa_counts->{$lineage_str}{$i}
| |||||||||||||||||||||||||||||
| 485 | 0 | my ($count, $wcount) = @{$count_info}; | |||||||||||||||||||||||||||
| 486 | 0 | my $group = $group_template->clone; | |||||||||||||||||||||||||||
| 487 | 0 | $group->weights( $self->_calc_weights($count, $wcount) ); | |||||||||||||||||||||||||||
| 488 | 0 | ▶ | $summary->add_member($group, $count) if $count > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 489 | 0 | $i++; | |||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||
| 492 | 0 | return 1; | |||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | 1 | ▶ | method _new_summary ($meta) { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=4.1
Subroutine
_new_summary: not called CC=4 SCAR=27.4
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 497 | # Create a fresh metacommunity object to hold the summary. One summary per | ||||||||||||||||||||||||||||
| 498 | # input community. | ||||||||||||||||||||||||||||
| 499 | 0 | my $summary = Bio::Community::Meta->new; | |||||||||||||||||||||||||||
| 500 | 0 | ▶ | while (my $community = $meta->next_community) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 501 | 0 | my $name = $community->name; | |||||||||||||||||||||||||||
| 502 | #if ($name !~ / summarized$/) { | ||||||||||||||||||||||||||||
| 503 | # $name .= ' summarized'; | ||||||||||||||||||||||||||||
| 504 | #} | ||||||||||||||||||||||||||||
| 505 | 0 | my $use_weights = $community->use_weights; | |||||||||||||||||||||||||||
| 506 | 0 | my $comm_summary = Bio::Community->new( | |||||||||||||||||||||||||||
| 507 | -name => $name, | ||||||||||||||||||||||||||||
| 508 | -use_weights => $use_weights, | ||||||||||||||||||||||||||||
| 509 | ); | ||||||||||||||||||||||||||||
| 510 | 0 | $summary->add_communities([$comm_summary]); | |||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||
| 512 | 0 | return $summary; | |||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | 1 | 1; | |||||||||||||||||||||||||||