Views
No views yet
.h5ad files, remove low-quality cells, normalize expression counts to 10000,
and median normalize..h5ad file.<disease>, <tissue_type>, <sex>, <cell_type>) if needed.1git clone https://huggingface.co/Merck/TEDDY
2cd TEDDYpyenv to manage Python versions:1pyenv install 3.11.10
2pyenv local 3.11.10pyenv: pyenv documentation1curl -sSL https://install.python-poetry.org | python3 -
2export PATH="/PATH/TO/YOUR/USER/.local/bin:$PATH"pyenv which pythonpoetry env use /PATH/TO/YOUR/USER/.pyenv/versions/3.11.10/bin/python1poetry build
2poetry install.json with your parameters)from teddy.data_processing.preprocessing.preprocess import preprocess
preprocessing_config = {
"min_gene_counts": 225,
"remove_assays": ["10x5' v1", "10x3' v1"],
"max_mitochondrial_prop": 10,
"remove_cell_types": [],
"hvg_method": None,
"normalized_total": 10000,
"median_dict": "teddy/data_processing/utils/medians/data/teddy_gene_medians.json",
"log1p": False,
"compute_medians": False,
"median_column": "index",
"reference_id_only": False,
"load_dir": "<PATH_TO_RAW_DATA_PARENT>",
"save_dir": "<PATH_TO_PROCESSED_DATA_PARENT>",
}
preprocess(
data_path="data/RAW_SAMPLES/my_data.h5ad",
metadata_path="data/RAW_SAMPLES/my_data_metadata.json",
hyperparameters=preprocessing_config
)from teddy.data_processing.tokenization.tokenization import tokenize
tokenizer_config = {
"tokenizer_name_or_path": "teddy/models/teddy_g/400M",
"gene_id_column": "index",
"bio_annotations": True,
"disease_mapping": "teddy/data_processing/utils/bio_annotations/data/mappings/all_filtered_disease_mapping.json",
"tissue_mapping": "teddy/data_processing/utils/bio_annotations/data/mappings/all_filtered_tissue_mapping.json",
"cell_mapping": "teddy/data_processing/utils/bio_annotations/data/mappings/all_filtered_cell_mapping.json",
"sex_mapping": "teddy/data_processing/utils/bio_annotations/data/mappings/all_filtered_sex_mapping.json",
"max_shard_samples": 500,
"max_seq_len": 2048,
"pad_length": 2048,
"add_cls": False,
"bins": 0,
"continuous_rank": True,
"truncation_method": "max",
"add_disease_annotation": False,
"include_zero_genes": False,
"load_dir": "<PATH_TO_PROCESSED_DATA_PARENT>",
"save_dir": "<PATH_TO_TOKENIZED_DATA>"
}
tokenize(
data_path="outputs/preprocessed/my_data_preprocessed.h5ad",
metadata_path="outputs/preprocessed/my_data_preprocessed_metadata.json",
hyperparameters=tokenizer_config
)config.json and Running It with Bash{
"min_gene_counts": null,
"remove_assays": [],
"max_mitochondrial_prop": null,
"remove_cell_types": [],
"hvg_method": null,
"normalized_total": 10000,
"median_dict": "teddy/data_processing/utils/medians/data/teddy_gene_medians.json",
"log1p": false,
"compute_medians": false,
"median_column": "index",
"reference_id_only": false,
"load_dir": "<PATH_TO_RAW_DATA_PARENT>",
"save_dir": "<PATH_TO_PROCESSED_DATA_PARENT>"
}python teddy/data/preprocessing/preprocess.py \
--data_path data/RAW_SAMPLES/my_data.h5ad \
--metadata_path data/RAW_SAMPLES/my_data_metadata.json \
--config preprocess_config.json--config tokenize_config.json.).sh File and Executing It (With Poetry)#!/bin/bash -l
# (Optional) Activate your Poetry environment
poetry shell
# 1) Generate a JSON config file on the fly
cat <<EOF > configs/my_preprocess_config.json
{
"load_dir": "data",
"save_dir": "data/processed",
"min_gene_counts": null,
"remove_assays": [],
"max_mitochondrial_prop": null,
"remove_cell_types": [],
"hvg_method": null,
"normalized_total": null,
"median_dict": "teddy/data_processing/utils/medians/data/teddy_gene_medians.json",
"log1p": false,
"compute_medians": false,
"median_column": "index",
"reference_id_only": false
}
EOF
# 2) Call preprocess.py, explicitly passing data_path, metadata_path, and config_path
python teddy/data_processing/preprocessing/preprocess.py \
--data_path data/sample_data.h5ad \
--metadata_path data/sample_data_metadata.json \
--config_path my_preprocess_config.jsonchmod +x preprocess_sample_data.sh
./preprocess_sample_data.sh.json, or updating the Python dictionary.from teddy.models.model_directory import get_architecture, model_dict
model_name_or_path = 'teddy/models/teddy_g/400M' # or local path to model files
arch = get_architecture(model_name_or_path)
config_cls = model_dict[arch]["config_cls"]
model_cls = model_dict[arch]["model_cls"]
# Load the configuration and model
config = config_cls.from_pretrained(model_name_or_path)
model = model_cls.from_pretrained(model_name_or_path, config=config)
# model is now ready for inference or further fine-tuningscripts directory of this repository, sample code has been included with which to preprocess and tokenize the sample data in the data directory. To switch this out for your own data, simply replace the data within the data directory with your data and rename file paths within the scripts as needed.teddy-models repository.chmod +x scripts/*
./scripts/preprocess_sample_data.sh
./scripts/tokenize_sample_data.shpoetry run pytest. The tests should all pass, but receiving runtime warnings is expected behavior with the simulated data for the tests.@misc{chevalier2025teddyfamilyfoundationmodels,
title={TEDDY: A Family Of Foundation Models For Understanding Single Cell Biology},
author={Alexis Chevalier and Soumya Ghosh and Urvi Awasthi and James Watkins and Julia Bieniewska and Nichita Mitrea and Olga Kotova and Kirill Shkura and Andrew Noble and Michael Steinbaugh and Julien Delile and Christoph Meier and Leonid Zhukov and Iya Khalil and Srayanta Mukherjee and Judith Mueller},
year={2025},
eprint={2503.03485},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2503.03485},