{"id":18501582,"url":"https://github.com/const-ae/transformgampoi","last_synced_at":"2025-09-12T02:39:58.496Z","repository":{"id":50259778,"uuid":"378919382","full_name":"const-ae/transformGamPoi","owner":"const-ae","description":"Variance stabilizing transformation for Gamma Poisson distributed data","archived":false,"fork":false,"pushed_at":"2023-04-11T08:34:39.000Z","size":379,"stargazers_count":21,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"devel","last_synced_at":"2025-03-23T20:36:57.204Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/const-ae.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-21T12:15:11.000Z","updated_at":"2024-08-08T08:15:21.000Z","dependencies_parsed_at":"2025-01-14T21:54:24.283Z","dependency_job_id":"e7642e0a-b802-4e98-8c69-fde3bc29c34a","html_url":"https://github.com/const-ae/transformGamPoi","commit_stats":{"total_commits":74,"total_committers":3,"mean_commits":"24.666666666666668","dds":0.08108108108108103,"last_synced_commit":"10bcccd4fc02e2659c2803ec97ccfbc6215e9600"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2FtransformGamPoi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2FtransformGamPoi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2FtransformGamPoi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2FtransformGamPoi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/const-ae","download_url":"https://codeload.github.com/const-ae/transformGamPoi/tar.gz/refs/heads/devel","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248088057,"owners_count":21045640,"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","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":[],"created_at":"2024-11-06T13:54:20.734Z","updated_at":"2025-04-09T18:33:09.226Z","avatar_url":"https://github.com/const-ae.png","language":"R","readme":"---\noutput: github_document\n---\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\"\n)\n```\n\n# transformGamPoi\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\nR package that accompanies our paper 'Comparison of transformations for single-cell RNA-seq data\n' (https://www.nature.com/articles/s41592-023-01814-1).\n\n`transformGamPoi` provides methods to stabilize the variance of single cell count data:\n\n* acosh transformation based on the delta method\n* shifted logarithm (log(x + c)) with a pseudo-count c, so that it approximates the acosh transformation\n* randomized quantile and Pearson residuals \n\n## Installation\n\nYou can install the current development version of `transformGamPoi` by typing the following into the [_R_](https://cloud.r-project.org/) console:\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"const-ae/transformGamPoi\")\n```\nThe installation should only take a few seconds and work across all major operating systems (MacOS, Linux, Windows). \n\n## Example\n\nLet's compare the different variance-stabilizing transformations.\n\nWe start by loading the `transformGamPoi` package and setting a seed to make sure the results are reproducible.\n```{r loadLibraries}\nlibrary(transformGamPoi)\nset.seed(1)\n```\n\nWe then load some example data, which we subset to 1000 genes and 500 cells\n```{r loadData}\nsce \u003c- TENxPBMCData::TENxPBMCData(\"pbmc4k\")\nsce_red \u003c- sce[sample(which(rowSums2(counts(sce)) \u003e 0), 1000),\n               sample(ncol(sce), 500)]\n```\n\nWe calculate the different variance-stabilizing transformations. We can either use the generic `transformGamPoi()` method and specify the `transformation`, or we use the low-level functions `acosh_transform()`, `shifted_log_transform()`, and `residual_transform()` which provide more settings. All functions return a matrix, which we can for example insert back into the `SingleCellExperiment` object:\n```{r applyVSTs}\nassay(sce_red, \"acosh\") \u003c- transformGamPoi(sce_red, transformation = \"acosh\")\nassay(sce_red, \"shifted_log\") \u003c- shifted_log_transform(sce_red, overdispersion = 0.1)\n# For large datasets, we can also do the processing without \n# loading the full dataset into memory (on_disk = TRUE)\nassay(sce_red, \"rand_quant\") \u003c- residual_transform(sce_red, \"randomized_quantile\", on_disk = FALSE)\nassay(sce_red, \"pearson\") \u003c- residual_transform(sce_red, \"pearson\", clipping = TRUE, on_disk = FALSE)\n```\n\nFinally, we compare the variance of the genes after transformation using a scatter plot\n```{r plotMeanVar, warning=FALSE}\npar(pch = 20, cex = 1.15)\nmus \u003c- rowMeans2(counts(sce_red))\nplot(mus, rowVars(assay(sce_red, \"acosh\")), log = \"x\", col = \"#1b9e77aa\", cex = 0.6,\n     xlab =  \"Log Gene Means\", ylab = \"Variance after transformation\")\npoints(mus, rowVars(assay(sce_red, \"shifted_log\")), col = \"#d95f02aa\", cex = 0.6)\npoints(mus, rowVars(assay(sce_red, \"pearson\")), col = \"#7570b3aa\", cex = 0.6)\npoints(mus, rowVars(assay(sce_red, \"rand_quant\")), col = \"#e7298aaa\", cex = 0.6)\nlegend(\"topleft\", legend = c(\"acosh\", \"shifted log\", \"Pearson Resid.\", \"Rand. Quantile Resid.\"),\n       col = c(\"#1b9e77\", \"#d95f02\", \"#7570b3\", \"#e7298a\"), pch = 16)\n```\n\n# See also\n\nThere are a number of preprocessing methods and packages out there. Of particular interests are\n\n* [sctransform](https://github.com/ChristophH/sctransform) by Christoph Hafemeister and the [Satija lab](https://satijalab.org/). The original developers of the Pearson residual variance-stabilizing transformation approach for single cell data.\n* [scuttle::logNormCounts()](https://bioconductor.org/packages/release/bioc/html/scuttle.html) by Aaron Lun. This is an alternative to the `shifted_log_transform()` and plays nicely together with the Bioconductor universe. For more information, I highly recommend to take a look at the [normalization](https://bioconductor.org/books/release/OSCA/normalization.html) section of the [OSCA book](https://bioconductor.org/books/release/OSCA/).\n* [Sanity](https://github.com/jmbreda/Sanity) by Jérémie Breda _et al._. This method is not directly concerned with variance stabilization, but still provides an interesting approach for single cell data preprocessing.\n\n\n\n# Session Info\n\n```{r}\nsessionInfo()\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconst-ae%2Ftransformgampoi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconst-ae%2Ftransformgampoi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconst-ae%2Ftransformgampoi/lists"}