Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
✓DOI references
Found 7 DOI reference(s) in README -
○Academic publication links
-
✓Committers with academic emails
3 of 9 committers (33.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (20.9%) to scientific vocabulary
Keywords
deep-learning
gpu-acceleration
machine-learning
species-distribution-modelling
species-interactions
Last synced: 6 months ago
·
JSON representation
Repository
Scalable joint species distribution modeling
Basic Info
- Host: GitHub
- Owner: TheoreticalEcology
- License: gpl-3.0
- Language: R
- Default Branch: master
- Homepage: https://cran.r-project.org/web/packages/sjSDM/index.html
- Size: 51.3 MB
Statistics
- Stars: 70
- Watchers: 6
- Forks: 15
- Open Issues: 48
- Releases: 6
Topics
deep-learning
gpu-acceleration
machine-learning
species-distribution-modelling
species-interactions
Created over 6 years ago
· Last pushed 7 months ago
Metadata Files
Readme
License
README.Rmd
---
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
[](http://www.repostatus.org/#active) [](https://www.gnu.org/licenses/gpl-3.0) [](https://cran.r-project.org/package=sjSDM)  [](https://www.doi.org/10.1111/2041-210X.13687)
# s-jSDM - Fast and accurate Joint Species Distribution Modeling
## About sjSDM
The sjSDM package is an R package for estimating joint species distribution models. A jSDM is a GLMM that models a multivariate (i.e. a many-species) response to the environment, space and a covariance term that models conditional (on the other terms) correlations between the outputs (i.e. species).

A big challenge in jSDM implementation is computational speed. The goal of the sjSDM (which stands for "scalable joint species distribution models") is to make jSDM computations fast and scalable. Unlike many other packages, which use a latent-variable approximation to make estimating jSDMs faster, sjSDM fits a full covariance matrix in the likelihood, which is, however, numerically approximated via simulations. The method is described in Pichler & Hartig (2021) A new joint species distribution model for faster and more accurate inference of species associations from big community data, https://www.doi.org/10.1111/2041-210X.13687.
The core code of sjSDM is implemented in Python / PyTorch, which is then wrapped into an R package. In principle, you can also use it stand-alone under Python (see instructions below). Note: for both the R and the python package, python \>= 3.7 and pytorch must be installed (more details below). However, for most users, it will be more convenient to use sjSDM via the sjSDM R package, which also provides a large number of downstream functionalities.
To get citation info for sjSDM when you use it for your reseach, type
```{r,eval=FALSE}
citation("sjSDM")
```
## Installing the R package
sjSDM is distributed via [CRAN](https://cran.rstudio.com/web/packages/sjSDM/index.html). For most users, it will be best to install the package from CRAN
```{r,eval=FALSE}
install.packages("sjSDM")
```
Depencies for the package can be installed before or after installing the package. Detailed explanations of the dependencies are provided in vignette("Dependencies", package = "sjSDM"), source code [here](https://github.com/TheoreticalEcology/s-jSDM/blob/master/sjSDM/vignettes/Dependencies.Rmd). Very briefly, the dependencies can be automatically installed from within R:
```{r,eval=FALSE}
sjSDM::install_sjSDM(version = "gpu") # or
sjSDM::install_sjSDM(version = "cpu")
```
For advanced users: if you want to install the current (development) version from this repository, run
```{r,eval=FALSE}
devtools::install_github("https://github.com/TheoreticalEcology/s-jSDM", subdir = "sjSDM", ref = "master")
```
dependencies should be installed as above. If the installation fails, check out the help of ?install_sjSDM, ?installation_help, and vignette("Dependencies", package = "sjSDM").
1. Try install_sjSDM()
2. New session, if no 'PyTorch not found' appears it should work, otherwise see ?installation_help
3. If do not get the pkg to run, create an issue [issue tracker](https://github.com/TheoreticalEcology/s-jSDM/issues) or write an email to maximilian.pichler at ur.de
## Basic Workflow
Load the package
```{r, message = F}
library(sjSDM)
```
Simulate some community data
```{r}
set.seed(42)
community <- simulate_SDM(sites = 100, species = 10, env = 3, se = TRUE)
Env <- community$env_weights
Occ <- community$response
SP <- matrix(rnorm(200, 0, 0.3), 100, 2) # spatial coordinates (no effect on species occurences)
```
This fits the standard SDM with environmental, spatial and covariance terms
```{r, results='hide'}
model <- sjSDM(Y = Occ, env = linear(data = Env, formula = ~X1+X2+X3), spatial = linear(data = SP, formula = ~0+X1:X2), se = TRUE, family=binomial("probit"), sampling = 100L, verbose = FALSE)
```
```{r}
summary(model)
```
Plot the niche estimates, i.e the estimates in the environmental component:
```{r, results='hide'}
plot(model)
```
Visualize the species-species association matrix
```{r}
image(getCor(model))
```
## Anova / Variation partitioning
### Global ANOVA
As in other models, it can be interesting to analyze how much variation is explained by which parts of hte model.
{{width=70%}}
For the Env, Spatial, Covariance terms, this is implemented in
```{r, results='hide'}
an = anova(model, verbose = FALSE)
```
```{r,fig.height=7, fig.width=6.3}
summary(an)
plot(an)
```
The anova shows the relative changes in the R^2^ of the groups and their intersections.
### Internal metacommunity structure
Following [Leibold et al., 2022](https://doi.org/10.1111/oik.08618) we can calculate and visualize the internal metacommunity structure (=partitioning of the three components for species and sites). The internal structure is already calculated by the ANOVA and we can visualize it with the plot method:
```{r,fig.height=7, fig.width=8, warning=FALSE}
results = internalStructure(an) # or plot(an, internal = TRUE)
```
The plot function returns the results for the internal metacommunity structure:
```{r}
plot(results)
```
Which can be regressed against covariates to analyse assembly processes:
```{r}
plotAssemblyEffects(results)
```
## Python Package
If you want to use sjSDM from python (as said, not encouraged because all help and downstream functions are in R), install via
```{bash,eval=FALSE}
pip install sjSDM_py
```
Python example
```{python,eval=FALSE}
import sjSDM_py as fa
import numpy as np
import torch
Env = np.random.randn(100, 5)
Occ = np.random.binomial(1, 0.5, [100, 10])
model = fa.Model_sjSDM(device=torch.device("cpu"), dtype=torch.float32)
model.add_env(5, 10)
model.build(5, optimizer=fa.optimizer_adamax(0.001),scheduler=False)
model.fit(Env, Occ, batch_size = 20, epochs = 10)
# print(model.weights)
# print(model.covariance)
```
Calculate Importance:
```{python, eval=FALSE}
Beta = np.transpose(model.env_weights[0])
Sigma = ( model.sigma @ model.sigma.t() + torch.diag(torch.ones([1])) ).data.cpu().numpy()
covX = fa.covariance( torch.tensor(Env).t() ).data.cpu().numpy()
fa.importance(beta=Beta, covX=covX, sigma=Sigma)
```
Owner
- Name: Theoretical Ecology
- Login: TheoreticalEcology
- Kind: organization
- Location: Regensburg, Germany
- Website: http://www.uni-regensburg.de/biologie-vorklinische-medizin/theoretische-oekologie/forschung/index.html
- Repositories: 10
- Profile: https://github.com/TheoreticalEcology
Repositories of the Theoretical Ecology Group, University of Regensburg
GitHub Events
Total
- Issues event: 17
- Watch event: 2
- Issue comment event: 19
- Push event: 2
- Fork event: 1
Last Year
- Issues event: 17
- Watch event: 2
- Issue comment event: 19
- Push event: 2
- Fork event: 1
Committers
Last synced: about 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| MaximilianPi | m****r@b****e | 141 |
| MaximilianPi | M****r@u****e | 115 |
| Maximilian Pichler | M****r@s****e | 103 |
| MaximilianPi | 2****i | 73 |
| florianhartig | f****g | 17 |
| dwjak123lkdmaKOP | M****r@b****e | 12 |
| CaiWang0503 | 4****T | 1 |
| MaximilianPi | m****r@M****l | 1 |
| CaiWang0503 | 4****3 | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 117
- Total pull requests: 29
- Average time to close issues: 7 months
- Average time to close pull requests: 9 days
- Total issue authors: 43
- Total pull request authors: 2
- Average comments per issue: 2.77
- Average comments per pull request: 0.14
- Merged pull requests: 27
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 17
- Pull requests: 0
- Average time to close issues: 3 months
- Average time to close pull requests: N/A
- Issue authors: 11
- Pull request authors: 0
- Average comments per issue: 0.41
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- MaximilianPi (22)
- florianhartig (20)
- dougwyu (6)
- frmunoz (5)
- wevertonbio (4)
- dansmi-hub (3)
- YJ781 (3)
- CaiWang0503 (3)
- AndrewCSlater (3)
- mtva0001 (3)
- sogm (3)
- agnes-duhamet (3)
- chnpenny (2)
- mdayii (2)
- kjmtaylor22 (2)
Pull Request Authors
- MaximilianPi (28)
- CaiWang0503 (1)
Top Labels
Issue Labels
enhancement (18)
bug (10)
question (5)
documentation (3)
future (2)
installation help (2)
help wanted (2)
CRAN (1)
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 6 last-month
- cran 325 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 12
- Total maintainers: 2
pypi.org: sjsdm-py
jSDM package
- Homepage: https://github.com/TheoreticalEcology/s-jSDM
- Documentation: https://sjsdm-py.readthedocs.io/
- License: GNU General Public License v3 (GPLv3)
-
Latest release: 0.1.1
published over 4 years ago
Rankings
Dependent packages count: 7.3%
Stargazers count: 8.9%
Forks count: 9.9%
Average: 19.4%
Dependent repos count: 22.1%
Downloads: 48.7%
Maintainers (1)
Last synced:
6 months ago
cran.r-project.org: sjSDM
Scalable Joint Species Distribution Modeling
- Homepage: https://github.com/TheoreticalEcology/s-jSDM/
- Documentation: http://cran.r-project.org/web/packages/sjSDM/sjSDM.pdf
- License: GPL-3
-
Latest release: 1.0.6
published over 1 year ago
Rankings
Forks count: 5.6%
Stargazers count: 7.2%
Average: 26.2%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Downloads: 52.8%
Maintainers (1)
Last synced:
6 months ago
Dependencies
sjSDM/DESCRIPTION
cran
- R >= 3.0 depends
- Metrics * imports
- Ternary * imports
- abind * imports
- checkmate * imports
- cli * imports
- crayon * imports
- ggplot2 * imports
- ggtern * imports
- grDevices * imports
- graphics * imports
- mathjaxr * imports
- mgcv * imports
- mvtnorm * imports
- parallel * imports
- reticulate * imports
- rstudioapi * imports
- stats * imports
- utils * imports
- knitr * suggests
- rmarkdown * suggests
- testthat * suggests
sjSDM/inst/python/setup.py
pypi
- numpy *
.github/workflows/automatic-installation.yaml
actions
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
- r-lib/actions/setup-tinytex master composite
.github/workflows/check-standard.yaml
actions
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact main composite
- conda-incubator/setup-miniconda v2 composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
- r-lib/actions/setup-tinytex master composite