r-spatialecology / shar Goto Github PK
View Code? Open in Web Editor NEW:package: Analyse species-habitat associations in R
Home Page: https://r-spatialecology.github.io/shar
License: GNU General Public License v3.0
:package: Analyse species-habitat associations in R
Home Page: https://r-spatialecology.github.io/shar
License: GNU General Public License v3.0
Maybe instead of checking if objects are suitable, introduce classes?
Hello,
I would like to reconstruct a point pattern from a small tree plot data to a larger size (eg. from 0.3 ha to 1 ha).
For this, I tried reconstruct_pattern_marks(). However, I learned that it will produce a pattern with the same number of points.
Do you have any advice, which function I can use for this? I wonder if there is an option to vary the number of points and window-extent to reconstruct.
Thanks,
kiranaw
Use viridis scale
Regarding @openjournals/joss-reviews#3811 JOSS requires "clear guidelines for third parties wishing to 1) Contribute to the software 2) Report issues or problems with the software 3) Seek support" so I think you need to add something to the README to explain that.
I think I also forgot to include this for my JOSS paper ๐ณ, so if it is helpful you could look at my virtualNicheR package to see how I included that information.
Check if https://zenodo.org/record/8026693 can be used to optimize reconstruction
Can you please do your homepage magic @marcosci ? I started with a .yaml-file but not quite sure how do build it.
Regarding @openjournals/joss-reviews#3811 I think there a couple of typos that you could correct:
Line 41: environmental conditions need to be broken by randomizing the data as a null model
Line 45: The first approach to simulate null model data, is to randomize the environmental data
Not sure if the function is really needed or just an old artifact of older package structure
Regarding @openjournals/joss-reviews#3811 I'm wondering if you could improve the test data examples slightly to avoid any confusion.
Ideally I think I should be able to run test data and get exactly the same results to confirm everything is working properly. This is a bit challenging for you as the software uses data randomisation so you are unlikely to get exactly the same results. However, I think it would be helpful if the conclusions of the results stays the same.
Everything seems to be fine with
results_habitat_association(pattern = species_a, raster = torus_trans)
## > Input: randomized raster | Quantile thresholds: negative < 0.025 - positive > 0.975
## habitat count lo hi significance
## 1 1 9 2 14 n.s.
## 2 2 25 9 24 positive
## 3 3 27 11 26 positive
## 4 4 0 11 29 negative
## 5 5 12 5 18 n.s.
for which I get identical output in R.
But for
results_habitat_association(pattern = reconstruction, raster = landscape_classified)
## > Input: randomized point pattern | Quantile thresholds: negative < 0.025 - positive > 0.975
## habitat count lo hi significance
## 1 1 8 1.00 23.35 n.s.
## 2 2 22 25.85 49.10 negative
## 3 3 33 40.80 68.05 negative
## 4 4 19 44.00 71.10 negative
## 5 5 118 20.85 60.05 positive
I get the following result
results_habitat_association(pattern = reconstruction, raster = landscape_classified)
> Input: randomized point pattern | Quantile thresholds: negative < 0.025 - positive > 0.975
habitat count lo hi significance
1 1 8 27.90 48.10 negative
2 2 22 52.90 77.05 negative
3 3 33 29.00 57.30 n.s.
4 4 19 24.90 46.10 negative
5 5 118 11.85 26.00 positive
that has quite differrent lo and hi values, and different significance results for habitat classes 1 and 3.
I am assuming that all is running correctly, but I feel a bit nervous that my conclusion is different to that of the test data example.
I would suggest you:
set.seed()
as part of the example code so that the results will be the same.Regarding @openjournals/joss-reviews#3811 JOSS requires a "clearly-stated list of dependencies" at the moment you state in the README that "shar is mainly based on the spatstat (Baddeley et al. 2015) and raster (Hijmans 2017) package" but I think you should be specific as shar also requires the rcpp package.
I would suggest listing these somewhere, perhaps within the installation section.
I have spotted that you have an open issue about whether to include the rcpp requirement. This is very much a style thing, but I prefer to have absolutely minimal package dependencies to make maintenance easier. So you could help resolve this issue by removing that rcpp dependency - but a clear list of the remaining dependencies would still be helpful I think ๐
e.g.,
Line 61 in f4788a9
should be instead
if (inherits(pattern, c("rd_pat", "rd_mar"))) {
Reference: https://developer.r-project.org/Blog/public/2019/11/09/when-you-think-class.-think-again/
This is part of openjournals/joss-reviews#3811
Makes sense in results_habitat_associations()
Keep relocated pattern even if energy did not decrease in a few cases if e.g. annealing = 0.001
rcpp_sample
is a little bit faster than sample
but maybe that is not worth the Rcpp
dependency since its the only function?
This issue tracks all steps to integrate the new reconstruct_pattern_multi
function into the package. For this, I created a new branch called changes_multi
.
R-CMD-Check
testthat
suiteBetter use of functions is needed, e.g. wrapper using plot_randomized_pattern and calculate_energy
Regarding openjournals/joss-reviews#3811 I think there should be a note somewhere, perhaps in the README or the paper, maybe both around the expectation of how NA data in the raster landscape would be handled.
All the examples and supporting papers cited seem to work with landscapes that are "complete" in that points can occur anywhere within the unit-square for the point-process models and there is habitat everywhere within the raster landscape. But I suspect that in reality it will be quite common for the study area to be a more complex shape than a rectangle, and therefore there will be NA cells within the raster landscape in which points cannot occur. So I am left wondering if it is theoretically reasonable to use the methods in shar
with that kind of data. Essentially I am querying how NA data in a raster landscape is handled.
If shar
can't handle NA data that is absolutely fine, but I do think it should be highlighted to potential users if that will preclude use of the package so that they can quickly eliminate shar
as an option if it won't work for them.
Apologies if I have missed that information somewhere, but if it does exist, perhaps it could be made more prominent as I think that could have a massive bearing for potential users.
"Both functions return a list with randomized rasters and the observed one. For more information on the methods, please click here."
The here link currently doesn't go anywhere.
The four reconstruct_pattern
functions could be brought together into one where the user specify the type of reconstruction wanted, the function could then look like:
reconstruct_pattern(pattern, type = c("homo", "hetero", "cluster", "mark"))
Put simulated <- ... into n_random loop
Regarding @openjournals/joss-reviews#3811 requirement for a statement of need, I am not aware of any point pattern software in R that allows someone to do habitat analyses, so in that regard I am happy that this software fills a gap.
However, I think it would be helpful for me to understand if there are situations where this approach is beneficial over the multitude of other ways I could take xy point data and a raster and produce some sort of habitat/species distribution/ecological niche model.
I don't feel like I can articulate this question very well, so I do apologise for that ๐ฌ, and I haven't had time to fully read and digest the cited papers, but I think it could be very helpful to potential users to understand any specific instances where these kinds of approaches are beneficial when compared to other similar presence-background approaches available in R packages such as dismo, biomod2, zoon, adehabitat, and the like.
I guess I would say that at the moment I don't see what the benefit of treating my xy location data as a point pattern and analysing it though shar.
I am mentioning this as if you can highlight that benefit somehow, then I think you will increase the likelihood of ecologists engaging with shar.
Regarding @openjournals/joss-reviews#3811 I would have found it helpful to have links to the citations in the README. Any chance you could please add the missing links you have in the paper to the README as well? I think people who find your package via GitHub rather than via JOSS would find that helpful.
Add a quantum plot style to plot_randomized_pattern(x, method = "sf")
.
Technically it should be possible to torus translate the point pattern as well
In case you have ideas for future updates, simply post them here!
simplify
argument for all functions that would return only one element (e.g. reconstruct_pattern()
with n_random = 1
and return_input = FALSE
Remember to add list_to_randomized()
to NEWS.md
Use ads package for pcf
There seems to be a problem with the references, probably an issue with UTF codes
Introduce features to weight different summary functions or mean them
Start with heterogenous pattern
Regarding issue openjournals/joss-reviews#3811, it would be easiest if plot methods were created for the objects derived from shar (i.e. rd_pat), so basically instead of having to call:
pattern_random <- fit_point_process(species_a, n_random = 19, process = "cluster")
plot_randomized_pattern(pattern_random)
One could simply do:
plot(pattern_random)
This could be achieved by turning the plot_* functions into plot.rd_pat and plot.rd_ras, check http://adv-r.had.co.nz/S3.html for instance.
Use internal function for core reconstruction
Leads to crashes
Regarding openjournals/joss-reviews#3811, shar deals with point pattern data linked to categorical (discrete) environment variables. This information on the data requirements should be in the DESCRIPTION file. Maybe:
Therefore, information about the location of the species (as a point pattern) is needed together with environmental conditions (as a categorical raster).
Probably worth supporting terra soon or even make terra default und allow raster as legacy mode
Return warning if mean(pcf) is above threshold because clustered
The functions to reconstruct have a lot of repeated code, so could be combined
This is related to openjournals/joss-reviews#3811, the pair correlation plots from plot_reconstructed_pattern
sometime show axis that do not span the whole range of the data:
pp <- spatstat.core::rLGCP(win=spatstat.geom::owin(c(0, 10), c(0, 10)))
ff <- fit_point_process(pp)
plot_reconstructed_pattern(ff)
@ZekeMarshall had the idea to not include the breaks additionally to the classes in the results_habitat_association()
table.
That's a good idea, however, the breaks are not necessarily included in the provided raster object. Maybe add an argument (default NA
or NULL
), which allows providing breaks in the same order as classes. In this case, the breaks from classifiy_habitats
could be used. Or maybe a data.frame
which would allow to merge classes to breaks.
Related, maybe write a short helper function to convert the classInterval
object as data.frame
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.