danieltslz commited on
Commit
e64f90b
·
verified ·
1 Parent(s): fdcc3e9

Update curated CDS README documentation: data/embeddings/dnabert2_117m_cds/README.md

Browse files
data/embeddings/dnabert2_117m_cds/README.md CHANGED
@@ -1,40 +1,22 @@
1
- # dnabert2_117m_cds_v1_1
2
 
3
- Embedding ID: `dnabert2_117m_cds`
4
-
5
- Former processing ID: `dnabert2_117m_cds_v1_1`
 
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: `20085 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
 
@@ -42,28 +24,88 @@ assert X.shape[0] == len(genes)
42
  |---|---:|---:|---|---|
43
  | `ensembl_gene_id` | 20085 | 20085 | ENSG00000000003<br>ENSG00000000005<br>ENSG00000000419<br>ENSG00000000457 | Ensembl gene identifier; main stable identifier used to align genes across embeddings. |
44
  | `transcript_id` | 20085 | 20085 | ENST00000373020<br>ENST00000373031<br>ENST00000371588<br>ENST00000367771 | Transcript identifier used for sequence-based processing. |
45
- | `dnabert2_sequence_length` | 20085 | 2255 | 738<br>954<br>783<br>2067 | TODO: define this source-specific column during manual curation. |
46
  | `num_chunks` | 20085 | 19 | 1<br>2<br>3<br>4 | Number of chunks/windows used when the input was too long. |
47
  | `was_chunked` | 20085 | 2 | False<br>True | Whether the input sequence was split into chunks. |
48
 
49
- ## Basic metadata
50
 
51
- | Field | Value |
52
- |---|---|
53
- | `status` | processed_qc_passed |
54
- | `embedding_name` | dnabert2_117m_cds_v1_1 |
55
- | `pooling_strategy` | Mean pooling over final-layer non-special token embeddings. Long CDS sequences split into nucleotide chunks, then length-weighted mean of chunk-level embeddings. |
56
 
57
  ## Detailed processing notes
58
 
59
- TODO: manually paste and curate the processing explanation for this embedding from the central project README.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
- Please include, when relevant:
62
 
63
- - original source/model/checkpoint;
64
- - whether the embedding was downloaded or generated locally;
65
- - input data used;
66
- - identifier mapping and filtering decisions;
67
- - pooling, aggregation, PCA, or normalization method;
68
- - coverage and important caveats;
69
- - license or redistribution notes.
 
 
 
 
 
 
1
+ # Embedding name: DNABERT-2-117M-CDS
2
 
3
+ - Modality: DNA sequence / canonical CDS nucleotide language-model embedding
4
+ - Algorithm: Transformer genome language model
5
+ - Embedding source URL: Local generation from the canonical CDS sequence table prepared for NT-v2
6
+ - Original model/code URL: https://huggingface.co/zhihan1996/DNABERT-2-117M
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: `20085 genes × 768 dimensions`
17
  - Dtype: `float32`
 
 
 
 
 
 
 
18
 
 
19
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  ## genes.tsv columns
22
 
 
24
  |---|---:|---:|---|---|
25
  | `ensembl_gene_id` | 20085 | 20085 | ENSG00000000003<br>ENSG00000000005<br>ENSG00000000419<br>ENSG00000000457 | Ensembl gene identifier; main stable identifier used to align genes across embeddings. |
26
  | `transcript_id` | 20085 | 20085 | ENST00000373020<br>ENST00000373031<br>ENST00000371588<br>ENST00000367771 | Transcript identifier used for sequence-based processing. |
27
+ | `dnabert2_sequence_length` | 20085 | 2255 | 738<br>954<br>783<br>2067 | Length in nucleotides of the canonical CDS sequence used as DNABERT-2 input for this gene. |
28
  | `num_chunks` | 20085 | 19 | 1<br>2<br>3<br>4 | Number of chunks/windows used when the input was too long. |
29
  | `was_chunked` | 20085 | 2 | False<br>True | Whether the input sequence was split into chunks. |
30
 
 
31
 
 
 
 
 
 
32
 
33
  ## Detailed processing notes
34
 
35
+ ### Source and interpretation
36
+
37
+ This embedding is a gene-level canonical CDS representation derived from the DNABERT-2 117M genome language model. It was generated locally from the same canonical CDS sequence table used for NT-v2 and HyenaDNA, which was prepared from Ensembl release 114 GRCh38 CDS sequences and the canonical transcript IDs in master_gene_table.csv.
38
+
39
+ The model used was the official HuggingFace checkpoint `zhihan1996/DNABERT-2-117M`. For each matched gene, the canonical coding DNA sequence was tokenized with the DNABERT-2 tokenizer, embedded with the official custom model code, and summarized into one vector per gene by mean pooling final-layer non-special token embeddings. Long CDS sequences were split into 1,600 nt chunks and then combined with a sequence-length weighted mean.
40
+
41
+ This embedding should therefore be interpreted as a coding-DNA sequence language-model representation. It uses the same gene-level CDS input sequences as NT-v2 and HyenaDNA, so differences between these CDS embeddings mainly reflect model architecture, tokenizer, checkpoint, chunking, and pooling behaviour rather than differences in sequence selection.
42
+
43
+ ### Provenance fields
44
+
45
+ source_name: DNABERT-2 117M canonical CDS
46
+ original_model_or_method: DNABERT-2 genome language model
47
+ input_sequence_type: canonical coding DNA sequence
48
+ input_sequence_source: canonical CDS FASTA and metadata reused from the NT-v2 sequence-preparation workflow
49
+ genome_build: GRCh38
50
+ sequence_reference: Ensembl release 114 canonical CDS sequences prepared for NT-v2
51
+ model_checkpoint: zhihan1996/DNABERT-2-117M
52
+ model_url: https://huggingface.co/zhihan1996/DNABERT-2-117M
53
+ model_weight_sha256: 7ff39ec77a484dd01070a41bfd6e95cdd7247bec80fe357ab43a4be33687aeba
54
+ model_loading: official custom code with trust_remote_code=True
55
+ attention_workaround: force attention_probs_dropout_prob from 0.0 to 0.1 before model loading, then use model.eval()
56
+ model_output_dimension: 768
57
+ tokenizer: official DNABERT-2 tokenizer
58
+ chunk_nt: 1,600
59
+ max_tokens: 512
60
+ pooling_strategy: final-layer mean pooling over non-special tokens
61
+ long_sequence_handling: 1,600 nt chunks with sequence-length weighted mean across chunks
62
+ training_or_finetuning: none
63
+
64
+ ### Sequence and transcript decisions
65
+
66
+ The source gene set came from master_gene_table.csv. Canonical transcript IDs from the master table were already mapped to Ensembl release 114 GRCh38 CDS records during the NT-v2 sequence-preparation workflow. DNABERT-2 reused that exact CDS FASTA and metadata instead of preparing a separate sequence set.
67
+
68
+ The DNABERT-2 input TSV was created by merging the NT-v2 canonical CDS sequence metadata with the NT-v2 canonical CDS FASTA. All 20,085 sequences matched by transcript, with zero missing sequences and zero sequence-length mismatches.
69
+
70
+ Genes without a matched canonical CDS sequence in the reused CDS table were excluded from this embedding.
71
+
72
+ ### Processing workflow
73
+
74
+ For each gene in the reused canonical CDS table:
75
+
76
+ 1. Read the canonical CDS sequence prepared by the NT-v2 sequence workflow.
77
+ 2. Tokenize the CDS sequence with the official DNABERT-2 tokenizer.
78
+ 3. Load the official DNABERT-2 custom model code with trust_remote_code=True.
79
+ 4. Force attention_probs_dropout_prob from 0.0 to 0.1 before loading the model.
80
+ 5. Run the model in eval mode.
81
+ 6. Split long CDS sequences into 1,600 nt chunks.
82
+ 7. Mean-pool final-layer hidden states over non-special tokens.
83
+ 8. For chunked sequences, combine chunk vectors by sequence-length weighted mean.
84
+ 9. Save the final matrix as float32.
85
+
86
+ ### Important implementation decisions
87
+
88
+ The NT-v2 canonical CDS FASTA and metadata were reused intentionally. This avoids introducing a second CDS-selection procedure and makes DNABERT-2, NT-v2, and HyenaDNA easier to compare.
89
+
90
+ Plain BertConfig/BertModel loading was not used for the final output. That route appeared to run, but it initialized many encoder weights randomly, so it would not have produced a valid pretrained DNABERT-2 embedding.
91
+
92
+ The final run used the official custom DNABERT-2 code with trust_remote_code=True. In this environment, the original custom Triton FlashAttention path hung during smoke tests. The validated workaround was to set attention_probs_dropout_prob from 0.0 to 0.1 before model loading and then call model.eval(). This routed execution to the PyTorch attention path while keeping stochastic dropout disabled.
93
+
94
+ Long CDS sequences were chunked instead of truncated. This preserves information from the full canonical CDS sequence while staying within memory and model input constraints.
95
+
96
+ No model training or fine-tuning was performed. The final matrix was generated only by local inference from the official pretrained checkpoint.
97
 
98
+ ### Summary of final mapping:
99
 
100
+ Source identifiers / canonical CDS sequences: 20,085
101
+ Dimensions: 768
102
+ Rows generated before duplicate collapse: 20,085
103
+ Missing CDS genes: 12
104
+ Input TSV missing sequences: 0
105
+ Input TSV length mismatches: 0
106
+ Unmapped source rows: 0
107
+ Ambiguous source rows: 0
108
+ Final mapped genes: 20,085
109
+ Master table rows: 20,097
110
+ Master coverage: 99.940%
111
+ Duplicate final mappings averaged: 0