Skip to main content

scReg2: integrate RNA and ATAC dimention reduction with batch remove

Project description

BETA

This package still in beta, please feel free to e-mail me for any question about the package and usage.

email: fchang[at]clemson.edu

FULL Tutorial

scReg2

Install

pip install screg2

Usage

Load data form h5ad file

If you have 2 anndata object that already finished scaling, normalizing,... You can just simply use screg2.RegNMF() to integrate rna and atac data, with batch remove. screg2.RegNMF() will return the rna anndata object with scReg_reduction in it rna_adata.obsm

import pandas as pd
import numpy as np
import scanpy as sc
import screg2 

rna_file = '/path/to/your/rna/h5ad/file'
atac_file = '/path/to/your/atac/h5ad/file'
rna_adata = sc.read_h5ad(rna_file)
atac_adata= sc.read_h5ad(atac_file)
rna_adata = screg2.RegNMF(rna_data=rna_adata, atac_data=atac_adata, Meta_data=rna_adata.obs,batch_type='sample', maxiter=100, key_added="scReg_reduction")

screg2.RegNMF() will return the rna anndata object with scReg_reduction in it rna_adata.obsm

rna_adata.obsm['scReg_reduction']
array([[4.13353097e-14, 1.08500913e-10, 3.27313772e-11, ...,
        0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
      [2.09097071e-14, 1.96949657e-16, 1.67404740e-11, ...,
        0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
      [1.12355639e-10, 3.41268614e-11, 6.89114276e-11, ...,
        0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
      ...,
      [6.38938638e-14, 7.88140180e-11, 5.65415185e-13, ...,
        0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
      [1.88311115e-10, 1.70259133e-10, 6.51093299e-12, ...,
        0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
      [2.15576528e-12, 9.40752216e-11, 1.57056569e-12, ...,
        0.00000000e+00, 0.00000000e+00, 0.00000000e+00]])

Warning

If you do not have the meta data of cells for their sample infomation the nex code might help you

rna_adata.obs['sample'] = adata.obs_names.str.split("-").str[1]

Clustering and Umap

sc.pp.neighbors(rna_adata, use_rep='scReg_reduction', key_added='scReg_neighbors', n_neighbors=40)
sc.tl.leiden(rna_adata, neighbors_key='scReg_neighbors', key_added='scReg_leiden')
sc.tl.umap(rna_adata, neighbors_key='scReg_neighbors')
sc.pl.umap(rna_adata, color="scReg_leiden", legend_loc="on data",legend_fontsize="small",size=6, title="scReg")
# If you want to save the figure you can
# sc.pl.umap(rna_adata, color="scReg_leiden", legend_loc="on data",legend_fontsize="small",size=6, save="_scReg.pdf" title="scReg")

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

screg2-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

screg2-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file screg2-0.1.0.tar.gz.

File metadata

  • Download URL: screg2-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.9-arch1-2

File hashes

Hashes for screg2-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef23ded60557693d660b4971db5714cf2cf6ffac03aa5cd55a72b4d9054a1d41
MD5 4e7282707366e165a72e9df4a126080b
BLAKE2b-256 8909cd9b3ab2beecb3710e4f19e7ccbe96b174fe9eeb9e11e97b54d99edda49c

See more details on using hashes here.

File details

Details for the file screg2-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: screg2-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.9-arch1-2

File hashes

Hashes for screg2-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23bf8980c963512e48aebc582bb92a6332f999cbe5fa7fd96beb501d5a304b08
MD5 e8c9542d06e7909bf0ac45937884063f
BLAKE2b-256 cfe51b673bff53fd25975c4380f2298954a446fd31451517721e0b8f587a40cd

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