Giter Club home page Giter Club logo

pysctransform's Introduction

pySCTranscform

SCTransform for Python - interfaces with Scanpy

Demo Notebook

See demo.

Installation

Using conda

We recommend using conda for installing pySCTransform.

conda create -n pysct louvain scanpy
conda activate pysct
pip install git+https://github.com/saketkc/pysctransform.git@glmgp

If you would like to use glmGamPoi, a faster estimator, rpy2 and glmGamPoi need to be installed as well:

conda create -n pysct louvain scanpy rpy2 bioconductor-glmgampoi
conda activate pysct
pip install git+https://github.com/saketkc/pysctransform.git

Quickstart

import scanpy as sc
from pysctransform import SCTransform

pbmc3k = sc.read_h5ad("./pbmc3k.h5ad")

# Get pearson residuals for 3K highly variable genes
residuals = SCTransform(pbmc3k, var_features_n=3000)
pbmc3k.obsm["pearson_residuals"] = residuals

# Peform PCA on pearson residuals
pbmc3k.obsm["X_pca"] = sc.pp.pca(pbmc3k.obsm["pearson_residuals"])

# Clustering and visualization
sc.pp.neighbors(pbmc3k, use_rep="X_pca")
sc.tl.umap(pbmc3k, min_dist=0.3)
sc.tl.louvain(pbmc3k)
sc.pl.umap(pbmc3k, color=["louvain"], legend_loc="on data", show=True)
https://raw.githubusercontent.com/saketkc/pySCTransform/develop/notebooks/output_images/pbmc3k_pysct.png
# Perform variance stabilization using 'v2' regularization
from pysctransform import vst
from pysctransform.plotting import plot_residual_var
vst_out_3k = vst(umi = pbmc3k.X.T,
                 gene_names=pbmc3k.var_names.tolist(),
                 cell_names=pbmc3k.obs_names.tolist(),
                 method="fix-slope",
                 exclude_poisson=True
                )
plot_residual_var(vst_out_3k)
https://raw.githubusercontent.com/saketkc/pySCTransform/develop/notebooks/output_images/pysct_glmgp_residvar.png

Notes

  • batch_var is currently not supported

pysctransform's People

Contributors

saketkc avatar christian-heyer avatar sbooeshaghi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.