{"id":33187101,"url":"https://vbaliga.github.io/gaussplotR/","last_synced_at":"2025-11-25T18:00:40.837Z","repository":{"id":53099039,"uuid":"296948240","full_name":"vbaliga/gaussplotR","owner":"vbaliga","description":"🔔 Fit, predict, and plot 2D Gaussians in R","archived":false,"fork":false,"pushed_at":"2021-07-29T20:06:12.000Z","size":10678,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-20T14:07:07.363Z","etag":null,"topics":["2d-gaussian","gaussian","gaussian-fit","gaussian-interpolation","gaussian-plot","gaussian-volume","plotting","r","rstats"],"latest_commit_sha":null,"homepage":"https://vbaliga.github.io/gaussplotR/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vbaliga.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":null}},"created_at":"2020-09-19T20:40:38.000Z","updated_at":"2023-07-13T13:13:44.000Z","dependencies_parsed_at":"2022-08-27T03:16:43.299Z","dependency_job_id":null,"html_url":"https://github.com/vbaliga/gaussplotR","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/vbaliga/gaussplotR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbaliga%2FgaussplotR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbaliga%2FgaussplotR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbaliga%2FgaussplotR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbaliga%2FgaussplotR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vbaliga","download_url":"https://codeload.github.com/vbaliga/gaussplotR/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbaliga%2FgaussplotR/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286079811,"owners_count":27282121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-25T02:00:05.816Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d-gaussian","gaussian","gaussian-fit","gaussian-interpolation","gaussian-plot","gaussian-volume","plotting","r","rstats"],"created_at":"2025-11-16T05:00:30.371Z","updated_at":"2025-11-25T18:00:40.831Z","avatar_url":"https://github.com/vbaliga.png","language":"HTML","funding_links":[],"categories":["Data and models"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r opts, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  dpi = 300\n)\n```\n\n# gaussplotR \u003cimg src='man/figures/logo.png' align=\"right\" height=\"138.5\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![R build status](https://github.com/vbaliga/gaussplotR/workflows/R-CMD-check/badge.svg)](https://github.com/vbaliga/gaussplotR/actions)\n[![Codecov test coverage](https://codecov.io/gh/vbaliga/gaussplotR/graph/badge.svg)](https://codecov.io/gh/vbaliga/gaussplotR?branch=master)  \n[![status](https://joss.theoj.org/papers/10.21105/joss.03074/status.svg)](https://joss.theoj.org/papers/10.21105/joss.03074)  \n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4041073.svg)](https://doi.org/10.5281/zenodo.4041073)\n[![CRAN status](https://www.r-pkg.org/badges/version/gaussplotR)](https://CRAN.R-project.org/package=gaussplotR)\n\u003c!-- badges: end --\u003e\n\n`gaussplotR` provides functions to fit two-dimensional Gaussian functions,\npredict values from such functions, and produce plots of predicted data.\n\n## Installation\n\nYou can install `gaussplotR` from CRAN via:\n\n``` {r install_cran, eval = FALSE}\ninstall.packages(\"gaussplotR\")\n```\n\nOr to get the latest (developmental) version through GitHub, use:\n  \n``` {r install_github, eval = FALSE}\ndevtools::install_github(\"vbaliga/gaussplotR\")\n```\n\n\n## Example\n\nThe function `fit_gaussian_2D()` is the workhorse of `gaussplotR`. It uses\n`stats::nls()` to find the best-fitting parameters of a 2D-Gaussian fit to\nsupplied data based on one of three formula choices. The function\n`autofit_gaussian_2D()` can be used to automatically figure out the best formula\nchoice and arrive at the best-fitting parameters.\n\nThe `predict_gaussian_2D()` function can then be used to predict values from\nthe Gaussian over a supplied grid of X- and Y-values (generated here via \n`expand.grid()`). This is useful if the original data is relatively sparse and\ninterpolation of values is desired.\n\nPlotting can then be achieved via `ggplot_gaussian_2D()`, but note that the \n`data.frame` created by `predict_gaussian_2D()` can be supplied to other \nplotting frameworks such as `lattice::levelplot()`. A 3D plot can also be \nproduced via `rgl_gaussian_2D()` (not shown here).\n\n```{r example}\nlibrary(gaussplotR)\n\n## Load the sample data set\ndata(gaussplot_sample_data)\n\n## The raw data we'd like to use are in columns 1:3\nsamp_dat \u003c-\n  gaussplot_sample_data[,1:3]\n\n\n#### Example 1: Unconstrained elliptical ####\n## This fits an unconstrained elliptical by default\ngauss_fit_ue \u003c-\n  fit_gaussian_2D(samp_dat)\n\n## Generate a grid of X- and Y- values on which to predict\ngrid \u003c-\n  expand.grid(X_values = seq(from = -5, to = 0, by = 0.1),\n              Y_values = seq(from = -1, to = 4, by = 0.1))\n\n## Predict the values using predict_gaussian_2D\ngauss_data_ue \u003c-\n  predict_gaussian_2D(\n    fit_object = gauss_fit_ue,\n    X_values = grid$X_values,\n    Y_values = grid$Y_values,\n  )\n\n## Plot via ggplot2 and metR\nlibrary(ggplot2); library(metR)\nggplot_gaussian_2D(gauss_data_ue)\n\n## And another example plot via lattice::levelplot()\nlibrary(lattice)\nlattice::levelplot(\n  predicted_values ~ X_values * Y_values,\n  data = gauss_data_ue,\n  col.regions = colorRampPalette(\n    c(\"white\", \"blue\")\n    )(100),\n  asp = 1\n)\n\n#### Example 2: Constrained elliptical_log ####\n## This fits a constrained elliptical, as in Priebe et al. 2003\ngauss_fit_cel \u003c-\n  fit_gaussian_2D(\n    samp_dat,\n    method = \"elliptical_log\",\n    constrain_orientation = -1\n  )\n\n## Generate a grid of x- and y- values on which to predict\ngrid \u003c-\n  expand.grid(X_values = seq(from = -5, to = 0, by = 0.1),\n              Y_values = seq(from = -1, to = 4, by = 0.1))\n\n## Predict the values using predict_gaussian_2D\ngauss_data_cel \u003c-\n  predict_gaussian_2D(\n    fit_object = gauss_fit_cel,\n    X_values = grid$X_values,\n    Y_values = grid$Y_values,\n  )\n\n## Plot via ggplot2 and metR\nggplot_gaussian_2D(gauss_data_cel)\n\n```\n\nShould you be interested in having `gaussplotR` try to automatically determine\nthe best choice of `method` for `fit_gaussian_2D()`, the `autofit_gaussian_2D()`\nfunction can come in handy. The default is to select the `method` that \nproduces a fit with the lowest `rmse`, but other choices include `rss` and \n`AIC`.\n\n```{r autofit}\n## Use autofit_gaussian_2D() to automatically decide the best \n## model to use\ngauss_auto \u003c-\n  autofit_gaussian_2D(\n    samp_dat,\n    comparison_method = \"rmse\", \n    simplify = TRUE\n    )\n\n## The output has the same components as `fit_gaussian_2D()` \n## but for the automatically-selected best-fitting method only:\nsummary(gauss_auto)\n\n```\n\n## Contributing and/or raising Issues\n\nFeedback on bugs, improvements, and/or feature requests are all welcome. \nPlease see the Issues templates on GitHub to make a bug fix request or feature \nrequest.\n\nTo contribute code via a pull request, please consult the Contributing Guide \nfirst.\n\n\n## Citation\n\nBaliga, VB. 2021. gaussplotR: Fit, predict, and plot 2D-Gaussians in R. Journal of Open Source Software, 6(60), 3074. https://doi.org/10.21105/joss.03074\n\n\n## License\n\nGPL (\u003e= 3) + file LICENSE\n\n🐢\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/vbaliga.github.io%2FgaussplotR%2F","html_url":"https://awesome.ecosyste.ms/projects/vbaliga.github.io%2FgaussplotR%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/vbaliga.github.io%2FgaussplotR%2F/lists"}