Skip to main content

Reference-based cell type deconvolution in spatial transcriptomics.

Project description

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.

Download files

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

Source Distribution

ctdecon-1.0.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

ctdecon-1.0.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file ctdecon-1.0.0.tar.gz.

File metadata

  • Download URL: ctdecon-1.0.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.4

File hashes

Hashes for ctdecon-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0098e3361ff0d40918b159635926746ccf9641df6950a4768231ec15ed2f0486
MD5 e91836f10dee3a7d18afbd38132d358c
BLAKE2b-256 badee24de5d27aaccf4cfd57f68a8e22acb58ff120af9f5f2d7eb2033d83bcfd

See more details on using hashes here.

File details

Details for the file ctdecon-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ctdecon-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.4

File hashes

Hashes for ctdecon-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a242b68312f47ad29200ada718d04430820c6ffddde449cda675340de99f6e55
MD5 c8b9ae56a11768b711894e95781e224d
BLAKE2b-256 18e32a9106aa8557005e03a472135ecdc150b2285dc708d941f64d30661e3258

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