Metadata-Version: 2.4
Name: ctdecon
Version: 1.0.0
Summary: Reference-based cell type deconvolution in spatial transcriptomics.
Home-page: https://github.com/linjing-lab/ctdecon
Download-URL: https://github.com/linjing-lab/ctdecon/tags
Author: 林景
Author-email: linjing010729@163.com
License: MIT
Project-URL: Source, https://github.com/linjing-lab/ctdecon/tree/master/ctdecon/
Project-URL: Tracker, https://github.com/linjing-lab/ctdecon/issues
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Healthcare Industry
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.26.4
Requires-Dist: pandas>=2.3.1
Requires-Dist: POT>=0.9.5
Requires-Dist: pykan>=0.2.8
Requires-Dist: scanpy>=1.10.4
Requires-Dist: scikit-learn>=1.7.1
Requires-Dist: scipy>=1.11.4
Requires-Dist: tqdm>=4.67.1
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: download-url
Dynamic: home-page
Dynamic: license
Dynamic: project-url
Dynamic: requires-dist
Dynamic: summary

# ctdecon

Reference-based cell type deconvolution in spatial transcriptomics.

Experiments were executed with PyTorch 2.1.0+cu121 on NVIDIA A40 with 46068MiB memory in linux environment.

## adata_utils

adata_utils file contains 4 functions, preprocess function selects highly variable genes from raw adata, then normalize, log1p, and scale adata or adata_sc(scRNA-seq). The spot_graph function constructs spot-to-spot interactive graph with is_sparse and n_neighbors, is_sparse controls the way of creating interactions matrix, then interaction of graph neighborhood and symmetrical adjacent save in adata.obsm. The contrast function generates contrastive label for spots and save in adata.obsm. The get_feature function augmentes features of adata by permutation after selecting highly variable genes with bool deconvolution and choose whether instance of adata is csc_matrix or csr_matrix.

## deconvo

deconvo file contains 1 class named config, which have train, train_sc, and train_map functions to learn representation of adata and adata_sc. Parameter device sets the device of training process, while learning_rate set for train function and learng_rate_sc set for train_sc function. Parameter dim_output is the output representation of adata, while alpha and beta act on loss functions combination of train function. The train_sc function evaluates loss with mse_loss, while lambda1 and lambda2 control the influence of reconstruction loss and contrastive loss in mapping matrix learning. Class config uses default True in deconvolution and False in is_sparse to control whether uses sparse data.

## reference

reference file contains 2 functions, overlap_gene function computes the overlap genes of adata and adata_sc, while cell2spot projects cell types onto spatial transcriptomics data using mapped matrix in adata.obsm. The overlap_gene function selects and saves overlap data by genes with spatial data and scRNA-seq reference data. The cell2spot function extracts top-k values for each spot with float retain_percent, and using map_matrix.dot(matrix_cell_type) as projection by spot-level. Final mapped results are saved in adata.obs by columns of projection dataframes.
