Skip to main content

Python implementation of fastglmpca [Weine et al., Bioinformatics, 2024] algorithm with PyTorch

Project description

fastglmpca

Python implementation of fastglmpca (Weine et al., Bioinformatics, 2024) algorithm with PyTorch backend.

The main concept of fastglmpca is to use a fast iterative algorithm ("Alternative Poisson Regression") to find a low-rank approximation of the input matrix Y with a Poisson distribution. It might be used for dimensionality reduction of count data matrices (e.g. scRNA-Seq UMI matrices or nearest neighbours count matrices in Skip-Gram like representations). The original R package is available at GitHub, this Python package is not an official implementation.

Installation

fastglmpca might be installed via pip:

pip install fastglmpca

or the latest development version can be installed from GitHub using:

pip install git+https://github.com/serjisa/fastglmpca

Quck start

fastglmpca works with both sparse and dense matrices. The input matrix Y should be a 2D array-like object with shape (n_samples, n_features). The output matrix Z will have shape (n_samples, n_components), where n_components is the number of components to be computed.

import fastglmpca

Z = fastglmpca.poisson(Y, n_pcs=10)

Example with scRNA-Seq dataset processing is available in this notebook.

API

Function fastglmpca.poisson has the following parameters:

  • X : np.ndarray or torch.Tensor or scipy.sparse matrix Input data matrix of shape (n_samples, n_features).
  • n_pcs : int, optional Number of principal components to compute. Default is 30.
  • max_iter : int, optional Maximum number of iterations for the optimization algorithm. Default is 1000.
  • tol : float, optional Tolerance for convergence of the optimization algorithm. Default is 1e-4.
  • col_size_factor : bool, optional Whether to use column size factor in the model. Default is True.
  • row_intercept : bool, optional Whether to use row intercept in the model. Default is True.
  • verbose : bool, optional Whether to print verbose output during fitting. Default is False.
  • device : str or None, optional Device to use for computation. If None, uses "cuda" if available, otherwise "mps" if available, otherwise "cpu". Default is None.
  • progress_bar : bool, optional Whether to show a progress bar during fitting. Default is True.
  • seed : int or None, optional Random seed for reproducibility. Default is 42.
  • return_model : bool, optional Whether to return the fitted model object. Default is False.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastglmpca-0.0.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastglmpca-0.0.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file fastglmpca-0.0.1.tar.gz.

File metadata

  • Download URL: fastglmpca-0.0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for fastglmpca-0.0.1.tar.gz
Algorithm Hash digest
SHA256 eaf3b176d9a5588f34693fc968405f805e6498634313cd345e25db835f1c54f0
MD5 7385c5ff16eec7e3ff84f1f886baab42
BLAKE2b-256 8a2f40277941a51fc4eb2f8a33c0abbe2eee2c7e193d02a845e4caf6011204b4

See more details on using hashes here.

File details

Details for the file fastglmpca-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: fastglmpca-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for fastglmpca-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6f579a23cde8d6e47815fbafa4482c12ddd75b45fac847d7a2216c3b560ba67
MD5 36a5f79affb8132d207591e168e1a396
BLAKE2b-256 7cfb23bcafc08c471bf689146ce98b4ce9f760e69044294934ec77843b57c589

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page