quicklizard99 / cheddar

Analysis and visualisation of ecological communities in R
http://quicklizard99.github.io/cheddar/
Other
14 stars 3 forks source link

Improvements to enumerating trophic chains #12

Closed quicklizard99 closed 12 years ago

quicklizard99 commented 12 years ago

Two limitations relating to the way that Cheddar handles trophic chains:

  1. TrophicChains() allocates a chunk of memory large enough to hold max.chains chains of length NumberOfChains() - this is very inefficient, requires the user to tweak max.chains and means that highly connected communities, such as SkiwithPond, cannot be enumerated on 32-bit operating systems
  2. The only way to compute any statistics on trophic chains is to enumerate all of the chains using TrophicChains() and hold them in memory - very restrictive given point 1
quicklizard99 commented 12 years ago

Fixed in 0.1-618:

  1. TrophicChains() changed to allocate only the space that is needed. The following now works on 32-bit operating systems:
library(cheddar)
data(SkipwithPond)
chains <- TrophicChains(SkipwithPond)
dim(chains)    # 2538120 rows, 17 columns
  1. Added a new function, TrophicChainsStats():
library(cheddar)
data(SkipwithPond)
stats <- TrophicChainsStats(SkipwithPond)
length(stats$chain.length)    # The length (i.e. number of links) of each of the 2538120 chains
mean(stats$chain.length)
summary(stats$chain.length)
# A matrix with a row for each node (37 for Skipwith Pond) and '1+max(stats$chain.lengths)' columns. 
# Elements are the number of chains in which a node appear in that position.
stats$node.pos.counts