Update curated single-cell model README documentation: data/embeddings/genecompass_base_gene_token/README.md
Browse files
data/embeddings/genecompass_base_gene_token/README.md
CHANGED
|
@@ -1,40 +1,22 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
## Public files
|
| 8 |
|
| 9 |
- `embeddings.npz`: compressed NumPy archive containing the embedding matrix under key `embeddings`.
|
| 10 |
- `genes.tsv`: row metadata table. Row order matches the embedding matrix.
|
| 11 |
- `metadata.json`: machine-readable provenance and processing metadata.
|
| 12 |
-
- `README.md`: this per-embedding documentation file.
|
| 13 |
|
| 14 |
## Matrix
|
| 15 |
|
| 16 |
- Shape: `16578 genes × 768 dimensions`
|
| 17 |
- Dtype: `float32`
|
| 18 |
-
- NPZ array key: `embeddings`
|
| 19 |
-
|
| 20 |
-
The row order is authoritative:
|
| 21 |
-
|
| 22 |
-
```text
|
| 23 |
-
embeddings.npz['embeddings'][i, :] corresponds to genes.tsv row i
|
| 24 |
-
```
|
| 25 |
-
|
| 26 |
-
## Loading example
|
| 27 |
|
| 28 |
-
```python
|
| 29 |
-
import numpy as np
|
| 30 |
-
import pandas as pd
|
| 31 |
|
| 32 |
-
with np.load('embeddings.npz') as z:
|
| 33 |
-
X = z['embeddings']
|
| 34 |
-
|
| 35 |
-
genes = pd.read_csv('genes.tsv', sep='\t')
|
| 36 |
-
assert X.shape[0] == len(genes)
|
| 37 |
-
```
|
| 38 |
|
| 39 |
## genes.tsv columns
|
| 40 |
|
|
@@ -45,31 +27,105 @@ assert X.shape[0] == len(genes)
|
|
| 45 |
| `gene_symbol` | 16578 | 16578 | TSPAN6<br>TNMD<br>DPM1<br>SCYL3 | Gene symbol associated with the Ensembl gene ID. |
|
| 46 |
| `entrez_id` | 16556 | 16557 | 7105<br>64102<br>8813<br>57147 | NCBI Entrez Gene identifier, when available. |
|
| 47 |
| `uniprot_id` | 16565 | 16474 | O43657<br>Q9H2S6<br>O60762<br>Q8IZE3 | UniProt accession or identifier, when available. |
|
| 48 |
-
| `genecompass_token_id` | 16578 | 16578 | 16789<br>13066<br>11603<br>22048 |
|
| 49 |
| `status` | 16578 | 1 | mapped_exact_ensembl_gene_id | Processing or QC status for this row. |
|
| 50 |
|
| 51 |
-
## Basic metadata
|
| 52 |
|
| 53 |
-
| Field | Value |
|
| 54 |
-
|---|---|
|
| 55 |
-
| `status` | processed_qc_passed |
|
| 56 |
-
| `modality` | gene expression single-cell foundation model / knowledge-informed gene-token embedding |
|
| 57 |
-
| `embedding_name` | genecompass_base_gene_token_v1_1 |
|
| 58 |
-
| `download_source` | official GeneCompass ScienceDB checkpoint linked from official GitHub README |
|
| 59 |
-
| `original_model_or_method` | GeneCompass Base, 12-layer knowledge-informed cross-species foundation model |
|
| 60 |
-
| `embedding_generated_by` | Daniel locally by extracting checkpoint embedding weights; no training or inference |
|
| 61 |
-
| `pooling_strategy` | none; static learned token embedding weight extracted directly from checkpoint |
|
| 62 |
|
| 63 |
## Detailed processing notes
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Embedding name: GeneCompass-Base-gene-token
|
| 2 |
|
| 3 |
+
- Modality: Single-cell expression foundation model / knowledge-informed learned gene-token embedding
|
| 4 |
+
- Algorithm: Transformer gene-token embedding table extraction
|
| 5 |
+
- Embedding source URL: https://github.com/xCompass-AI/GeneCompass
|
| 6 |
+
- Original model/code URL: https://github.com/xCompass-AI/GeneCompass
|
| 7 |
|
| 8 |
## Public files
|
| 9 |
|
| 10 |
- `embeddings.npz`: compressed NumPy archive containing the embedding matrix under key `embeddings`.
|
| 11 |
- `genes.tsv`: row metadata table. Row order matches the embedding matrix.
|
| 12 |
- `metadata.json`: machine-readable provenance and processing metadata.
|
|
|
|
| 13 |
|
| 14 |
## Matrix
|
| 15 |
|
| 16 |
- Shape: `16578 genes × 768 dimensions`
|
| 17 |
- Dtype: `float32`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
## genes.tsv columns
|
| 22 |
|
|
|
|
| 27 |
| `gene_symbol` | 16578 | 16578 | TSPAN6<br>TNMD<br>DPM1<br>SCYL3 | Gene symbol associated with the Ensembl gene ID. |
|
| 28 |
| `entrez_id` | 16556 | 16557 | 7105<br>64102<br>8813<br>57147 | NCBI Entrez Gene identifier, when available. |
|
| 29 |
| `uniprot_id` | 16565 | 16474 | O43657<br>Q9H2S6<br>O60762<br>Q8IZE3 | UniProt accession or identifier, when available. |
|
| 30 |
+
| `genecompass_token_id` | 16578 | 16578 | 16789<br>13066<br>11603<br>22048 | GeneCompass token ID from human_mouse_tokens.pickle. |
|
| 31 |
| `status` | 16578 | 1 | mapped_exact_ensembl_gene_id | Processing or QC status for this row. |
|
| 32 |
|
|
|
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
## Detailed processing notes
|
| 36 |
|
| 37 |
+
### Source and interpretation
|
| 38 |
+
|
| 39 |
+
This embedding is a gene-level knowledge-informed single-cell foundation-model representation extracted from the official GeneCompass Base checkpoint. It was generated locally by extracting the fixed learned gene-token embedding table from the checkpoint.
|
| 40 |
+
|
| 41 |
+
The source vocabulary is the GeneCompass `human_mouse_tokens.pickle` dictionary, which contains a mixed human/mouse Ensembl-gene vocabulary plus special tokens. The retained output maps human GeneCompass gene tokens to master_gene_table.csv and stores one fixed vector per mapped gene.
|
| 42 |
+
|
| 43 |
+
This embedding should therefore be interpreted as a static GeneCompass gene-token embedding. It is not a contextual embedding averaged over cells and it is not one of the small downstream task-specific `GeneCompass-emb-0708.npy` files.
|
| 44 |
+
|
| 45 |
+
### Provenance fields
|
| 46 |
+
|
| 47 |
+
source_name: GeneCompass Base gene-token embedding
|
| 48 |
+
original_model_or_method: GeneCompass Base
|
| 49 |
+
input_data_type: official pretrained single-cell foundation-model checkpoint
|
| 50 |
+
embedding_generated_by: local extraction from official checkpoint gene-token embedding table
|
| 51 |
+
source_code_page: https://github.com/xCompass-AI/GeneCompass
|
| 52 |
+
raw_source_folder: ~/data/raw_embeddings/genecompass_v1_1/official_repo/
|
| 53 |
+
official_repository_commit_used_locally: 66ab82f90fa94f88613df7d89a2fb38165e2a82f
|
| 54 |
+
checkpoint_folder: pretrained_models/GeneCompass_Base/
|
| 55 |
+
checkpoint_files_retained: config.json, generation_config.json, pytorch_model.bin, training_args.bin
|
| 56 |
+
config_json_md5: 079a73a36316add7db0b4159dccdcbc4
|
| 57 |
+
generation_config_json_md5: a19745d9fa4bc315dd14703da7cc06c2
|
| 58 |
+
pytorch_model_bin_md5: 77719f3af27b3d3359032bf4ae315652
|
| 59 |
+
training_args_bin_md5: d446e3f18497732e19544b667e5a5671
|
| 60 |
+
token_dictionary: prior_knowledge/human_mouse_tokens.pickle
|
| 61 |
+
token_dictionary_entries: 50,558
|
| 62 |
+
special_tokens: <pad>=0, <mask>=1
|
| 63 |
+
source_identifier_type: Ensembl gene IDs in mixed human/mouse GeneCompass vocabulary
|
| 64 |
+
mapping_identifier_type: Ensembl gene ID matched to master_gene_table.csv
|
| 65 |
+
architecture: BertForMaskedLM
|
| 66 |
+
model_type: bert
|
| 67 |
+
checkpoint_model: GeneCompass_Base, 12-layer GeneCompass
|
| 68 |
+
vocab_size: 50,558
|
| 69 |
+
hidden_size: 768
|
| 70 |
+
num_hidden_layers: 12
|
| 71 |
+
num_attention_heads: 12
|
| 72 |
+
intermediate_size: 3,072
|
| 73 |
+
max_position_embeddings: 2,048
|
| 74 |
+
use_promoter: True
|
| 75 |
+
use_co_exp: True
|
| 76 |
+
use_gene_family: True
|
| 77 |
+
use_peca_grn: True
|
| 78 |
+
use_values: True
|
| 79 |
+
embedding_key: bert.embeddings.word_embeddings.weight
|
| 80 |
+
raw_tensor_shape: 50,558 x 768
|
| 81 |
+
model_output_dimension: 768
|
| 82 |
+
pooling_strategy: none; static learned token embedding weight extracted directly from checkpoint
|
| 83 |
+
training_or_finetuning: none
|
| 84 |
+
model_inference: none
|
| 85 |
+
final_embedding_dtype: float32
|
| 86 |
+
|
| 87 |
+
### Mapping and extraction decisions
|
| 88 |
+
|
| 89 |
+
GeneCompass source tokens were mapped to master_gene_table.csv using Ensembl gene IDs from `human_mouse_tokens.pickle`. Exact master-table Ensembl IDs were tried first. If needed, version suffixes were stripped.
|
| 90 |
+
|
| 91 |
+
Special tokens `<pad>` and `<mask>` were excluded. Only valid unique gene token IDs were accepted.
|
| 92 |
+
|
| 93 |
+
The bundled downstream-task files named `GeneCompass-emb-0708.npy` were inspected but not used. They are 1,582 x 256 task-specific contextual gene embeddings from downstream datasets, not the full GeneCompass vocabulary. The retained v1.1 embedding instead extracts the full checkpoint gene-token embedding matrix from GeneCompass_Base.
|
| 94 |
+
|
| 95 |
+
### Processing workflow
|
| 96 |
+
|
| 97 |
+
For the GeneCompass embedding:
|
| 98 |
+
|
| 99 |
+
1. Download or stage the official GeneCompass repository and GeneCompass_Base checkpoint.
|
| 100 |
+
2. Verify retained checkpoint files and MD5 hashes.
|
| 101 |
+
3. Load prior_knowledge/human_mouse_tokens.pickle.
|
| 102 |
+
4. Load pytorch_model.bin from the GeneCompass_Base checkpoint.
|
| 103 |
+
5. Extract bert.embeddings.word_embeddings.weight.
|
| 104 |
+
6. Exclude special tokens <pad> and <mask>.
|
| 105 |
+
7. Map GeneCompass Ensembl gene tokens to master_gene_table.csv.
|
| 106 |
+
8. Accept only valid unique token-to-master mappings.
|
| 107 |
+
9. Save the mapped matrix as float32.
|
| 108 |
+
|
| 109 |
+
### Important implementation decisions
|
| 110 |
+
|
| 111 |
+
The final output is a static checkpoint gene-token embedding extraction. It is not generated by running GeneCompass on a new single-cell expression dataset.
|
| 112 |
+
|
| 113 |
+
The smaller `GeneCompass-emb-0708.npy` files were not used because they are downstream task-specific contextual embeddings and do not cover the full GeneCompass gene vocabulary.
|
| 114 |
+
|
| 115 |
+
GeneCompass has lower coverage than Geneformer because the mixed human/mouse vocabulary and token dictionary map to fewer human master-table protein-coding genes under the strict unique-mapping rules.
|
| 116 |
+
|
| 117 |
+
### Summary of final mapping:
|
| 118 |
+
|
| 119 |
+
Source identifiers / GeneCompass token dictionary entries: 50,558
|
| 120 |
+
Raw embedding table shape: 50,558 x 768
|
| 121 |
+
Dimensions: 768
|
| 122 |
+
Final mapped genes: 16,578
|
| 123 |
+
Master table rows: 20,097
|
| 124 |
+
Missing master genes: 3,519
|
| 125 |
+
Master coverage: 82.490%
|
| 126 |
+
Special tokens excluded: <pad>, <mask>
|
| 127 |
+
NaN count: 0
|
| 128 |
+
Inf count: 0
|
| 129 |
+
Zero vectors: 0
|
| 130 |
+
Duplicated Ensembl IDs: 0
|
| 131 |
+
Duplicated GeneCompass token IDs: 0
|