quicklizard99 / cheddar Goto Github PK
View Code? Open in Web Editor NEWAnalysis and visualisation of ecological communities in R
Home Page: http://quicklizard99.github.io/cheddar/
License: Other
Analysis and visualisation of ecological communities in R
Home Page: http://quicklizard99.github.io/cheddar/
License: Other
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
Currently shows NetIndices and igraph. Should also show how to export to foodweb package of Lin et al and foodweb package of Perdomo et al. Any others?
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
Replace isfinite() with R_FINITE()
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!
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.
To reproduce:
library(cheddar)
data(BroadstoneStream)
NvMSlopeByClass(BroadstoneStream)
gives a slope for 'all' and 'invertebrate' but not for the empty category, which has all N and M of NA.
R_registerRoutines
R_useDynamicSymbols
CRAN requires that a Licence file is included
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.
Is: "Nodes that consume themselves in the food web."
Should be: "Nodes that consume two or more species and have a non-integer trophic level."
Thanks to @anubhav3 for reporting this.
Plot title contains references to removed nodes and links.
Several commonly computed diversity metrics require a site by species matrix - there is no function in Cheddar that generates these.
Code to reproduce:
library(cheddar)
data(pHWebs)
CollectionCPS(pHWebs, 'SumBiomassByClass')
The first column of the returned data frame applies to nodes with no category. Column title is V1.
Two limitations relating to the way that Cheddar handles trophic chains:
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).
These functions are hard-coded to use na.rm=TRUE. They should allow the user to set na.rm.
library(cheddar)
data(BroadstoneStream)
SumBiomassByClass(BroadstoneStream)
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 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.
Reproduce
library(cheddar)
data(TL84)
MinimiseSumDietGaps(TL84)$reordered
Give a community with a title of:
"Tuesday Lake sampled in 1984 sum diet gap minimised to containing 56 nodes."
The sum diet gaps is missing. It should read:
"Tuesday Lake sampled in 1984 sum diet gap minimised to 5 containing 56 nodes."
Create a community with one of more body mass values of NA
. Call PlotMRvMC
and you see an error message Error in plot.window(...) : need finite 'xlim' values
The PlotsAndStats vignette shows how to recreate Cohen et al (2009) PNAS, Table 1. This code should be wrapped up into a cheddar function.
Need to include climits
Instead of seeing r^2, you see rNA. Can be reproduced by:
library(cheddar)
data(TL84)
PlotNvM(TL84)
models <- NvMLinearRegressions(TL84)
colours <- PlotLinearModels(models)
legend("topright", legend=sapply(models, FormatLM), lty=1, col=colours)
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!
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.
Recreate all of the methods in Bersier et al 2002 Ecology. Add to Cheddar the Chesapeake Bay dataset presented in the paper. Recreate tables 1 and 2.
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.
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’
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.
Some missing journal names. Some author first names given in full, others as initials.
This would make the function more flexible.
Suppose we have a predation matrix that contains diet fractions, or a similar measure of link strength - PredationMatrixToLinks should include this information in the returned data.frame.
::: is used in two places within cheddar - remove these.
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.)
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)
Simulated annealing learning is a stochastic optimisation technique so several optimisations might be required to find the global minimum. These two functions should allow allow optimisations to be replicated.
Plot the focal node at the centre, with concentric circles radiating outwards to species that are 1, 2, 3 etc links away. Suggested by Guy Woodward and team.
These functions use read.csv / write.csv and so do not allow for R' s range of flexibility in handling CSV file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.