The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bio::Community::Tools::Sampler - Sample organisms according to their abundance

SYNOPSIS

  use Bio::Community::Tools::Sampler;

  # Sample members from a reference community 
  my $sampler = Bio::Community::Tools::Sampler->new( -community => $ref_community );
  my $member1 = $sampler->get_rand_member();
  my $member2 = $sampler->get_rand_member();

  # Or sample 100 members in one step
  my $rand_community = $sampler->get_rand_community( 100 );

DESCRIPTION

Pick individuals at random (without replacement) from a community.

Note that the sampling is done based on relative abundances, and is hence affected by weights. If you need to sample based on counts instead, simply set $community->use_weights(0), before using Bio::Community::Tools::Sampler.

AUTHOR

Florent Angly florent.angly@gmail.com

SUPPORT AND BUGS

User feedback is an integral part of the evolution of this and other Bioperl modules. Please direct usage questions or support issues to the mailing list, bioperl-l@bioperl.org, rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.

If you have found a bug, please report it on the BioPerl bug tracking system to help us keep track the bugs and their resolution: https://redmine.open-bio.org/projects/bioperl/

COPYRIGHT

Copyright 2011-2014 by Florent Angly <florent.angly@gmail.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.

APPENDIX

The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _

new

 Function: Create a new Bio::Community::Tool::Sampler object
 Usage   : my $sampler = Bio::Community::Tool::Sampler->new( );
 Args    : -community: See community().
           -seed     : See set_seed().
 Returns : a new Bio::Community::Tools::Sampler object

community

 Function: Get or set the community to sample from.
 Usage   : my $community = $sampler->community();
 Args    : a Bio::Community object
 Returns : a Bio::Community object

get_seed, set_seed

 Usage   : $sampler->set_seed(1234513451);
 Function: Get or set the seed used to pick the random members.
 Args    : Positive integer
 Returns : Positive integer

get_rand_member

 Function: Get a random member from a community (sample with replacement). This
           method requires the Math::GSL::Randist module.
           Note: If you need to draw many members, using get_rand_community() is
           much more efficient.
 Usage   : my $member = $sampler->get_rand_member();
 Args    : None
 Returns : A Bio::Community::Member object

get_rand_community

 Function: Create a community from random members of a community. This method
           requires the Math::GSL::Randist module.
 Usage   : my $community = $sampler->get_rand_community(1000);
 Args    : Number of members (positive integer)
 Returns : A Bio::Community object