Giter VIP home page Giter VIP logo

cheddar's People

Contributors

quicklizard99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cheddar's Issues

Plot pyramid functions fail for some communities

PlotNPyramid/PlotBPyramid fail for communities that have a one of more levels with no N/B.

library(cheddar)
data(BroadstoneStream)
PlotBPyramid(BroadstoneStream)

results in an error:

Error: min(v) >= 0 is not TRUE

AggregateCommunities fails for certain communities

x <- Community(nodes=data.frame(node='n', np='np'),
                trophic.links=data.frame(resource='n', consumer='n', tlp='tlp'),
                properties=list(title='x', cp='cp'))
y <- Community(nodes=data.frame(node='n', np='np'),
               trophic.links=data.frame(resource='n', consumer='n', tlp='tlp'),
               properties=list(title='y', cp='cp'))
collection <- CommunityCollection(list(x,y))
a <- AggregateCommunities(collection)

Fails with an error

Error in data.frame(..., check.names = FALSE) : 
  arguments imply differing number of rows: 1, 0

Apparent non-omnivores feeding at multiple trophic levels?

Hi

I think there is a problem with the implementation of omnivory.

I see in the code that omnivores are defined as 'species that consume two or more species and have a non-integer trophic level', and this is indeed what has been coded.

However, it is possible for a species to consumer from multiple trophic levels and have an integer trophic level. I am not sure why such a species should not be considered an omnivore (is there a valid reason?)

I have a minimum reproducible example that displays this issue:

require(cheddar)

# 4 species
node = data.frame(node = c("s1", "s2", "s3", "s4"))

# Trophic links:
# In both scenarios s4 eats from 2 trophic levels

# Scenario 1: s2 eats s1, s3 eats s2, s4 eats s1 & s3
tlinks_1 = data.frame(resource = c("s1", "s2", "s1", "s3"), consumer = c("s2", "s3", "s4", "s4"))

# Scenario 2: s2 eats s1, s3 eats s2, s4 eats s2 & s3
tlinks_2 = data.frame(resource = c("s1", "s2", "s2", "s3"), consumer = c("s2", "s3", "s4", "s4"))

# Properties:
prop_1 = list(title = "4 eats 1 & 3")
prop_2 = list(title = "4 eats 2 & 3")

# Build communities using the 2 scenarios:
comm_1 = Community(nodes = node, trophic.links = tlinks_1, properties = prop_1)
comm_2 = Community(nodes = node, trophic.links = tlinks_2, properties = prop_2)

# Trophic levels:

# Scenario 1: s4 trophic level is integer
PreyAveragedTrophicLevel(comm_1)

# Scenario 1: s4 trophic level is non-integer
PreyAveragedTrophicLevel(comm_2)

# Omnivory:

# s4 eats s1 & s3, not omnivory
Omnivory(comm_1) # 0
# s4 eats s2 & s3, counts as omnivory
Omnivory(comm_2) # 0.25

Thank you!

RemoveNodes is not able to propagate extinctions

Analyses that investigate the effect of species extinctions are likely to be interested in secondary (and further) extinctions. The RemoveNodes function should be enhanced to propagate extinctions.

New checks

  • Some S3 methods not registered
  • R_registerRoutines
  • R_useDynamicSymbols

PlotNvM() and friends always shows nodes that lack X and/or Y

The underlying master function, PlotNPS(), has a default of show.na=FALSE but PlotNvM() and friends default show.na=TRUE, for consistency with earlier releases of Cheddar. This default is not sensible - show.na=FALSE should be used across the board.

Improvements to enumerating trophic chains

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

A function to calculate log N versus log M convex hull

The area of the minimum convex hull (a polygon) in log-M vs log-N space that bounds all species. A method used by Woordward et al 2012 Phil Trans Roy Soc B 'Climate change impacts in multispecies systems: drought alters food web size structure in a field experiment' (10.1098/rstb.2012.0245).

Random, niche and other structural models

Many analyses require artificial communities generated by a structural model. The niche model of Williams and Martinez (2000) Nature and a model that assigns links at random are the minimum requirement. The cascade model and allometric diet breadth model of Petchey et al 2008 PNAS would be good.

Some units tests are testing equality of computed values

Some cheddar units tests are testing equality of computed values. These tests fail on Sparc Solaris when run without support for long doubles, which are very slow on that platform - R 3.0 and later will no longer support long doubles on Sparc Solaris.

Not available via cran

This package appears to be no longer available through the [R] CRAN. When trying to install, I get the following error:
Warning message:
package ‘cheddar’ is not available (for R version 3.6.2)

Apparently has also been removed from CRAN: https://cran.r-project.org/web/packages/cheddar/index.html

Would be great to still have a way to use this package, or even know at least which version of [R] it is compatible with.

Thank you!

Indicate that there are too many trophic chains to compute

For fully connected webs, the number of trophic chains is a factorial function of the number of nodes. For webs with many nodes and links the number of trophic chains is too large to compute within practical time and within available memory. TrophicChains presently attempts to compute all chains - it should fail when a limit has been reached.

Overestimating trophic similarity?

I was trying to understand the Jaccard similarity that is computed by the function TrophicSimilarity(). I realised that 'c', the number of resources and consumers common to both nodes could be the prey of one species, and the predator of the other species.

For instance, using the ChesapeakeBay dataset, the trophic similarity between Phytoplankton (#1) and Clupeidae (#21) is 0.125. While in the food web, the two species don't have any prey in common (no prey for Phytoplankton, while Clupeidae prey on Zooplankton) and they don't share any predators (the only predator for Clupeidae is Morone saxatilis, Phytoplankton has 7 predators - Microzooplankton, Zooplankton, Other suspension feeders, Mya, Crassostrea virginica, Anchoa mitchilli, Brevoortia tyrannus.

data("ChesapeakeBay")
Sim <- TrophicSimilarity(ChesapeakeBay)
Sim[1,21] #0.125

In the calculation of similarity, the number of common prey and predator is equal to 1 (because Zooplankton is a predator of Phytoplankton and a prey for Clupeidae).

I am not sure it is an issue (the calculation is correct and correspond to the formula explained in the documentation), but the formula doesn't feel right from an ecological point of view. I would recommend to calculate separately the number of common prey and the number of common predators. But maybe I misunderstood the original calculation from Neo Martinez and this issue can be closed without any modifications.

Does not build using modern C++ compilers

Fails with error:

* installing *source* package ‘cheddar’ ...
** package ‘cheddar’ successfully unpacked and MD5 sums checked
** libs
make[1]: Entering directory `/data/gannet/ripley/R/packages/tests-clang/cheddar/src'
clang++ -std=c++11 -stdlib=libc++ -I/data/gannet/ripley/R/R-clang/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O2 -Wall -pedantic -mtune=native  -c anneal.cpp -o anneal.o
anneal.cpp:203:50: error: field of type 'DoubleVec::const_iterator' (aka '__wrap_iter<const_pointer>') has private constructor
                                                 current_(0)
                                                 ^
/usr/include/c++/v1/iterator:1220:31: note: declared private here
    _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {}
                              ^
1 error generated.
make[1]: *** [anneal.o] Error 1
clang++ -std=c++11 -stdlib=libc++ -I/data/gannet/ripley/R/R-clang/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O2 -Wall -pedantic -mtune=native  -c shortest_paths.cpp -o shortest_paths.o
clang++ -std=c++11 -stdlib=libc++ -I/data/gannet/ripley/R/R-clang/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O2 -Wall -pedantic -mtune=native  -c trophic_chains.cpp -o trophic_chains.o
make[1]: Target `all' not remade because of errors.
make[1]: Leaving directory `/data/gannet/ripley/R/packages/tests-clang/cheddar/src'
make[1]: Entering directory `/data/gannet/ripley/R/packages/tests-clang/cheddar/src'
clang++ -std=c++11 -stdlib=libc++ -I/data/gannet/ripley/R/R-clang/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O2 -Wall -pedantic -mtune=native  -c anneal.cpp -o anneal.o
anneal.cpp:203:50: error: field of type 'DoubleVec::const_iterator' (aka '__wrap_iter<const_pointer>') has private constructor
                                                 current_(0)
                                                 ^
/usr/include/c++/v1/iterator:1220:31: note: declared private here
    _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {}
                              ^
1 error generated.
make[1]: *** [anneal.o] Error 1
make[1]: Target `symbols.rds' not remade because of errors.
make[1]: Leaving directory `/data/gannet/ripley/R/packages/tests-clang/cheddar/src'
ERROR: compilation failed for package ‘cheddar’
* removing ‘/data/gannet/ripley/R/packages/tests-clang/cheddar.Rcheck/cheddar’

Pyramid functions lack flexibility

Would be nice to be able to specify order of levels. Also good to be able to show levels that are not part of the community being plotted.

PredationMatrixToLinks requires a square predation matrix with ncol=nrow=number of nodes

PredationMatrixToLinks requires a square predation matrix with colnames==rownames as input, i.e. ncol==nrow==number of nodes in the web.

Using a non-square matrix:

library(cheddar)
m <- data.frame(a=c(1,1), b=c(1,0), c=c(0,1), row.names=c('d', 'e'))
PredationMatrixToLinks(m)

Results in an error:
Error in PredationMatrixToLinks(m) : pm is not square

This behaviour makes is hard to import certain datasets into Cheddar. Some food web data are represented by non-square matrices in which only those species that are consumers appear in columns and only those species that are consumed appear in rows (e.g. data from Yvon-Durocher et al 2008 Cent. Eur. J. Biol.)

PlotNPS() always shows nodes that lack X and/or Y

Nodes that lack X and/or Y are always shown at the lowest extent of the relevant axis. There should be an option to not plot such nodes

library(cheddar)
data(YthanEstuary)
par(mfrow=c(1,2))
PlotNvM(YthanEstuary)
PlotMvRankM(YthanEstuary)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.