{"id":32201064,"url":"https://github.com/lance-waller-lab/gater","last_synced_at":"2025-10-22T03:59:38.964Z","repository":{"id":44897615,"uuid":"294445148","full_name":"lance-waller-lab/gateR","owner":"lance-waller-lab","description":"Flow/Mass Cytometry Gating via Spatial Kernel Density Estimation","archived":false,"fork":false,"pushed_at":"2025-09-10T12:38:39.000Z","size":5024,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-10-22T03:59:18.389Z","etag":null,"topics":["cran","cran-r","cytometry","flow-cytometry","gating","kernel-density-estimation","mass-cytometry","non-euclidean-spaces","r","r-package","rstats","rstats-package","spatial-analysis"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lance-waller-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-09-10T15:12:56.000Z","updated_at":"2025-08-29T04:33:30.000Z","dependencies_parsed_at":"2023-02-17T10:46:00.687Z","dependency_job_id":null,"html_url":"https://github.com/lance-waller-lab/gateR","commit_stats":{"total_commits":67,"total_committers":3,"mean_commits":"22.333333333333332","dds":0.08955223880597019,"last_synced_commit":"02c7a4f92c5820d9d2c9a8b223fe1bef59a2fe70"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/lance-waller-lab/gateR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lance-waller-lab%2FgateR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lance-waller-lab%2FgateR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lance-waller-lab%2FgateR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lance-waller-lab%2FgateR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lance-waller-lab","download_url":"https://codeload.github.com/lance-waller-lab/gateR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lance-waller-lab%2FgateR/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280376547,"owners_count":26320275,"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-10-22T02:00:06.515Z","response_time":63,"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":["cran","cran-r","cytometry","flow-cytometry","gating","kernel-density-estimation","mass-cytometry","non-euclidean-spaces","r","r-package","rstats","rstats-package","spatial-analysis"],"created_at":"2025-10-22T03:59:35.202Z","updated_at":"2025-10-22T03:59:38.956Z","avatar_url":"https://github.com/lance-waller-lab.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"gateR: Flow/Mass Cytometry Gating via Spatial Kernel Density Estimation \u003cimg src=\"man/figures/gateR.png\" width=\"120\" align=\"right\" /\u003e\n===================================================\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/lance-waller-lab/gateR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/lance-waller-lab/gateR/actions/workflows/R-CMD-check.yaml)\n[![CRAN status](http://www.r-pkg.org/badges/version/gateR)](https://cran.r-project.org/package=gateR)\n[![CRAN version](https://www.r-pkg.org/badges/version-ago/gateR)](https://cran.r-project.org/package=gateR)\n[![CRAN RStudio mirror downloads total](https://cranlogs.r-pkg.org/badges/grand-total/gateR?color=blue)](https://r-pkg.org/pkg/gateR)\n[![CRAN RStudio mirror downloads monthly ](http://cranlogs.r-pkg.org/badges/gateR)](https://www.r-pkg.org:443/pkg/gateR)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/license/apache-2-0)\n![GitHub last commit](https://img.shields.io/github/last-commit/lance-waller-lab/gateR)\n[![](https://img.shields.io/badge/DOI-10.32614/CRAN.package.gateR-1f57b6?style=flat\u0026link=https://doi.org/10.32614/CRAN.package.gateR)](https://doi.org/10.32614/CRAN.package.gateR)\n\u003c!-- badges: end --\u003e\n\n**Date repository last updated**: August 29, 2025\n\n\u003ch2 id=\"overview\"\u003e\n\nOverview\n\n\u003c/h2\u003e\n\nThe `gateR` package is a suite of `R` functions to identify significant spatial clustering of flow and mass cytometry data used in immunological investigations. For a two-group comparison, we detect clusters using the kernel-based spatial relative risk function estimated using the [sparr](https://CRAN.R-project.org/package=sparr) package. The tests are conducted in a two-dimensional space comprised of two fluorescent markers. \n\nExamples of a single condition with two groups:\n\n1. Disease case vs. Healthy control\n2. Time 2 vs. Time 1 (baseline)\n\nFor a two-group comparison of two conditions, we estimate two relative risk surfaces for one condition and then a ratio of the relative risks. For example:\n\n1. Estimate a relative risk surface for:\n    1. Condition 2B vs. Condition 2A\n    2. Condition 1B vs. Condition 1A\n2. Estimate the relative risk surface for the ratio:\n\n$$\\frac{ \\big(\\frac{Condition2B}{Condition2A}\\big)}{\\big(\\frac{Condition1B}{Condition1A}\\big)}$$\n\nWithin areas where the relative risk exceeds an asymptotic normal assumption, the `gateR` package has the functionality to examine the features of these cells. Basic visualization is also supported. \n\n\u003ch2 id=\"install\"\u003e\n\nInstallation\n\n\u003c/h2\u003e\n\nTo install the release version from CRAN:\n\n    install.packages(\"gateR\")\n\nTo install the development version from GitHub:\n\n    devtools::install_github(\"lance-waller-lab/gateR\")\n\n\u003ch2 id=\"available-functions\"\u003e\n\nAvailable functions\n\n\u003c/h2\u003e\n\n\u003ctable\u003e\n\u003ccolgroup\u003e\n\u003ccol width=\"30%\"/\u003e\n\u003ccol width=\"70%\"/\u003e\n\u003c/colgroup\u003e\n\u003cthead\u003e\n\u003ctr class=\"header\"\u003e\n\u003cth\u003eFunction\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctd\u003e\u003ccode\u003egating\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eMain function. Conduct a gating strategy for flow and mass cytometry data.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ccode\u003errs\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eCalled within \u003ccode\u003egating\u003c/code\u003e, one condition comparison.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ccode\u003elotrrs\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eCalled within \u003ccode\u003egating\u003c/code\u003e, two condition comparison. \u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ccode\u003epval_correct\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eCalled within \u003ccode\u003errs\u003c/code\u003e and \u003ccode\u003elotrrs\u003c/code\u003e, calculates various multiple testing corrections for the alpha level. Five methods account for (spatially) dependent, multiple testing.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ccode\u003elrr_plot\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eCalled within \u003ccode\u003errs\u003c/code\u003e and \u003ccode\u003elotrrs\u003c/code\u003e, provides functionality for basic visualization of a log relative risk surface.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ccode\u003epval_plot\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eCalled within \u003ccode\u003errs\u003c/code\u003e and \u003ccode\u003elotrrs\u003c/code\u003e, provides functionality for basic visualization of a significant p-value surface.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003ctable\u003e\n\nThe repository also includes the code and resources to create the project hexagon sticker.\n\n\u003ch2 id=\"available-data\"\u003e\n\nAvailable sample data sets\n\n\u003c/h2\u003e\n\n\u003ctable\u003e\n\u003ccolgroup\u003e\n\u003ccol width=\"30%\"/\u003e\n\u003ccol width=\"70%\"/\u003e\n\u003c/colgroup\u003e\n\u003cthead\u003e\n\u003ctr class=\"header\"\u003e\n\u003cth\u003eData\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctd\u003e\u003ccode\u003erandCyto\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA sample dataset containing information about flow cytometry data with two binary conditions and four markers. The data are a random subset of the 'extdata' data in the \u003ca href=\"https://bioconductor.org/packages/release/data/experiment/html/flowWorkspaceData.html\"\u003eflowWorkspaceData\u003c/a\u003e package found on \u003ca href=\"https://bioconductor.org\"\u003eBioconductor\u003c/a\u003e and formatted for `gateR` input.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003ctable\u003e\n\n\u003ch2 id=\"authors\"\u003e\n\nAuthors\n\n\u003c/h2\u003e\n\n* **Ian D. Buller** - *DLH, LLC (formerly Social \u0026 Scientific Systems, Inc.), Bethesda, Maryland (current)* - *Occupational and Environmental Epidemiology Branch, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland (former)* - *Environmental Health Sciences, James T. Laney School of Graduate Studies, Emory University, Atlanta, Georgia. (original)* - [GitHub](https://github.com/idblr) - [ORCID](https://orcid.org/0000-0001-9477-8582)\n\nSee also the list of [contributors](https://github.com/lance-waller-lab/gateR/graphs/contributors) who participated in this project. Main contributors include:\n\n* **Elena Hsieh** - *Immunology \u0026 Microbiology and Pediatrics, University of Colorado Anschutz School of Medicine* - [GitHub](https://github.com/elenahsieh1407) - [ORCID](https://orcid.org/0000-0003-3969-6597)\n* **Debashis Ghosh** - *Biostatistics \u0026 Informatics, Colorado School of Public Health, Aurora, Colorado* - [GitHub](https://github.com/ghoshd) - [ORCID](https://orcid.org/0000-0001-5672-7645)\n* **Lance A. Waller** - *Biostatistics and Bioinformatics, Emory University, Atlanta, Georgia* - [GitHub](https://github.com/lance-waller) - [ORCID](https://orcid.org/0000-0001-5002-8886)\n\n## Usage\n\n``` r\nset.seed(1234) # for reproducibility\n\n# ------------------ #\n# Necessary packages #\n# ------------------ #\n\nlibrary(gateR)\nlibrary(dplyr)\nlibrary(flowWorkspaceData)\nlibrary(ncdfFlow)\nlibrary(stats)\n\n# ---------------- #\n# Data preparation #\n# ---------------- #\n\n# Use 'extdata' from the {flowWorkspaceData} package\nflowDataPath \u003c- system.file(\"extdata\", package = \"flowWorkspaceData\")\nfcsFiles \u003c- list.files(pattern = \"CytoTrol\", flowDataPath, full = TRUE)\nncfs  \u003c- ncdfFlow::read.ncdfFlowSet(fcsFiles)\nfr1 \u003c- ncfs[[1]]\nfr2 \u003c- ncfs[[2]]\n\n## Comparison of two samples (single condition) \"g1\"\n## Two gates (four markers) \"CD4\", \"CD38\", \"CD8\", and \"CD3\"\n## Arcsinh Transformation for all markers\n## Remove cells with NA and Inf values\n\n# First sample\nobs_dat1 \u003c- data.frame(\"id\" = seq(1, nrow(fr1@exprs), 1),\n                       \"g1\" = rep(1, nrow(fr1@exprs)),\n                       \"arcsinh_CD4\" = asinh(fr1@exprs[ , 5]),\n                       \"arcsinh_CD38\" = asinh(fr1@exprs[ , 6]),\n                       \"arcsinh_CD8\" = asinh(fr1@exprs[ , 7]),\n                       \"arcsinh_CD3\" = asinh(fr1@exprs[ , 8]))\n# Second sample\nobs_dat2 \u003c- data.frame(\"id\" = seq(1, nrow(fr2@exprs), 1),\n                       \"g1\" = rep(2, nrow(fr2@exprs)),\n                       \"arcsinh_CD4\" = asinh(fr2@exprs[ , 5]),\n                       \"arcsinh_CD38\" = asinh(fr2@exprs[ , 6]),\n                       \"arcsinh_CD8\" = asinh(fr2@exprs[ , 7]),\n                       \"arcsinh_CD3\" = asinh(fr2@exprs[ , 8]))\n                       \n# Full set\nobs_dat \u003c- rbind(obs_dat1, obs_dat2)\nobs_dat \u003c- obs_dat[complete.cases(obs_dat), ] # remove NAs\nobs_dat \u003c- obs_dat[is.finite(rowSums(obs_dat)), ] # remove Infs\nobs_dat$g1 \u003c- as.factor(obs_dat$g1) # set \"g1\" as binary factor\n\n## Create a second condition (randomly split the data)\n## In practice, use data with a measured second condition\ng2 \u003c- stats::rbinom(nrow(obs_dat), 1, 0.5)\nobs_dat$g2 \u003c- as.factor(g2)\nobs_dat \u003c- obs_dat[ , c(1:2,7,3:6)]\n\n# Export 'randCyto' data for CRAN examples\nrandCyto \u003c- dplyr::sample_frac(obs_dat, size = 0.1) # random subsample\n\n# ---------------------------- #\n# Run gateR with one condition #\n# ---------------------------- #\n\n# Single condition\n## A p-value uncorrected for multiple testing\ntest_gating \u003c- gateR::gating(dat = obs_dat,\n                             vars = c(\"arcsinh_CD4\", \"arcsinh_CD38\",\n                                      \"arcsinh_CD8\", \"arcsinh_CD3\"),\n                             n_condition = 1,\n                             plot_gate = TRUE,\n                             upper_lrr = 1,\n                             lower_lrr = -1)\n\n# -------------------- #\n# Post-gate assessment #\n# -------------------- #\n\n# Density of arcsinh-transformed CD4 post-gating\ngraphics::plot(stats::density(test_gating$obs[test_gating$obs$g1 == 1, 4]),\n               main = \"arcsinh CD4\",\n               lty = 2)\ngraphics::lines(stats::density(test_gating$obs[test_gating$obs$g1 == 2, 4]),\n                lty = 3)\ngraphics::legend(\"topright\",\n                 legend = c(\"Sample 1\", \"Sample 2\"),\n                 lty = c(2, 3),\n                 bty = \"n\")\n```\n\n![](man/figures/gate1.png)\n![](man/figures/gate2.png)\n![](man/figures/postgate.png)\n\n```r\n# ----------------------------- #\n# Run gateR with two conditions #\n# ----------------------------- #\n\n## A p-value uncorrected for multiple testing\ntest_gating2 \u003c- gateR::gating(dat = obs_dat,\n                              vars = c(\"arcsinh_CD4\", \"arcsinh_CD38\",\n                                       \"arcsinh_CD8\", \"arcsinh_CD3\"),\n                              n_condition = 2)\n\n# --------------------------------------------- #\n# Perform a single gate without data extraction #\n# --------------------------------------------- #\n\n# Single condition\n## A p-value uncorrected for multiple testing\n## For \"arcsinh_CD4\" and \"arcsinh_CD38\"\ntest_rrs \u003c- gateR::rrs(dat = obs_dat[ , -7:-6])\n\n# Two conditions\n## A p-value uncorrected for multiple testing\n## For \"arcsinh_CD8\" and \"arcsinh_CD3\"\ntest_lotrrs \u003c- gateR::lotrrs(dat = obs_dat[ , -5:-4])\n\n# ------------------------------------------ #\n# Run gateR with multiple testing correction #\n# ------------------------------------------ #\n\n## False Discovery Rate\ntest_gating_fdr \u003c- gateR::gating(dat = obs_dat,\n                              vars = c(\"arcsinh_CD4\", \"arcsinh_CD38\",\n                                       \"arcsinh_CD8\", \"arcsinh_CD3\"),\n                              n_condition = 1,\n                              p_correct = \"FDR\")\n```\n\n### Funding\n\nThis package was developed while the author was originally a doctoral student at in the [Environmental Health Sciences doctoral program](https://sph.emory.edu/degrees-programs/phd/environmental-health-sciences) at [Emory University](https://www.emory.edu/home/index.html) and later as a postdoctoral fellow supported by the [Cancer Prevention Fellowship Program](https://cpfp.cancer.gov/) at the [National Cancer Institute](https://www.cancer.gov/). Any modifications since December 05, 2022 were made while the author was an employee of [DLH, LLC](https://www.dlhcorp.com) (formerly Social \u0026 Scientific Systems, Inc.).\n\n### Acknowledgments\n\nWhen citing this package for publication, please follow:\n\n    citation(\"gateR\")\n\n### Questions? Feedback?\n\nFor questions about the package, please contact the maintainer [Dr. Ian D. Buller](mailto:ian.buller@alumni.emory.edu) or [submit a new issue](https://github.com/lance-waller-lab/gateR/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flance-waller-lab%2Fgater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flance-waller-lab%2Fgater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flance-waller-lab%2Fgater/lists"}