wingen

Continuous mapping of genetic diversity

https://github.com/anushapb/wingen

Science Score: 49.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
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (18.1%) to scientific vocabulary
Last synced: 6 months ago · JSON representation

Repository

Continuous mapping of genetic diversity

Basic Info
  • Host: GitHub
  • Owner: AnushaPB
  • License: other
  • Language: R
  • Default Branch: main
  • Homepage:
  • Size: 116 MB
Statistics
  • Stars: 15
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 8
Created almost 4 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---


# wingen 


[![codecov](https://codecov.io/gh/AnushaPB/wingen/graph/badge.svg?token=P4Z35HFR4Y)](https://app.codecov.io/gh/AnushaPB/wingen)
[![R-CMD-check](https://github.com/AnushaPB/wingen/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/AnushaPB/wingen/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/wingen)](https://CRAN.R-project.org/package=wingen)
[![license: MIT](https://img.shields.io/badge/license-MIT-blue)](https://img.shields.io/badge/license-MIT-blue)
[![Zenodo DOI](https://zenodo.org/badge/499617621.svg)](https://zenodo.org/badge/latestdoi/499617621)


Generate continuous maps of genetic diversity using moving windows with options for rarefaction, interpolation, and masking.

![](man/figures/README-gif.gif)

## Citation

Please cite the original Bishop et al. (2023) paper if you use this package:

**Bishop, A. P., Chambers, E. A., & Wang, I. J. (2023). Generating continuous maps of genetic diversity using moving windows. ***Methods in Ecology and Evolution***, 14, 1175–1181. http://doi.org/10.1111/2041-210X.14090**

Checkout our [Methods blog post](https://methodsblog.com/2023/05/03/wingen-mapping-genetic-diversity-using-moving-windows/) about wingen for a quick overview of the package and its uses.

## Installation

Install the released version of wingen from CRAN:
``` r
install.packages("wingen")
```

Or install the development version from GitHub:
``` r
# install.packages("devtools")
devtools::install_github("AnushaPB/wingen")
```

## Example

The following example demonstrates the basic functionality of wingen using a **small subset (100 variant loci x 100 samples) of the simulated data from [Bishop et al. (2023)](http://doi.org/10.1111/2041-210X.14090)**.

```{r, comment = FALSE, message = FALSE, results = FALSE, warning = FALSE}
library(wingen)

# Load ggplot for plotting
library(ggplot2)

# Load example data
load_middle_earth_ex()
```

The core function of this package is `window_gd()`, which takes as inputs a vcfR object (or a path to a .vcf file), sample coordinates (as a data.frame, matrix, or sf object), and a raster layer (as a SpatRaster or RasterLayer) which the moving window will slide across. Users can control the genetic diversity statistic that is calculated (`stat`), the window dimensions (`wdim`), the aggregation factor to use on the raster (`fact`), whether to perform rarefaction (`rarify`), and other aspects of the moving window calculations. Additional arguments for this function are described in the vignette and function documentation.

```{r window_gd, warning = FALSE, message = FALSE, results = FALSE, fig.height = 4, fig.width = 4.5}
# Run moving window calculations of pi with rarefaction
wgd <- window_gd(lotr_vcf,
  lotr_coords,
  lotr_lyr,
  stat = "pi",
  wdim = 7,
  fact = 3,
  rarify = TRUE
)

# Use ggplot_gd() to plot the genetic diversity layer and ggplot_count() to plot the sample counts layer
ggplot_gd(wgd) +
  ggtitle("Moving window pi")
```
```{r, fig.width = 5, fig.height = 4}
ggplot_count(wgd) +
  ggtitle("Moving window sample counts")
```

Next, the output from `window_gd()` can be interpolated using kriging with the `wkrig_gd()` function.

```{r krig_gd, warning = FALSE, message = FALSE, results = FALSE}
# Interpolate to a higher resolution
krige_layer <- disagg(wgd, 2) 
kgd <- wkrig_gd(wgd, krige_layer)
```

Finally, the output from `wkrig_gd()` (or `window_gd()`) can be masked to exclude areas that fall outside of the study area or that were undersampled.

```{r mask_gd, warning = FALSE, message = FALSE, results = FALSE}
# Mask results that fall outside of the "range"
mgd <- mask_gd(kgd, lotr_range)
```

```{r result, warning = FALSE, message = FALSE, results = FALSE, fig.height = 4, fig.width = 4.5}
# Plot results
ggplot_gd(kgd) +
  ggtitle("Kriged pi")

ggplot_gd(mgd) +
  ggtitle("Masked pi")
```

For an extended walk through, see the package vignette:

``` r
vignette("wingen-vignette")
```

A pdf of the vignette can also be found [here](https://github.com/AnushaPB/wingen/blob/main/vignettes/wingen-vignette.pdf)

Example analyses from [Bishop et al. (2023)](http://doi.org/10.1111/2041-210X.14090) can be found in the [paperex](https://github.com/AnushaPB/wingen/tree/main/paperex) directory.

Owner

  • Name: Anusha Bishop
  • Login: AnushaPB
  • Kind: user
  • Company: UC Berkeley

GitHub Events

Total
  • Release event: 1
  • Watch event: 2
  • Delete event: 2
  • Push event: 31
  • Pull request review comment event: 6
  • Pull request review event: 5
  • Pull request event: 4
  • Create event: 4
Last Year
  • Release event: 1
  • Watch event: 2
  • Delete event: 2
  • Push event: 31
  • Pull request review comment event: 6
  • Pull request review event: 5
  • Pull request event: 4
  • Create event: 4

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 months
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 months
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • pandanusposs (1)
Pull Request Authors
  • AnushaPB (10)
  • olivroy (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 102 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 1
cran.r-project.org: wingen

Continuous Mapping of Genetic Diversity

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 102 Last month
Rankings
Dependent packages count: 28.1%
Dependent repos count: 36.1%
Average: 49.8%
Downloads: 85.0%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 3.5.0 depends
  • Rcpp * imports
  • SpatialKDE * imports
  • adegenet * imports
  • automap * imports
  • crayon * imports
  • furrr * imports
  • future * imports
  • graphics * imports
  • hierfstat * imports
  • magrittr * imports
  • purrr * imports
  • raster * imports
  • sf * imports
  • sp * imports
  • terra * imports
  • utils * imports
  • vcfR * imports
  • viridis * imports
  • MASS * suggests
  • covr * suggests
  • devtools * suggests
  • knitr * suggests
  • rgdal * suggests
  • rgeos * suggests
  • rmarkdown * suggests
  • stringr * suggests
  • testthat >= 3.0.0 suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite