danieltslz commited on
Commit
8411cfe
·
verified ·
1 Parent(s): f11deb6

Update curated KG README documentation: data/embeddings/primekg_nonppi_biomedical_context_tfidf_svd256/README.md

Browse files
data/embeddings/primekg_nonppi_biomedical_context_tfidf_svd256/README.md CHANGED
@@ -1,40 +1,22 @@
1
- # PrimeKG-nonPPI-biomedical-context-TFIDF-SVD256-v1.1
2
 
3
- Embedding ID: `primekg_nonppi_biomedical_context_tfidf_svd256`
4
-
5
- Former processing ID: `primekg_nonppi_biomedical_context_tfidf_svd256_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: `19216 genes × 256 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
 
@@ -44,29 +26,102 @@ assert X.shape[0] == len(genes)
44
  | `ensembl_gene_id` | 19216 | 19216 | ENSG00000000003<br>ENSG00000000005<br>ENSG00000000419<br>ENSG00000000457 | Ensembl gene identifier; main stable identifier used to align genes across embeddings. |
45
  | `gene_symbol` | 19216 | 19190 | TSPAN6<br>TNMD<br>DPM1<br>SCYL3 | Gene symbol associated with the Ensembl gene ID. |
46
  | `gene_type` | 19216 | 1 | protein_coding | Gene biotype, usually protein_coding. |
47
- | `entrez_id` | 19216 | 19181 | 7105<br>64102<br>8813<br>57147 | NCBI Entrez Gene identifier, when available. |
48
  | `uniprot_id` | 19209 | 19039 | O43657<br>Q9H2S6<br>O60762<br>Q8IZE3 | UniProt accession or identifier, when available. |
49
- | `source_entrez_id` | 19216 | 19181 | 7105<br>64102<br>8813<br>57147 | Entrez Gene identifier from the original source before final mapping. |
50
  | `source_gene_symbol` | 19216 | 19181 | TSPAN6<br>TNMD<br>DPM1<br>SCYL3 | Original gene symbol from the source before final mapping. |
51
 
52
- ## Basic metadata
53
 
54
- | Field | Value |
55
- |---|---|
56
- | `status` | processed_qc_passed |
57
- | `modality` | heterogeneous biomedical knowledge graph / non-PPI gene context |
58
- | `embedding_name` | PrimeKG-nonPPI-biomedical-context-TFIDF-SVD256-v1.1 |
59
 
60
  ## Detailed processing notes
61
 
62
- TODO: manually paste and curate the processing explanation for this embedding from the central project README.
63
-
64
- Please include, when relevant:
65
-
66
- - original source/model/checkpoint;
67
- - whether the embedding was downloaded or generated locally;
68
- - input data used;
69
- - identifier mapping and filtering decisions;
70
- - pooling, aggregation, PCA, or normalization method;
71
- - coverage and important caveats;
72
- - license or redistribution notes.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Embedding name: PrimeKG-nonPPI-biomedical-context-TFIDF-SVD256
2
 
3
+ - Modality: Heterogeneous biomedical knowledge graph / non-PPI gene context
4
+ - Algorithm: Typed biomedical-neighbor TF-IDF with randomized TruncatedSVD256
5
+ - Embedding source URL: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/IXA7BM
6
+ - Original model/code URL: Not applicable; source is a biomedical knowledge graph edge list, not a model/code release
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: `19216 genes × 256 dimensions`
17
  - Dtype: `float32`
 
 
 
 
 
 
 
 
 
18
 
 
 
 
19
 
 
 
 
 
 
 
20
 
21
  ## genes.tsv columns
22
 
 
26
  | `ensembl_gene_id` | 19216 | 19216 | ENSG00000000003<br>ENSG00000000005<br>ENSG00000000419<br>ENSG00000000457 | Ensembl gene identifier; main stable identifier used to align genes across embeddings. |
27
  | `gene_symbol` | 19216 | 19190 | TSPAN6<br>TNMD<br>DPM1<br>SCYL3 | Gene symbol associated with the Ensembl gene ID. |
28
  | `gene_type` | 19216 | 1 | protein_coding | Gene biotype, usually protein_coding. |
29
+ | `entrez_id` | 19216 | 19181 | 7105<br>64102<br>8813<br>57147 | NCBI Entrez Gene identifier mapped from the source knowledge-graph gene node. |
30
  | `uniprot_id` | 19209 | 19039 | O43657<br>Q9H2S6<br>O60762<br>Q8IZE3 | UniProt accession or identifier, when available. |
31
+ | `source_entrez_id` | 19216 | 19181 | 7105<br>64102<br>8813<br>57147 | Original Entrez Gene identifier from the PrimeKG gene/protein node before final master-table mapping. |
32
  | `source_gene_symbol` | 19216 | 19181 | TSPAN6<br>TNMD<br>DPM1<br>SCYL3 | Original gene symbol from the source before final mapping. |
33
 
 
34
 
 
 
 
 
 
35
 
36
  ## Detailed processing notes
37
 
