GithubHelp home page GithubHelp logo

theoreticalecology / ecophylosim Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 17.71 MB

R package for simulation of biogeographical and phylogenetic data

Home Page: http://theoreticalecology.github.io/EcoPhyloSim/

R 9.95% C++ 35.03% HTML 54.82% TeX 0.13% C 0.07%

ecophylosim's Introduction

EcoPhyloSim

A model, provided as an R package, for the simulation of spatially explicit biogeographical and phylogenetic data.

Installation

You can install directly from gh, using the 'devtools' package:

devtools::install_github(repo = "TheoreticalEcology/EcoPhyloSim/", 
                         subdir = "phylosim",  
                         dependencies = T, 
                         build_vignettes = T)

?PhyloSim
browseVignettes("PhyloSim")

Example

library(PhyloSim)

# Define a parameter set
par <- createCompletePar(x = 50, y = 50, dispersal = 1 , runs = 1000,
        density = 0)

# Run the model
simu <- runSimulation(par)
## [1] "Core simulation finished after 0 minute(s) and 1.71 second(s). Converting data"
## done!
plot(simu)

#Look at the species area relation
sac(simu, rep = 100, plot= TRUE)

##    size sr.Mean sr.UpperCI sr.LowerCI
## 1     4    1.38       2.00       1.00
## 2    49    1.95       3.00       1.00
## 3   144    2.75       4.05       1.95
## 4   324    3.35       5.00       2.00
## 5   529    4.06       6.00       3.00
## 6   784    4.58       6.00       3.00
## 7  1156    5.49       7.00       4.00
## 8  1521    5.92       7.00       4.00
## 9  1936    6.45       7.00       5.00
## 10 2500    7.00       7.00       7.00

ecophylosim's People

Contributors

betim1988 avatar christianbuschbeck avatar d-maar avatar florianhartig avatar paul-bauche avatar stefan-paul avatar tankredo avatar

Watchers

 avatar

ecophylosim's Issues

rPackage Examples

Examples for all functions in the package. Requires example dataset.

Installation with devtools not working properly

The automatic installation of the package with devtools leads to an error in the runSimulation-function.
R cannot find the callModel-function which is used by runSimulation. Tried it on Win7 with R 3.2.1 and 3.2.2.

Add tests for the package functions

Wenn die checks erst mal laufen wäre noch eine super Sache für Schlüsselfunktionen ein paar Test zu haben. Siehe

http://r-pkgs.had.co.nz/tests.html
http://kbroman.org/pkg_primer/pages/tests.html

Du könntest ja mal einen Test zum Versuch machen, und wenn du neue Sachen implementierst könntest du auch direkt einen Test machen der dir sinnvoll erscheint.

Ansonsten würde ich hier später noch mal eine Liste machen mit Sachen die bei check getestet werden sollen

Doc for neutral model

Although it's an internal function, it would be good to have a minimal roxygen documentation for the neutral model function.

Vignette optimieren

und die bilder

Inkl am Ende als appendix einer Beschreibung wie man das package mit Rstudio kompiliert

Package doesn't compile with R 3.2.x

At least on the server ... seems like there is some Rcpp problem, but I didn't manage to fix it so I went back to R 3.1 where everything went fine.

plotTraitDistribution

the plot is not nice.

different colors for the landscape - maybe use the image.plot function, or change colors in image to black/white?

Can you try to plot the histograms in different colors

  • first get min / max of traits
  • then create empty histogram
  • then add trait hist for each species with add = T, and col = '#rrggbbtt" where tt is the transparancy. If you want to have the same color scheme as above, you can get the rgb values from the colors above, and use string replacement to make them semi-transparent

not existing functions in the code

in the phylogeneticDispersion.R - file are two functions that neither exist within the package nor did i find them online in any other package:

emptyplot (line 109)
filledrectangle (line 128)

anybody any idea what to do with them ?

compilation error / VLA problem

Zumindest mein Compiler scheint ein Problem zu haben dieses Array aus Pairs zu initialisieren.

In vector umwandeln, oder gibt es da einen Trick? War das bei euch kein Problem?

GridMod.cpp:252:34: error: variable length array of non-POD element type 'std::pair<int, int>'
std::pair<int, int> parents[m_KernelSize];
^
GridMod.cpp:471:34: error: variable length array of non-POD element type 'std::pair<int, int>'
std::pair<int, int> parents[m_KernelSize];

Package installation fails

I got the following error when trying to install

Downloading github repo biometry/phylosim@master
Installing PhylGeo
Installing dependencies for PhylGeo:
kulife, doParallel, XML
trying URL 'http://ftp5.gwdg.de/pub/misc/cran/bin/macosx/mavericks/contrib/3.1/kulife_0.1-14.tgz'
Content type 'application/x-gzip' length 2149440 bytes (2.0 Mb)

