Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.6 #21

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: onpoint
Title: Helper Functions for Point Pattern Analysis
Version: 1.0.5
Version: 1.0.6
Authors@R:
person("Maximilian H.K.", "Hesselbarth",
email = "[email protected]",
Expand Down Expand Up @@ -29,5 +29,5 @@ Suggests:
spatstat (>= 2.0.0),
testthat (>= 3.0.0)
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Config/testthat/edition: 3
113 changes: 58 additions & 55 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,58 @@
# onpoint 1.0.5
* Streamlined documentation
* Updated testthat v3
* Updated ggplot2 linewidth internally
* `verbose` does not affect warnings

# onpoint 1.0.4
* Update some plotting functions

# onpoint 1.0.3
* Small updates to internal code structure
* Fix DESCRIPTION
* Update CI actions
* Update `spatstat` dependency

# onpoint 1.0.2
* Adapt new `spatstat` package structure

# onpoint 1.0.1
* Improve documentation for CRAN submission
* Renamed `summarise_envelope` to `summarize_envelope`

# onpoint 1.0
* Use GPL3 license
* Adapt to new `spatstat` structure
* Prepare CRAN submission

# onpoint 0.6.1
* Use GitHub actions

# onpoint 0.6
* `plot_quantums()` uses `geom_linerange()`

# onpoint 0.5
* add `rlabel_local()` function

# onpoint 0.4
* Printing method for result of `summarise_envelope()`
* Plotting method for result of `summarise_envelope()`

# onpoint 0.3
* New function `summarise_envelope()`

# onpoint 0.2.1
* Better size arguments for lines and base_size for `plot_quantums()`
* Generic labels for `plot_quantums()`
* Use fix_n argument in `simulate_heterogenous_patter()`

# onpoint 0.2.0
* Added `simulate_antecedent_conditions`.
* Added `estimate_pcf_fast`

# onpoint 0.1.0
* Initialised package
* Added a `NEWS.md` file to track changes to the package.
# onpoint 1.0.6
* Order of stable `i` and randomized pattern `j` changed in `simulate_antecedent_conditions`

# onpoint 1.0.5
* Streamlined documentation
* Updated testthat v3
* Updated ggplot2 linewidth internally
* `verbose` does not affect warnings

# onpoint 1.0.4
* Update some plotting functions

# onpoint 1.0.3
* Small updates to internal code structure
* Fix DESCRIPTION
* Update CI actions
* Update `spatstat` dependency

# onpoint 1.0.2
* Adapt new `spatstat` package structure

# onpoint 1.0.1
* Improve documentation for CRAN submission
* Renamed `summarise_envelope` to `summarize_envelope`

# onpoint 1.0
* Use GPL3 license
* Adapt to new `spatstat` structure
* Prepare CRAN submission

# onpoint 0.6.1
* Use GitHub actions

# onpoint 0.6
* `plot_quantums()` uses `geom_linerange()`

# onpoint 0.5
* add `rlabel_local()` function

# onpoint 0.4
* Printing method for result of `summarise_envelope()`
* Plotting method for result of `summarise_envelope()`

# onpoint 0.3
* New function `summarise_envelope()`

# onpoint 0.2.1
* Better size arguments for lines and base_size for `plot_quantums()`
* Generic labels for `plot_quantums()`
* Use fix_n argument in `simulate_heterogenous_patter()`

# onpoint 0.2.0
* Added `simulate_antecedent_conditions`.
* Added `estimate_pcf_fast`

# onpoint 0.1.0
* Initialised package
* Added a `NEWS.md` file to track changes to the package.
50 changes: 21 additions & 29 deletions R/simulate_antecedent_conditions.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
#' @description Simulate heterogenous pattern
#'
#' @param x ppp
#' @param i Mark of points that are randomized.
#' @param j Mark of points that do not change.
#' @param i Mark of points that are not not changed.
#' @param j Mark of points that are randomized.
#' @param nsim Number of patterns to simulate.
#' @param heterogenous If TRUE, points with the mark i are randomized using a heterogeneous
#' @param heterogenous If TRUE, points with the mark j are randomized using a heterogeneous
#' Poisson process.
#' @param ... Arguments passed to \code{spatstat.explore::density.ppp()}.
#'
#' @details
#' Simulate point patterns as null model data for \code{spatstat.explore::envelope()} using
#' antecedent conditions as null model. \code{x} must be marked point pattern.
#' Antecedent conditions are suitable as a null model if points of type j may influence
#' points of type i, but not the other way around (Velazquez et al 2016). One example are
#' the positions of seedlings that may be influenced by the position of mature trees.
#' antecedent conditions as null model. \code{x} must be a marked point pattern with
#' two types of marks. Antecedent conditions are suitable as a null model if points
#' of type i may influence points of type j, but not the other way around (Velazquez et al 2016).
#' One example are the positions of seedlings that may be influenced by the position
#' of mature trees.
#'
#' Returns a \code{list} with \code{ppp} objects.
#'
Expand All @@ -32,7 +33,7 @@
#' spatstat.geom::marks(pattern_b) <- "b"
#' pattern <- spatstat.geom::superimpose(pattern_a, pattern_b)
#'
#' null_model <- simulate_antecedent_conditions(x = pattern, i = "b", j = "a", nsim = 19)
#' null_model <- simulate_antecedent_conditions(x = pattern, i = "a", j = "b", nsim = 19)
#' spatstat.explore::envelope(Y = pattern, fun = spatstat.explore::pcf,
#' nsim = 19, simulate = null_model)
#'
Expand Down Expand Up @@ -62,41 +63,32 @@ simulate_antecedent_conditions <- function(x, i, j, nsim, heterogenous = FALSE,
stop("i and j must be marks of x.", call. = FALSE)
}

# only points with mark j
pattern_j <- spatstat.geom::subset.ppp(x, marks == j, drop = TRUE)

# only points with mark i
# only points with mark i to keep stable
pattern_i <- spatstat.geom::subset.ppp(x, marks == i, drop = TRUE)

if (heterogenous) {
# only points with mark j to randomze
pattern_j <- spatstat.geom::subset.ppp(x, marks == j, drop = TRUE)

lambda_xy <- spatstat.explore::density.ppp(pattern_i, ...)
if (heterogenous) {
lambda_j <- spatstat.explore::density.ppp(pattern_j, ...)
}

# create nsim patterns
result <- lapply(seq_len(length.out = nsim), function(current_nsim) {

# use heterogeneous Poisson
if (!heterogenous) {

# random pattern i
random_i <- spatstat.random::rpoint(n = pattern_i$n,
win = pattern_i$window)
}

else {

# random pattern i
random_i <- spatstat.random::rpoint(n = pattern_i$n,
f = lambda_xy,
win = x$window)
random_j <- spatstat.random::rpoint(n = pattern_j$n, win = pattern_j$window)
# use homogenous Poisson
} else {
random_j <- spatstat.random::rpoint(n = pattern_j$n, f = lambda_j, win = x$window)
}

# assign same marks again
spatstat.geom::marks(random_i) <- spatstat.geom::marks(pattern_i)
spatstat.geom::marks(random_j) <- spatstat.geom::marks(pattern_j)

# combine random i with original j
pattern_combined <- spatstat.geom::superimpose(j = pattern_j,
i = random_i,
pattern_combined <- spatstat.geom::superimpose(i = pattern_i, j = random_j,
W = pattern_j$window)

# select only original marks
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ README Last updated: `r Sys.Date()`
[![Project Status](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
[![CRAN status](https://www.r-pkg.org/badges/version/onpoint)](https://CRAN.R-project.org/package=onpoint)
[![CRAN logs](http://cranlogs.r-pkg.org/badges/grand-total/onpoint)](http://cran.rstudio.com/web/packages/onpoint/index.html)
[![CRAN logs](https://cranlogs.r-pkg.org/badges/grand-total/onpoint)](http://cran.rstudio.com/web/packages/onpoint/index.html)
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

<!-- badges: end -->
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<!-- badges: start -->

README Last updated: 2023-03-08
README Last updated: 2024-07-29

[![R-CMD-check](https://github.com/r-spatialecology/onpoint/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-spatialecology/onpoint/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/r-spatialecology/onpoint/branch/main/graph/badge.svg?token=RkgCfHnPyf)](https://codecov.io/gh/r-spatialecology/onpoint)
Expand All @@ -15,7 +15,7 @@ Status](https://www.repostatus.org/badges/latest/active.svg)](https://www.repost
[![CRAN
status](https://www.r-pkg.org/badges/version/onpoint)](https://CRAN.R-project.org/package=onpoint)
[![CRAN
logs](http://cranlogs.r-pkg.org/badges/grand-total/onpoint)](http://cran.rstudio.com/web/packages/onpoint/index.html)
logs](https://cranlogs.r-pkg.org/badges/grand-total/onpoint)](http://cran.rstudio.com/web/packages/onpoint/index.html)
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

<!-- badges: end -->
Expand Down
75 changes: 39 additions & 36 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
# onpoint 1.0.5
* Minor cosmetic updates

# onpoint 1.0.4
* Some small function updates

# onpoint 1.0.3
* Small DESCRIPTION fixes

# onpoint 1.0.2
* Adapt new `spatstat` package structure

# onpoint 1.0.1
Please add some more details about the package functionality and implemented methods in your Description text.

* Done as suggested

Please add \value to .Rd files regarding exported methods and explain the functions results in the documentation. [...]

* Done as suggested

# onpoint 1.0
* First submission to CRAN

## Test environments
* local R installation, R 4.1.1
* GitHub Actions
* {os: windows-latest, r: 'release'}
* {os: macOS-latest, r: 'release'}
* {os: ubuntu-20.04, r: 'release'}

## R CMD check results

0 errors ✓ | 0 warnings ✓ | 0 notes ✓

* This is a new release.
# onpoint 1.0.6
* Minor methodological improvements

# onpoint 1.0.5
* Minor cosmetic updates

# onpoint 1.0.4
* Some small function updates

# onpoint 1.0.3
* Small DESCRIPTION fixes

# onpoint 1.0.2
* Adapt new `spatstat` package structure

# onpoint 1.0.1
Please add some more details about the package functionality and implemented methods in your Description text.

* Done as suggested

Please add \value to .Rd files regarding exported methods and explain the functions results in the documentation. [...]

* Done as suggested

# onpoint 1.0
* First submission to CRAN

## Test environments
* local R installation, R 4.1.1
* GitHub Actions
* {os: windows-latest, r: 'release'}
* {os: macOS-latest, r: 'release'}
* {os: ubuntu-20.04, r: 'release'}

## R CMD check results

0 errors ✓ | 0 warnings ✓ | 0 notes ✓

* This is a new release.
Binary file modified man/figures/README-plot_antecedent-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-plot_hetero-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-plot_oring-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-plot_quantums-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/onpoint.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions man/simulate_antecedent_conditions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading