Title: | Analysis and Visualisation of Ecological Communities |
---|---|
Description: | Provides a flexible, extendable representation of an ecological community and a range of functions for analysis and visualisation, focusing on food web, body mass and numerical abundance data. Allows inter-web comparisons such as examining changes in community structure over environmental, temporal or spatial gradients. |
Authors: | Lawrence Hudson with contributions from Dan Reuman and Rob Emerson |
Maintainer: | Lawrence Hudson <[email protected]> |
License: | BSD_2_clause + file LICENSE |
Version: | 0.1-639 |
Built: | 2024-11-01 11:42:54 UTC |
Source: | CRAN |
Functions that aggregate communities in a collection.
AggregateCommunities(collection, aggregate = names(collection), weight.by='N', title = NULL) AggregateCommunitiesBy(collection, aggregate.by, ...)
AggregateCommunities(collection, aggregate = names(collection), weight.by='N', title = NULL) AggregateCommunitiesBy(collection, aggregate.by, ...)
collection |
an object of class |
aggregate |
the names of the communities to aggregate. |
weight.by |
the name of a column by which to compute weighted mean of numeric values. |
title |
the title of the new |
aggregate.by |
the name of a community property, either first-class or computed, over which to aggregate. |
... |
values passed to |
AggregateCommunities
combines communities given in
aggregate
in to a single new Community
.
Nodes that appear in one or more of the communities in aggregate
are combined into a single node in the returned community.
The way in which numeric node properties are aggregated is governed by the
weight.by
parameter.
If weight.by
is NULL
or is not the name of a node property,
the arithmetic mean is computed for each numeric node property.
If weight.by
is the name of a node property, that property is used to
compute weighted means of the other numeric node properties; the
arithmetic mean of weight.by
is computed. This scheme means that
if a community contains both N and M, aggregation using
weight.by='N'
results in the arithmetic mean of N and the
N-weighted mean of M for each node.
Node properties that are characters or logicals are aggregated by joining
unique values with a ‘,’. Empty character strings are ignored.
Species that are not present in some communities in the collection are
assumed to have a value of 0
for all numeric node properties,
an empty string (''
) for all character node properties and
a value of NA
for all logical node properties.
The returned community contains the union of trophic links for each node. Community properties are aggregated by computing the arithmetic mean of numeric values and joining unique character and logical values with a ‘,’.
See the ‘Aggregating communities’ section of the ‘Collections’ vignette for a more detailed explanation and examples of how properties are aggregated.
AggregateCommunitiesBy
aggregates by a property of the communities,
either first-class or computed. If there is more than one unique value of the
property across the contained communities, a new CommunityCollection
object is returned. If there is just one unique value, a single
Community
is returned.
A new object that is either of class Community
or
CommunityCollection
.
Lawrence Hudson
CommunityCollection
,
CollectionCPS
data(pHWebs) # An aggregate of 3 communities AggregateCommunities(pHWebs, c('Old Lodge', 'Afon Hafren', 'Broadstone')) # The Duddon Pike Beck and Mosedal Beck communities share the same # latitude and have pH values of 6.1 and 5.9 respectively. CollectionCPS(pHWebs[c('Duddon Pike Beck', 'Mosedal Beck')]) # Aggregating by the 'lat' property therefore results in a new collection # of nine communities. CollectionCPS(AggregateCommunitiesBy(pHWebs, 'lat')) # Would produce an error ## Not run: AggregateCommunities(pHWebs, c('not a community', 'Afon Hafren'))
data(pHWebs) # An aggregate of 3 communities AggregateCommunities(pHWebs, c('Old Lodge', 'Afon Hafren', 'Broadstone')) # The Duddon Pike Beck and Mosedal Beck communities share the same # latitude and have pH values of 6.1 and 5.9 respectively. CollectionCPS(pHWebs[c('Duddon Pike Beck', 'Mosedal Beck')]) # Aggregating by the 'lat' property therefore results in a new collection # of nine communities. CollectionCPS(AggregateCommunitiesBy(pHWebs, 'lat')) # Would produce an error ## Not run: AggregateCommunities(pHWebs, c('not a community', 'Afon Hafren'))
Apply functions to a group of values given by a node property.
ApplyByClass(community, property, class, fn, ...) SumMByClass(community, class, na.rm=FALSE) SumNByClass(community, class, na.rm=FALSE) SumBiomassByClass(community, class, na.rm=FALSE)
ApplyByClass(community, property, class, fn, ...) SumMByClass(community, class, na.rm=FALSE) SumNByClass(community, class, na.rm=FALSE) SumBiomassByClass(community, class, na.rm=FALSE)
community |
an object of class |
property |
the property to which |
class |
the property over which |
fn |
a function. |
na.rm |
logical - if |
... |
Other parameters to |
ApplyByClass
applies fn
to property
by class.
property
and class
should both be names that meet the criteria
of the properties
argument of NPS
.
SumMByClass
, SumNByClass
and SumBiomassByClass
are
convenient wrapper around ApplyByClass
.
A vector or list of values, named by unique values of class
.
Lawrence Hudson
data(TL84) # Sum body mass by category ApplyByClass(TL84, 'M', 'category', sum) # A more convenient way to sum body mass by category SumMByClass(TL84) # Sum body mass by kingdom. The 'Unclassified flagellates' node does not have a # kingdom, so we get a value labelled '<unnamed>'. SumMByClass(TL84, 'kingdom') # Maximum body mass by category ApplyByClass(TL84, 'M', 'category', max) # A list of min and max M ApplyByClass(TL84, 'M', 'category', range) # A list of min and max M by kingom ApplyByClass(TL84, 'M', 'kingdom', range) # The same values as a matrix do.call('rbind', ApplyByClass(TL84, 'M', 'kingdom', range)) # Broadstone Stream has some nodes in every category without M so all returned # values are NA. data(BroadstoneStream) SumMByClass(BroadstoneStream) # Get rid of the NA values SumMByClass(BroadstoneStream, na.rm=TRUE)
data(TL84) # Sum body mass by category ApplyByClass(TL84, 'M', 'category', sum) # A more convenient way to sum body mass by category SumMByClass(TL84) # Sum body mass by kingdom. The 'Unclassified flagellates' node does not have a # kingdom, so we get a value labelled '<unnamed>'. SumMByClass(TL84, 'kingdom') # Maximum body mass by category ApplyByClass(TL84, 'M', 'category', max) # A list of min and max M ApplyByClass(TL84, 'M', 'category', range) # A list of min and max M by kingom ApplyByClass(TL84, 'M', 'kingdom', range) # The same values as a matrix do.call('rbind', ApplyByClass(TL84, 'M', 'kingdom', range)) # Broadstone Stream has some nodes in every category without M so all returned # values are NA. data(BroadstoneStream) SumMByClass(BroadstoneStream) # Get rid of the NA values SumMByClass(BroadstoneStream, na.rm=TRUE)
The food-web of the Benguela ecosystem.
Community
.
Yodzis, 1988.
Yodzis, P. (1988) Local trophodynamics and the interaction of marine mammals and fisheries in the Benguela ecosystem. Journal of Animal Ecology 67, 4, 635–658.
Convenience functions for accessing log10-transformed body mass, M, numerical abundance, N, and biomass abundance, B.
Log10M(community) Log10N(community) Biomass(community) Log10Biomass(community) Log10MNBiomass(community) RCMRatio(community) Log10RCMRatio(community) CRMRatio(community) Log10CRMRatio(community)
Log10M(community) Log10N(community) Biomass(community) Log10Biomass(community) Log10MNBiomass(community) RCMRatio(community) Log10RCMRatio(community) CRMRatio(community) Log10CRMRatio(community)
community |
an object of class |
Log10M
, Log10N
, Biomass
, Log10Biomass
and
each return a value per node. Log10MNBiomass
returns a matrix with a row
per node and columns ‘Log10M’, ‘Log10N’ and ‘Log10Biomass’. These functions
are all suitable for use with NPS
.
RCMRatio
returns the ratio between the resource and consumer body mass
for every trophic link. Log10RCMRatio
returns the same data
log10-transformed. CRMRatio
and Log10CRMRatio
are analagous
functions that return the ratio between the consumer and resource body mass.
These functions are all suitable for use with TLPS
.
A vector of length NumberOfNodes
or a vector of length
NumberOfTrophicLinks
Lawrence Hudson
NumberOfNodes
, NPS
,
NumberOfTrophicLinks
, TLPS
data(TL84) NPS(TL84, c('M', 'Log10M', 'N', 'Log10N', 'Biomass', 'Log10Biomass')) NPS(TL84, 'Log10MNBiomass') TLPS(TL84, link.properties=c('Log10RCMRatio', 'Log10CRMRatio'))
data(TL84) NPS(TL84, c('M', 'Log10M', 'N', 'Log10N', 'Biomass', 'Log10Biomass')) NPS(TL84, 'Log10MNBiomass') TLPS(TL84, link.properties=c('Log10RCMRatio', 'Log10CRMRatio'))
Function that assigns each node in a Community
to a
body-mass bin.
BodyMassBins(community, lower=min(NP(community,'M'), na.rm=TRUE), upper=max(NP(community,'M'), na.rm=TRUE), n.bins=10)
BodyMassBins(community, lower=min(NP(community,'M'), na.rm=TRUE), upper=max(NP(community,'M'), na.rm=TRUE), n.bins=10)
community |
an object of class |
lower |
lower bound of the bins. |
upper |
upper bound of the bins. |
n.bins |
the number of bins. |
Divides the range lower
to upper
in to n.bins
equally-spaced log10(M) bins. Assigns each node in the
community
to one of these bins and returns the bins numbers.
The returned vector has attributes bin.centres
and breaks
.
A vector of length NumberOfNodes
.
Lawrence Hudson
data(TL84) BodyMassBins(TL84)
data(TL84) BodyMassBins(TL84)
The community of Broadstone Stream.
Taxonomic classification provided by Guy Woodward.
Community
.
Woodward et al, 2005.
Woodward, G. and Speirs, D.C. and Hildrew, A.G. (2005) Quantification and resolution of a complex, size-structured food web. Advances in Ecological Research 36, 85–135.
Cheddar provides a flexible, extendable representation of an ecological community and a range of functions for analysis and visualisation, focusing on food web, body mass and numerical abundance data. It also allows inter-web comparisons such as examining changes in community structure over environmental, temporal or spatial gradients.
Details of differences between versions of Cheddar are in the the online release history: https://github.com/quicklizard99/cheddar/blob/master/release_history.md.
Package: | cheddar |
Type: | Package |
Version: | 0.1-639 |
Date: | 2024-07-24 |
License: | BSD 2 clause |
Maintainer: Lawrence Hudson <[email protected]>
# The dataset of Tuesday Lake sampled in 1984 data(TL84) # Properties of the community CPS(TL84) # Properties of each node head(NPS(TL84)) # Some computed node properties head(NPS(TL84, c('Log10M', 'Log10N', 'Log10Biomass', TL='PreyAveragedTrophicLevel', TS='TrophicSpecies'))) # Properties of each trophic link head(TLPS(TL84)) # Computed properties of each node in each link head(TLPS(TL84, node.properties=c('Log10M', 'Log10N', 'Log10Biomass', 'PreyAveragedTrophicLevel'))) # A collection of 10 webs sampled across a wide pH gradient data(pHWebs) # A data.frame of predictors and responses CollectionCPS(pHWebs, c('pH', S='NumberOfNodes', L='NumberOfTrophicLinks', C='DirectedConnectance', Slope='NvMSlope'))
# The dataset of Tuesday Lake sampled in 1984 data(TL84) # Properties of the community CPS(TL84) # Properties of each node head(NPS(TL84)) # Some computed node properties head(NPS(TL84, c('Log10M', 'Log10N', 'Log10Biomass', TL='PreyAveragedTrophicLevel', TS='TrophicSpecies'))) # Properties of each trophic link head(TLPS(TL84)) # Computed properties of each node in each link head(TLPS(TL84, node.properties=c('Log10M', 'Log10N', 'Log10Biomass', 'PreyAveragedTrophicLevel'))) # A collection of 10 webs sampled across a wide pH gradient data(pHWebs) # A data.frame of predictors and responses CollectionCPS(pHWebs, c('pH', S='NumberOfNodes', L='NumberOfTrophicLinks', C='DirectedConnectance', Slope='NvMSlope'))
The community of Chesapeake Bay sampled in the years 1983 to 1986.
Community
.
Baird and Ulanowicz, 1989; Bersier et al, 2002.
Bersier, L. and Banasek-Richter, C. and Cattin, M. (2002) Ecology 80 2394–2407.
Baird, D. and Ulanowicz. R. E. (1989) Ecological Monographs 59, 329–364.
Apply a function to every Community
in a
CommunityCollection
. Works the same as lapply
but returns a
CommunityCollection
rather than a list
.
CollectionApply(collection, f, ...)
CollectionApply(collection, f, ...)
collection |
an object of class |
f |
a function to be applied to each |
... |
optional arguments passed to |
A new object of class CommunityCollection
.
Lawrence Hudson
data(pHWebs) # Remove isolated nodes from each community CollectionCPS(pHWebs, 'FractionIsolatedNodes') pHWebs.no.iso <- CollectionApply(pHWebs, RemoveIsolatedNodes) CollectionCPS(pHWebs.no.iso, 'FractionIsolatedNodes') # Remove cannibalistic links from each community sapply(pHWebs, function(community) length(Cannibals(community))) pHWebs.no.can <- CollectionApply(pHWebs, RemoveCannibalisticLinks) sapply(pHWebs.no.can, function(community) length(Cannibals(community))) # Order the nodes each community by body mass head(CollectionNPS(pHWebs)) pHWebs.by.M <- CollectionApply(pHWebs, OrderCommunity, 'M') head(CollectionNPS(pHWebs.by.M))
data(pHWebs) # Remove isolated nodes from each community CollectionCPS(pHWebs, 'FractionIsolatedNodes') pHWebs.no.iso <- CollectionApply(pHWebs, RemoveIsolatedNodes) CollectionCPS(pHWebs.no.iso, 'FractionIsolatedNodes') # Remove cannibalistic links from each community sapply(pHWebs, function(community) length(Cannibals(community))) pHWebs.no.can <- CollectionApply(pHWebs, RemoveCannibalisticLinks) sapply(pHWebs.no.can, function(community) length(Cannibals(community))) # Order the nodes each community by body mass head(CollectionNPS(pHWebs)) pHWebs.by.M <- CollectionApply(pHWebs, OrderCommunity, 'M') head(CollectionNPS(pHWebs.by.M))
Returns a data.frame
of first-class and computed properties
of communities in a CommunityCollection
.
CollectionCPS(collection, properties=NULL)
CollectionCPS(collection, properties=NULL)
collection |
an object of class |
properties |
the names of the properties to be returned. |
This function is named CollectionCPS for Collection Community PropertieS.
The properties argument is a vector whose entries are either names of
first-class properties or names of functions which take as single required
argument a CommunityCollection
and return a single value.
If properties
is NULL
, all first-class properties
are included in the returned data.frame
.
A data.frame
.
Lawrence Hudson
CPS
, CommunityPropertyNames
,
CommunityCollection
data(pHWebs) CollectionCPS(pHWebs) # pH and a computed property CollectionCPS(pHWebs, c('pH', 'NumberOfNodes')) # A shorter name for the 'NumberOfNodes' column CollectionCPS(pHWebs, c('pH', S='NumberOfNodes')) # A function that returns more than one value. Some pHWebs communities contain # nodes (detritus and the like) that do not have a category. These appear in # <unnamed>. CollectionCPS(pHWebs, 'SumBiomassByClass') # Prefix columns with 'B' CollectionCPS(pHWebs, c(B='SumBiomassByClass')) # Remove biomasses of NA CollectionCPS(pHWebs, list(B=list('SumBiomassByClass', na.rm=TRUE)))
data(pHWebs) CollectionCPS(pHWebs) # pH and a computed property CollectionCPS(pHWebs, c('pH', 'NumberOfNodes')) # A shorter name for the 'NumberOfNodes' column CollectionCPS(pHWebs, c('pH', S='NumberOfNodes')) # A function that returns more than one value. Some pHWebs communities contain # nodes (detritus and the like) that do not have a category. These appear in # <unnamed>. CollectionCPS(pHWebs, 'SumBiomassByClass') # Prefix columns with 'B' CollectionCPS(pHWebs, c(B='SumBiomassByClass')) # Remove biomasses of NA CollectionCPS(pHWebs, list(B=list('SumBiomassByClass', na.rm=TRUE)))
Returns a data.frame
of first-class and computed node
properties of communities in a CommunityCollection
.
CollectionNPS(collection, properties=NULL)
CollectionNPS(collection, properties=NULL)
collection |
an object of class |
properties |
names of the properties. These can be names of first-class
properties and names of functions. Names must meet the criteria of
the |
This function is named CollectionNPS for Collection Node PropertieS.
If properties
is NULL
, all first-class node properties are
included in the returned data.frame
.
A data.frame
.
Lawrence Hudson
data(pHWebs) head(CollectionNPS(pHWebs), 10) head(CollectionNPS(pHWebs, 'M'), 10) # Biomass is a function head(CollectionNPS(pHWebs, 'Biomass'), 10) head(CollectionNPS(pHWebs, c(B='Biomass')), 10) # Several first-class and computed properties head(CollectionNPS(pHWebs, c('M', 'N', B='Biomass', 'TrophicSpecies', TL='PreyAveragedTrophicLevel')), 10) # Pass parameters to functions head(CollectionNPS(pHWebs, list(TS1='TrophicSpecies', TS2=list('TrophicSpecies', include.isolated=FALSE), Iso='IsIsolatedNode')), 10)
data(pHWebs) head(CollectionNPS(pHWebs), 10) head(CollectionNPS(pHWebs, 'M'), 10) # Biomass is a function head(CollectionNPS(pHWebs, 'Biomass'), 10) head(CollectionNPS(pHWebs, c(B='Biomass')), 10) # Several first-class and computed properties head(CollectionNPS(pHWebs, c('M', 'N', B='Biomass', 'TrophicSpecies', TL='PreyAveragedTrophicLevel')), 10) # Pass parameters to functions head(CollectionNPS(pHWebs, list(TS1='TrophicSpecies', TS2=list('TrophicSpecies', include.isolated=FALSE), Iso='IsIsolatedNode')), 10)
Returns a data.frame
of first-class and computed
trophic-link properties of communities in a CommunityCollection
.
CollectionTLPS(collection, node.properties=NULL, link.properties=NULL)
CollectionTLPS(collection, node.properties=NULL, link.properties=NULL)
collection |
an object of class |
node.properties |
the names of the node properties to return. Should
meet the critera of the |
link.properties |
the names of the trophic link properties to return.
Should meet the critera of the |
This function is named CollectionTLPS for Collection Trophic Link
PropertieS. It returns a data.frame
containing the columns ‘resource’
and ‘consumer’ and any requested node and trophic-link properties.
If node.properties
and link.properties
are both NULL
then
all first-class trophic-link properties are included in the returned
data.frame
.
A data.frame
.
Lawrence Hudson
data(pHWebs) # Just community, resource and consumer head(CollectionTLPS(pHWebs), 10) # The M of the resource and consumer in each link head(CollectionTLPS(pHWebs, node.properties='M'), 10)
data(pHWebs) # Just community, resource and consumer head(CollectionTLPS(pHWebs), 10) # The M of the resource and consumer in each link head(CollectionTLPS(pHWebs, node.properties='M'), 10)
Creates and returns a new object that represents an ecological community.
Community(nodes, properties, trophic.links = NULL) ## S3 method for class 'Community' print(x, ...) ## S3 method for class 'Community' plot(x, ...) ## S3 method for class 'Community' summary(object, ...)
Community(nodes, properties, trophic.links = NULL) ## S3 method for class 'Community' print(x, ...) ## S3 method for class 'Community' plot(x, ...) ## S3 method for class 'Community' summary(object, ...)
nodes |
a |
properties |
a list of properties the community as a whole. All elements must be named and must be of length one. |
trophic.links |
|
x |
an object of class |
object |
an object of class |
... |
further arguments passed to other methods. |
The most convenient way to import community data in to Cheddar is
to put data in to CSV files and use the LoadCommunity
function.
Many of Cheddar's plot and analysis functions make use of the ‘category’ node property by default, following previously-used metabolic groupings (Yodzis and Innes, 1992). The column nodes$category is optional but, if given, it should contain one of ‘producer’, ‘invertebrate’, ‘vert.ecto’, ‘vert.endo’ or should be an empty string.
Community
supports standard generic functions plot
,
print
, and summary
.
A new object of class Community
.
Lawrence Hudson
Yodzis, P. and Innes, S. (1992) Body size and resource-consumer dynamics. The American Naturalist 139, 1151–1175.
CPS
,
NPS
,
TLPS
,
LoadCommunity
SaveCommunity
data(TL84) TL84 # Node properties NPS(TL84) # Trophic-link properties TLPS(TL84) # Eyeball the data plot(TL84) # A different plot function PlotWebByLevel(TL84) # Construct a new community. # TL84.new is an exact copy of TL84 TL84.new <- Community(properties=CPS(TL84), nodes=NPS(TL84), trophic.links=TLPS(TL84)) identical(TL84, TL84.new) # A copy of TL84 without trophic links TL84.no.links <- Community(properties=CPS(TL84), nodes=NPS(TL84)) NumberOfTrophicLinks(TL84.no.links) # A community with 10 species and no properties test <- Community(nodes=data.frame(node=paste('Species', 1:10)), properties=list(title='Test community')) test NPS(test)
data(TL84) TL84 # Node properties NPS(TL84) # Trophic-link properties TLPS(TL84) # Eyeball the data plot(TL84) # A different plot function PlotWebByLevel(TL84) # Construct a new community. # TL84.new is an exact copy of TL84 TL84.new <- Community(properties=CPS(TL84), nodes=NPS(TL84), trophic.links=TLPS(TL84)) identical(TL84, TL84.new) # A copy of TL84 without trophic links TL84.no.links <- Community(properties=CPS(TL84), nodes=NPS(TL84)) NumberOfTrophicLinks(TL84.no.links) # A community with 10 species and no properties test <- Community(nodes=data.frame(node=paste('Species', 1:10)), properties=list(title='Test community')) test NPS(test)
Functions that return whether or not a community has a particular property.
HasM(community) HasN(community) HasTrophicLinks(community)
HasM(community) HasN(community) HasTrophicLinks(community)
community |
an object of class |
A logical
.
Lawrence Hudson
# Tuesday Lake 1984 has all three data(TL84) HasM(TL84) HasN(TL84) HasTrophicLinks(TL84) # Skipwith Pond has trophic links but not M or N data(SkipwithPond) HasM(SkipwithPond) HasN(SkipwithPond) HasTrophicLinks(SkipwithPond)
# Tuesday Lake 1984 has all three data(TL84) HasM(TL84) HasN(TL84) HasTrophicLinks(TL84) # Skipwith Pond has trophic links but not M or N data(SkipwithPond) HasM(SkipwithPond) HasN(SkipwithPond) HasTrophicLinks(SkipwithPond)
Collections of communities
CommunityCollection(communities) ## S3 method for class 'CommunityCollection' print(x, ...) ## S3 method for class 'CommunityCollection' plot(x, ncol=min(length(x),5), by.col=TRUE, plot.fn=plot, ...) ## S3 method for class 'CommunityCollection' summary(object, ...)
CommunityCollection(communities) ## S3 method for class 'CommunityCollection' print(x, ...) ## S3 method for class 'CommunityCollection' plot(x, ncol=min(length(x),5), by.col=TRUE, plot.fn=plot, ...) ## S3 method for class 'CommunityCollection' summary(object, ...)
communities |
a |
x |
an object of class |
object |
an object of class |
ncol |
the number of columns in the plot. |
by.col |
logical - if |
plot.fn |
a plot function that accepts a |
... |
further arguments passed to other methods. |
Constructs a new CommunityCollection
from a list of existing
Community
objects. CommunityCollection
is a subclass of
list
. CommunityCollection
objects can not be modified directly.
An error is raised if any Community
objects in communities
share
the same ‘title’ community property.
An error is also raised if the Community
objects in communities
do not all have the same value of the community properties ‘M.units’ and
‘N.units’.
CommunityCollection
places no restrictions on other properties.
For example, all of the ten communities with the pHWebs
collection has a valid pH property but this is not enforced by
CommunityCollection
- it would be possible for a Community
within a collection to not have a pH property, to have a pH of NA
or
even to have an invalid pH, for example a negative value.
CommunityCollection
supports standard generic functions plot
,
print
, subset
and summary
.
A new object of class CommunityCollection
.
Lawrence Hudson
Community
,
CollectionCPS
CollectionNPS
CollectionTLPS
,
OrderCollection
,
subset.CommunityCollection
,
AggregateCommunitiesBy
,
AggregateCommunities
,
pHWebs
# 10 stream webs sampled over a wide pH gradient data(pHWebs) pHWebs # Eyeball the webs plot(pHWebs) # Consistent axis limits plot(pHWebs, xlim=c(-14,6), ylim=c(-3,13)) # Different plot function plot(pHWebs, plot.fn=PlotWebByLevel, ylim=c(1,4.5)) # list-like operations length(pHWebs) sapply(pHWebs, 'NumberOfTrophicLinks') pHWebs[['Broadstone']] # Access the Community # A new CommunityCollection containing every other ph web pHWebs[seq(1, 10, by=2)] # A new CommunityCollection containing two webs pHWebs[c('Old Lodge','Bere Stream')] # CollectionCPS gets community properties CollectionCPS(pHWebs) # Webs are sorted by increasing pH # Order by decreasing pH pHWebs.decreasing.pH <- OrderCollection(pHWebs, 'pH', decreasing=TRUE) CollectionCPS(pHWebs.decreasing.pH) # Order by name pHWebs.name <- OrderCollection(pHWebs, 'title') CollectionCPS(pHWebs.name, c('pH', 'NumberOfNodes')) # The following will always be TRUE. all(FALSE==duplicated(names(pHWebs))) # A new collection of the two Tuesday Lake communities data(TL84, TL86) BothTL <- CommunityCollection(list(TL84, TL86)) CollectionCPS(BothTL) # You can't modify CommunityCollections ## Not run: pHWebs[1] <- 'silly'
# 10 stream webs sampled over a wide pH gradient data(pHWebs) pHWebs # Eyeball the webs plot(pHWebs) # Consistent axis limits plot(pHWebs, xlim=c(-14,6), ylim=c(-3,13)) # Different plot function plot(pHWebs, plot.fn=PlotWebByLevel, ylim=c(1,4.5)) # list-like operations length(pHWebs) sapply(pHWebs, 'NumberOfTrophicLinks') pHWebs[['Broadstone']] # Access the Community # A new CommunityCollection containing every other ph web pHWebs[seq(1, 10, by=2)] # A new CommunityCollection containing two webs pHWebs[c('Old Lodge','Bere Stream')] # CollectionCPS gets community properties CollectionCPS(pHWebs) # Webs are sorted by increasing pH # Order by decreasing pH pHWebs.decreasing.pH <- OrderCollection(pHWebs, 'pH', decreasing=TRUE) CollectionCPS(pHWebs.decreasing.pH) # Order by name pHWebs.name <- OrderCollection(pHWebs, 'title') CollectionCPS(pHWebs.name, c('pH', 'NumberOfNodes')) # The following will always be TRUE. all(FALSE==duplicated(names(pHWebs))) # A new collection of the two Tuesday Lake communities data(TL84, TL86) BothTL <- CommunityCollection(list(TL84, TL86)) CollectionCPS(BothTL) # You can't modify CommunityCollections ## Not run: pHWebs[1] <- 'silly'
Returns a vector of names of community properties.
CommunityPropertyNames(community)
CommunityPropertyNames(community)
community |
an object of class |
A vector of names of community properties.
Lawrence Hudson
data(TL84) CommunityPropertyNames(TL84)
data(TL84) CommunityPropertyNames(TL84)
Returns a single community property or NA
if property is
not in CommunityPropertyNames
.
CP(community, property)
CP(community, property)
community |
an object of class |
property |
the name of the community property to be returned. |
This function is named CP for Community Property.
A single community property.
Lawrence Hudson
Community
, CPS
,
CommunityPropertyNames
data(TL84) CP(TL84, 'title') CP(TL84, 'lat') CP(TL84, 'M.units') # Returns a vector of NA CP(TL84, 'not a property')
data(TL84) CP(TL84, 'title') CP(TL84, 'lat') CP(TL84, 'M.units') # Returns a vector of NA CP(TL84, 'not a property')
Returns a list of first-class and computed community properties.
CPS(community, properties = NULL)
CPS(community, properties = NULL)
community |
an object of class |
properties |
the names of the properties to be returned. |
This function is named CPS for Community PropertieS.
If properties is NULL
, all properties are returned. If properties is
not NULL
then a list containing that subset of community properties is
returned. Elements will be NA
for values of property
not in
CommunityPropertyNames
.
A list
.
Lawrence Hudson
Community
, CP
,
CommunityPropertyNames
data(TL84) # All properties CPS(TL84) # Just lat and long CPS(TL84, c('lat', 'long')) # lat and long and number of nodes CPS(TL84, c('lat', 'long', 'NumberOfNodes')) # lat and long and number of nodes, renamed CPS(TL84, c('lat', 'long', S='NumberOfNodes')) # 'not a property' is NA CPS(TL84, c('lat', 'long', S='NumberOfNodes', 'not a property'))
data(TL84) # All properties CPS(TL84) # Just lat and long CPS(TL84, c('lat', 'long')) # lat and long and number of nodes CPS(TL84, c('lat', 'long', 'NumberOfNodes')) # lat and long and number of nodes, renamed CPS(TL84, c('lat', 'long', S='NumberOfNodes')) # 'not a property' is NA CPS(TL84, c('lat', 'long', S='NumberOfNodes', 'not a property'))
The number of trophic links in to and out of nodes in a
Community
.
Degree(community) InDegree(community) TrophicGenerality(community) NumberOfResources(community) OutDegree(community) TrophicVulnerability(community) NumberOfConsumers(community) NormalisedTrophicGenerality(community) NormalisedTrophicVulnerability(community)
Degree(community) InDegree(community) TrophicGenerality(community) NumberOfResources(community) OutDegree(community) TrophicVulnerability(community) NumberOfConsumers(community) NormalisedTrophicGenerality(community) NormalisedTrophicVulnerability(community)
community |
an object of class |
InDegree
and OutDegree
return the number of trophic
links in-to and out-of each node. Degree
returns InDegree
+
OutDegree
. TrophicGenerality
and NumberOfResources
are synonyms for InDegree
. TrophicVulnerability
and
NumberOfResources
are synonyms for OutDegree
.
NormalisedTrophicGenerality
and NormalisedTrophicVulnerability
return the containing the number of resources and consumer of each node,
normalised with respect to LinkageDensity
. The mean of the values
returned by both NormalisedTrophicGenerality
and
NormalisedTrophicVulnerability
is 1, making their standard
deviations comparable across different food webs.
A vector of length NumberOfNodes
.
Lawrence Hudson
Williams, R.J. and Martinez, N.D. (2000) Simple rules yield complex food webs. Nature 404, 180–183.
Community
, NumberOfNodes
,
LinkageDensity
, DirectedConnectance
,
DegreeDistribution
data(TL84) d <- Degree(TL84) i <- InDegree(TL84) o <- OutDegree(TL84) # This equality is always TRUE for all food webs all(d == i+o) ntg <- NormalisedTrophicGenerality(TL84) mean(ntg) # Equals 1 ntv <- NormalisedTrophicVulnerability(TL84) mean(ntv) # Equals 1
data(TL84) d <- Degree(TL84) i <- InDegree(TL84) o <- OutDegree(TL84) # This equality is always TRUE for all food webs all(d == i+o) ntg <- NormalisedTrophicGenerality(TL84) mean(ntg) # Equals 1 ntv <- NormalisedTrophicVulnerability(TL84) mean(ntv) # Equals 1
Node degree distribution.
DegreeDistribution(community, cumulative=FALSE)
DegreeDistribution(community, cumulative=FALSE)
community |
an object of class |
cumulative |
logical - if |
Returns a vector of proportions of nodes with
0:max(Degree(community))
trophic links.
A vector of numbers.
Lawrence Hudson
Degree
, PlotDegreeDistribution
data(TL84) DegreeDistribution(TL84) DegreeDistribution(TL84, cumulative=TRUE)
data(TL84) DegreeDistribution(TL84) DegreeDistribution(TL84, cumulative=TRUE)
Functions for computing the sum diet/consumer gaps of each
species in a Community
and for minimising the sum diet/consumer gaps
using a simulated annealing learning method.
SumDietGaps(community) SumConsumerGaps(community) MinimiseSumDietGaps(community, T.start = 10, T.stop = 0.1, c = 0.9, swaps.per.T = 1000, trace.anneal = FALSE, n = 1, best = TRUE) MinimiseSumConsumerGaps(community, T.start = 10, T.stop = 0.1, c = 0.9, swaps.per.T = 1000, trace.anneal = FALSE, n = 1, best = TRUE)
SumDietGaps(community) SumConsumerGaps(community) MinimiseSumDietGaps(community, T.start = 10, T.stop = 0.1, c = 0.9, swaps.per.T = 1000, trace.anneal = FALSE, n = 1, best = TRUE) MinimiseSumConsumerGaps(community, T.start = 10, T.stop = 0.1, c = 0.9, swaps.per.T = 1000, trace.anneal = FALSE, n = 1, best = TRUE)
community |
an object of class |
T.start |
the temperature at which annealing starts; must be >0 |
T.stop |
annealing will stop when the system temperature drops below
|
c |
cooling coefficient; must be >0 and <1. |
swaps.per.T |
the number of predation matrix row swaps per temperature. |
trace.anneal |
logical - if |
n |
numeric - the number of repetitions of the minimisation procedure. |
best |
logical - if |
SumDietGaps
and SumConsumerGaps
return the total number
of gaps in each species' diet (Stouffer et al 2006) and each species' consumers
(Zook et al 2011) respectively.
MinimiseSumDietGaps
and MinimiseSumConsumerGaps
use the
simulated annealing learning method described by Stouffer et al (2006) to
minimise either SumDietGaps
or SumConsumerGaps
. Simulated
annealing learning is a stochastic method so several optimisations might be
required to find the global minimum. Use a value of n
greater than 1 to
perform several optimisations.
For SumDietGaps
and SumConsumerGaps
, a single number.
For the two minimisation functions, if n
is 1 or best
is
TRUE
, a list
containing the values
sum.gaps |
the lowest |
order |
a vector of node names giving the best ordering. |
reordered |
|
If n
is greater than 1 and best
is FALSE
then a list of
n
lists, each list containing the above three values, sorted by
increasing sum.gaps
.
Lawrence Hudson
Stouffer, D.B. and Camacho, J. and Amaral, L.A.N. (2006) Proceedings of the National Academy of Sciences of the United States of America 103, 50, 19015–19020.
Zook, A.E. and Eklof, A. and Jacob, U. and Allesina, S. (2011) Journal of Theoretical Biology 271, 1 106–113.
Community
, OrderCommunity
,
PredationMatrix
, PlotPredationMatrix
data(TL84) # Perform 5 independent optimisations res <- MinimiseSumDietGaps(TL84, n=5) # Compare the original, ordered by body mass and minimised predation matrices par(mfrow=c(1,3)) PlotPredationMatrix(TL84, main=paste('Sum diet gap', SumDietGaps(TL84))) TL84.by.M <- OrderCommunity(TL84, 'M') PlotPredationMatrix(TL84.by.M, main=paste('Sum diet gap', SumDietGaps(TL84.by.M))) PlotPredationMatrix(res$reordered, main=paste('Sum diet gap', res$sum.gaps)) # The same comparison but retaining the original column ordering par(mfrow=c(1,3)) PlotPredationMatrix(TL84) PlotPredationMatrix(TL84, resource.order=NP(TL84.by.M, 'node')) PlotPredationMatrix(TL84, resource.order=res$order)
data(TL84) # Perform 5 independent optimisations res <- MinimiseSumDietGaps(TL84, n=5) # Compare the original, ordered by body mass and minimised predation matrices par(mfrow=c(1,3)) PlotPredationMatrix(TL84, main=paste('Sum diet gap', SumDietGaps(TL84))) TL84.by.M <- OrderCommunity(TL84, 'M') PlotPredationMatrix(TL84.by.M, main=paste('Sum diet gap', SumDietGaps(TL84.by.M))) PlotPredationMatrix(res$reordered, main=paste('Sum diet gap', res$sum.gaps)) # The same comparison but retaining the original column ordering par(mfrow=c(1,3)) PlotPredationMatrix(TL84) PlotPredationMatrix(TL84, resource.order=NP(TL84.by.M, 'node')) PlotPredationMatrix(TL84, resource.order=res$order)
Nodes that consume themselves in the food web.
IsCannibal(community) Cannibals(community) FractionCannibalistic(community)
IsCannibal(community) Cannibals(community) FractionCannibalistic(community)
community |
an object of class |
IsCannibal
returns a vector of logical
of length
NumberOfNodes
; values are TRUE
for nodes consume themselves.
Cannibals
returns the names of nodes for which IsCannibals
returns TRUE
. FractionCannibalistic
returns the proportion of
nodes for which IsCannibal
returns TRUE
Either a logical
vector of length NumberOfNodes
or a
vector of names.
Lawrence Hudson
RemoveCannibalisticLinks
,
NumberOfNodes
,
PredationMatrix
,
Degree
,
InDegree
,
OutDegree
,
ResourcesByNode
,
ConsumersByNode
,
ResourcesOfNodes
,
ConsumersOfNodes
data(TL84) IsCannibal(TL84) Cannibals(TL84) FractionCannibalistic(TL84)
data(TL84) IsCannibal(TL84) Cannibals(TL84) FractionCannibalistic(TL84)
Fit linear regressions to node data by class.
LinearRegressionByClass(community, X, Y, class)
LinearRegressionByClass(community, X, Y, class)
community |
an object of class |
X |
Independent variable. A property name that must meet the criteria of
the |
Y |
Dependent variable. A property name that must meet the criteria of
the |
class |
The property over which linear regressions are fitted. |
A linear model is fitted through all data points and through each
subset of the data given by class
. A list of lm
objects is
returned. The list will contain NULL
if it is not possible to fit a
linear regression to that class; this will happen for classes that contain
just a single node or that contain all or all but one nodes where X
and/or Y
is NA
.
A list
of lm
objects.
Lawrence Hudson
Community
,
ApplyByClass
,
NPS
,
NvMLinearRegressions
,
lm
data(TL84) # Regressions fitted to log10(Biomass) versus log10(M) data. models <- LinearRegressionByClass(TL84, 'Log10M', 'Log10Biomass', 'category') # 'all', 'producer', 'invertebrate', 'vert.ecto' names(models) # Extract slopes and intercepts sapply(models, coef)
data(TL84) # Regressions fitted to log10(Biomass) versus log10(M) data. models <- LinearRegressionByClass(TL84, 'Log10M', 'Log10Biomass', 'category') # 'all', 'producer', 'invertebrate', 'vert.ecto' names(models) # Extract slopes and intercepts sapply(models, coef)
LoadCollection
and SaveCollection
are functions
for loading and saving CommunityCollection
objects to text files.
LoadCollection(dir, ...) SaveCollection(collection, dir, ...)
LoadCollection(dir, ...) SaveCollection(collection, dir, ...)
collection |
an object of class |
dir |
a directory. |
... |
other values to |
The Community
objects in collection
are saved to a
directory named communities
inside dir
. The order of the
collection is not saved. Any existing data in dir
is ignored.
LoadCollection
returns a new CommunityCollection
.
Lawrence Hudson
CommunityCollection
,
OrderCollection
,
LoadCommunity
,
SaveCommunity
data(pHWebs) temp.path <- tempfile() SaveCollection(pHWebs, temp.path) pHWebs.loaded <- LoadCollection(temp.path) pHWebs.loaded <- OrderCollection(pHWebs.loaded, 'pH') unlink(temp.path, recursive=TRUE) identical(pHWebs, pHWebs.loaded) # TRUE
data(pHWebs) temp.path <- tempfile() SaveCollection(pHWebs, temp.path) pHWebs.loaded <- LoadCollection(temp.path) pHWebs.loaded <- OrderCollection(pHWebs.loaded, 'pH') unlink(temp.path, recursive=TRUE) identical(pHWebs, pHWebs.loaded) # TRUE
LoadCommunity
and SaveCommunity
are functions for loading and
saving Community
objects to CSV files.
LoadCommunity(dir, fn='read.csv', ...) SaveCommunity(community, dir, fn='write.csv', na='', ...)
LoadCommunity(dir, fn='read.csv', ...) SaveCommunity(community, dir, fn='write.csv', na='', ...)
community |
an object of class |
dir |
a directory. |
fn |
the name of an R function that loads/saves CSV files. |
na |
the string to use for missing values in the data; see
|
... |
other values to |
Data are stored in CSV (Comma-Separated Value) files in dir
.
Properties of any aspect of the community (nodes, links or the whole community)
can be added simply by adding columns to the relevant CSV file.
The data-quality checks defined by Community
are applied by
LoadCommunity
. The fn
and dots
arguments can be used to
read/write files in a range of formats.
properties.csv
defines items applicable to the community as a
whole, such as sampling date, lat & long or altitude and environmental
variables such as temperature or pH. This file must contain a column called
‘title’.
nodes.csv
should contain the list of nodes and together with any
associated properties such as mean body mass, mean numerical abundance and
classification. This file must contain a column called ‘node’ that must contain
node names. Many of Cheddar's plot and analysis functions make use of the
‘category’ node property by default, following previously-used metabolic
groupings (Yodzis & Innes, 1992). The ‘category’ column of nodes.csv
is optional but, if given, it should contain one of ‘producer’,
‘invertebrate’, ‘vert.ecto’, ‘vert.endo’ or should be an empty string.
trophic.links.csv
is optional. It defines trophic links in columns
‘resource’ and ‘consumer’, which should be names of nodes. Properties
of trophic links such as evidence for the presence of the link (e.g.
empirically observed or inferred from literature) can be added to this file.
LoadCommunity
returns a new Community
.
Lawrence Hudson
Yodzis, P. and Innes, S. (1992) Body size and resource-consumer dynamics. The American Naturalist 139, 1151–1175.
Community
,
read.csv
,
write.csv
data(TL84) temp.path <- tempfile() SaveCommunity(TL84, temp.path) TL84.loaded <- LoadCommunity(temp.path) unlink(temp.path, recursive=TRUE) identical(TL84, TL84.loaded) # TRUE
data(TL84) temp.path <- tempfile() SaveCommunity(TL84, temp.path) TL84.loaded <- LoadCommunity(temp.path) unlink(temp.path, recursive=TRUE) identical(TL84, TL84.loaded) # TRUE
A function that lumps together nodes in a Community
.
LumpNodes(community, lump, title = NULL, weight.by = 'N')
LumpNodes(community, lump, title = NULL, weight.by = 'N')
community |
an object of class |
lump |
a vector of of length |
title |
the title of the new |
weight.by |
the name of a column by which to compute weighted mean of numeric values. |
If weight.by
is not NULL
and it is the name of
a node property, it is used to compute weighted means of all the other
numeric node properties. The arithmetic mean of weight.by
is
computed.
If weight.by
is NULL
or is not the name of a node property,
the arithmetic mean is computed for each numeric node property.
Node properties that are characters or logicals are aggregated by joining
unique values with a ‘,’. Empty character strings are ignored.
A new object of class Community
.
Lawrence Hudson
LumpTrophicSpecies
,
IsIsolatedNode
, IsolatedNodes
,
NPS
, weighted.mean
data(TL84) # Lump together isolated nodes in TL84 length(which(IsIsolatedNode(TL84))) # 6 isolated species IsolatedNodes(TL84) # Names of isolated nodes lump <- NP(TL84, 'node') # Existing node names # Give isolated nodes the same lump value lump[IsolatedNodes(TL84)] <- 'Isolated nodes lumped together' TL84.lumped <- LumpNodes(TL84, lump) NumberOfNodes(TL84) # 56 nodes in unlumped web NumberOfNodes(TL84.lumped) # 51 nodes in lumped web IsolatedNodes(TL84.lumped) # A single node # This trivial example shows that no nodes are lumped if values in lump are # unique to each node lump <- NP(TL84, 'node') identical(TL84, LumpNodes(TL84, lump, title=CP(TL84, 'title'))) # Ythan Estuary contains two species that are split in to adult and # juvenile forms. The example below lumps these in to single species. data(YthanEstuary) # The names of nodes in YthanEstuary lump <- NP(YthanEstuary, 'node') # European flounder: # "Platichthys flesus" and "Platichthys flesus (juvenile)" # Lump these in to one node lump["Platichthys flesus (juvenile)"==lump] <- "Platichthys flesus" # Common eider: # "Somateria mollissima" and "Somateria mollissima (juvenile)" # Lump these in to one node lump["Somateria mollissima (juvenile)"==lump] <- "Somateria mollissima" YthanEstuary.lumped <- LumpNodes(YthanEstuary, lump) # Examine the computed means for Somateria mollissima # Arithmetic mean of N is 2592 NP(YthanEstuary.lumped, 'N')['Somateria mollissima'] mean(NP(YthanEstuary, 'N')[c("Somateria mollissima (juvenile)", "Somateria mollissima")]) # N-weighted mean of M is 1637.018 NP(YthanEstuary.lumped, 'M')['Somateria mollissima'] weighted.mean(NP(YthanEstuary, 'M')[c("Somateria mollissima (juvenile)", "Somateria mollissima")], NP(YthanEstuary, 'N')[c("Somateria mollissima (juvenile)", "Somateria mollissima")], ) # Plot the original community and the community with lumped nodes par(mfrow=c(1,2)) plot(YthanEstuary, highlight.nodes=c("Platichthys flesus", "Platichthys flesus (juvenile)", "Somateria mollissima", "Somateria mollissima (juvenile)")) plot(YthanEstuary.lumped, highlight.nodes=c("Platichthys flesus", "Somateria mollissima"))
data(TL84) # Lump together isolated nodes in TL84 length(which(IsIsolatedNode(TL84))) # 6 isolated species IsolatedNodes(TL84) # Names of isolated nodes lump <- NP(TL84, 'node') # Existing node names # Give isolated nodes the same lump value lump[IsolatedNodes(TL84)] <- 'Isolated nodes lumped together' TL84.lumped <- LumpNodes(TL84, lump) NumberOfNodes(TL84) # 56 nodes in unlumped web NumberOfNodes(TL84.lumped) # 51 nodes in lumped web IsolatedNodes(TL84.lumped) # A single node # This trivial example shows that no nodes are lumped if values in lump are # unique to each node lump <- NP(TL84, 'node') identical(TL84, LumpNodes(TL84, lump, title=CP(TL84, 'title'))) # Ythan Estuary contains two species that are split in to adult and # juvenile forms. The example below lumps these in to single species. data(YthanEstuary) # The names of nodes in YthanEstuary lump <- NP(YthanEstuary, 'node') # European flounder: # "Platichthys flesus" and "Platichthys flesus (juvenile)" # Lump these in to one node lump["Platichthys flesus (juvenile)"==lump] <- "Platichthys flesus" # Common eider: # "Somateria mollissima" and "Somateria mollissima (juvenile)" # Lump these in to one node lump["Somateria mollissima (juvenile)"==lump] <- "Somateria mollissima" YthanEstuary.lumped <- LumpNodes(YthanEstuary, lump) # Examine the computed means for Somateria mollissima # Arithmetic mean of N is 2592 NP(YthanEstuary.lumped, 'N')['Somateria mollissima'] mean(NP(YthanEstuary, 'N')[c("Somateria mollissima (juvenile)", "Somateria mollissima")]) # N-weighted mean of M is 1637.018 NP(YthanEstuary.lumped, 'M')['Somateria mollissima'] weighted.mean(NP(YthanEstuary, 'M')[c("Somateria mollissima (juvenile)", "Somateria mollissima")], NP(YthanEstuary, 'N')[c("Somateria mollissima (juvenile)", "Somateria mollissima")], ) # Plot the original community and the community with lumped nodes par(mfrow=c(1,2)) plot(YthanEstuary, highlight.nodes=c("Platichthys flesus", "Platichthys flesus (juvenile)", "Somateria mollissima", "Somateria mollissima (juvenile)")) plot(YthanEstuary.lumped, highlight.nodes=c("Platichthys flesus", "Somateria mollissima"))
Lump trophic species.
LumpTrophicSpecies(community, include.isolated=TRUE, title=NULL, ...)
LumpTrophicSpecies(community, include.isolated=TRUE, title=NULL, ...)
community |
an object of class |
include.isolated |
if |
title |
the title of the new |
... |
other parameters to |
Aggregates nodes that share identical sets of prey and predators.
A Community
.
Lawrence Hudson
Briand, F and Cohen, J.E. 1984 Community food webs have scale-invariant structure Nature 307, 264–267.
Jonsson, T. and Cohen, J.E. and Carpenter, S. R. 2005 Food webs, body size, and species abundance in ecological community description. Advances in Ecological Research 36, 1–84.
Pimm, S.L. and Lawton, J.H. and Cohen, J.E. 1991 Food web patterns and their consequences Nature 350, 669–674.
Williams, R.J. and Martinez, N.D. 2000 Simple rules yield complex food webs 404, 180–183.
TrophicSpecies
, LumpNodes
,
IsIsolatedNode
data(TL84) NumberOfNodes(TL84) TL84.lumped <- LumpTrophicSpecies(TL84) length(unique(TrophicSpecies(TL84))) # 22 trophic species in TL84... NumberOfNodes(TL84.lumped) # ... and 22 nodes in the lumped web
data(TL84) NumberOfNodes(TL84) TL84.lumped <- LumpTrophicSpecies(TL84) length(unique(TrophicSpecies(TL84))) # 22 trophic species in TL84... NumberOfNodes(TL84.lumped) # ... and 22 nodes in the lumped web
The control and drought treatments from one of the four replicates from a long-running study of the effects of drought on community structure.
Taxonomic classification provided by Mark Ledger.
CommunityCollection
.
Ledger et al, 2011; Ledger et al, 2012; Woodward et al 2012.
Ledger, M.E. and Edwards, F.K. and Brown, L.E. and Milner, A.M. and Woodward, G. (2011) Impact of simulated drought on ecosystem biomass production: an experimental test in stream mesocosms. Global Change Biology 17, 7, 2288–2297.
Ledger, M.E., and Brown, L.E., and Edwards, F.K. and Milner, A.M. and Woodward, G. (2012) Drought alters the structure and functioning of complex food webs. Nature Climate Change 2, 9, 1–5.
Woodward, G. and Brown, L.E and Edwards, F. and Hudson, L.N. and Milner, A.M. and Reuman, D.C. and Mark E.L. (2012) Climate change impacts in multispecies systems: drought alters food web size-structure in a field experiment. Philosophical Transactions of the Royal Society B: Biological Sciences.
Functions that report the connectivity of nodes in a food web.
IsBasalNode(community) IsTopLevelNode(community) IsIntermediateNode(community) IsIsolatedNode(community) IsConnectedNode(community) IsNonBasalNode(community) IsNonTopLevelNode(community) BasalNodes(community) TopLevelNodes(community) IntermediateNodes(community) IsolatedNodes(community) ConnectedNodes(community) NonTopLevelNodes(community) NonBasalNodes(community) FractionBasalNodes(community) FractionIntermediateNodes(community) FractionTopLevelNodes(community) FractionIsolatedNodes(community) FractionNonBasalNodes(community) FractionConnectedNodes(community) FractionNonTopLevelNodes(community)
IsBasalNode(community) IsTopLevelNode(community) IsIntermediateNode(community) IsIsolatedNode(community) IsConnectedNode(community) IsNonBasalNode(community) IsNonTopLevelNode(community) BasalNodes(community) TopLevelNodes(community) IntermediateNodes(community) IsolatedNodes(community) ConnectedNodes(community) NonTopLevelNodes(community) NonBasalNodes(community) FractionBasalNodes(community) FractionIntermediateNodes(community) FractionTopLevelNodes(community) FractionIsolatedNodes(community) FractionNonBasalNodes(community) FractionConnectedNodes(community) FractionNonTopLevelNodes(community)
community |
an object of class |
Each node in a community is defined as:
isolated | No resources or consumers, other than possibly itself |
basal | No resources and one or more consumers |
top-level | One or more resources and no consumers, other than possibly itself |
intermediate | Nodes not fitting any of the above categories |
These definitions allow the following additional definitions:
connected | basal, intermediate or top-level |
non-basal | isolated, intermediate or top-level |
non-top-level | isolated, basal or intermediate |
For each of the above seven definitions, ‘X’, there are three functions:
IsX
, X
and FractionX
.
The first returns a vector of logical
of length NumberOfNodes
;
values are TRUE
for nodes that fit the definition of ‘X’.
The second returns the names of nodes for which IsX
returns TRUE
.
The third returns the proportion of nodes in the community that fit the
definition of ‘X’.
Either a logical
vector of length NumberOfNodes
or a
vector of names.
Lawrence Hudson
NumberOfNodes
,
Cannibals
,
IsCannibal
,
NumberOfTrophicLinks
,
PredationMatrix
,
Degree
,
InDegree
,
OutDegree
,
ResourcesByNode
,
ConsumersByNode
,
ResourcesOfNodes
,
ConsumersOfNodes
data(TL84) # Assemble a table of node connectivity. Only one of each of the following # four properties is TRUE for each node. connectivity <- NPS(TL84, c('IsBasalNode', 'IsIsolatedNode', 'IsIntermediateNode', 'IsTopLevelNode')) connectivity # Each row sums to 1, confirming that exactly one of the columns in each row # is TRUE. all(1==rowSums(connectivity)) # These summations are 1 sum(FractionBasalNodes(TL84), FractionIntermediateNodes(TL84), FractionTopLevelNodes(TL84), FractionIsolatedNodes(TL84)) sum(FractionConnectedNodes(TL84), FractionIsolatedNodes(TL84)) sum(FractionBasalNodes(TL84), FractionNonBasalNodes(TL84)) sum(FractionTopLevelNodes(TL84), FractionNonTopLevelNodes(TL84))
data(TL84) # Assemble a table of node connectivity. Only one of each of the following # four properties is TRUE for each node. connectivity <- NPS(TL84, c('IsBasalNode', 'IsIsolatedNode', 'IsIntermediateNode', 'IsTopLevelNode')) connectivity # Each row sums to 1, confirming that exactly one of the columns in each row # is TRUE. all(1==rowSums(connectivity)) # These summations are 1 sum(FractionBasalNodes(TL84), FractionIntermediateNodes(TL84), FractionTopLevelNodes(TL84), FractionIsolatedNodes(TL84)) sum(FractionConnectedNodes(TL84), FractionIsolatedNodes(TL84)) sum(FractionBasalNodes(TL84), FractionNonBasalNodes(TL84)) sum(FractionTopLevelNodes(TL84), FractionNonTopLevelNodes(TL84))
Node name indices.
NodeNameIndices(community, nodes)
NodeNameIndices(community, nodes)
community |
an object of class |
nodes |
node names. |
Returns integer indices of names in nodes
.
A vector of integers
Lawrence Hudson
data(TL84) NodeNameIndices(TL84, 'Umbra limi') NodeNameIndices(TL84, c('Nostoc sp.','Umbra limi'))
data(TL84) NodeNameIndices(TL84, 'Umbra limi') NodeNameIndices(TL84, c('Nostoc sp.','Umbra limi'))
Returns a vector of names of node properties.
NodePropertyNames(community)
NodePropertyNames(community)
community |
an object of class |
A vector of the names of node properties.
Lawrence Hudson
data(TL84) NodePropertyNames(TL84)
data(TL84) NodePropertyNames(TL84)
Returns a node property.
NP(community, property)
NP(community, property)
community |
an object of class |
property |
the name of the property to return. |
This function is named NP for Node Property. It returns a vector
containing the value of property
for every node. The returned vector
is named by node. If the name is not a property, a vector of NA
is
returned.
A vector of length NumberOfNodes
.
Lawrence Hudson
data(TL84) NP(TL84, 'M') # Returns a vector of NA NP(TL84, 'not a property')
data(TL84) NP(TL84, 'M') # Returns a vector of NA NP(TL84, 'not a property')
Returns a data.frame
of first-class and computed node
properties.
NPS(community, properties = NULL)
NPS(community, properties = NULL)
community |
an object of class |
properties |
the names of node properties. These can be names of
first-class properties (returned by |
This function is named NPS for Node Properties. It returns a
data.frame
containing the column ‘node’ and any requested properties.
If properties
is NULL
, all first-class node properties are
included in the returned data.frame
.
properties
should be either a vector or a list that contains either
names of first class properties, names of functions that take only a community
or lists in which the first element is the name of a function that takes
a community and subsequent elements are named arguments to that function.
Names of properties
are column names in the returned data.frame
.
A data.frame
with NumberOfNodes
rows.
Lawrence Hudson
data(TL84) NPS(TL84) NPS(TL84, 'M') # Biomass is a function NPS(TL84, 'Biomass') NPS(TL84, c(B='Biomass')) # Several first-class and computed properties NPS(TL84, c('M', 'N', B='Biomass', 'TrophicSpecies', TL='PreyAveragedTrophicLevel')) # Pass parameters to functions NPS(TL84, list(TS1='TrophicSpecies', TS2=list('TrophicSpecies', include.isolated=FALSE), Iso='IsIsolatedNode'))
data(TL84) NPS(TL84) NPS(TL84, 'M') # Biomass is a function NPS(TL84, 'Biomass') NPS(TL84, c(B='Biomass')) # Several first-class and computed properties NPS(TL84, c('M', 'N', B='Biomass', 'TrophicSpecies', TL='PreyAveragedTrophicLevel')) # Pass parameters to functions NPS(TL84, list(TS1='TrophicSpecies', TS2=list('TrophicSpecies', include.isolated=FALSE), Iso='IsIsolatedNode'))
Functions that return the number of nodes in the community.
NumberOfNodes(community) NumberOfNodesByClass(community, class) FractionOfNodesByClass(community, class)
NumberOfNodes(community) NumberOfNodesByClass(community, class) FractionOfNodesByClass(community, class)
community |
an object of class |
class |
the property over which |
NumberOfNodes
returns a single number.
NumberOfNodesByClass
and FractionOfNodesByClass
both return
a value for each class
.
Lawrence Hudson
data(TL84) NumberOfNodes(TL84) NumberOfNodesByClass(TL84) FractionOfNodesByClass(TL84)
data(TL84) NumberOfNodes(TL84) NumberOfNodesByClass(TL84) FractionOfNodesByClass(TL84)
The number of trophic links in Community
.
NumberOfTrophicLinks(community) LinkageDensity(community) DirectedConnectance(community)
NumberOfTrophicLinks(community) LinkageDensity(community) DirectedConnectance(community)
community |
an object of class |
NumberOfTrophicLinks
returns the total number of links in the
web, including cannibalistic links.
LinkageDensity
returns the NumberOfTrophicLinks
/
NumberOfNodes
, including cannibalistic links and isolated nodes.
DirectedConnectance
returns NumberOfTrophicLinks
/
NumberOfNodes
^2, including cannibalistic links and isolated nodes.
A single number.
Lawrence Hudson
Martinez, N. D. 1991 Artifacts or attributes? Effects of resolution on the Little Rock Lake food web. Ecological Monographs 61, 367–392.
data(TL84) NumberOfTrophicLinks(TL84) LinkageDensity(TL84) DirectedConnectance(TL84)
data(TL84) NumberOfTrophicLinks(TL84) LinkageDensity(TL84) DirectedConnectance(TL84)
Compute the convex hull around log-transformed $N$ versus $M$ data.
NvMConvexHull(community)
NvMConvexHull(community)
community |
an object of class |
Returns the points and area of the minimum convex hull (a polygon in log10-transformed numerical abundance versus log10-transformed body mass space) that bounds all the species within the community.
A list
containing the values
nodes |
The names of the nodes that make up the convex hull. |
points |
A matrix containing columns ‘x’ and ‘y’ that contain the coordinates of the points that make up the convex hull. |
area |
The area within the convex hull. |
Lawrence Hudson
Leaper, R. and Raffaelli, D. (1999) Defining the abundance body-size constraint space: data from a real food web. Ecology Letters 2, 3, 191–199.
data(TL84) # Compute convex hull convex.hull <- NvMConvexHull(TL84) # The nodes that form the hull convex.hull$nodes # The area of the hull convex.hull$area # Plot the hull in red around the nodes PlotNvM(TL84) polygon(convex.hull$points, lwd=2, border='red')
data(TL84) # Compute convex hull convex.hull <- NvMConvexHull(TL84) # The nodes that form the hull convex.hull$nodes # The area of the hull convex.hull$area # Plot the hull in red around the nodes PlotNvM(TL84) polygon(convex.hull$points, lwd=2, border='red')
Creation and analysis of linear regressions fitted to log10- transformed numerical abundance versus log10-transformed body mass.
NvMLinearRegressions(community, class) NvMSlope(community) NvMIntercept(community) NvMSlopeAndIntercept(community) NvMSlopeByClass(community, class) NvMInterceptByClass(community, class) NvMSlopeAndInterceptByClass(community, class)
NvMLinearRegressions(community, class) NvMSlope(community) NvMIntercept(community) NvMSlopeAndIntercept(community) NvMSlopeByClass(community, class) NvMInterceptByClass(community, class) NvMSlopeAndInterceptByClass(community, class)
community |
an object of class |
class |
the property over which linear regressions are fitted. Defaults to 'category' if the community has a node property with that name. |
NvMLinearRegressions
returns a list
of lm
objects, one for each class
and one fitted to all data.
The list will contain NULL
if it is not possible to fit a
linear regression to that class; this will happen for classes that contain
just a single node or that contain all or all but one nodes where X
and/or Y
is NA
.
NvMSlope
, NvMIntercept
and NvMSlopeAndIntercept
return
the slope, intercept and both, respectively, of a single linear regression
fitted to all data.
NvMSlopeByClass
, NvMInterceptByClass
and
NvMSlopeAndInterceptByClass
return the slope, intercept and both,
respectively, of linear regressions fitteed to each class
and one
to all data. For classes where it is not possible to fit a linear
regression (for the reasons given above), NvMSlopeByClass
,
NvMInterceptByClass
and NvMSlopeAndInterceptByClass
will
return NA
.
Lawrence Hudson
Community
,
CommunityCollection
ApplyByClass
data(TL84) models <- NvMLinearRegressions(TL84) # 'all', 'producer', 'invertebrate', 'vert.ecto' names(models) # Extract slopes and intercepts sapply(models, coef) # Slopes and intercepts through all data for each web in the pHWebs # collection data(pHWebs) CollectionCPS(pHWebs, properties=c('NvMSlope')) CollectionCPS(pHWebs, properties=c('NvMIntercept')) CollectionCPS(pHWebs, properties=c('NvMSlopeAndIntercept')) # Slopes and intercepts through each category for each web in pHWebs CollectionCPS(pHWebs, properties=c('NvMSlopeAndInterceptByClass'))
data(TL84) models <- NvMLinearRegressions(TL84) # 'all', 'producer', 'invertebrate', 'vert.ecto' names(models) # Extract slopes and intercepts sapply(models, coef) # Slopes and intercepts through all data for each web in the pHWebs # collection data(pHWebs) CollectionCPS(pHWebs, properties=c('NvMSlope')) CollectionCPS(pHWebs, properties=c('NvMIntercept')) CollectionCPS(pHWebs, properties=c('NvMSlopeAndIntercept')) # Slopes and intercepts through each category for each web in pHWebs CollectionCPS(pHWebs, properties=c('NvMSlopeAndInterceptByClass'))
Tri-trophic statistics.
NvMTriTrophicStatistics(community)
NvMTriTrophicStatistics(community)
community |
an object of class |
Tri-trophic statistics as described by Cohen et al 2009 PNAS.
A list
containing
links |
a |
three.node.chains |
a |
trophic.chains |
a |
Lawrence Hudson
Cohen, J.E. and Schittler, D.N. and Raffaelli, D.G. and Reuman, D.C. (2009) Food webs are more than the sum of their tritrophic parts. Proceedings of the National Academy of Sciences of the United States of America 106, 52, 22335–22340.
TLPS
,
ThreeNodeChains
,
TrophicChains
,
PlotAuppervAlower
,
NvMTriTrophicTable
data(TL84) tts <- NvMTriTrophicStatistics(TL84) nrow(tts$links) head(tts$links) nrow(tts$three.node.chains) head(tts$three.node.chains) nrow(tts$trophic.chains) head(tts$trophic.chains)
data(TL84) tts <- NvMTriTrophicStatistics(TL84) nrow(tts$links) head(tts$links) nrow(tts$three.node.chains) head(tts$three.node.chains) nrow(tts$trophic.chains) head(tts$trophic.chains)
Tri-trophic statistics.
NvMTriTrophicTable(collection)
NvMTriTrophicTable(collection)
collection |
an object of class |
Returns a data.frame
that contains the same statistics
presented in Table 1 on Cohen et al 2009 PNAS. The function removes
nodes lacking body mass (M) and/or numerical abundance (N), cannibalistic
links and isolated nodes from each community. The last eight rows of the
table contain four network statistics both with and without these removals.
A data.frame
with a column per community and the rows
Mean link length |
|
Mean L upper |
|
Mean L lower |
|
2 x mean link length |
|
Mean 2-span |
|
Mean L upper + L lower |
|
2 x mean link length / mean 2-span |
|
Mean L upper + L lower/ mean 2-span |
|
Mean count chain length |
|
Mean count chain length x mean link length |
|
Community span |
|
Mean count chain length x mean link length / community span |
|
Mean sum chain lengths |
|
Mean chain span |
|
Mean chain span / community span |
|
Mean sum chain lengths / mean chain span |
|
Mean sum chain lengths / community span |
|
L |
number of trophic links after removals. |
S^2 |
number of nodes squared after removals. |
L/S^2 |
directed connectance links after removals. |
L/S |
linkage density after removals. |
L |
number of trophic links before removals. |
S^2 |
number of nodes squared before removals. |
L/S^2 |
directed connectance links before removals. |
L/S |
linkage density before removals. |
Lawrence Hudson
Cohen, J.E. and Schittler, D.N. and Raffaelli, D.G. and Reuman, D.C. (2009) Food webs are more than the sum of their tritrophic parts. Proceedings of the National Academy of Sciences of the United States of America 106, 52, 22335–22340.
NvMTriTrophicStatistics
, CommunityCollection
data(TL84, TL86, YthanEstuary) collection <- CommunityCollection(list(TL84, TL86, YthanEstuary)) table <- NvMTriTrophicTable(collection) print(round(table, 2))
data(TL84, TL86, YthanEstuary) collection <- CommunityCollection(list(TL84, TL86, YthanEstuary)) table <- NvMTriTrophicTable(collection) print(round(table, 2))
Nodes that consume two or more species and have a non-integer trophic level.
IsOmnivore(community, level=PreyAveragedTrophicLevel) Omnivores(community, ...) FractionOmnivorous(community, ...) Omnivory(community, ...)
IsOmnivore(community, level=PreyAveragedTrophicLevel) Omnivores(community, ...) FractionOmnivorous(community, ...) Omnivory(community, ...)
community |
an object of class |
level |
a function that returns the trophic level of each node in
|
... |
other values to |
Omnivores are those nodes that consume two or more species and have a
non-integer trophic level (Polis 1991). IsOmnivore
returns a vector of
logical
of length NumberOfNodes
; values are TRUE
for
nodes that are omnivorous. Omnivores
returns the names of nodes for
which IsOmnivore
returns TRUE
. FractionOmnivorous
and
Omnivory
both return the proportion of nodes for which IsOmnivore
returns TRUE
.
Many researchers have used chain-averaged trophic level when computing omnivory
(Polis, 1991; Bersier et al 2002). Computing chain-averaged trophic level
requires enumerating every unique food chain - this can be lengthy for complex
food webs so the default function used by IsOmnivore
is
PreyAveragedTrophicLevel
. Omnivory values obtained using these two
methods might differ slightly.
Either a logical
vector of length NumberOfNodes
or a
vector of names.
Lawrence Hudson
Polis, G. A. (1991) Complex desert food webs: an empirical critique
of food web theory. American Naturalist 138
, 123–155.
Bersier, L. and Banasek-Richter, C. and Cattin, M. (2002) Ecology 80 2394–2407.
NumberOfNodes
, PreyAveragedTrophicLevel
,
ChainAveragedTrophicLevel
data(TL84) IsOmnivore(TL84) Omnivores(TL84) Omnivory(TL84) # Omnivory values found using PreyAveragedTrophicLevel and # ChainAveragedTrophicLevel differ for ChesapeakeBay data(ChesapeakeBay) Omnivory(ChesapeakeBay) Omnivory(ChesapeakeBay, level=ChainAveragedTrophicLevel)
data(TL84) IsOmnivore(TL84) Omnivores(TL84) Omnivory(TL84) # Omnivory values found using PreyAveragedTrophicLevel and # ChainAveragedTrophicLevel differ for ChesapeakeBay data(ChesapeakeBay) Omnivory(ChesapeakeBay) Omnivory(ChesapeakeBay, level=ChainAveragedTrophicLevel)
Order a CommunityCollection
OrderCollection(collection, ..., decreasing=FALSE)
OrderCollection(collection, ..., decreasing=FALSE)
collection |
an object of class |
... |
the names of properties by which to order the communities. |
decreasing |
logical. |
A CommunityCollection
.
Lawrence Hudson
CommunityCollection
,
order
,
CollectionCPS
data(pHWebs) CollectionCPS(pHWebs, c('pH', 'NumberOfNodes')) # Order by name pHWebs.name <- OrderCollection(pHWebs, 'title') CollectionCPS(pHWebs.name, c('pH', 'NumberOfNodes')) # Order by decreasing pH pHWebs.decreasing.pH <- OrderCollection(pHWebs, 'pH', decreasing=TRUE) CollectionCPS(pHWebs.decreasing.pH, c('pH', 'NumberOfNodes')) # Order by increasing diversity pHWebs.increasing.S <- OrderCollection(pHWebs, 'NumberOfNodes') CollectionCPS(pHWebs.increasing.S, c('pH', 'NumberOfNodes'))
data(pHWebs) CollectionCPS(pHWebs, c('pH', 'NumberOfNodes')) # Order by name pHWebs.name <- OrderCollection(pHWebs, 'title') CollectionCPS(pHWebs.name, c('pH', 'NumberOfNodes')) # Order by decreasing pH pHWebs.decreasing.pH <- OrderCollection(pHWebs, 'pH', decreasing=TRUE) CollectionCPS(pHWebs.decreasing.pH, c('pH', 'NumberOfNodes')) # Order by increasing diversity pHWebs.increasing.S <- OrderCollection(pHWebs, 'NumberOfNodes') CollectionCPS(pHWebs.increasing.S, c('pH', 'NumberOfNodes'))
Order a Community
.
OrderCommunity(community, ..., decreasing=FALSE, na.last = TRUE, new.order=NULL, title=NULL)
OrderCommunity(community, ..., decreasing=FALSE, na.last = TRUE, new.order=NULL, title=NULL)
community |
an object of class |
... |
the names of properties by which to order the communities. |
decreasing |
logical. |
na.last |
logical. |
new.order |
a vector of either node integer indices or node names giving the order. |
title |
the title of the new |
Returns a new Community
object. dots
can contain
any name that meets the criteria of the properties
parameter of
NPS
. If new.order
is NULL
then ...
and optionally
decreasing
are used to compute the new node ordering.
Different node orders will yield different SumDietGaps
and
SumConsumerGaps
(e.g. Stouffer et al 2006, Zook et al 2011).
A Community
.
Lawrence Hudson
Stouffer, D.B. and Camacho, J. and Amaral, L.A.N. (2006) Proceedings of the National Academy of Sciences of the United States of America 103, 50, 19015–19020.
Zook, A.E. and Eklof, A. and Jacob, U. and Allesina, S. (2011) Journal of Theoretical Biology 271, 1 106–113.
Community
,
order
,
Intervality
,
CollectionNPS
,
PreyAveragedTrophicLevel
,
PlotPredationMatrix
data(TL84) NPS(TL84) # Order by increasing M TL84.increasing.M <- OrderCommunity(TL84, 'M', title='Increasing M') NPS(TL84.increasing.M) # Order by decreasing M TL84.decreasing.M <- OrderCommunity(TL84, 'M', decreasing=TRUE) NPS(TL84.decreasing.M) # Order by increasing M and N TL84.increasing.MN <- OrderCommunity(TL84, 'M', 'N') NPS(TL84.increasing.MN) # Reverse existing order TL84.reversed <- OrderCommunity(TL84, new.order=56:1) NPS(TL84.reversed) # Sort alphabetically by category and by increasing M within each category TL84.category <- OrderCommunity(TL84, 'category', 'M') # Increasing trophic level, then randomly sorted within trophic level new.order <- order(PreyAveragedTrophicLevel(TL84), sample(1:56)) TL84.increasing.TL <- OrderCommunity(TL84, new.order=new.order, title='Increasing TL') NPS(TL84.increasing.TL) # Graphically show the effect of different orders par(mfrow=c(1,2)) PlotPredationMatrix(TL84.increasing.M) PlotPredationMatrix(TL84.increasing.TL)
data(TL84) NPS(TL84) # Order by increasing M TL84.increasing.M <- OrderCommunity(TL84, 'M', title='Increasing M') NPS(TL84.increasing.M) # Order by decreasing M TL84.decreasing.M <- OrderCommunity(TL84, 'M', decreasing=TRUE) NPS(TL84.decreasing.M) # Order by increasing M and N TL84.increasing.MN <- OrderCommunity(TL84, 'M', 'N') NPS(TL84.increasing.MN) # Reverse existing order TL84.reversed <- OrderCommunity(TL84, new.order=56:1) NPS(TL84.reversed) # Sort alphabetically by category and by increasing M within each category TL84.category <- OrderCommunity(TL84, 'category', 'M') # Increasing trophic level, then randomly sorted within trophic level new.order <- order(PreyAveragedTrophicLevel(TL84), sample(1:56)) TL84.increasing.TL <- OrderCommunity(TL84, new.order=new.order, title='Increasing TL') NPS(TL84.increasing.TL) # Graphically show the effect of different orders par(mfrow=c(1,2)) PlotPredationMatrix(TL84.increasing.M) PlotPredationMatrix(TL84.increasing.TL)
Ten stream food webs sampled across a large pH gradient.
CommunityCollection
.
Layer et al 2010.
Layer, K. and Riede, J.O. and Hildrew, A.G. and Woodward, G. (2010) Food web structure and stability in 20 streams across a wide pH gradient. Advances in Ecological Research 42, 265–299.
High-level function for plotting upper-versus-lower link angles.
PlotAuppervAlower(community, main=CPS(community)$title, xlab=~A[lower], ylab=~A[upper], xlim=c(-180, 180), ylim=c(-180, 180), pch=19, ...)
PlotAuppervAlower(community, main=CPS(community)$title, xlab=~A[lower], ylab=~A[upper], xlim=c(-180, 180), ylim=c(-180, 180), pch=19, ...)
community |
an object of class |
main |
title of the plot |
xlab |
title of the x axis. |
ylab |
title of the y axis. |
xlim |
limits of the x axis. |
ylim |
limits of the y axis. |
pch |
plotting symbol. |
... |
other values to plot functions. |
Lawrence Hudson
Cohen, J.E. and Schittler, D.N. and Raffaelli, D.G. and Reuman, D.C. (2009) Food webs are more than the sum of their tritrophic parts. Proceedings of the National Academy of Sciences of the United States of America 106, 52, 22335–22340.
data(TL84) PlotAuppervAlower(TL84)
data(TL84) PlotAuppervAlower(TL84)
High-level function for plotting nodes in a circle.
PlotCircularWeb(community, clockwise = TRUE, origin.degrees = 0, proportional.radius = 1, frame.plot = FALSE, xlim = c(-1,1), ylim = c(-1,1), ...)
PlotCircularWeb(community, clockwise = TRUE, origin.degrees = 0, proportional.radius = 1, frame.plot = FALSE, xlim = c(-1,1), ylim = c(-1,1), ...)
community |
an object of class |
clockwise |
logical - if |
origin.degrees |
the angle in degrees at which the first node in
|
proportional.radius |
a value between 0 and 1. |
frame.plot |
logical. |
xlim |
limits of the x axis. |
ylim |
limits of the y axis. |
... |
other values to |
Lawrence Hudson
Community
,
PlotBSpectrum
,
PlotWagonWheel
,
PlotNPS
,
PlotNPSDistribution
,
PlotNSpectrum
,
PlotRankNPS
,
PlotTLPS
,
PlotWebByLevel
data(TL84) PlotCircularWeb(TL84) # Plot the first node at the 6 o'clock position PlotCircularWeb(TL84, origin.degrees=180) # Plot the first node at the 6 o'clock position and plot nodes # counter-clockwise PlotCircularWeb(TL84, origin.degrees=180, clockwise=FALSE)
data(TL84) PlotCircularWeb(TL84) # Plot the first node at the 6 o'clock position PlotCircularWeb(TL84, origin.degrees=180) # Plot the first node at the 6 o'clock position and plot nodes # counter-clockwise PlotCircularWeb(TL84, origin.degrees=180, clockwise=FALSE)
Functions that are useful for customising plots and for creating your own plot functions.
Log10BLabel(community, name = "italic(B)", units = with(CPS(community), paste(M.units, "~", N.units))) Log10MLabel(community, name = "italic(M)", units = CPS(community)$M.units) Log10NLabel(community, name = "italic(N)", units = CPS(community)$N.units) DefaultCategoryColours() DefaultCategoryLabelColours() DefaultCategorySymbols() DefaultLinkColour() PlaceMissingPoints(x, xlim, y, ylim) LMabline(model, ...) PlotLinearModels(models, colour.spec, col, ...) FormatLM(model, slope.95.ci = FALSE, ci.plus.minus.style = FALSE, r = FALSE, r.squared = TRUE, model.var.names = TRUE, dp = 2)
Log10BLabel(community, name = "italic(B)", units = with(CPS(community), paste(M.units, "~", N.units))) Log10MLabel(community, name = "italic(M)", units = CPS(community)$M.units) Log10NLabel(community, name = "italic(N)", units = CPS(community)$N.units) DefaultCategoryColours() DefaultCategoryLabelColours() DefaultCategorySymbols() DefaultLinkColour() PlaceMissingPoints(x, xlim, y, ylim) LMabline(model, ...) PlotLinearModels(models, colour.spec, col, ...) FormatLM(model, slope.95.ci = FALSE, ci.plus.minus.style = FALSE, r = FALSE, r.squared = TRUE, model.var.names = TRUE, dp = 2)
community |
an object of class |
name |
the name that appears in the label. |
units |
the units that appears in the label. |
x |
x values. |
y |
y values. |
xlim |
limits of the x axis. |
ylim |
limits of the y axis. |
models |
a |
colour.spec |
either |
col |
plot colours. |
model |
an |
slope.95.ci |
logical - if |
ci.plus.minus.style |
logical - if |
r |
logical - if |
r.squared |
logical - if |
model.var.names |
logical - if |
dp |
the number of decimal places to which values are presented. |
... |
other values passed to plotting functions. |
Lawrence Hudson
Community
,
DefaultCategoryColours
,
NvMLinearRegressions
,
LinearRegressionByClass
,
lm
High-level functions for plotting node properties.
PlotNPS(community, X, Y, main = CPS(community)$title, xlab, ylab, xlim = NULL, ylim = NULL, colour.by, colour.spec, col = NULL, symbol.by, symbol.spec, pch = NULL, bg.by, bg.spec, bg = NULL, cex.by = NULL, cex.spec = NULL, cex = NULL, label.colour.by = NULL, label.colour.spec = NULL, label.colour = NULL, link.colour.by = NULL, link.colour.spec = NULL, link.col = NULL, link.line.type.by = NULL, link.line.type.spec = NULL, link.lty = NULL, link.lwd = NULL, highlight.links = NULL, highlight.nodes = Cannibals, lowlight.nodes, show.na = FALSE, show.web = TRUE, show.nodes.as = "points", node.labels = NULL, label.cex = 0.6, are.values = FALSE, frame.plot = TRUE, ...) PlotMvN(community, xlab = Log10NLabel(community), ylab = Log10MLabel(community), ...) PlotNvM(community, xlab = Log10MLabel(community), ylab = Log10NLabel(community), ...) PlotBvM(community, xlab = Log10MLabel(community), ylab = Log10BLabel(community), ...) PlotMvB(community, xlab = Log10BLabel(community), ylab = Log10MLabel(community), ...)
PlotNPS(community, X, Y, main = CPS(community)$title, xlab, ylab, xlim = NULL, ylim = NULL, colour.by, colour.spec, col = NULL, symbol.by, symbol.spec, pch = NULL, bg.by, bg.spec, bg = NULL, cex.by = NULL, cex.spec = NULL, cex = NULL, label.colour.by = NULL, label.colour.spec = NULL, label.colour = NULL, link.colour.by = NULL, link.colour.spec = NULL, link.col = NULL, link.line.type.by = NULL, link.line.type.spec = NULL, link.lty = NULL, link.lwd = NULL, highlight.links = NULL, highlight.nodes = Cannibals, lowlight.nodes, show.na = FALSE, show.web = TRUE, show.nodes.as = "points", node.labels = NULL, label.cex = 0.6, are.values = FALSE, frame.plot = TRUE, ...) PlotMvN(community, xlab = Log10NLabel(community), ylab = Log10MLabel(community), ...) PlotNvM(community, xlab = Log10MLabel(community), ylab = Log10NLabel(community), ...) PlotBvM(community, xlab = Log10MLabel(community), ylab = Log10BLabel(community), ...) PlotMvB(community, xlab = Log10BLabel(community), ylab = Log10MLabel(community), ...)
community |
an object of class |
X |
the name of a property that is plotted on the x axis. Must meet the
criteria of the |
Y |
plotted on the y axis; see |
xlab |
title of the x axis. |
ylab |
title of the y axis. |
main |
title of the plot. |
xlim |
limits of the x axis. |
ylim |
limits of the y axis. |
colour.by |
node colours property. Either |
colour.spec |
node colours specification. Either |
col |
node colours. |
symbol.by |
node symbols property; must meet the criteria of
|
symbol.spec |
node symbols specification. |
pch |
node symbols. |
bg.by |
node background colours property; must meet the criteria of
|
bg.spec |
node background colours specification; must meet the
criteria of |
bg |
node background colours. |
cex.by |
node cex values property; must meet the criteria of
|
cex.spec |
node cex values specification; must meet the
criteria of |
cex |
node cex values. |
label.colour.by |
node label colours property; must meet the criteria
of |
label.colour.spec |
node label colours specification; must meet the
criteria of |
label.colour |
node label colours. |
link.colour.by |
link colours; either |
link.colour.spec |
link line colour specification; either
|
link.col |
link colours. |
link.line.type.by |
link link types; must meet the criteria of
|
link.line.type.spec |
link line type specification; must meet the
criteria of |
link.lty |
link line types. |
link.lwd |
line line widths. |
highlight.links |
either |
highlight.nodes |
nodes to be highlighted; either |
lowlight.nodes |
nodes to be lowlighted; must meet the criteria of
|
show.na |
logical - if |
show.web |
logical - if |
show.nodes.as |
how nodes should be plotted. One of
|
node.labels |
Either |
label.cex |
a character expansion factor; used only if
|
are.values |
logical - if |
frame.plot |
logical - default |
... |
other values to plot functions. |
The general-purpose function PlotNPS
plots one
node property against another.
For colour.by
, symbol.by
, bg.by
, cex.by
and
label.colour.by
, if X.by
is not NULL
and a relevant
X.spec
is not given, the X.by
values are converted to a
factor
, the levels of which are used as the plot parameter.
An error is raised if X.by
contains any values not present in
X.spec
.
If colour.by
/bg.by
/symbol.by
is NULL
and
community
has a node property named ‘category’ then node
colours/background colours/symbols are given by ‘category’ using the
colour.spec
/bg.spec
/symbol.spec
given by
DefaultCategoryColours
/DefaultCategorySymbols
.
label.colour.by
, node.labels
and label.cex
are used only
if show.nodes.as
is equal to "points".
The convenience functions PlotMvN
, PlotNvM
, PlotBvM
and
PlotMvB
are ‘wrappers’ around PlotNPS
that plot
log10-transformed body mass (M), numerical abundance (N) or biomass (B).
All of the parameters of PlotNPS
, with the exception of
X
, Y
and are.values
, can be used with these four
functions.
If show.nodes.as
is equal to "points" then labels are plotted using
label.cex
and label.colour
.
Lawrence Hudson
Community
,
NPS
,
DefaultCategoryColours
,
DefaultCategorySymbols
,
PlotBSpectrum
,
PlotCircularWeb
,
PlotNPSDistribution
,
PlotNSpectrum
,
PlotRankNPS
,
PlotTLPS
,
PlotWebByLevel
PlaceMissingPoints
data(TL84) PlotNvM(TL84) # Set colours and plot symbols directly PlotNvM(TL84, col=1, pch=19, highlight.nodes=NULL) # Plot each level of taxonomic resolution in a different colour PlotNvM(TL84, colour.by='resolved.to', pch=19, highlight.nodes=NULL) # Plot each level of taxonomic resolution in a specific colour colour.spec <- c(Species='purple3', Genus='green3', 'red3') PlotNvM(TL84, colour.by='resolved.to', colour.spec=colour.spec, pch=19, highlight.nodes=NULL) legend("topright", legend=names(colour.spec), pch=19, col=colour.spec) # Use PlotNPS to plot trophic height against log10 body mass PlotNPS(TL84, 'Log10M', 'TrophicHeight', xlab=Log10MLabel(TL84), ylab='Trophic height') # The 'POM (detritus)' node in the Ythan Estuary dataset lacks both body mass # and numerical abundance. par(mfrow=c(1,2)) data(YthanEstuary) PlotNvM(YthanEstuary) PlotNvM(YthanEstuary, show.na=TRUE)
data(TL84) PlotNvM(TL84) # Set colours and plot symbols directly PlotNvM(TL84, col=1, pch=19, highlight.nodes=NULL) # Plot each level of taxonomic resolution in a different colour PlotNvM(TL84, colour.by='resolved.to', pch=19, highlight.nodes=NULL) # Plot each level of taxonomic resolution in a specific colour colour.spec <- c(Species='purple3', Genus='green3', 'red3') PlotNvM(TL84, colour.by='resolved.to', colour.spec=colour.spec, pch=19, highlight.nodes=NULL) legend("topright", legend=names(colour.spec), pch=19, col=colour.spec) # Use PlotNPS to plot trophic height against log10 body mass PlotNPS(TL84, 'Log10M', 'TrophicHeight', xlab=Log10MLabel(TL84), ylab='Trophic height') # The 'POM (detritus)' node in the Ythan Estuary dataset lacks both body mass # and numerical abundance. par(mfrow=c(1,2)) data(YthanEstuary) PlotNvM(YthanEstuary) PlotNvM(YthanEstuary, show.na=TRUE)
High-level functions for plotting distributions of node properties.
PlotNPSDistribution(community, property, main = CPS(community)$title, density.args = list(), ...) PlotBDistribution(community, xlab = Log10BLabel(community), ...) PlotMDistribution(community, xlab = Log10MLabel(community), ...) PlotNDistribution(community, xlab = Log10NLabel(community), ...) PlotDegreeDistribution(community, xlab = "Number of links", ...)
PlotNPSDistribution(community, property, main = CPS(community)$title, density.args = list(), ...) PlotBDistribution(community, xlab = Log10BLabel(community), ...) PlotMDistribution(community, xlab = Log10MLabel(community), ...) PlotNDistribution(community, xlab = Log10NLabel(community), ...) PlotDegreeDistribution(community, xlab = "Number of links", ...)
community |
an object of class |
property |
the name of a property that is plotted on the y axis. Must
meet the criteria of the |
main |
title of the plot. |
density.args |
arguments passed to R's |
xlab |
title of the x axis. |
... |
other values to plot functions. |
The convenience functions PlotBDistribution
,
PlotMDistribution
and PlotNDistribution
are wrappers around
PlotNPSDistribution
.
Lawrence Hudson
Community
,
NPS
,
DegreeDistribution
,
PlotCircularWeb
,
PlotNPS
,
PlotNPSDistribution
,
PlotRankNPS
,
PlotTLPS
,
PlotWebByLevel
data(TL84) PlotMDistribution(TL84) # A bandwidth of 3 PlotMDistribution(TL84, density.args=list(bw=3)) PlotDegreeDistribution(TL84)
data(TL84) PlotMDistribution(TL84) # A bandwidth of 3 PlotMDistribution(TL84, density.args=list(bw=3)) PlotDegreeDistribution(TL84)
High-level functions for plotting value-versus-rank of node properties.
PlotRankNPS(community, property, rank.by=property, log10.rank = FALSE, xlab, ylab, show.web=FALSE, ...) PlotMvRankM(community, log10.rank = FALSE, xlab, ylab, ...) PlotNvRankN(community, log10.rank = FALSE, xlab, ylab, ...) PlotBvRankB(community, log10.rank = FALSE, xlab, ylab, ...)
PlotRankNPS(community, property, rank.by=property, log10.rank = FALSE, xlab, ylab, show.web=FALSE, ...) PlotMvRankM(community, log10.rank = FALSE, xlab, ylab, ...) PlotNvRankN(community, log10.rank = FALSE, xlab, ylab, ...) PlotBvRankB(community, log10.rank = FALSE, xlab, ylab, ...)
community |
an object of class |
property |
the name of a property that is plotted on the y axis. Must
meet the criteria of the |
rank.by |
the name of a property by which points are ordered along the
x axis. Must meet the criteria of the |
log10.rank |
logical - if |
xlab |
title of the x axis. |
ylab |
title of the y axis. |
show.web |
logical - if |
... |
other values to |
The convenience functions PlotMvRankM
, PlotNvRankN
and
PlotBvRankB
are ‘wrappers’ around PlotRankNPS
that plot rank
log10-transformed body mass (M), numerical abundance (N) or biomass (B).
Lawrence Hudson
Community
,
NPS
,
PlotBSpectrum
,
PlotCircularWeb
,
PlotNPS
,
PlotNPSDistribution
,
PlotNSpectrum
,
PlotTLPS
,
PlotWebByLevel
data(TL84) PlotNvRankN(TL84) # log10(N) against log10(rank of M) PlotRankNPS(TL84, property='Log10N', rank.by='M', log10.rank=TRUE) # The 'POM (detritus)' node in the Ythan Estuary dataset lacks body mass. par(mfrow=c(1,2)) data(YthanEstuary) PlotMvRankM(YthanEstuary) PlotMvRankM(YthanEstuary, show.na=TRUE)
data(TL84) PlotNvRankN(TL84) # log10(N) against log10(rank of M) PlotRankNPS(TL84, property='Log10N', rank.by='M', log10.rank=TRUE) # The 'POM (detritus)' node in the Ythan Estuary dataset lacks body mass. par(mfrow=c(1,2)) data(YthanEstuary) PlotMvRankM(YthanEstuary) PlotMvRankM(YthanEstuary, show.na=TRUE)
High-level functions for plotting trophic link properties.
PlotTLPS(community, X, Y, xlab, ylab, axes.limits.equal = FALSE, xlim = NULL, ylim = NULL, main = CPS(community)$title, highlight.links = NULL, lowlight.links = NULL, colour.by, colour.spec, col = NULL, symbol.by, symbol.spec, pch = NULL, bg.by, bg.spec, bg = NULL, cex.by = NULL, cex.spec = NULL, cex = NULL, are.values = FALSE, ...) PlotPredationMatrix(community, xlab='Consumer', ylab='Resource', resource.order, consumer.order, ...) PlotMRvMC(community, xlab=Log10MLabel(community, name='italic(M)[consumer]'), ylab=Log10MLabel(community, name='italic(M)[resource]'), axes.limits.equal = TRUE, ...) PlotMCvMR(community, xlab=Log10MLabel(community, name='italic(M)[resource]'), ylab=Log10MLabel(community, name='italic(M)[consumer]'), axes.limits.equal = TRUE, ...) PlotNRvNC(community, xlab=Log10NLabel(community, name='italic(N)[consumer]'), ylab=Log10NLabel(community, name='italic(N)[resource]'), axes.limits.equal = TRUE, ...) PlotNCvNR(community, xlab=Log10NLabel(community, name='italic(N)[resource]'), ylab=Log10NLabel(community, name='italic(N)[consumer]'), axes.limits.equal = TRUE, ...) PlotBRvBC(community, xlab=Log10BLabel(community, name='italic(B)[consumer]'), ylab=Log10BLabel(community, name='italic(B)[resource]'), axes.limits.equal = TRUE, ...) PlotBCvBR(community, xlab=Log10BLabel(community, name='italic(B)[resource]'), ylab=Log10BLabel(community, name='italic(B)[consumer]'), axes.limits.equal = TRUE, ...)
PlotTLPS(community, X, Y, xlab, ylab, axes.limits.equal = FALSE, xlim = NULL, ylim = NULL, main = CPS(community)$title, highlight.links = NULL, lowlight.links = NULL, colour.by, colour.spec, col = NULL, symbol.by, symbol.spec, pch = NULL, bg.by, bg.spec, bg = NULL, cex.by = NULL, cex.spec = NULL, cex = NULL, are.values = FALSE, ...) PlotPredationMatrix(community, xlab='Consumer', ylab='Resource', resource.order, consumer.order, ...) PlotMRvMC(community, xlab=Log10MLabel(community, name='italic(M)[consumer]'), ylab=Log10MLabel(community, name='italic(M)[resource]'), axes.limits.equal = TRUE, ...) PlotMCvMR(community, xlab=Log10MLabel(community, name='italic(M)[resource]'), ylab=Log10MLabel(community, name='italic(M)[consumer]'), axes.limits.equal = TRUE, ...) PlotNRvNC(community, xlab=Log10NLabel(community, name='italic(N)[consumer]'), ylab=Log10NLabel(community, name='italic(N)[resource]'), axes.limits.equal = TRUE, ...) PlotNCvNR(community, xlab=Log10NLabel(community, name='italic(N)[resource]'), ylab=Log10NLabel(community, name='italic(N)[consumer]'), axes.limits.equal = TRUE, ...) PlotBRvBC(community, xlab=Log10BLabel(community, name='italic(B)[consumer]'), ylab=Log10BLabel(community, name='italic(B)[resource]'), axes.limits.equal = TRUE, ...) PlotBCvBR(community, xlab=Log10BLabel(community, name='italic(B)[resource]'), ylab=Log10BLabel(community, name='italic(B)[consumer]'), axes.limits.equal = TRUE, ...)
community |
an object of class |
X |
the name of a node or link property to plot on the x axis.
If the name begins with 'resource.' or 'consumer.', the remainder of the
name is assumed to be a node property and should meet the criteria of the
If |
Y |
plotted on the y axis; see |
xlab |
title of the x axis. |
ylab |
title of the y axis. |
axes.limits.equal |
logical - if |
xlim |
limits of the x axis |
ylim |
limits of the y axis |
main |
title of the plot |
highlight.links |
trophic links to be highlighted; either |
lowlight.links |
trophic links to be lowlighted; should meet criteria
of |
colour.by |
trophic link colours property. Either |
colour.spec |
trophic links colours specification. either |
col |
trophic links colours. |
symbol.by |
trophic links symbols property; must meet the criteria of
|
symbol.spec |
trophic links symbols specification specification; must
meet the criteria of |
pch |
trophic links symbols. |
bg.by |
trophic links background colours property; must meet the
criteria of |
bg.spec |
trophic links background colours specification; must meet the
criteria of |
bg |
trophic links background colours. |
cex.by |
trophic links cex property; must meet the criteria of
|
cex.spec |
cex values specification; must meet the criteria of
|
cex |
cex values. |
are.values |
logical - if |
resource.order |
the order in which to show resources. Either missing,
which implies the native node order, a vector of length
|
consumer.order |
the order in which to show consumer; requirements
are the same as |
... |
other values to plot functions. |
The general-purpose function PlotTLPS
plots one trophic-link
property against another.
If colour.by
/bg.by
/symbol.by
is NULL
and
community
has a node property named ‘category’ then trophic-link
colours/background colours/symbols are given by ‘resource.category’ using
colour.spec
/bg.spec
/symbol.spec
given by
DefaultCategoryColours
/DefaultCategorySymbols
.
PlotPredationMatrix
shows trophic links as a binary matrix with species
shown in node order, starting at the top-left. If row.node
and
col.order
are both missing (the default) or are the same, then a
dashed diagonal line is drawn. Points on the dashed line indicate
cannibalistic trophic links.
The convenience functions PlotMRvMC
, PlotMCvMR
, PlotNRvNC
,
PlotNCvNR
, PlotBRvBC
, PlotBCvBR
are ‘wrappers’ around
PlotRankNPS
that plot a log10-transformed body mass, M, numerical
abundance, N, or biomass abundance, B.
Lawrence Hudson
Community
,
TLPS
,
PlotBSpectrum
,
PlotCircularWeb
,
PlotNPS
,
PlotNPSDistribution
,
PlotNSpectrum
,
PlotRankNPS
,
PlotWebByLevel
data(TL84) # The predation matrix PlotPredationMatrix(TL84) # The predation matrix with rows ordered by body mass PlotPredationMatrix(TL84, resource.order='M') # Colours and symbols by resource.category PlotMCvMR(TL84) # Colours and symbols by consumer.category PlotMCvMR(TL84, bg.by='consumer.category', symbol.by='consumer.category', colour.by='consumer.category') # Consumer trophic height against resource log10(M) PlotTLPS(TL84, 'resource.Log10M', 'consumer.TrophicHeight') # Log10(M of resource / M of consumer) against consumer log10(M) PlotTLPS(TL84, 'consumer.Log10M', 'Log10RCMRatio')
data(TL84) # The predation matrix PlotPredationMatrix(TL84) # The predation matrix with rows ordered by body mass PlotPredationMatrix(TL84, resource.order='M') # Colours and symbols by resource.category PlotMCvMR(TL84) # Colours and symbols by consumer.category PlotMCvMR(TL84, bg.by='consumer.category', symbol.by='consumer.category', colour.by='consumer.category') # Consumer trophic height against resource log10(M) PlotTLPS(TL84, 'resource.Log10M', 'consumer.TrophicHeight') # Log10(M of resource / M of consumer) against consumer log10(M) PlotTLPS(TL84, 'consumer.Log10M', 'Log10RCMRatio')
Plot a nodes as concentric circles around a focal node.
PlotWagonWheel(community, focus, clockwise=TRUE, origin.degrees=0, frame.plot=FALSE, main=NULL, ...)
PlotWagonWheel(community, focus, clockwise=TRUE, origin.degrees=0, frame.plot=FALSE, main=NULL, ...)
community |
an object of class |
focus |
the node to be placed at the centre of the plot - a node name or integer index. |
clockwise |
logical - if |
origin.degrees |
the angle in degrees at which the first node in
|
frame.plot |
logical. |
main |
the plot's title. |
... |
other values to |
The node given in focus
is plotted at the centre of the
wagon wheel. Other nodes in the community are plotted in concentric circles
that are one, two, three etc trophic links away from the focus. Isolated
nodes - those with no resources or consumers, other than possibly themselves -
are not shown.
Lawrence Hudson
Community
,
Degree
,
IsolatedNodes
,
OrderCommunity
,
PlotCircularWeb
,
PlotNPS
,
PlotWebByLevel
,
rgb
,
ShortestPaths
data(TL84) # Ploesoma sp. is the focal species PlotWagonWheel(TL84, 'Ploesoma sp.') # Show nodes as numbers PlotWagonWheel(TL84, 'Ploesoma sp.', show.nodes.as='labels') # 'Daphnia pulex' is the focus, nodes ordered by degree (total number of # trophic links), lines partially transparent PlotWagonWheel(OrderCommunity(TL84, 'Degree'), 'Daphnia pulex', show.nodes.as='labels', link.col=rgb(0.8,0.8,0.8,0.5))
data(TL84) # Ploesoma sp. is the focal species PlotWagonWheel(TL84, 'Ploesoma sp.') # Show nodes as numbers PlotWagonWheel(TL84, 'Ploesoma sp.', show.nodes.as='labels') # 'Daphnia pulex' is the focus, nodes ordered by degree (total number of # trophic links), lines partially transparent PlotWagonWheel(OrderCommunity(TL84, 'Degree'), 'Daphnia pulex', show.nodes.as='labels', link.col=rgb(0.8,0.8,0.8,0.5))
A high-level function for plotting a food-web by vertically with the lowest trophic-level nodes at the bottom.
PlotWebByLevel(community, level='PreyAveragedTrophicLevel', max.nodes.per.row=20, round.levels.to.nearest=0.2, stagger=0.1, x.layout='wide', y.layout='compress', show.level.labels=TRUE, show.level.lines=FALSE, xaxt='n', yaxt='n', xlab='', ylab='', frame.plot=FALSE, ylim=NULL, ...)
PlotWebByLevel(community, level='PreyAveragedTrophicLevel', max.nodes.per.row=20, round.levels.to.nearest=0.2, stagger=0.1, x.layout='wide', y.layout='compress', show.level.labels=TRUE, show.level.lines=FALSE, xaxt='n', yaxt='n', xlab='', ylab='', frame.plot=FALSE, ylim=NULL, ...)
community |
an object of class |
level |
either a function, a name that meets the criteria of the
|
max.nodes.per.row |
a number greater than 2. |
round.levels.to.nearest |
a number greater or equal to 0 and less than 1. |
stagger |
a number greater or equal to 0 and less than 1. Only used if
|
x.layout |
'skinny', 'narrow' or 'wide'. |
y.layout |
'stagger' or 'compress'. Only has an effect if
|
show.level.labels |
logical - if |
show.level.lines |
logical - if |
xaxt |
a character that specifies the type of the x axis. |
yaxt |
a character that specifies the type of the y axis. |
xlab |
title of the x axis. |
ylab |
title of the y axis. |
frame.plot |
logical - if |
ylim |
limits of the y axis |
... |
other values to |
If round.levels.to.nearest
is greater than 0, values in
level
are rounded to the nearest round.levels.to.nearest
.
Rounded values are used by the x.layout
and y.layout
engines.
If x.layout
is 'skinny' then nodes are spaced one x unit apart and
max.nodes.per.row
is ignored. If x.layout
is 'narrow',
nodes are spaced one x unit apart if fewer than max.nodes.per.row
on
that row, otherwise nodes are squashed in to the available x space. If
x.layout
is 'wide', nodes are spaced widely.
If y.layout
is 'compress', then nodes are always shown at the values in
level
. If y.layout
is 'stagger' and there are more than
max.nodes.per.row
on a level
then the plotted levels are
staggered by the values in stagger
.
Lawrence Hudson
Community
,
PlotBSpectrum
,
PlotCircularWeb
,
PlotNPS
,
PlotNPSDistribution
,
PlotNSpectrum
,
PlotRankNPS
,
PlotTLPS
# Compare prey-averaged and chain-averaged trophic level data(TL84) par(mfrow=c(1,2)) PlotWebByLevel(TL84, ylim=c(1,5.8), main='Prey-averaged') PlotWebByLevel(TL84, ylim=c(1,5.8), level='ChainAveragedTrophicLevel', main='Chain-averaged') # Compare the three different x layouts par(mfrow=c(1,3)) for(x.layout in c('skinny', 'narrow', 'wide')) { PlotWebByLevel(TL84, x.layout=x.layout, main=x.layout) } # Compare the effect of round levels before plotting # Different x-spacing of the four nodes around level 3 par(mfrow=c(1,2)) PlotWebByLevel(TL84, round.levels.to.nearest=0.2) PlotWebByLevel(TL84, round.levels.to.nearest=0) # Compare the effect of staggering levels # Primary producers are staggered in the second plot par(mfrow=c(1,2)) # No staggering - stagger and max.nodes.per.row are ignored PlotWebByLevel(TL84, y.layout='compress') # Stagger PlotWebByLevel(TL84, y.layout='stagger', stagger=0.1, max.nodes.per.row=20)
# Compare prey-averaged and chain-averaged trophic level data(TL84) par(mfrow=c(1,2)) PlotWebByLevel(TL84, ylim=c(1,5.8), main='Prey-averaged') PlotWebByLevel(TL84, ylim=c(1,5.8), level='ChainAveragedTrophicLevel', main='Chain-averaged') # Compare the three different x layouts par(mfrow=c(1,3)) for(x.layout in c('skinny', 'narrow', 'wide')) { PlotWebByLevel(TL84, x.layout=x.layout, main=x.layout) } # Compare the effect of round levels before plotting # Different x-spacing of the four nodes around level 3 par(mfrow=c(1,2)) PlotWebByLevel(TL84, round.levels.to.nearest=0.2) PlotWebByLevel(TL84, round.levels.to.nearest=0) # Compare the effect of staggering levels # Primary producers are staggered in the second plot par(mfrow=c(1,2)) # No staggering - stagger and max.nodes.per.row are ignored PlotWebByLevel(TL84, y.layout='compress') # Stagger PlotWebByLevel(TL84, y.layout='stagger', stagger=0.1, max.nodes.per.row=20)
Returns a predation matrix.
PredationMatrix(community, weight=NULL)
PredationMatrix(community, weight=NULL)
community |
an object of class |
weight |
either the name of a first-class link property or the name of
a function that meets the specification of the |
Returns a square matrix with NumberOfNodes
rows and columns.
If weight
is NULL
then a binary matrix, in which elements are
either 0 or 1, is returned; 1 indicates a trophic link from a resource
(row) to a consumer (column). If weight
is not NULL
then elements
of the returned matrix will be set to the values given by weight
.
Row names and column names of the returned matrix
are node names.
A square matrix
.
Lawrence Hudson
PlotPredationMatrix
,
TLPS
,
NumberOfNodes
,
NumberOfTrophicLinks
,
ResourcesByNode
,
ConsumersByNode
,
PredationMatrixToLinks
data(TL84) # A square matrix of NumberOfNodes rows and columns dim(PredationMatrix(TL84)) NumberOfNodes(TL84) # Should contain NumberOfTrophicLinks links sum(PredationMatrix(TL84)) NumberOfTrophicLinks(TL84) # Compare an unweighted matrix and a matrix weighted by diet fraction data(Benguela) PredationMatrix(Benguela) PredationMatrix(Benguela, weight='diet.fraction')
data(TL84) # A square matrix of NumberOfNodes rows and columns dim(PredationMatrix(TL84)) NumberOfNodes(TL84) # Should contain NumberOfTrophicLinks links sum(PredationMatrix(TL84)) NumberOfTrophicLinks(TL84) # Compare an unweighted matrix and a matrix weighted by diet fraction data(Benguela) PredationMatrix(Benguela) PredationMatrix(Benguela, weight='diet.fraction')
A function that converts a predation matrix to a
data.frame
with the columns ‘resource’ and ‘consumer’.
PredationMatrixToLinks(pm, link.property=NULL)
PredationMatrixToLinks(pm, link.property=NULL)
pm |
a |
link.property |
either |
Returns a data.frame
of trophic links contained within
pm
. Non-zero and non-NA
values indicate a trophic link between
a resource (row) and consumer (column). pm
should have both row names
and column names. The returned data.frame
will contain the columns
‘resource’ and ‘consumer’. If pm
contains quantitative information
such as diet fractions or number of observations then you can set
link.property
to the name of the quantity and the returned
data.frame
will include a column with that name, that contains link
strength values extracted from pm
.
If you have existing food-web data in predation-matrix form then this function can help to import your data in to Cheddar.
A data.frame
Lawrence Hudson
Community
,
PredationMatrix
,
TLPS
data(TL84) links <- PredationMatrixToLinks(PredationMatrix(TL84)) identical(links, TLPS(TL84)) # TRUE # Create a Cheddar community from an existing square predation matrix node <- c('Leaf', 'Caterpillar', 'Bluetit') pm <- matrix( c(0, 1, 0, 0, 0, 1, 0, 0, 0), ncol=3, byrow=TRUE, dimnames=list(node, node)) community1 <- Community(nodes=data.frame(node=node), trophic.links=PredationMatrixToLinks(pm), properties=list(title='Test community')) TLPS(community1) # The same set of trophic links could be represented by a non-square predation # matrix pm <- matrix( c(1, 0, 0, 1), ncol=2, byrow=TRUE, dimnames=list(node[1:2], node[2:3])) community2 <- Community(nodes=data.frame(node=node), trophic.links=PredationMatrixToLinks(pm), properties=list(title='Test community')) TLPS(community2) all.equal(community1, community2) # TRUE # Extract quantitative information node <- c('Leaf 1', 'Leaf 2', 'Caterpillar 1', 'Caterpillar 2') pm <- matrix( c(0, 0, 0.4, 0.8, 0, 0, 0.6, 0.2, 0, 0, 0, 0, 0, 0, 0, 0), ncol=4, byrow=TRUE, dimnames=list(node, node)) # A data.frame that has a column called diet.fraction PredationMatrixToLinks(pm, link.property='diet.fraction')
data(TL84) links <- PredationMatrixToLinks(PredationMatrix(TL84)) identical(links, TLPS(TL84)) # TRUE # Create a Cheddar community from an existing square predation matrix node <- c('Leaf', 'Caterpillar', 'Bluetit') pm <- matrix( c(0, 1, 0, 0, 0, 1, 0, 0, 0), ncol=3, byrow=TRUE, dimnames=list(node, node)) community1 <- Community(nodes=data.frame(node=node), trophic.links=PredationMatrixToLinks(pm), properties=list(title='Test community')) TLPS(community1) # The same set of trophic links could be represented by a non-square predation # matrix pm <- matrix( c(1, 0, 0, 1), ncol=2, byrow=TRUE, dimnames=list(node[1:2], node[2:3])) community2 <- Community(nodes=data.frame(node=node), trophic.links=PredationMatrixToLinks(pm), properties=list(title='Test community')) TLPS(community2) all.equal(community1, community2) # TRUE # Extract quantitative information node <- c('Leaf 1', 'Leaf 2', 'Caterpillar 1', 'Caterpillar 2') pm <- matrix( c(0, 0, 0.4, 0.8, 0, 0, 0.6, 0.2, 0, 0, 0, 0, 0, 0, 0, 0), ncol=4, byrow=TRUE, dimnames=list(node, node)) # A data.frame that has a column called diet.fraction PredationMatrixToLinks(pm, link.property='diet.fraction')
High-level functions that create pyramid plots.
PlotBPyramid(community, level = floor(PreyAveragedTrophicLevel(community)), expected.levels, fill.missing.levels = TRUE, order.by.expected = TRUE, show.level.labels = TRUE, xlab = Log10BLabel(community, name=expression(~sum(italic(B)))), ylab = "", xlim = NULL, col = NULL, text.col = 'black', main = CPS(community)$title, ...) PlotNPyramid(community, level = floor(PreyAveragedTrophicLevel(community)), expected.levels, fill.missing.levels = TRUE, order.by.expected = TRUE, show.level.labels = TRUE, xlab = Log10NLabel(community, name=expression(~sum(italic(N)))), ylab = "", xlim = NULL, col = NULL, text.col = 'black', main = CPS(community)$title, ...)
PlotBPyramid(community, level = floor(PreyAveragedTrophicLevel(community)), expected.levels, fill.missing.levels = TRUE, order.by.expected = TRUE, show.level.labels = TRUE, xlab = Log10BLabel(community, name=expression(~sum(italic(B)))), ylab = "", xlim = NULL, col = NULL, text.col = 'black', main = CPS(community)$title, ...) PlotNPyramid(community, level = floor(PreyAveragedTrophicLevel(community)), expected.levels, fill.missing.levels = TRUE, order.by.expected = TRUE, show.level.labels = TRUE, xlab = Log10NLabel(community, name=expression(~sum(italic(N)))), ylab = "", xlim = NULL, col = NULL, text.col = 'black', main = CPS(community)$title, ...)
community |
an object of class |
level |
levels by which values are summed. Can be either the name of a
node property, in which case it must meet the criteria of the
|
expected.levels |
the values that are expected to be in |
fill.missing.levels |
if |
order.by.expected |
if |
show.level.labels |
logical - if |
xlab |
title of the x axis. |
ylab |
title of the y axis. |
xlim |
limits of the x axis. |
col |
fill colour; either a single colour a vector containing a colour
per |
text.col |
colour for the text showing the log10-transformed sums in the
blocks of the pyramid; ; either a single colour a vector containing a
colour per |
main |
title of the plot. |
... |
other values to plot functions. |
PlotBPyramid
plots log10-transformed sum biomass abundance in
each level
and PlotNPyramid
plots log10-transformed sum
numerical abundance in each level
.
expected.levels
provides two behaviours. First, it provides error
checking: an error is raised if values are in level
that
are not in expected.levels
. Second, it interacts with
fill.missing.levels
and order.by.expected
to control which levels
are drawn and how. If fill.missing.levels
is TRUE
then values
in expected.levels
that are not present in level
are shown on the
pyramid plot. If order.by.level
is TRUE
then the levels are
plotted in the order given in expected.levels
.
If level
contains numbers then expected.levels
defaults to a
sequence of integers floor(min(level)):ceiling(max(level))
.
If level
is ‘category’ then expected.levels
defaults to the
intersection of values of ‘category’ that are present in community
and
the usual Cheddar default values: ‘<unnamed>’, ‘producer’,
‘invertebrate’, ‘vert.ecto’, ‘vert.endo’.
Lawrence Hudson
Community
, SumBiomassByClass
,
SumNByClass
, Log10BLabel
,
Log10NLabel
, floor
, ceiling
data(TL84) # Use a large left-hand margin to show level text reset.par <- par(mar=c(5,8,1,1)) # Using prey-averaged trophic level PlotNPyramid(TL84) # Using chain-averaged of trophic level PlotNPyramid(TL84, level=floor(ChainAveragedTrophicLevel(TL84))) # Show by category PlotNPyramid(TL84, level='category') # Taxonomic kingdoms as levels PlotNPyramid(TL84, level='kingdom') # Taxonomic kingdoms as levels, with a defined order PlotNPyramid(TL84, level='kingdom', expected.levels=c("<unnamed>", "Plantae", "Chromista","Bacteria","Protozoa","Animalia")) # Compare the YthanEstuary and the TL84 datasets. YthanEstuary has nodes in # each of the categories whereas TL84 only has producer, invertebrate and # vert.ecto nodes. Show categories that are not present in TL84 par(mfrow=c(1,2)) data(YthanEstuary) xlim <- range(c(Log10N(TL84), Log10N(YthanEstuary)), na.rm=TRUE) PlotNPyramid(TL84, level='category', xlim=xlim, expected.levels=c('<unnamed>', 'producer', 'invertebrate', 'vert.ecto', 'vert.endo')) PlotNPyramid(YthanEstuary, level='category', xlim=xlim) par(mfrow=c(1,1)) # For the BroadstoneStream dataset, the LongestTrophicLevel function returns # nodes in levels 1 and 7 to 10 but no nodes in levels 2 to 6. # By default all levels between the minimum and maximum are shown, so levels # 2 to 6 appear with no boxes. data(BroadstoneStream) PlotNPyramid(BroadstoneStream, level=floor(LongestTrophicLevel(BroadstoneStream))) # Set fill.missing.levels to FALSE to prevent levels 2 to 6 from being drawn. PlotNPyramid(BroadstoneStream, level=floor(LongestTrophicLevel(BroadstoneStream)), fill.missing.levels=FALSE) par(reset.par)
data(TL84) # Use a large left-hand margin to show level text reset.par <- par(mar=c(5,8,1,1)) # Using prey-averaged trophic level PlotNPyramid(TL84) # Using chain-averaged of trophic level PlotNPyramid(TL84, level=floor(ChainAveragedTrophicLevel(TL84))) # Show by category PlotNPyramid(TL84, level='category') # Taxonomic kingdoms as levels PlotNPyramid(TL84, level='kingdom') # Taxonomic kingdoms as levels, with a defined order PlotNPyramid(TL84, level='kingdom', expected.levels=c("<unnamed>", "Plantae", "Chromista","Bacteria","Protozoa","Animalia")) # Compare the YthanEstuary and the TL84 datasets. YthanEstuary has nodes in # each of the categories whereas TL84 only has producer, invertebrate and # vert.ecto nodes. Show categories that are not present in TL84 par(mfrow=c(1,2)) data(YthanEstuary) xlim <- range(c(Log10N(TL84), Log10N(YthanEstuary)), na.rm=TRUE) PlotNPyramid(TL84, level='category', xlim=xlim, expected.levels=c('<unnamed>', 'producer', 'invertebrate', 'vert.ecto', 'vert.endo')) PlotNPyramid(YthanEstuary, level='category', xlim=xlim) par(mfrow=c(1,1)) # For the BroadstoneStream dataset, the LongestTrophicLevel function returns # nodes in levels 1 and 7 to 10 but no nodes in levels 2 to 6. # By default all levels between the minimum and maximum are shown, so levels # 2 to 6 appear with no boxes. data(BroadstoneStream) PlotNPyramid(BroadstoneStream, level=floor(LongestTrophicLevel(BroadstoneStream))) # Set fill.missing.levels to FALSE to prevent levels 2 to 6 from being drawn. PlotNPyramid(BroadstoneStream, level=floor(LongestTrophicLevel(BroadstoneStream)), fill.missing.levels=FALSE) par(reset.par)
Quantitative descriptors after Bersier at al Ecology 2002.
NodeQuantitativeDescriptors(community, weight) QuantitativeDescriptors(community, weight, top.level.threshold=0.99)
NodeQuantitativeDescriptors(community, weight) QuantitativeDescriptors(community, weight, top.level.threshold=0.99)
community |
an object of class |
weight |
the name of a tropic-link property with which quantitative
descriptors should be computed. It can be the name of a first-class property
(returned by |
top.level.threshold |
TODO |
Quantitative food-web descriptors as described by Bersier et al 2002 Ecology.
NodeQuantitativeDescriptors computes a table of node-level quantitative
descripttors, as presented in Bersier et al 2002, Table 1. It returns a
matrix
with columns NResources, NConsumers, bIn, bOut, nN, nP, d.prime,
d, o.prime, o, g.prime, g, v.prime, v.
QuantitativeDescriptors computes values presented in Bersier et al 2002 Table
2. It returns a matrix
with columns Qualitative, Unweighted and
Weighted and rows Fraction top level, Fraction intermediate, Fraction basal,
Ratio resources:consumers, Link density, Connectance,
Fraction links top:intermediate, Fraction links top:basal,
Fraction links intermediate:intermediate, Fraction links intermediate:basal,
Mean chain length, Median chain length, SD chain length, Max chain length,
Degree of omnivory, Generality, Vulnerability, SD standardised generality,
SD standardised vulnerability.
A matrix
.
Lawrence Hudson
Bersier, L. and Banasek-Richter, C. and Cattin, M. (2002) Ecology 80 2394–2407.
TrophicLinkPropertyNames
,
NumberOfTrophicLinks
, NumberOfNodes
data(ChesapeakeBay) QuantitativeDescriptors(ChesapeakeBay, 'biomass.flow') NodeQuantitativeDescriptors(ChesapeakeBay, 'biomass.flow')
data(ChesapeakeBay) QuantitativeDescriptors(ChesapeakeBay, 'biomass.flow') NodeQuantitativeDescriptors(ChesapeakeBay, 'biomass.flow')
Remove cannibalistic trophic links.
RemoveCannibalisticLinks(community, title)
RemoveCannibalisticLinks(community, title)
community |
an object of class |
title |
a title for the new community. |
Returns a new Community
with any cannibalistic trophic links
removed.
A new object of class Community
.
Lawrence Hudson
data(TL84) NumberOfTrophicLinks(TL84) TL84.no.cannibal <- RemoveCannibalisticLinks(TL84) NumberOfTrophicLinks(TL84.no.cannibal)
data(TL84) NumberOfTrophicLinks(TL84) TL84.no.cannibal <- RemoveCannibalisticLinks(TL84) NumberOfTrophicLinks(TL84.no.cannibal)
Remove isolated nodes.
RemoveIsolatedNodes(community, title)
RemoveIsolatedNodes(community, title)
community |
an object of class |
title |
a title for the new community. |
Returns a new Community
with isolated nodes removed.
A new object of class Community
.
Lawrence Hudson
data(TL84) IsolatedNodes(TL84) TL84.no.isolated <- RemoveIsolatedNodes(TL84) IsolatedNodes(TL84.no.isolated)
data(TL84) IsolatedNodes(TL84) TL84.no.isolated <- RemoveIsolatedNodes(TL84) IsolatedNodes(TL84.no.isolated)
Remove one or more nodes.
RemoveNodes(community, remove, title, method=c('direct','secondary','cascade'))
RemoveNodes(community, remove, title, method=c('direct','secondary','cascade'))
community |
an object of class |
remove |
a vector of either names, integer indices or logicals indicating nodes to be removed. |
title |
a title for the new community. |
method |
how species removals are propogated through the food web. |
Returns a new Community
with nodes in remove
removed.
An error is raised if remove
refers to nodes not in the
community
of if remove
refers to all nodes in the
community
.
If method
is ‘direct’, only the nodes in remove
are removed.
If method
is ‘secondary’, secondarily extinct nodes - those that
directly consume one or more nodes in ‘remove’ and that no longer have any
resources (except themselves) after the removal - are also removed.
If method
is ‘cascade’, a multistep version of ‘secondary’ is applied.
This has the effect of propogating extinctions though the community - all
consumers that are ultimately dependent upon all species in ‘remove’, and upon
no other nodes (except themselves), will be removed.
A new object of class Community
.
Lawrence Hudson
Community
, BasalNodes
,
IsolatedNodes
, NumberOfNodes
data(TL84) # Three different ways of removing node 56 (Umbra limi) a <- RemoveNodes(TL84, 56) b <- RemoveNodes(TL84, 'Umbra limi') c <- RemoveNodes(TL84, c(rep(FALSE,55), TRUE)) identical(a,b) # TRUE identical(a,c) # TRUE # The behaviours of the different methods NumberOfNodes(TL84) # 56 nodes in total length(BasalNodes(TL84)) # 25 basal nodes length(IsolatedNodes(TL84)) # 6 isolated nodes RemoveNodes(TL84, BasalNodes(TL84)) # 56 - 25 = 31 nodes remain RemoveNodes(TL84, BasalNodes(TL84), method='secondary') # 14 nodes remain RemoveNodes(TL84, BasalNodes(TL84), method='cascade') # 6 isolated nodes remain # Results in an error ## Not run: RemoveNodes(TL84, 1:NumberOfNodes(TL84))
data(TL84) # Three different ways of removing node 56 (Umbra limi) a <- RemoveNodes(TL84, 56) b <- RemoveNodes(TL84, 'Umbra limi') c <- RemoveNodes(TL84, c(rep(FALSE,55), TRUE)) identical(a,b) # TRUE identical(a,c) # TRUE # The behaviours of the different methods NumberOfNodes(TL84) # 56 nodes in total length(BasalNodes(TL84)) # 25 basal nodes length(IsolatedNodes(TL84)) # 6 isolated nodes RemoveNodes(TL84, BasalNodes(TL84)) # 56 - 25 = 31 nodes remain RemoveNodes(TL84, BasalNodes(TL84), method='secondary') # 14 nodes remain RemoveNodes(TL84, BasalNodes(TL84), method='cascade') # 6 isolated nodes remain # Results in an error ## Not run: RemoveNodes(TL84, 1:NumberOfNodes(TL84))
Trophic links in which the resource has a larger body mass than the consumer.
ResourceLargerThanConsumer(community)
ResourceLargerThanConsumer(community)
community |
an object of class |
Returns a data.frame
with columns ‘resource’, ‘consumer’,
‘resource.M’ and ‘consumer.M’.
A data.frame
Lawrence Hudson
data(TL84) ResourceLargerThanConsumer(TL84) # Highlight trophic links PlotNvM(TL84, highlight.links=ResourceLargerThanConsumer)
data(TL84) ResourceLargerThanConsumer(TL84) # Highlight trophic links PlotNvM(TL84, highlight.links=ResourceLargerThanConsumer)
Functions that return the resources and consumers of nodes.
ResourcesByNode(community) ConsumersByNode(community) ResourcesAndConsumersByNode(community) ResourcesOfNodes(community, nodes) ConsumersOfNodes(community, nodes) TrophicLinksForNodes(community, nodes, node.properties=NULL, link.properties=NULL)
ResourcesByNode(community) ConsumersByNode(community) ResourcesAndConsumersByNode(community) ResourcesOfNodes(community, nodes) ConsumersOfNodes(community, nodes) TrophicLinksForNodes(community, nodes, node.properties=NULL, link.properties=NULL)
community |
an object of class |
nodes |
either the names or integer indices of nodes. |
node.properties |
passed to |
link.properties |
passed to |
ResourcesByNode
/ConsumersByNode
/
ResourcesAndConsumersByNode
all return a list of length
NumberOfNodes
; list elements are names of nodes that are
resources/consumers/resources and/or consumers.
If nodes
is of length one then ResourcesOfNodes
and
ConsumersOfNodes
return a vector of resources / consumers. If
nodes
contains more than one value, then a list of vectors is returned.
TrophicLinksForNodes
returns a data.frame
containing the columns
‘resource’ and 'consumer' and a row for each trophic link in-to and out-of
nodes
.
Either a vector
, a list
or a data.frame
Lawrence Hudson
TLPS
, PredationMatrix
,
NumberOfNodes
data(TL84) # A list containing a vector of resources for each node. ResourcesByNode(TL84) # A vector of resources of 'Umbra limi' ResourcesOfNodes(TL84, 'Umbra limi') # A vector of resources of 'Umbra limi' ResourcesOfNodes(TL84, 56) # A list containing vectors of resources for nodes 50:56 ResourcesOfNodes(TL84, 50:56) # A data.frame containin columns resource and consumer TrophicLinksForNodes(TL84, 'Umbra limi') # A data.frame containin columns resource, consumer, resource.M and consumer.M TrophicLinksForNodes(TL84, 'Umbra limi', node.properties='M')
data(TL84) # A list containing a vector of resources for each node. ResourcesByNode(TL84) # A vector of resources of 'Umbra limi' ResourcesOfNodes(TL84, 'Umbra limi') # A vector of resources of 'Umbra limi' ResourcesOfNodes(TL84, 56) # A list containing vectors of resources for nodes 50:56 ResourcesOfNodes(TL84, 50:56) # A data.frame containin columns resource and consumer TrophicLinksForNodes(TL84, 'Umbra limi') # A data.frame containin columns resource, consumer, resource.M and consumer.M TrophicLinksForNodes(TL84, 'Umbra limi', node.properties='M')
Functions that compute the shortest trophic paths between nodes.
ShortestPaths(community, weight.by=NULL) CharacteristicPathLength(community)
ShortestPaths(community, weight.by=NULL) CharacteristicPathLength(community)
community |
an object of class |
weight.by |
the name of a property by which to weight paths. |
ShortestPaths uses Dijkstra's algorithm to compute the number
of trophic links between each pair of nodes in the food web.
CharacteristicPathLength
returns the mean of path lengths.
A square matrix
with NumberOfNodes
rows and columns or
a single number.
Lawrence Hudson
Williams, R.J. and Berlow, E.L. and Dunne, J.A. and Barabási, A.L. and Martinez, N.D. (2002) Two degrees of separation in complex food webs. Proceedings of the National Academy of Sciences of the United States of America 99, 20, 12913–12916
data(Benguela) # Compare weighted and unweighted ShortestPaths(Benguela) ShortestPaths(Benguela, weight.by='diet.fraction') CharacteristicPathLength(Benguela)
data(Benguela) # Compare weighted and unweighted ShortestPaths(Benguela) ShortestPaths(Benguela, weight.by='diet.fraction') CharacteristicPathLength(Benguela)
Returns a matrix with a column per community and a row per unique node within communities in the collection.
SiteBySpeciesMatrix(collection, abundance=NULL, na.missing=FALSE)
SiteBySpeciesMatrix(collection, abundance=NULL, na.missing=FALSE)
collection |
an object of class |
abundance |
the name of a node property that provides abundance values.
This can be the name of a first-class propery or the name of a function.
The name must meet the criteria of the |
na.missing |
if |
If abundance
is NULL
, the returned matrix
indicates presence (1) or absence (0 or NA
- see na.missing
)
of nodes. If abundance
is given, values are the abundances of nodes,
or 0 or NA
where nodes are absent.
A matrix
.
Lawrence Hudson
CommunityCollection
, NPS
,
CollectionCPS
, Biomass
,
Log10Biomass
, matrix
data(pHWebs) # If abundance is NULL, you get a presence/absence matrix: SiteBySpeciesMatrix(pHWebs) # Numerical abundance SiteBySpeciesMatrix(pHWebs, 'N') # Biomass abundance SiteBySpeciesMatrix(pHWebs, 'Biomass') # Log10 biomass abundance SiteBySpeciesMatrix(pHWebs, 'Log10Biomass') # Example showing how to model biomass in term of pH using vegan's rda function m <- SiteBySpeciesMatrix(pHWebs, 'Biomass') # Some nodes (e.g. CPOM) do not have a biomass. The rows in m for these nodes # will contain all NA. Rows containing all NA will upset vegan's rda function # so these rows must be removed. m <- m[apply(m, 1, function(row) all(!is.na(row))),] # Tranpose to get row per site - the format required by vegan's rda function m <- t(m) # Matrix (with a row per site) of variables on the right hand side of the # model equation variables <- CollectionCPS(pHWebs) ## Not run: library(vegan) ## Not run: res <- rda(m~pH,variables)
data(pHWebs) # If abundance is NULL, you get a presence/absence matrix: SiteBySpeciesMatrix(pHWebs) # Numerical abundance SiteBySpeciesMatrix(pHWebs, 'N') # Biomass abundance SiteBySpeciesMatrix(pHWebs, 'Biomass') # Log10 biomass abundance SiteBySpeciesMatrix(pHWebs, 'Log10Biomass') # Example showing how to model biomass in term of pH using vegan's rda function m <- SiteBySpeciesMatrix(pHWebs, 'Biomass') # Some nodes (e.g. CPOM) do not have a biomass. The rows in m for these nodes # will contain all NA. Rows containing all NA will upset vegan's rda function # so these rows must be removed. m <- m[apply(m, 1, function(row) all(!is.na(row))),] # Tranpose to get row per site - the format required by vegan's rda function m <- t(m) # Matrix (with a row per site) of variables on the right hand side of the # model equation variables <- CollectionCPS(pHWebs) ## Not run: library(vegan) ## Not run: res <- rda(m~pH,variables)
The food-web of Skipwith Pond.
Taxonomic classification provided by Guy Woodward.
Community
.
Warren, 1989.
Warren, P.H. (1989) Spatial and temporal variation in the structureof a freshwater food web. Oikos 55, 299–311.
High-level functions that plot the sum numerical abundance (N) or biomass abundance (B) in equally-spaced log10 body-mass bins.
PlotBSpectrum(community, lower = min(NP(community, "M"), na.rm = TRUE), upper = max(NP(community, "M"), na.rm = TRUE), n.bins = 10, main = CPS(community)$title, xlab = Log10MLabel(community), ylab = Log10BLabel(community), xlim = NULL, ylim = NULL, pch = 19, show.bin.limits = TRUE, show.bin.centres = FALSE, ...) PlotNSpectrum(community, lower = min(NP(community, "M"), na.rm = TRUE), upper = max(NP(community, "M"), na.rm = TRUE), n.bins = 10, main = CPS(community)$title, xlab = Log10MLabel(community), ylab = Log10NLabel(community), xlim = NULL, ylim = NULL, pch = 19, show.bin.limits = TRUE, show.bin.centres = FALSE, ...)
PlotBSpectrum(community, lower = min(NP(community, "M"), na.rm = TRUE), upper = max(NP(community, "M"), na.rm = TRUE), n.bins = 10, main = CPS(community)$title, xlab = Log10MLabel(community), ylab = Log10BLabel(community), xlim = NULL, ylim = NULL, pch = 19, show.bin.limits = TRUE, show.bin.centres = FALSE, ...) PlotNSpectrum(community, lower = min(NP(community, "M"), na.rm = TRUE), upper = max(NP(community, "M"), na.rm = TRUE), n.bins = 10, main = CPS(community)$title, xlab = Log10MLabel(community), ylab = Log10NLabel(community), xlim = NULL, ylim = NULL, pch = 19, show.bin.limits = TRUE, show.bin.centres = FALSE, ...)
community |
an object of class |
lower |
lower bound of the bins. |
upper |
upper bound of the bins. |
n.bins |
the number of bins. |
main |
title of the plot |
xlab |
title of the x axis. |
ylab |
title of the y axis. |
xlim |
limits of the x axis. |
ylim |
limits of the y axis. |
pch |
plotting symbol. |
show.bin.limits |
logical - if |
show.bin.centres |
logical - if |
... |
other values to plot functions. |
A list
:
bins |
value returned by the |
lm |
a linear regression fitted through the data. |
Lawrence Hudson
Community
,
BodyMassBins
,
PlotCircularWeb
,
PlotNPS
,
PlotNPSDistribution
,
PlotRankNPS
,
PlotTLPS
,
PlotWebByLevel
data(TL84) PlotNSpectrum(TL84) PlotBSpectrum(TL84)
data(TL84) PlotNSpectrum(TL84) PlotBSpectrum(TL84)
A subset of a CommunityCollection
.
## S3 method for class 'CommunityCollection' subset(x, subset, properties=NULL, ...)
## S3 method for class 'CommunityCollection' subset(x, subset, properties=NULL, ...)
x |
An object of class |
subset |
logical expression indicating communities to keep. |
properties |
The names of properties passed to |
... |
further arguments passed to other methods. |
CollectionCPS
is used to gather properties
.
properties
should contain the names of properties required to evaluate
subset
. If properties
is NULL
, all first-class properties
are available to the subset
expression. Returns a new
CommunityCollection
or NULL
if no communities in x
meet
the criteria in subset
.
A new object of class CommunityCollection
or NULL
.
Lawrence Hudson
CommunityCollection
, CollectionCPS
,
subset
data(pHWebs) # Two communities have pH>7 subset(pHWebs, pH>7) # No communities have pH>10 so this returns NULL subset(pHWebs, pH>7) # Get a subset based on a computed property subset(pHWebs, S>50, properties=c(S='NumberOfNodes')) # X is not a property so this raises an error ## Not run: subset(pHWebs, X==1)
data(pHWebs) # Two communities have pH>7 subset(pHWebs, pH>7) # No communities have pH>10 so this returns NULL subset(pHWebs, pH>7) # Get a subset based on a computed property subset(pHWebs, S>50, properties=c(S='NumberOfNodes')) # X is not a property so this raises an error ## Not run: subset(pHWebs, X==1)
Enumerates every three-node chain in a food web.
ThreeNodeChains(community, exclude.loops=FALSE, node.properties=NULL, chain.properties=NULL)
ThreeNodeChains(community, exclude.loops=FALSE, node.properties=NULL, chain.properties=NULL)
community |
an object of class |
exclude.loops |
logical - should loops A -> B -> A be included? |
node.properties |
the names of the node properties to return. Should
meet the criteria of the |
chain.properties |
the names of chain properties to return. |
Enumerates every three-node chain in the food-web and returns a
data.frame
containing the columns bottom, intermediate and
top and any requested node and trophic-link columns.
A data.frame
.
Lawrence Hudson
data(TL84) nrow(ThreeNodeChains(TL84)) nrow(ThreeNodeChains(TL84, exclude.loops=TRUE)) # bottom, intermediate and top head(ThreeNodeChains(TL84)) # bottom, intermediate, top, bottom.M, intermediate.M and top.M head(ThreeNodeChains(TL84, node.properties='M')) # As above with the addition of bottom.N, intermediate.N and top.N head(ThreeNodeChains(TL84, node.properties=c('M','N')))
data(TL84) nrow(ThreeNodeChains(TL84)) nrow(ThreeNodeChains(TL84, exclude.loops=TRUE)) # bottom, intermediate and top head(ThreeNodeChains(TL84)) # bottom, intermediate, top, bottom.M, intermediate.M and top.M head(ThreeNodeChains(TL84, node.properties='M')) # As above with the addition of bottom.N, intermediate.N and top.N head(ThreeNodeChains(TL84, node.properties=c('M','N')))
The communities of Tuesday Lake, Michigan, USA sampled in 1984 and 1986.
Taxonomic classification fish: Froese and Pauly (2012), invertebrates: Smith (2001), phytoplankton: Guiry and Guiry (2012).
Community
objects.
Carpenter and Kitchell, 1996; Cohen et al, 2003; Johnsson et al 2005.
Carpenter, S.R. and Kitchell, J.F., eds. (1996) The trophic cascade in lakes. Cambridge University Press.
Cohen, J.E. and Jonsson, T. and Carpenter, S.R. (2003) Ecological community description using the food web, species abundance, and body size. Proceedings of the National Academy of Sciences of the United States of America 100, 4, 1781–1786.
Froese, R. and Pauly, D., eds. 2012. FishBase. World Wide Web electronic publication. https://fishbase.mnhn.fr, version (08/2012).
Guiry, M.D. and Guiry, G.M. (2012) AlgaeBase. World-wide electronic publication, National University of Ireland, Galway. https://www.algaebase.org; searched on 20 September 2012.
Jonsson, T. and Cohen, J.E. and Carpenter, S.R. (2005) Food webs, body size, and species abundance in ecological community description. Advances in Ecological Research 36, 1–84.
Smith, D.G. (2001) Pennak's Freshwater Invertebrates of the United States: Porifera to Crustacea, John Wiley and Sons, 4th Edition.
Returns a single trophic-link property.
TLP(community, property)
TLP(community, property)
community |
an object of class |
property |
the name of the property to return. |
This function is named TLP for Trophic Link Property. It returns a
vector containing the value of property for every trophic link. The returned
vector is all NA
if there is no trophic-link property with that name.
A vector of length NumberOfTrophicLinks
.
Lawrence Hudson
TrophicLinkPropertyNames
, TLPS
,
NumberOfTrophicLinks
# Skipwith Pond has a first-class property called link.evidence data(SkipwithPond) TLP(SkipwithPond, 'link.evidence') # Benguela has a first-class property called diet.fraction data(Benguela) TLP(Benguela, 'diet.fraction') # All NA TLP(SkipwithPond, 'not a property')
# Skipwith Pond has a first-class property called link.evidence data(SkipwithPond) TLP(SkipwithPond, 'link.evidence') # Benguela has a first-class property called diet.fraction data(Benguela) TLP(Benguela, 'diet.fraction') # All NA TLP(SkipwithPond, 'not a property')
Returns a data.frame
of first-class and computed
trophic-link properties.
TLPS(community, node.properties=NULL, link.properties=NULL)
TLPS(community, node.properties=NULL, link.properties=NULL)
community |
an object of class |
node.properties |
the names of the node properties to return. Should
meet the criteria of the |
link.properties |
the names of link properties. These can be names of
first-class properties (returned by |
This function is named TLPS for Trophic Link PropertieS. It returns
a data.frame
containing the columns 'resource' and 'consumer'
and any requested properties.
A data.frame
with NumberOfTrophicLinks
rows.
Lawrence Hudson
TrophicLinkPropertyNames
, TLP
,
NumberOfTrophicLinks
, NPS
,
Log10RCMRatio
,
ThreeNodeChains
, TrophicChains
data(TL84) # Just resource and consumer head(TLPS(TL84)) # resource, consumer, resource.M and consumer.M head(TLPS(TL84, node.properties='M')) # Log10RCMRatio returns log10-transformed resource.M / consumer.M head(TLPS(TL84, node.properties='M', link.properties='Log10RCMRatio')) # Skipwith Pond has link.evidence and link.life.stage first-class properties data(SkipwithPond) head(TLPS(SkipwithPond)) # resource, consumer and link.evidence head(TLPS(SkipwithPond, link.properties='link.evidence')) # Skipwith Pond has diet.fraction first-class property data(Benguela) head(TLPS(Benguela))
data(TL84) # Just resource and consumer head(TLPS(TL84)) # resource, consumer, resource.M and consumer.M head(TLPS(TL84, node.properties='M')) # Log10RCMRatio returns log10-transformed resource.M / consumer.M head(TLPS(TL84, node.properties='M', link.properties='Log10RCMRatio')) # Skipwith Pond has link.evidence and link.life.stage first-class properties data(SkipwithPond) head(TLPS(SkipwithPond)) # resource, consumer and link.evidence head(TLPS(SkipwithPond, link.properties='link.evidence')) # Skipwith Pond has diet.fraction first-class property data(Benguela) head(TLPS(Benguela))
Enumerates every trophic chain in a food web.
TrophicChains(community, node.properties = NULL, chain.properties = NULL)
TrophicChains(community, node.properties = NULL, chain.properties = NULL)
community |
an object of class |
node.properties |
the names of the node properties to return. Should
meet the criteria of the |
chain.properties |
the names of chain properties to return. |
Enumerates every trophic chain in the food-web and returns a
data.frame
containing any requested node and trophic-link columns.
Some network properties and analyses require knowledge of every unique path
- ‘trophic chain’ - through the food-web. A trophic chain starts at a basal
node (BasalNodes
) and ends when it is not possible to
add nodes that are not already in the chain, so loops and cannibalism are
ignored. For communities that have one or more top-level nodes
(TopLevelNodes
) each trophic chain will end with a top-level node.
If your analysis requires only simple statistics about trophic chains, the
TrophicChainsStats
function is more suitable as it is much faster and
requires less memory than TrophicChains
. This is particularly true
for communities that contain a large number of trophic chains, such as the
SkipwithPond
dataset, which has more than $10^5$ unique chains.
It will not be possible to compute, within reasonable time and available system
memory, trophic chains for food webs with a large number of nodes and/or
trophic links. TrophicChains
will raises an error 'Unable to compute
paths' for these food webs. The ‘Large numbers of trophic chains’ section of
the ‘Community’ vignette explains this in more detail.
A data.frame
.
Lawrence Hudson
BasalNodes
, TopLevelNodes
,
TLPS
, ThreeNodeChains
,
TrophicChainsStats
, SkipwithPond
data(TL84) tc <- TrophicChains(TL84) # Every chain starts with a basal node BasalNodes(TL84) first <- tc[,1] all(IsBasalNode(TL84)[unique(first)]) # TL84 has a single top-level consumer - every trophic chain ends with this # consumer TopLevelNodes(TL84) # Get the last node in each chain last <- apply(tc, 1, function(row) row[max(which(""!=row))]) unique(last) # M of nodes head(TrophicChains(TL84, node.properties='M')) # M and N of nodes head(TrophicChains(TL84, node.properties=c('M','N'))) # Skipwith Pond has more than 10e5 unique chains data(SkipwithPond) # Not all systems will be able to allocate the memory required to hold the # chains ## Not run: dim(TrophicChains(SkipwithPond))
data(TL84) tc <- TrophicChains(TL84) # Every chain starts with a basal node BasalNodes(TL84) first <- tc[,1] all(IsBasalNode(TL84)[unique(first)]) # TL84 has a single top-level consumer - every trophic chain ends with this # consumer TopLevelNodes(TL84) # Get the last node in each chain last <- apply(tc, 1, function(row) row[max(which(""!=row))]) unique(last) # M of nodes head(TrophicChains(TL84, node.properties='M')) # M and N of nodes head(TrophicChains(TL84, node.properties=c('M','N'))) # Skipwith Pond has more than 10e5 unique chains data(SkipwithPond) # Not all systems will be able to allocate the memory required to hold the # chains ## Not run: dim(TrophicChains(SkipwithPond))
Computes simple statistics about every trophic chain in a food web.
TrophicChainsStats(community)
TrophicChainsStats(community)
community |
an object of class |
Enumerates every trophic chain in the food-web and returns a
list
object containing some simple statistics.
If your analysis requires only simple statistics about trophic chains then
this function is more suitable than TrophicChains
because it is faster and requires less memory.
A list containing:
chain.lengths |
The number of nodes in each trophic chain. |
node.pos.counts |
A |
Lawrence Hudson
TrophicChains
, NumberOfNodes
,
IsolatedNodes
, BasalNodes
,
IntermediateNodes
, TopLevelNodes
data(TL84) chain.stats <- TrophicChainsStats(TL84) # The length of every chain length(chain.stats$chain.lengths) # 5,988 chains summary(chain.stats$chain.lengths) # The number of chains in which a node appears in that position in a chain chain.stats$node.pos.counts # Basal nodes only have counts in the first column. chain.stats$node.pos.counts[BasalNodes(TL84),] # Consumers only have counts in columns two and up. chain.stats$node.pos.counts[c(IntermediateNodes(TL84),TopLevelNodes(TL84)),] # All counts are zero for isolated nodes IsolatedNodes. chain.stats$node.pos.counts[IsolatedNodes(TL84),]
data(TL84) chain.stats <- TrophicChainsStats(TL84) # The length of every chain length(chain.stats$chain.lengths) # 5,988 chains summary(chain.stats$chain.lengths) # The number of chains in which a node appears in that position in a chain chain.stats$node.pos.counts # Basal nodes only have counts in the first column. chain.stats$node.pos.counts[BasalNodes(TL84),] # Consumers only have counts in columns two and up. chain.stats$node.pos.counts[c(IntermediateNodes(TL84),TopLevelNodes(TL84)),] # All counts are zero for isolated nodes IsolatedNodes. chain.stats$node.pos.counts[IsolatedNodes(TL84),]
Functions that compute different measures of trophic level.
PreyAveragedTrophicLevel(community, include.isolated=TRUE) FlowBasedTrophicLevel(community, weight.by, include.isolated=TRUE) ShortestTrophicLevel(community, include.isolated=TRUE) ShortWeightedTrophicLevel(community, include.isolated=TRUE) LongestTrophicLevel(community, include.isolated=TRUE) LongWeightedTrophicLevel(community, include.isolated=TRUE) ChainAveragedTrophicLevel(community, include.isolated=TRUE) TrophicHeight(community, include.isolated=TRUE) TrophicLevels(community, weight.by=NULL, include.isolated=TRUE)
PreyAveragedTrophicLevel(community, include.isolated=TRUE) FlowBasedTrophicLevel(community, weight.by, include.isolated=TRUE) ShortestTrophicLevel(community, include.isolated=TRUE) ShortWeightedTrophicLevel(community, include.isolated=TRUE) LongestTrophicLevel(community, include.isolated=TRUE) LongWeightedTrophicLevel(community, include.isolated=TRUE) ChainAveragedTrophicLevel(community, include.isolated=TRUE) TrophicHeight(community, include.isolated=TRUE) TrophicLevels(community, weight.by=NULL, include.isolated=TRUE)
community |
an object of class |
include.isolated |
if |
weight.by |
the name of a node property, either first-class or computed,
by which to weight flow-based trophic level. Must satisfy the criteria
of the |
Trophic level is a measure of a node's ‘distance’ from the primary
producers in the community and hence indicates how many steps matter, and hence
energy, has been through to reach that node. Each function (with the exception
of TrophicLevels
) returns a vector containing a different measure of
trophic level. These functions follow the definitions of Williams and Martinez
(2004).
PreyAveragedTrophicLevel
returns 1 plus the mean trophic level of the
node's resources, using the matrix inversion method of Levine (1980) that is
very fast and accounts for flow through loops. If this matrix inversion fails
then there is an important problem with the network topology and the function
will return a vector containing all NA
s. For a food web to be
energetically feasible, every node must be connected to a basal node. When the
inversion fails it is because there is at least one node that has no connection
to a basal node. FlowBasedTrophicLevel
also implements the matrix
inversion technique and uses the weight.by
node property to provide an
estimate of energy flow through each trophic link.
ShortestTrophicLevel
, ShortWeightedTrophicLevel
,
LongestTrophicLevel
, LongWeightedTrophicLevel
and ChainAveragedTrophicLevel
compute trophic level by
examining the position of each node in every food chain in which it appears.
ShortestTrophicLevel
returns 1 plus the shortest chain length from a
node to a basal species. ShortWeightedTrophicLevel
returns the average
of ShortestTrophicLevel
and PreyAveragedTrophicLevel
.
LongestTrophicLevel
is the longest chain length from each node to a
basal species. LongWeightedTrophicLevel
is the average of
LongestTrophicLevel
and PreyAveragedTrophicLevel
.
ChainAveragedTrophicLevel
is 1 plus the average chain length of all
paths from each node to a basal species. These five functions each
enumerate every unique food chain (using TrophicChainsStats
), which can
be lengthy for complex food webs. If more than one of these five measures of
trophic level is required, it will be faster to use the TrophicLevels
convenience function, which enumerates unique food chains only once and returns
a matrix containing every measure of trophic level in columns ‘ShortestTL’,
‘ShortWeightedTL’, ‘LongestTL’, ‘LongWeightedTL’, ‘ChainAveragedTL’,
‘PreyAveragedTL’ and, if weight.by
is given, ‘FlowBasedTL’.
Jonsson et al (2005) defined ‘trophic height’ to be the same as
Williams and Martinez' (2004) chain-averaged trophic level so
TrophicHeight
is a synonym for ChainAveragedTrophicLevel
.
All methods will return a vector containing all NA
s if no nodes are basal
i.e., all nodes are cannibalistic or ‘community’ has no trophic links.
Either a vector of length NumberOfNodes
or a matrix
with
NumberOfNodes
rows.
Lawrence Hudson and Rich Williams
Jonsson, T. and Cohen, J. E. and Carpenter, S. R. (2005) Food webs, body size, and species abundance in ecological community description. Advances in Ecological Research 36, 1–84.
Levine, S (1980) Several measures of trophic structure applicable to complex food webs. Journal of Theoretical Biology 83, 195–207.
Williams, R. J. and Martinez, N. D. (2004) Limits to Trophic Levels and Omnivory in Complex Food Webs: Theory and Data. American Naturalist 163, 63, 458–468.
IsIsolatedNode
, IsBasalNode
,
IsCannibal
, NPS
,
TrophicChains
, NumberOfNodes
,
NumberOfTrophicLinks
, TrophicChainsStats
,
PredationMatrix
data(TL84) # Six different measures of trophic level TrophicLevels(TL84) # The Benguela data contains diet.fraction data(Benguela) # Compare prey-averaged and flow-based cbind(pa=PreyAveragedTrophicLevel(Benguela), fb=FlowBasedTrophicLevel(Benguela, weight.by='diet.fraction'))
data(TL84) # Six different measures of trophic level TrophicLevels(TL84) # The Benguela data contains diet.fraction data(Benguela) # Compare prey-averaged and flow-based cbind(pa=PreyAveragedTrophicLevel(Benguela), fb=FlowBasedTrophicLevel(Benguela, weight.by='diet.fraction'))
Returns the names of the first-class trophic link properties in a community.
TrophicLinkPropertyNames(community)
TrophicLinkPropertyNames(community)
community |
an object of class |
The names 'resource' and 'consumer' are always returned.
Two or more characters.
Lawrence Hudson
data(TL84, SkipwithPond) # Just 'resource' and 'consumer' TrophicLinkPropertyNames(TL84) # Just 'resource', 'consumer', 'link.evidence' and 'link.life.stage' TrophicLinkPropertyNames(SkipwithPond)
data(TL84, SkipwithPond) # Just 'resource' and 'consumer' TrophicLinkPropertyNames(TL84) # Just 'resource', 'consumer', 'link.evidence' and 'link.life.stage' TrophicLinkPropertyNames(SkipwithPond)
A measure of trophic overlap between nodes in a community.
TrophicSimilarity(community) MeanMaximumTrophicSimilarity(community)
TrophicSimilarity(community) MeanMaximumTrophicSimilarity(community)
community |
an object of class |
TrophicSimilarity
computes ‘trophic similarity’ (I) as defined
by Martinez (1991). For each pair of nodes, I = c/(a+b+c), where a is the
number of resources and consumers unique to one node, b is number of resources
and consumers unique to the other node and c is the number of resources and
consumers common to both nodes. Where two nodes have exactly the same set of
resources and consumers, I = 1. Where two nodes have no resources or consumers
in common, I = 0.
Williams and Martinez (2000) defined the mean maximum trophic similarity as the sum of the largest value in each column of I (excluding the diagonal), divided by the number of nodes.
TrophicSimilarity
returns a matrix
with
NumberOfNodes
rows and columns. MeanMaximumSimilarity
returns
a number.
Lawrence Hudson
Martinez, N. D. (1991) Ecological Monographs 61, 367–392.
Williams, R. J. and Martinez, N. D. (2000) Nature 404 180–182.
PredationMatrix
, NumberOfNodes
,
TrophicSpecies
data(TL84) I <- TrophicSimilarity(TL84) I MeanMaximumTrophicSimilarity(TL84)
data(TL84) I <- TrophicSimilarity(TL84) I MeanMaximumTrophicSimilarity(TL84)
A function that computes trophic species numbers.
TrophicSpecies(community, include.isolated=TRUE)
TrophicSpecies(community, include.isolated=TRUE)
community |
an object of class |
include.isolated |
if |
Returns a vector containing the trophic species number of each node in the community. Nodes with identical sets of prey and predators are given the same trophic species number.
A vector of length NumberOfNodes
.
Lawrence Hudson
Briand, F. and Cohen, J.E. 1984 Community food webs have scale-invariant structure Nature 307, 264–267.
Pimm, S.L. and Lawton, J.H. and Cohen, J.E. 1991 Food web patterns and their consequences Nature 350, 669–674.
Williams, R.J. and Martinez, N.D. 2000 Simple rules yield complex food webs 404, 180–183.
Jonsson, T. and Cohen, J.E. and Carpenter, S.R. 2005 Food webs, body size, and species abundance in ecological community description. Advances in Ecological Research 36, 1–84.
Community
, IsIsolatedNode
,
NPS
, LumpTrophicSpecies
,
NumberOfNodes
data(TL84) # Isolated nodes assigned their own trophic species number TrophicSpecies(TL84) # Isolated nodes assigned a trophic species of NA TrophicSpecies(TL84, include.isolated=FALSE) # Compare including and excluding isolated nodes NPS(TL84, list(TS1='TrophicSpecies', TS2=list('TrophicSpecies', include.isolated=FALSE), Iso='IsIsolatedNode'))
data(TL84) # Isolated nodes assigned their own trophic species number TrophicSpecies(TL84) # Isolated nodes assigned a trophic species of NA TrophicSpecies(TL84, include.isolated=FALSE) # Compare including and excluding isolated nodes NPS(TL84, list(TS1='TrophicSpecies', TS2=list('TrophicSpecies', include.isolated=FALSE), Iso='IsIsolatedNode'))
The community of Ythan Estuary.
Taxonomic classification for birds: Dickinson et al (2003), fish: Froese and Pauly (2012), invertebrates: Appeltans et al (2012), mammals: Wilson and Reeder (2005), phytoplankton: Guiry and Guiry (2012).
Community
.
Hall and Raffaelli, 1991; Emmerson and Raffaelli, 2004.
Appeltans W., Bouchet P., Boxshall G.A., De Broyer C., de Voogd N.J., Gordon D.P., Hoeksema B.W., Horton T., Kennedy M., Mees J., Poore G.C.B., Read G., Stöhr S., Walter T.C., Costello M.J. Editors. (2012) World Register of Marine Species. Accessed at https://www.marinespecies.org on 2012-09-20.
Dickinson, E.C., ed. (2003) The Howard and Moore complete checklist of the birds of the world, Christopher Helm, London, third edition.
Emmerson, M.C. and Raffaelli, D. (2004) Predator-prey body size, interaction strength and the stability of a real food web. Journal of Animal Ecology 73, 3, 399–409.
Froese, R. and Pauly, D., eds. 2012. FishBase. World Wide Web electronic publication. https://fishbase.mnhn.fr, version (08/2012).
Guiry, M.D. and Guiry, G.M. (2012) AlgaeBase. World-wide electronic publication, National University of Ireland, Galway. https://www.algaebase.org; searched on 20 September 2012.
Hall, S.J. and Raffaelli, D. (1991) Food-web patterns: lessons from a species-rich web. Journal of Animal Ecology. 60, 3, 823–841.
Wilson, D.E. and Reeder, D.M., eds. (2005) Mammal species of the world. A taxonomic and geographic reference. Johns Hopkins University Press, third edition.