Skip to main content

Single-cell cross-species cell type annotation tool using knowledge graph.

Project description

Xener

This is the public version, containing only the necessary code.

A cross-species single-cell cell type annotation tool using knowledge graph.

Installation

pip install .
# or
pip install xener

Quick Start

from xener import Xener

# Initialize
annor = Xener()

# Run full pipeline
cluster2celltype, _ = annor.run_from_yaml('config.yaml')

config.yaml example.

cluster_key: leiden
model_species:
- Brassica_rapa
non_model_fasta: Arabidopsis_thaliana.fasta
non_model_h5ad: ERP132245.h5ad
organ: leaf
outdir: output/ERP132245

Step-by-step

from xener import Xener
import scanpy as sc

annor = Xener()
adata = sc.read('ERP132245.h5ad')
cluster_key = 'leiden'
non_model_fasta = 'Arabidopsis_thaliana.fasta'
model_species = ['Brassica_rapa']
organ = 'leaf'
outdir = 'output/ERP132245'

marker_gene = annor.get_markers(adata, cluster_key)

marker_weight = annor.get_gene_weight(marker_gene)

gene_homolo_weight = annor.mapping(marker_weight, non_model_fasta, model_species, outdir)

topk_markers = annor.get_topk_gene(gene_homolo_weight, k=30)
# Only the top 30 genes will be retained for the subsequent steps.

cluster2celltype, _, celltype_weight, _, _ = annor.cell_annotation(
            topk_markers, annotation_info_path, organ)

Sub-cluster refinement

cluster_id = 0
candidate_celltype = ['type1', 'type2']# Only support the values that appear in celltype_weight[celltype_weight['cluster'] == cluster_id]['celltype'].unique()
key_added = 'xener_refine'
moranI_threshold = 0.5
# moranI_threshold used for gene screening, the effective value ranges from [-1, 1]. The closer to 1, the stricter it is. If an invalid value is input, the screening step will be skipped.

annor.refine_single_cluster(adata, topk_markers, 
            cluster_key, cluster_id, candidate_celltype, 
            key_added, organ, moranI_threshold)
# The results can be found in  adata.obs[key_added]

Links

Homepage: https://xenor.dcs.cloud/

pypi: https://pypi.org/project/xener

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

xener-0.1.2-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file xener-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: xener-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for xener-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 233dece9fafa6e9b03c6ab80f517a899c9c10ceb9beee933817b6927390c7903
MD5 19662574497274fe7f81629ec6f108e9
BLAKE2b-256 c188f3482f88408d0b6c19eab25bebbff7e4a25ab7b86da53755f796ad52eb95

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