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.1.tar.gz (10.4 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.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ctdecon-1.0.1.tar.gz
  • Upload date:
  • Size: 10.4 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.1.tar.gz
Algorithm Hash digest
SHA256 a6802e27e956edc27b33ca025af1255e7ff06e115c3606fe32b2f410b609c78b
MD5 dde338abb684c5403b8de4a53536b80d
BLAKE2b-256 c73058f1058a5e7217769c00af70d03f383e5f682792330692ffb293b28c1dc5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ctdecon-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a3400328c7671211ff0f4588cfed211815eec842a755352104183138fd40f6c7
MD5 149be4f92ad07d900b6ccba4fbcc4a50
BLAKE2b-256 15dccdc843b24e1c41a86b7ed810c13923f59edadfdf6ec25b71fa00a8e1b1da

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