Skip to content

rarefaction not working with the min species number

3 messages · stephen sefick, Jari Oksanen

#
I will provide reproducible code if I need to.

All:

I am trying to set up a 1000 pulls of a community data frame for 
calculating richness measures.  I would like to be able to code the 
sample number based on the minimum of all of the samples.  I can do this 
but there is an error:

Error in sample(rep(nm, times = x[i, ]), sample[i]) :
   cannot take a sample larger than the population when 'replace = FALSE'

when using:

rrarefy(L, min(apply(L, 1, sum)))

min is returning the lowest sample abundance of all of the samples.  
rrarefy works if I subtract 5 (arbitrary) from the min(...) statement.  
I am sure that I am missing something simple.
many thanks,
#
On 24/04/2012, at 15:39 PM, Stephen Sefick wrote:

            
Stephen,

I can reproduce this if input data ('L') contain non-integer data. The function is only able to handle integer data, but it does not check the input. Probably it should: the error would still be there, but the message would be more informative.

Cheers, Jari

--
Jari Oksanen, Dept Biology, Univ Oulu, 90014 Finland
#
Jari,

Many thanks, that did the trick.  Here is a little bit of code that 
took my non-integer data (abundance estimates), rounds, and turns the 
numbers into a data.frame with all integers col classes.

community_round2int <- function(L){

row <- rownames(L)

a <- as.data.frame(apply(L, 2, round))

b <- as.data.frame(apply(a, 2, as.integer))

rownames(b) <- row

return(b)

}

kindest regards,

Stephen
On Tue 24 Apr 2012 08:01:16 AM CDT, Jari Oksanen wrote:
--
Stephen Sefick
**************************************************
Auburn University
Biological Sciences
331 Funchess Hall
Auburn, Alabama
36849
**************************************************
sas0025 at auburn.edu
http://www.auburn.edu/~sas0025
**************************************************

Let's not spend our time and resources thinking about things that are 
so little or so large that all they really do for us is puff us up and 
make us feel like gods.  We are mammals, and have not exhausted the 
annoying little problems of being mammals.

                                -K. Mullis

"A big computer, a complex algorithm and a long time does not equal 
science."

                              -Robert Gentleman