Giter Site home page Giter Site logo

project-gen3sis / r-package Goto Github PK

View Code? Open in Web Editor NEW
28.0 6.0 9.0 59.8 MB

Repository of the R-packageGen3sis

Home Page: https://project-gen3sis.github.io/R-package/

License: GNU General Public License v3.0

R 92.30% C++ 7.70%
model evolution modeling r-package r ecology biodiversity mechanistic simulation

r-package's People

Contributors

benj919 avatar cakloecker avatar cndesantana avatar ffopp avatar florianhartig avatar julianoscabral avatar loic-pellissier avatar mmore500 avatar ohagen avatar richelbilderbeek avatar yihui avatar zhg2017 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

r-package's Issues

South America distances missing

Impossible to follow the tutorial, since distances matrices are currently not provided with the package. Either provide a line in the vignette to compile these distances or use another landscape as example at the vignette

multiple richenss plot with tag -1 when simulation starts with multiple species

Reproduce issue:
datapath <- system.file(file.path("extdata", "SouthAmerica"), package="gen3sis")
config_object_old <- create_input_config(file.path(datapath, "config/config_southamerica.R"))
sim_old <- run_simulation(config = config_object_old,
landscape = file.path(datapath, "landscape"),
verbose=0, # no progress printed
output_directory=tempdir())

precompute partial distance matrices

Currently the distance matrices can only be left out or computed fully during the input creation.

We may want to offer calculating partial/full distance matrices from existing inputs.

add to imports

  • checking R code for possible problems ... NOTE
    conditional_plot : : no visible global function definition
    for 'is'
    conditional_plot: no visible global function definition for 'png'
    Undefined global functions or variables:
    is png
    Consider adding
    importFrom("grDevices", "png")
    importFrom("methods", "is")
    to your NAMESPACE file (and ensure that your DESCRIPTION Imports field
    contains 'methods').

CRAN Fixes gen3sis 1.4

##1
If there are references describing the methods in your package, please add these in the description field of your DESCRIPTION file in the form authors (year) doi:... authors (year) arXiv:... authors (year, ISBN:...) or if those are not available: https:... with no space after 'doi:', 'arXiv:', 'https:' and angle brackets for auto-linking.
(If you want to add a title as well please put it in quotes: "Title")

##2
Please add \value to .Rd files regarding exported methods and explain the functions results in the documentation. Please write about the structure of the output (class) and also what the output means. (If a function does not return a value, please document that too, e.g.
\value{No return value, called for side effects} or similar) Missing Rd-tags in up to 18 .Rd files, e.g.:
evolution_mode_none.Rd: \value
plot_landscape_overview.Rd: \value
plot_landscape.Rd: \value
plot_ranges.Rd: \value
plot_raster_multiple.Rd: \value
plot_raster_single.Rd: \value
...

##3
Please always make sure to reset to user's options(), working directory or par() after you changed it in examples and vignettes and demos.
e.g.: inst/doc/introduction.R
oldpar <- par(mfrow = c(1,2))
...
par(oldpar)

Please do not modify the .GlobalEnv. This is not allowed by the CRAN policies. e.g.: .Random.seed

##4
Additionally:
Have the issues why your package was archived been fixed?
Please explain this in the submission comments.

landscapes argument of the create_input()

So, I tried to use for the function's argument the list of data frames that I used to produce the rds file before. Then I get this error "unkown landscapes; it has to be a named list of list of either rasters or raster files..."
This means I need to transform my data frames into rasters instead of directly providing a list of data frames that can be directly saved into rds. That seems a bit counterproductive. It would be nice if the function would recognize that the list of landscapes is already in the format necessary to write a .rds.
Meanwhile I have to check how to transform my arrays into raster stacks then so the function can use them.

calling of plots from observer not working

If you add the following lines to the observer function:

plot_richness(species, landscape)
plot_landscape(landscape)
plot_species_presence(species[[1]], landscape)"

run

run_simulation(config = "./inst/extdata/WorldCenter/config/config_worldcenter.R", 
+                     landscape = "./inst/extdata/WorldCenter/landscape",
+                     call_observer = "all", output_directory = "YOURTEMPDIRHERE")

breaks with error:

[1] "config found: ./inst/extdata/WorldCenter/config/config_worldcenter.R"
[1] "landscape found: ./inst/extdata/WorldCenter/landscape"
[1] "output directory is: C:/temp/config_worldcenter"
Error in rownames(landscape[["coordinates"]]) : 
  object 'landscape' not found

implement CI

previously relying on Travis, now we need another solution. Specially if we want to improve collaboration

Vignettes cleanup

Hi Oskar,

I just looked at the vignettes because of the CRAN check problems - if you want to push this on CRAN soon, I would clean up the vignettes before. If you have the money, this could also be a work that a student helper with good english could do.

Build error due to create_input.Rmd

Hi Juliano, this file currently doesn't run, probably due to #24