opened URL

downloaded 2.0 Mb

trying URL 'http://ftp5.gwdg.de/pub/misc/cran/bin/macosx/mavericks/contrib/3.1/doParallel_1.0.8.tgz'
Content type 'application/x-gzip' length 180277 bytes (176 Kb)

opened URL

downloaded 176 Kb

trying URL 'http://ftp5.gwdg.de/pub/misc/cran/bin/macosx/mavericks/contrib/3.1/XML_3.98-1.2.tgz'
Content type 'application/x-gzip' length 1890981 bytes (1.8 Mb)

opened URL

downloaded 1.8 Mb

tar: Failed to set default locale
tar: Failed to set default locale
tar: Failed to set default locale

The downloaded binary packages are in
/var/folders/0b/z4_cv_xx26bgzwvyyr1tgsyc0000gp/T//Rtmp16YfyZ/downloaded_packages
'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD INSTALL
'/private/var/folders/0b/z4_cv_xx26bgzwvyyr1tgsyc0000gp/T/Rtmp16YfyZ/devtools182c644f4750a/biometry-phylosim-160c5c12c5df0c9449b14924635d1367ac3c4bf4/PhylGeo'
--library='/Library/Frameworks/R.framework/Versions/3.1/Resources/library'
--install-tests

During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_TIME failed, using "C"
3: Setting LC_MESSAGES failed, using "C"
4: Setting LC_MONETARY failed, using "C"

  • installing source package 'PhylGeo' ...
    ** libs
    clang++ -arch x86_64 -ftemplate-depth-256 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o PhylGeo.so RcppExports.o rcpp_Model.o rcpp_hello_world.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
    ld: warning: ld: warning: ignoring file RcppExports.o, file was built for unsupported file format ( 0x64 0x86 0x7A 0x00 0x00 0x00 0x00 0x00 0x32 0x6C 0x00 0x00 0x91 0x01 0x00 0x00 ) which is not the architecture being linked (x86_64): RcppExports.oignoring file rcpp_Model.o, file was built for unsupported file format ( 0x64 0x86 0x68 0x00 0x00 0x00 0x00 0x00 0xDA 0x62 0x00 0x00 0x59 0x01 0x00 0x00 ) which is not the architecture being linked (x86_64): rcpp_Model.o

ld: warning: ignoring file rcpp_hello_world.o, file was built for unsupported file format ( 0x64 0x86 0x4E 0x00 0x00 0x00 0x00 0x00 0xDC 0x37 0x00 0x00 0x01 0x01 0x00 0x00 ) which is not the architecture being linked (x86_64): rcpp_hello_world.o
installing to /Library/Frameworks/R.framework/Versions/3.1/Resources/library/PhylGeo/libs
** R
** data
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_TIME failed, using "C"
3: Setting LC_MESSAGES failed, using "C"
4: Setting LC_MONETARY failed, using "C"
Error in library.dynam(lib, package, package.lib) :
shared object 'thesis.so' not found
Error: loading failed
Execution halted
ERROR: loading failed

  • removing '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/PhylGeo'
    Error: Command failed (1)

Add simulation output in data folder to be used for examples

Create one or several representative simulation outputs and store the simu objects in the data folder so that we can use them for the examples of, e.g. the plotting functions.

I'm thinking of maybe three datasets with 100x100 grid size, run for 10000 yrs, for

  • Neutral, global
  • Neutral, local dispersal
  • Competition and Environment, local dispersal

Read up on how to create data for a package here http://r-pkgs.had.co.nz/data.html

Save the script for for how to create this data, we maybe need to recreate it if we change something in the package.

Implement output of multiple time steps

I have already a parameter for this in the model call in R, but there is no function behind that yet.

The idea would be that the user specifies a vector with time steps, which is passed on to C.

In the C function, we do everything we did before, just that we collect the output for each time step that is specified in the time step variable.

The return to R should be a list, with each list element being the output that we currently do.

See also ticket with classes - at some point it would be good to introduce classes for this!

Flowcharts für das Package

Christian, kannst du mal versuchen diese Übersicht die ich gezeichnet hatte für die Package funktionen und Klassen in Inkscape oder einem anderen Programm das pdf erzeugen kann abzuzeichnen und Stefan zu geben damit er die in die Vignette einfügen kann?

Vignette

Ich kann die Vignette immer noch nicht kompilieren, gerade bekomme ich den Fehler

Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Vignette_new.tex' failed.
LaTeX errors:
1750267b/PhylGeo/vignettes/Vignette_new.tex:126: LaTeX Error: File `flowchart'
not found.

See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
1750267b/PhylGeo/vignettes/Vignette_new.tex:273: LaTeX Error: File `flowchart_p
lots' not found.

