Coder Social home page Coder Social logo

basingstoke's Introduction

Basingstoke - food-web structural models in R

Travis status Coverage Status

Basingstoke provides implementations of some published food-web structural models, allowing artificial ecological communities to be generated in silico.

Visual comparison of the different types of structural models

library(Basingstoke)

# A helper function to make the comparisons easier
Artificial <- function(original, main, ...) {
    artificial <- CommunityFactory(nodes=NPS(original),
                                   C=DirectedConnectance(original),
                                   properties=CPS(original),
                                   n=1,
                                   ...)[[1]]
    PlotPredationMatrix(artificial, main=paste0(main, ', C=',
        sprintf('%.4f', DirectedConnectance(artificial))))
    return (invisible(artificial))
}

data(TL84)
TL84 <- RemoveIsolatedNodes(OrderCommunity(TL84, 'M'), title='Tuesday Lake 1984')
par(mfrow=c(2,2))

PlotPredationMatrix(TL84,
    main=paste0('Original, C=', sprintf('%.4f', DirectedConnectance(TL84))))
Artificial(TL84, generator=RandomLinks, main='Random')
Artificial(TL84, generator=CascadeModelLinks, main='Cacade')
Artificial(TL84, generator=NicheModelLinks, main='Niche')

Example artificial communities

The NicheModelLinks function has some more flexibility. First, we can specify species' positions on the niche axis, which takes values between 0 and 1. Second, it can generate links using the probabilistic niche model, which allows gaps in consumers' diets - seen in the bottom two plots.

par(mfrow=c(2,2))
PlotPredationMatrix(TL84, main=paste0('Original, C=',
    sprintf('%.4f', DirectedConnectance(TL84))))

niche.positions <- order(NP(TL84, 'M'))/NumberOfNodes(TL84)
Artificial(TL84, generator=NicheModelLinks,
    main='Niche,\ncentres are order of M',
    niche.positions=niche.positions)

Artificial(TL84, generator=NicheModelLinks,
    main='Probabilistic niche,\ncentres are order of M',
    niche.positions=niche.positions, probabilistic=TRUE)

# The allometric niche model is the probabilistic niche model with niche
# positions computed from log-transformed body masses scaled to be between 0
# and 1 (Williams et al 2010 PLoS ONE)
logM <- Log10M(TL84)
niche.positions <- (logM-min(logM)) / diff(range(logM))
Artificial(TL84, generator=NicheModelLinks,
    main='Probabilistic niche,\ncentres are normalised log M',
    niche.positions=niche.positions, probabilistic=TRUE)

Example artificial communities

basingstoke's People

Contributors

quicklizard99 avatar

Stargazers

Shai Pilosof avatar Jon Borrelli avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.