{"id":22021745,"url":"https://github.com/lieberinstitute/scmeformer","last_synced_at":"2025-08-06T08:25:49.321Z","repository":{"id":233184774,"uuid":"786221933","full_name":"LieberInstitute/scMeformer","owner":"LieberInstitute","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-19T22:03:50.000Z","size":22000,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":5,"default_branch":"devel","last_synced_at":"2025-06-03T01:47:07.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LieberInstitute.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-04-13T19:36:34.000Z","updated_at":"2025-05-25T15:02:29.000Z","dependencies_parsed_at":"2024-04-14T12:15:14.064Z","dependency_job_id":null,"html_url":"https://github.com/LieberInstitute/scMeformer","commit_stats":null,"previous_names":["lieberinstitute/scmeformer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LieberInstitute/scMeformer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LieberInstitute%2FscMeformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LieberInstitute%2FscMeformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LieberInstitute%2FscMeformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LieberInstitute%2FscMeformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LieberInstitute","download_url":"https://codeload.github.com/LieberInstitute/scMeformer/tar.gz/refs/heads/devel","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LieberInstitute%2FscMeformer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269044784,"owners_count":24350264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T06:14:28.562Z","updated_at":"2025-08-06T08:25:49.271Z","avatar_url":"https://github.com/LieberInstitute.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"#\nThis repository contains source code of scMeformer for single cell DNAm data imputation.\n\n# Hardware requirements\nscMeformer package requires only a standard computer with GPUs and enough RAM to support the in-memory operations.\n\n\n# Software requirements\n## OS Requirements\nThis package is supported by Linux. The package has been tested on Rocky Linux 9.2.\n\n## Python Dependencies\nscMeformer mainly depends on the following Python packages. \u003cbr/\u003e\nPyTorch \u003cbr/\u003e\napex \u003cbr/\u003e\nnumpy \u003cbr/\u003e\nscipy \u003cbr/\u003e\nscikit-learn \u003cbr/\u003e\npandas \u003cbr/\u003e\nloompy \u003cbr/\u003e\njson \u003cbr/\u003e\nh5py\n\n# Usage\n\n## 1. Clustering\n\n### 1.1. Calculate DNAm levels for each 100kb bin and cluster cells based on DNAm levels of 100kb bins.\n\n### Example\n```bash\nClusters all cells for a brain sample (Br1092)\n\n$python clustering.py Br1092\n\n```\n\n### 1.2. Calculate cluster features for each CpG site based on cell clusters produced by step 1.1\n\n### Example\n```bash\nConstruct training data and calculate cluster features for a brain sample (Br1092)\n\n$python run_feature.py Br1092\n\n```\n\n\n## 2. Training\n\n### 2.1. Train DNAm prediction model using single cell data. We trained a prediction model for each brain sample. \n\n### Example\n```bash\ntrain the DNAm prediction model for one brain sample (Br1092) using four GPUs\n\nCUDA_VISIBLE_DEVICES=0,1,2,3 python3 -m torch.distributed.launch main.py transformer single_cell_regression \\\n\t--exp_name single_cell_regression \\\n\t--learning_rate 0.000176 \\\n\t--batch_size 128 \\\n\t--data_dir ./datasets/Schizo_Control/Br1092 \\\n\t--output_dir ./outputs/Schizo_Control/Br1092 \\\n\t--warmup_steps 10000 \\\n\t--gradient_accumulation_steps 1 \\\n\t--fp16 --local_rank 0 \\\n\t--nproc_per_node 4 \\\n\t--model_config_file ./config/config.json\n```\n\"num_features\" and \"task_size\" in \"./config/schizo_control/Br1092/config.json\" denote the numbers of clusters and cells in the brain sample (Br1092).\n\n## 3. Prediction\n\n### 3.1. Predicts DNAm levels of CpGs from DNA sequence using one GPU.\n### Example\n```bash\npredict DNAm levels of CpGs for all cells in a brain sample (Br1092) using the trained model\n\nCUDA_VISIBLE_DEVICES=0 python3 main.py transformer single_cell_prediction \\\n\t--exp_name single_cell_prediction \\\n\t--batch_size 1024 \\\n\t--learning_rate 0.000176 \\\n\t--fp16 \\\n\t--warmup_steps 10000 \\\n\t--gradient_accumulation_steps 1 \\\n\t--data_dir ./datasets/genome_cpg \\\n\t--output_dir ./outputs/prediction/schizo_control/Br1092/chr1 \\\n\t--num_train_epochs 500 \\\n\t--model_config_file ./config/config.json \\\n\t--from_pretrained ./outputs/Schizo_Control/Br1092 \\\n\t--split chr1\n```\n\n## 4. Demo\n\n### 4.1 Training data from snmCAT-seq data include following four files:\n\n#### 4.1.1 ./scMeformer/datasets/methylation_data/chr1.json contains 10000 CpGs and each CpG have five keys: \n(1) chromosome \u003cbr/\u003e\n(2) position \u003cbr/\u003e\n(3) strand \u003cbr/\u003e\n(4) cells that are methylated at the CpG site \u003cbr/\u003e\n(5) that are unmethylated at the CpG site \u003cbr/\u003e\n\n#### 4.1.2 ./scMeformer/datasets/feature_data/chr1.npy contains DNAm levels of 89 clusters for above 10000 CpGs\n\n#### 4.1.3 ./scMeformer/datasets/genome/chr1.npy contains one-hot encoded genome sequences covering above 10000 CpGs\n\n#### 4.1.4 ./scMeformer/datasets/position/chr1.npy provides the index of each CpG in ./scMeformer/datasets/feature_data/chr1.npy by its position.\n\n\n### 4.2 Validation and test data include CpGs on chromosomes 21 and 22, respectively. Both include four files of the same format with training data.\n\n#### 4.2.1 Both validation and test data consist of 2000 CpGs.\n\n### 4.3 Train DNAm imputation model by this demo data.\n\n```bash\n\nCUDA_VISIBLE_DEVICES=0,1,2,3 python3 -m torch.distributed.launch main.py transformer single_cell_regression \\\n        --exp_name single_cell_regression \\\n        --learning_rate 0.000176 \\\n        --batch_size 128 \\\n        --data_dir ./datasets/ \\\n        --output_dir ./scMeformer/outputs/demo_model \\\n        --warmup_steps 10000 \\\n        --gradient_accumulation_steps 1 \\\n        --fp16 --local_rank 0 \\\n        --nproc_per_node 4 \\\n        --model_config_file ./config/config.json\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flieberinstitute%2Fscmeformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flieberinstitute%2Fscmeformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flieberinstitute%2Fscmeformer/lists"}