{"id":31805773,"url":"https://github.com/theislab/spatial_atlas_ssl","last_synced_at":"2025-10-11T02:58:23.126Z","repository":{"id":270341431,"uuid":"643937145","full_name":"theislab/spatial_atlas_ssl","owner":"theislab","description":"Self-supervised learning for mask inpainting on large spatial atlasses such as the BICCN 2.0 data.","archived":false,"fork":false,"pushed_at":"2023-11-08T09:23:33.000Z","size":20876,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-22T09:28:44.195Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","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/theislab.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,"publiccode":null,"codemeta":null}},"created_at":"2023-05-22T13:16:29.000Z","updated_at":"2025-02-18T16:23:36.000Z","dependencies_parsed_at":"2025-01-06T07:48:04.689Z","dependency_job_id":null,"html_url":"https://github.com/theislab/spatial_atlas_ssl","commit_stats":null,"previous_names":["theislab/spatial_atlas_ssl"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/theislab/spatial_atlas_ssl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theislab%2Fspatial_atlas_ssl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theislab%2Fspatial_atlas_ssl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theislab%2Fspatial_atlas_ssl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theislab%2Fspatial_atlas_ssl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theislab","download_url":"https://codeload.github.com/theislab/spatial_atlas_ssl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theislab%2Fspatial_atlas_ssl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005949,"owners_count":26084009,"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-10-11T02:00:06.511Z","response_time":55,"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":"2025-10-11T02:58:17.383Z","updated_at":"2025-10-11T02:58:23.121Z","avatar_url":"https://github.com/theislab.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpatialSSL: Whole-Brain Spatial Transcriptomics in the Mouse Brain with Self-Supervised Learning (NeurIPS 2023 AI for Science Workshop)\n\nLink to full paper:\nhttps://openreview.net/forum?id=bfD3Fzy7Mb\n\n### Authors\n\n- Till Richter\n- Anna Schaar\n- Francesca Drummer\n- Cheng Wei\n- Leopold Endres\n- Fabian Theis\n\n## Visual Abstract\n\n![visual abstract](images/visual_abstract.png)\n\n## Introduction\n\nSpatialSSL is a research project that explores different methods of self-supervised learning applied to spatial\ntranscriptomics data in the mouse brain. Self-supervised learning is a type of machine learning where models are trained\nto predict certain aspects of the data without explicit human annotations. The project focuses on modeling spatial data\nas graphs and applying graph-based machine learning and pretraining methods. The goal of this project is to analyse how\ndifferent pretrained models perform on downstream tasks.\n\n### Provided Data\n\nThe dataset used in SpatialSSL leverages the BICCN 2.0 [[1]](#1) dataset, which contains spatial data of approximately 4 million\nbrain cells, measuring the expression of 550 genes. Spatial transcriptomics data combines positional information (\nusually in the form of x-y coordinates) with gene expression for each cell. The dataset is organized into 59 \"images,\"\neach containing spatially independent cells. Depending on the annotation levels, there are 15, 30, or 35 different cell\ntypes present.\n\n### Dataset Construction - Two Methods\n\n1. **Create Single Graph for Each Image in the Dataset:**\n    - Parameters: Radius, threshold distance between cells to draw edges between them.\n    - This method results in relatively large graphs spanning from 30k to 60k nodes.\n\n2. **Splicing Graphs into Subgraphs Using Egonet of Each Node:**\n    - Parameters: Radius, threshold distance between cells to draw edges between them; k_hop: the number of \"hops\" for\n      subgraph creation.\n    - This method results in approximately 4 million small graphs, with the size depending on the radius and k_hop\n      parameters.\n\n### Masking Techniques for Pretraining\n\nFor both datasets, several masking methods were explored during the pretraining phase:\n\n- Masking all gene expression values of 20% of cells.\n- Masking specific cell types.\n\nIn the final experiments, we masked all gene expression values of 20% of cells.\n\n### Pretraining\n\nPretraining of the models was performed using graph neural networks with graph attention and convolution. The task was to reconstruct the masked gene expression values. \n\n\n### Downstream Task: Cell Type Prediction\n\nSpatialSSL develops various models, including both pre-trained models and models that are not pre-trained. Pre-trained weights are utilized for fine-tuning the model specifically for cell type prediction. Subsequently, the performance of these models is assessed in the context of predicting cell types based on gene expression values.\n\n## Citation\n\nIf you use this code or our paper in your research, please cite the following paper:\n```\n@inproceedings{\n   richter2023spatialssl,\n   title={Spatial{SSL}: Whole-Brain Spatial Transcriptomics in the Mouse Brain with Self-Supervised Learning},\n   author={Till Richter and Anna Schaar and Francesca Drummer and Cheng-Wei Liao and Leopold Endres and Fabian Theis},\n   booktitle={NeurIPS 2023 AI for Science Workshop},\n   year={2023},\n   url={https://openreview.net/forum?id=bfD3Fzy7Mb}\n}\n```\n\n## References\n\u003ca id=\"1\"\u003e[1]\u003c/a\u003e \nZhang M, Pan X, Jung W, Halpern A, Eichhorn SW, Lei Z, Cohen L, Smith KA, Tasic B, Yao Z, Zeng H, Zhuang X. A molecularly defined and spatially resolved cell atlas of the whole mouse brain. bioRxiv [Preprint]. 2023 Mar 7:2023.03.06.531348. doi: 10.1101/2023.03.06.531348. PMID: 36945367; PMCID: PMC10028822.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheislab%2Fspatial_atlas_ssl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheislab%2Fspatial_atlas_ssl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheislab%2Fspatial_atlas_ssl/lists"}