38
+ ### Source and interpretation
39
+
40
+ This embedding is a gene-level heterogeneous biomedical knowledge-graph context representation derived from PrimeKG. It was generated locally from the PrimeKG `kg.csv` edge list and mapped to master_gene_table.csv using Entrez gene identifiers interpreted from PrimeKG gene/protein endpoints.
41
+
42
+ The goal was not to make another PPI embedding. Direct gene-gene or PPI-like edges were excluded. Instead, each gene was represented by its typed non-gene biomedical neighbors, such as anatomy/tissue expression context, biological process, cellular component, disease, molecular function, pathway, drug, phenotype, and exposure entities. The resulting sparse gene x biomedical-context matrix was weighted with sublinear TF-IDF, reduced to 256 dimensions with randomized TruncatedSVD, and z-scored across genes.
43
+
44
+ This embedding should therefore be interpreted as a broader biomedical-context prior for each gene. It is complementary to Node2Vec-consensus-PPI, which remains the dedicated PPI-only graph embedding.
45
+
46
+ ### Provenance fields
47
+
48
+ source_name: PrimeKG non-PPI biomedical context
49
+ original_model_or_method: PrimeKG heterogeneous biomedical knowledge graph
50
+ input_data_type: biomedical knowledge-graph edge list
51
+ input_source_file: kg.csv
52
+ source_download_page: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/IXA7BM
53
+ source_docs_or_code: https://github.com/mims-harvard/PrimeKG
54
+ source_file_size: 937 MB
55
+ total_source_rows_read: 8,100,498
56
+ included_nonppi_gene_context_edges: 3,978,158
57
+ excluded_both_gene_ppi_like_edges: 642,150
58
+ excluded_no_gene_endpoint_edges: 3,480,190
59
+ source_genes_with_context: 27,460
60
+ typed_biomedical_context_features: 35,897
61
+ sparse_matrix_nnz_after_duplicate_collapse: 1,989,079
62
+ sparse_matrix_density: 0.00201787
63
+ feature_definition: relation + display_relation + neighbor_type + neighbor_id
64
+ weighting: sublinear TF-IDF
65
+ dimensionality_reduction: randomized TruncatedSVD
66
+ svd_components: 256
67
+ svd_total_explained_variance_ratio: 0.577759
68
+ transformation_after_svd: z-score SVD dimensions across source genes
69
+ source_identifier_type: PrimeKG gene/protein x_id/y_id interpreted as NCBI Entrez Gene ID
70
+ mapping_identifier_type: Entrez Gene ID matched to master_gene_table.csv
71
+ final_embedding_dtype: float32
72
+
73
+ ### Mapping and graph-processing decisions
74
+
75
+ PrimeKG gene/protein node identifiers in `x_id` or `y_id` were interpreted as NCBI Entrez Gene IDs and mapped to `entrez_id` in master_gene_table.csv.
76
+
77
+ Only edges with exactly one gene/protein endpoint were retained. Edges where both endpoints were genes/proteins were excluded to avoid duplicating direct PPI or gene-gene graph information already represented by the dedicated PPI embedding. Edges with no gene/protein endpoint were also excluded because they cannot directly define a gene-level vector.
78
+
79
+ Each retained edge was converted into a typed biomedical context feature using the relation, display relation, neighbor type, and neighbor identifier. Duplicate gene-feature observations were collapsed by summation before TF-IDF weighting.
80
+
81
+ The final output keeps distinct master-table Ensembl rows even when some rows share the same Entrez ID. This preserves alignment with master_gene_table.csv.
82
+
83
+ ### Processing workflow
84
+
85
+ For the PrimeKG embedding:
86
+
87
+ 1. Read PrimeKG kg.csv in chunks.
88
+ 2. Identify edges with exactly one gene/protein endpoint.
89
+ 3. Exclude edges where both endpoints are genes/proteins.
90
+ 4. Exclude edges with no gene/protein endpoint.
91
+ 5. Interpret gene/protein endpoint IDs as NCBI Entrez Gene IDs.
92
+ 6. Define typed biomedical context features as relation + display_relation + neighbor_type + neighbor_id.
93
+ 7. Build a sparse gene x typed-biomedical-context count matrix.
94
+ 8. Collapse duplicate gene-feature edges by summation.
95
+ 9. Apply sublinear TF-IDF weighting.
96
+ 10. Reduce to 256 dimensions with randomized TruncatedSVD.
97
+ 11. Z-score SVD dimensions across source genes.
98
+ 12. Map source Entrez IDs to master_gene_table.csv.
99
+ 13. Save the final matrix as float32.
100
+
101
+ ### Important implementation decisions
102
+
103
+ This embedding was deliberately processed as a non-PPI biomedical-context representation. Direct gene-gene or PPI-like edges were excluded so that PrimeKG adds information beyond the existing PPI-only graph embedding.
104
+
105
+ TF-IDF was used because some biomedical context features are very common. Sublinear TF-IDF downweights generic high-frequency neighbors while retaining informative typed biomedical context.
106
+
107
+ Randomized TruncatedSVD was used because the intermediate gene x context matrix is sparse and high-dimensional. The 256-dimensional output is compact while preserving a reproducible KG-derived signal.
108
+
109
+ ### Summary of final mapping:
110
+
111
+ Source identifiers / PrimeKG rows read: 8,100,498
112
+ Included non-PPI gene-context edges: 3,978,158
113
+ Excluded both-gene/PPI-like edges: 642,150
114
+ Excluded no-gene-endpoint edges: 3,480,190
115
+ Source genes with at least one included context edge: 27,460
116
+ Typed biomedical context features: 35,897
117
+ Sparse matrix nnz after duplicate collapse: 1,989,079
118
+ Dimensions before SVD: 35,897
119
+ Dimensions after SVD: 256
120
+ SVD total explained variance ratio: 0.577759
121
+ Rows generated before duplicate collapse: 19,216
122
+ Unique final Entrez IDs: 19,181
123
+ Duplicated Entrez master rows retained: 35
124
+ Final mapped genes: 19,216
125
+ Master table rows: 20,097
126
+ Master coverage: 95.616%
127
+ Duplicate final mappings averaged: 0