See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
Calls: -> texi2pdf -> texi2dvi
Execution halted
Error: Command failed (1)
Execution halted

Exited with status 1.

sac

x axis need to be corrected to incorporate potential rounding

Obsolete fields in individual.cpp?

in individual.cpp

// THESE SEEM OBSOLTE ???
this ->m_FitnessWeight = 0.5;
this ->m_DensityStrength = 0.4;
this ->m_Weight = 1.0;
// END OBSOLETE

Model crashes

OK, mit den Änderungen läuft es zwar jetzt, aber irgendwie crasht es mir jedesmal wenn ich versuche irgendwas sinnvolles einzustellen, e.g.

myModel <- fullMod(x = 50, y = 50, dispersal = 2, runs = 500, specRate = 1.0, density = FALSE, environment = FALSE, neutral = TRUE, seed = 1500)

Error with model run if compiled on server

Now if I compile the package on our server, and try to run the model (any version), I get

Error: not compatible with STRSXP
3 stop(structure(list(message = "not compatible with STRSXP", call = NULL,
cppstack = NULL), .Names = c("message", "call", "cppstack"
), class = c("Rcpp::not_compatible", "C++Error", "error", "condition"
)))
2 callModel(x, y, dispersal, runs, specRate, density, environment,
neutral, mortalityFitness, fitnessBaseMortalityRatio, reproductiveFitness,
dispersalCut, densityCut, seed) at modelSingle.R#86
1 fullMod(x = 50, y = 50, dispersal = 1, runs = 200, specRate = 1,
density = F, environment = F, seed = 1, fitnessBaseMortalityRatio = 10)

On my mac the same version works fine (apparently)

Add examples in the roxygen description of all plotting functions

except for the null models

examples need to be able to run stand-alone.

Because examples will be run for testing, we should not include the simulation in the example. That's why I created this ticket #31 for creating adding some simulation outputs as data in the package, so that you can make an example as in

plot(simulationResultNull, ...)

where simulationResultNull is one of the datasets include in the data folder

See http://r-pkgs.had.co.nz/man.html#man-workflow for how to include data in a package

Make sure the package checks out

Before we go on with details / add stuff, let's make sure the package checks work. Currently, I get an error from the vignette if I click on the check button in Rstudio

The check runs through all sorts of things, typically building package, vignette, help files, and running all code from the help see

http://kbroman.org/pkg_primer/pages/check.html
https://support.rstudio.com/hc/en-us/articles/200486508-Building-Testing-and-Distributing-Packages

This goes to both of you - please check this option and make sure we have no errors any more - if you get errors in code for which the other is responsible, either write a ticket or notify the other that you are making the change, otherwise we may run into a lot of conflicts

Package Name

We need a good package name

PhyloSim
PhyloGeoSim
PhyloGeo

Irgendwelche Ideen? Ich tendiere gerade zu Phylosim

Main package help file

Create / modify the package help file.

It should be named "packageName"-package.Rd , but it's not quite clear to me what's the best way to create / modify it.

Read

and google a bit more to see if you discover a good workflow - if not, better do nothing and ask me again

F

Create class for data in the package

We should have a central class that takes all model outputs, parameters and model calls and that is recognized by all functions. Structure should be something like

$ Model
/ parameters
/ model
/ runs
/ runtime
$ Output
/ matrix
/ phylogenye

Test Null Models

Ich habe hier https://www.dropbox.com/sh/9phdoheyn62abw2/AACqvy-VyF1kOA5LKzjcbwR5a?dl=0

Resultate von Modellläufen kreiert mit /PhylGeo/examples/PhylogeneticDispersionConfigurations/run100x100.r

(die Unterschiede ergeben sich aus verschieden Versionen des C codes), sollte eigentlich egal sein welches File du nimmst

In /PhylGeo/examples/PhylogeneticDispersionConfigurations sind die Auswertungen die wir machen wollen.

Kannst du erst mal schauen dass alles noch so läuft wir vorher, vor allem das Null Modell.

Schau auch noch mal nach dieser Funktion die die lokalen Plots auswählt

  • Ist die gut dokumentiert?
  • Macht die was sie soll?
  • Um letzeres zu schauen wäre es vielleicht gar nicht schlecht wenn man eine kleine Plot funktion erstellen würde die lokalen Plots graphisch darstellt --> auf der specMatrix

reconstructPhylogeny.R

Muss noch aufgeraeumt / getestet / gebeispielt werden

Die Funktion macht was ich meinte - den neutralen Trait zu benutzen und daraus eine neue Phylogeny zu erzeugen.

Wenn du ein Beispiel machst könntest du mal die erzeugte Phylogeny gegen die echte plotten, wäre auch was für die Vignentte wenn du den neutralen Trait erklärst

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.