No problem, but now that we have the CI running, to be able to check the model, it would be better move this file into a new branch, so that we have the master branch clean / can check if everything works fine.

I can do it for you, I just didn't want to do it in case you are currently working on it.

axis label for time series in summary plot is wrong

the indexing for the timestep labels on the x-axis is wrong.

line 132-134

  axis_lab <- seq(from=1, to=nrow(d), length.out = max((nrow(d)/20),2))
  axis(1, at=rev(as.numeric(rownames(d)))[axis_lab], labels = rownames(d)[axis_lab])
  mtext(side=1, text="Time steps", line=2.5, cex=1.1)

the "at" uses the row number 0 as starting index. indexing is positional and starts at 1. hence all axis labels are shifted by one to the left

distance matrix test fails now

I suspect that this could have something with the new change of the distances in Km to m (1/1000)
When checking -as --cran on R.4.0:

*** checking for unstated dependencies in 'tests' ... OK
* checking tests ...
** running tests for arch 'i386' ...
  Running 'testthat.R'
 ERROR
Running the tests in 'tests/testthat.R' failed.
Last 13 lines of output:
  > 
  > test_check("gen3sis")
  -- 1. Failure: distance matrix creation works (@test-distances.R#26)  ---------------------------------------------------------------------------------------
  isTRUE(all.equal(unname(dist_m), gdist_m)) isn't true.
  
  -- 2. Failure: get_local_distances works (@test-input_creation.R#134)  --------------------------------------------------------------------------------------
  isTRUE(all.equal(unname(distance_local), local_tr)) isn't true.
  
  == testthat results  ========================================================================================================================================
  [ OK: 26 | SKIPPED: 10 | WARNINGS: 0 | FAILED: 2 ]
  1. Failure: distance matrix creation works (@test-distances.R#26) 
  2. Failure: get_local_distances works (@test-input_creation.R#134) 
  
  Error: testthat unit tests failed
  Execution halted
** running tests for arch 'x64' ...
  Running 'testthat.R'
 ERROR
Running the tests in 'tests/testthat.R' failed.
Last 13 lines of output:
  > 
  > test_check("gen3sis")
  -- 1. Failure: distance matrix creation works (@test-distances.R#26)  ---------------------------------------------------------------------------------------
  isTRUE(all.equal(unname(dist_m), gdist_m)) isn't true.
  
  -- 2. Failure: get_local_distances works (@test-input_creation.R#134)  --------------------------------------------------------------------------------------
  isTRUE(all.equal(unname(distance_local), local_tr)) isn't true.
  
  == testthat results  ========================================================================================================================================
  [ OK: 26 | SKIPPED: 10 | WARNINGS: 0 | FAILED: 2 ]
  1. Failure: distance matrix creation works (@test-distances.R#26) 
  2. Failure: get_local_distances works (@test-input_creation.R#134) 
  
  Error: testthat unit tests failed
  Execution halted**

plot_landscape function crash

returning:

Error in matrix(no_data, nrow = nrow(landscape[["coordinates"]]), ncol = ncol(values) +  : 
  non-numeric matrix extent
Called from: matrix(no_data, nrow = nrow(landscape[["coordinates"]]), 
    ncol = ncol(values) + 2, dimnames = list(rownames(landscape[["coordinates"]]), 
        c(colnames(landscape[["coordinates"]]), colnames(values))))
Error during wrapup: unimplemented type (29) in 'eval'

Error: no more error handlers available (recursive errors?); invoking 'abort' restart
Error during wrapup: INTEGER() can only be applied to a 'integer', not a 'unknown type #29'
Error: no more error handlers available (recursive errors?); invoking 'abort' restart

Once landscape input is only for a certain environment (e.g. landscape$temp) it returns:

plot_landscape(l$temp)
Error in matrix(no_data, nrow = nrow(landscape[["coordinates"]]), ncol = ncol(values) +  : 
  non-numeric matrix extent
Called from: matrix(no_data, nrow = nrow(landscape[["coordinates"]]), 
    ncol = ncol(values) + 2, dimnames = list(rownames(landscape[["coordinates"]]), 
        c(colnames(landscape[["coordinates"]]), colnames(values))))
Error during wrapup: unimplemented type (29) in 'eval'

Error: no more error handlers available (recursive errors?); invoking 'abort' restart
Error during wrapup: INTEGER() can only be applied to a 'integer', not a 'unknown type #29'
Error: no more error handlers available (recursive errors?); invoking 'abort' restart

changing landscape[["environment"]] does not help.

plot_richness

plot_richness causes gen3sis to crash when called in the observer function when all species have gone extinct.

plot_richness(species, landscape)
Error in (mult * length(col)):1 : NA/NaN argument
In addition: Warning message:
In x[] <- col[x] :
number of items to replace is not a multiple of replacement length

The problem is there is no color in the richness palette for values of 0

max(richness)
[1] 0
color_richness(max(richness, na.rm=TRUE))
[1] character(0)
color_richness(1)
[1] "#440154"

This problem also means colours on a richness plot cannot distinguish between cells with 1 species and cells with 2 species.

Habitability mask during Input creation

Currently the habitability mask in the input creation overrides the habitable cells in the landscape rasters. This is going to be inconsistent with NA-cells in the input rasters as these are used to determine habitable cells during the simulation run.

I think a better/more intuitive way would be to use the habitability mask in addition to the landscapes, as such that for example it allows to limit the world to a smaller extract.

versions history

releases summary files. maybe just a a single file e.g. releases_history.txt? any other idea?

Missing help file

Warning: [/Users/florian/Dropbox/Home/Projekte/Papers_in_Review/19-rGAsm-package/R-package/R/observations.R:146] @example '/Users/florian/Dropbox/Home/Projekte/Papers_in_Review/19-rGAsm-package/R-package/inst/examples/observer_plot_help.R' doesn't exist

-> should I add the file?

build package NOTE

Returning this NOTE when checked on CRAN:

  • checking LazyData ... NOTE 'LazyData' is specified without a 'data' directory

Relates to the update on Fri, 23 Apr 2021:
https://developer.r-project.org/blosxom.cgi/R-devel/NEWS/2021/04/23#n2021-04-23

CRAN Build feedback:
package gen3sis_1.3.tar.gz does not pass the incoming checks automatically, please see the following pre-tests:
Windows: https://win-builder.r-project.org/incoming_pretest/gen3sis_1.3_20210630_120636/Windows/00check.log
Status: 1 NOTE
Debian: https://win-builder.r-project.org/incoming_pretest/gen3sis_1.3_20210630_120636/Debian/00check.log
Status: 1 NOTE

Related issue forum:
https://stackoverflow.com/questions/66860659/lazydata-is-specified-without-a-data-directory-error-when-submitting-r-packa

create_input scaling bug/problem

create_input scales from meters to kilometers by multiplying a factor of 1/1000. This only works if a coordinate system is set for the input rasters.

line ~159 in Input_creation.R:
correction@transitionMatrix@x <- (1/1000) / correction@transitionMatrix@x

Should we remove that and tell the user the cost/distances are in meters, if they want kilometers they have to scale their cost function by 1/1000?

plot_summary fails if simulation ends before reaching step 0

make_summary hardcodes richness_final to
sgen3sis$summary <- c(data$summaries, list("richness-final"=data$geo_richness[,c(1,2,ncol(data$geo_richness))]))

This will be all NAs if the simulation aborts (too many species) or if end_time is not 0.
Subsequently this:

  ras <- rasterFromXYZ(output$summary$`richness-final`)
  rc <- color_richness(max(ras@data@values, na.rm=TRUE) + 1)

will call max() with an all NA vector which will return -Inf. Of course a colorRampPalette can't produce -Inf many colours and it fails.

path magic feature and bug

Currently there is quite some magic going on trying to divine the config, input, and output paths from partial info when running a simulation. Currently it is a bit inconsistent and intransparent on what is going on. Should we remove all/most of it and instead expect all three to be provided when calling a simulation?

The only part I'd keep is creating a subfolder with the config name in the output path.

(config_handling.R, prepare_directories, lines 16-81)

Automatic tests / continuous integration

Hi guys,

just as we talked about the tests - you haven't set up CI tests yet, right? There are at least two options, Travis CI, which I do for DHARMa, and there is a new option directly via GitHub workflows, see an example here https://github.com/TheoreticalEcology/s-jSDM/actions

The advantage of using the workflows is that a) I think it can also be done on a private repo b) it also tests Windows and MacOS. Advantage of TravisCI is that it looks nicer (in my opinion), especially when you work a lot with branches.

Anyway, we should decide for one or the other, this will help a lot with the tests and questions such as #6

misplaced loop_ecology() call

loop_ecology() is currently called in line 270 in gen3sis_main.R script. As the observer is invoked before, observer output does not reflect ecology processes of this time step.

val <- loop_ecology(val$config, val$data, val$vars)

Documentation and comments in the code suggest that it should be called after the evolution step and prior to the end of loop updates in line 232.

R-package/R/gen3sis_main.R

Lines 226 to 232 in d7a65d8

# #--------------------------------------------------------#
# ######## loop ecology #######
# #--------------------------------------------------------#
if(verbose>=2){
cat("ecology \n")
}

vignette problems in CRAN Should be corrected by 2021-10-19 to safely retain gen3sis on CRAN.

Please see the problems shown on
https://cran.r-project.org/web/checks/check_results_gen3sis.html.

The vignette problems are from vignettes that contain unbalanced code chunk delimiters (e.g., a chunk opened by five backticks but closed by four, or opened by three but closed by four, etc.).

See yihui/knitr#2057 for more information.

Please correct before 2021-10-19 to safely retain your package on CRAN.

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.