transformGamPoi

Variance stabilizing transformation for Gamma Poisson distributed data

https://github.com/const-ae/transformgampoi

Science Score: 33.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
  • Academic publication links
    Links to: nature.com
  • Committers with academic emails
    1 of 3 committers (33.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.1%) to scientific vocabulary

Keywords from Contributors

bioconductor-package gene sequencing ontology proteomics
Last synced: 10 months ago · JSON representation

Repository

Variance stabilizing transformation for Gamma Poisson distributed data

Basic Info
  • Host: GitHub
  • Owner: const-ae
  • Language: R
  • Default Branch: devel
  • Size: 370 KB
Statistics
  • Stars: 22
  • Watchers: 3
  • Forks: 1
  • Open Issues: 1
  • Releases: 0
Created about 5 years ago · Last pushed over 3 years ago
Metadata Files
Readme Changelog

README.Rmd

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-"
)
```

# transformGamPoi




R package that accompanies our paper 'Comparison of transformations for single-cell RNA-seq data
' (https://www.nature.com/articles/s41592-023-01814-1).

`transformGamPoi` provides methods to stabilize the variance of single cell count data:

* acosh transformation based on the delta method
* shifted logarithm (log(x + c)) with a pseudo-count c, so that it approximates the acosh transformation
* randomized quantile and Pearson residuals 

## Installation

You can install the current development version of `transformGamPoi` by typing the following into the [_R_](https://cloud.r-project.org/) console:
``` r
# install.packages("devtools")
devtools::install_github("const-ae/transformGamPoi")
```
The installation should only take a few seconds and work across all major operating systems (MacOS, Linux, Windows). 

## Example

Let's compare the different variance-stabilizing transformations.

We start by loading the `transformGamPoi` package and setting a seed to make sure the results are reproducible.
```{r loadLibraries}
library(transformGamPoi)
set.seed(1)
```

We then load some example data, which we subset to 1000 genes and 500 cells
```{r loadData}
sce <- TENxPBMCData::TENxPBMCData("pbmc4k")
sce_red <- sce[sample(which(rowSums2(counts(sce)) > 0), 1000),
               sample(ncol(sce), 500)]
```

We 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:
```{r applyVSTs}
assay(sce_red, "acosh") <- transformGamPoi(sce_red, transformation = "acosh")
assay(sce_red, "shifted_log") <- shifted_log_transform(sce_red, overdispersion = 0.1)
# For large datasets, we can also do the processing without 
# loading the full dataset into memory (on_disk = TRUE)
assay(sce_red, "rand_quant") <- residual_transform(sce_red, "randomized_quantile", on_disk = FALSE)
assay(sce_red, "pearson") <- residual_transform(sce_red, "pearson", clipping = TRUE, on_disk = FALSE)
```

Finally, we compare the variance of the genes after transformation using a scatter plot
```{r plotMeanVar, warning=FALSE}
par(pch = 20, cex = 1.15)
mus <- rowMeans2(counts(sce_red))
plot(mus, rowVars(assay(sce_red, "acosh")), log = "x", col = "#1b9e77aa", cex = 0.6,
     xlab =  "Log Gene Means", ylab = "Variance after transformation")
points(mus, rowVars(assay(sce_red, "shifted_log")), col = "#d95f02aa", cex = 0.6)
points(mus, rowVars(assay(sce_red, "pearson")), col = "#7570b3aa", cex = 0.6)
points(mus, rowVars(assay(sce_red, "rand_quant")), col = "#e7298aaa", cex = 0.6)
legend("topleft", legend = c("acosh", "shifted log", "Pearson Resid.", "Rand. Quantile Resid."),
       col = c("#1b9e77", "#d95f02", "#7570b3", "#e7298a"), pch = 16)
```

# See also

There are a number of preprocessing methods and packages out there. Of particular interests are

* [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.
* [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/).
* [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.



# Session Info

```{r}
sessionInfo()
```


Owner

  • Name: Constantin
  • Login: const-ae
  • Kind: user
  • Location: Heidelberg, Germany
  • Company: EMBL

PhD Student, Biostats, R

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 74
  • Total Committers: 3
  • Avg Commits per committer: 24.667
  • Development Distribution Score (DDS): 0.081
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
const-ae a****5@g****m 68
Nitesh Turaga n****a@g****m 4
J Wokaty j****y@s****u 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 6
  • Total pull requests: 0
  • Average time to close issues: 4 days
  • Average time to close pull requests: N/A
  • Total issue authors: 6
  • Total pull request authors: 0
  • Average comments per issue: 1.5
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ChristophH (1)
  • stanleyjs (1)
  • adamov-artem (1)
  • PedroMilanezAlmeida (1)
  • cnk113 (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • bioconductor 7,090 total
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 5
  • Total maintainers: 1
bioconductor.org: transformGamPoi

Variance Stabilizing Transformation for Gamma-Poisson Models

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 7,090 Total
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Stargazers count: 8.0%
Forks count: 18.4%
Average: 23.1%
Downloads: 89.3%
Maintainers (1)
Last synced: 11 months ago

Dependencies

DESCRIPTION cran
  • DelayedArray * imports
  • HDF5Array * imports
  • Matrix * imports
  • MatrixGenerics * imports
  • Rcpp * imports
  • SummarizedExperiment * imports
  • glmGamPoi * imports
  • methods * imports
  • utils * imports
  • TENxPBMCData * suggests
  • knitr * suggests
  • rmarkdown * suggests
  • scran * suggests
  • testthat * suggests