add _new_datasets (#2)
Browse files- git lfs track new datasets (6f33aef1b1084c2f366ab6fcde05c403511f1ab5)
- add new datasets (e5de966305a3236ebc83263aa73141d98a23209e)
- refactor vep causal eqtl name (fb5e83ea8c8da8784c60c3466547b6947f473443)
- refactor folder name (0e903895e3f050c79d2d7ac3844a2d7e17781219)
- update files to be lfs tracked (98eadaf1a715eed8381c32f3c30e9a5d6899c7f8)
- update main loader script for new datasets (ca412e99e53c186014c69a30e05756f35c4d4024)
- fix file path for causal eqtl data (561af90663da0da6aaee642622e0b661744e742a)
- fix file names for pathogenic datasets (cc38ba3856a08d6401eeff1a36fe5b8dafc1cfe1)
- fix label naming chromatin features (461969927800e16441b1362f60613ed4cb74f12f)
- fix cage file path naming (07eece405aaeb544ff18813d84f9374152352ea8)
- update loading script (1575e22e185371f31365424ed36ba54a547910ff)
- update readme for additional datasets (46d85ff2b9ed6819b26d06fc35d9651d60e51abc)
- update README (66099dcefd0a4c704f334718dafb33c23fefbf74)
- update the return values for cage and regulatory elements (634eabc0c55af9cfa443b4caea908949a20514e3)
- update readme for return values (2f79d04a93ddddeae89b3ad72c9f6c47fc8b5549)
- update the return values for cage (4504d2df698616dd2ed3f3300b7925e6c3036152)
- missing punctuation (ea6154d266f23abce923a09961af9cdc2164e41b)
- .gitattributes +10 -0
- README.md +215 -57
- chromatin_features/histones_and_dnase.csv +3 -0
- chromatin_features/histones_and_dnase_subset.csv +3 -0
- genomics-long-range-benchmark.py +422 -56
- regulatory_elements/enhancer_dataset.csv +3 -0
- regulatory_elements/enhancer_dataset_subset.csv +3 -0
- regulatory_elements/promoter_dataset.csv +3 -0
- regulatory_elements/promoter_dataset_subset.csv +3 -0
- variant_effect_causal_eqtl/All_Tissues.csv +3 -0
- variant_effect_gene_expression/All_Tissues.csv +0 -0
- variant_effect_pathogenic/vep_pathogenic_coding.csv +3 -0
- variant_effect_pathogenic/vep_pathogenic_non_coding.csv +3 -0
- variant_effect_pathogenic/vep_pathogenic_non_coding_subset.csv +3 -0
|
@@ -54,3 +54,13 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 56 |
rna_expression_values.csv filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 56 |
rna_expression_values.csv filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
chromatin_features/histones_and_dnase_subset.csv filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
chromatin_features/histones_and_dnase.csv filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
regulatory_elements/enhancer_dataset.csv filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
regulatory_elements/enhancer_dataset_subset.csv filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
regulatory_elements/promoter_dataset.csv filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
regulatory_elements/promoter_dataset_subset.csv filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
variant_effect_pathogenic/vep_pathogenic_coding.csv filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
variant_effect_pathogenic/vep_pathogenic_non_coding.csv filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
variant_effect_pathogenic/vep_pathogenic_non_coding_subset.csv filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
variant_effect_causal_eqtl/All_Tissues.csv filter=lfs diff=lfs merge=lfs -text
|
|
@@ -3,30 +3,40 @@ license: cc-by-nc-sa-4.0
|
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
tags:
|
| 6 |
-
-
|
| 7 |
-
-
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
viewer: false
|
| 10 |
---
|
| 11 |
|
| 12 |
## Summary
|
| 13 |
-
The motivation of the genomics long
|
|
|
|
| 14 |
While serving as a strong basis of evaluation, the benchmark must also be efficient and user-friendly.
|
| 15 |
To achieve this we strike a balance between task complexity and computational cost through strategic decisions, such as down-sampling or combining datasets.
|
| 16 |
|
| 17 |
-
##
|
| 18 |
-
The Genomics LRB is a collection of tasks which can be loaded by passing in the
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
*Note that as you increase the context length to very large numbers you may start to reduce the size of the dataset since a large context size may
|
| 22 |
cause indexing outside the boundaries of chromosomes.
|
| 23 |
|
| 24 |
-
|
|
| 25 |
-
|
| 26 |
-
|
|
| 27 |
-
|
|
| 28 |
-
| Variant Effect
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
## Usage Example
|
| 32 |
```python
|
|
@@ -35,8 +45,13 @@ from datasets import load_dataset
|
|
| 35 |
# Use this parameter to download sequences of arbitrary length (see docs below for edge cases)
|
| 36 |
sequence_length=2048
|
| 37 |
|
| 38 |
-
# One of
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
dataset = load_dataset(
|
| 42 |
"InstaDeepAI/genomics-long-range-benchmark",
|
|
@@ -46,20 +61,128 @@ dataset = load_dataset(
|
|
| 46 |
|
| 47 |
```
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
|
|
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
#### Source
|
| 57 |
-
Original CAGE data comes from FANTOM5. We used processed labeled data obtained from
|
|
|
|
|
|
|
| 58 |
Sequence data originates from the GRCh38 genome assembly.
|
| 59 |
|
| 60 |
#### Data Processing
|
| 61 |
The original dataset from the Basenji paper includes labels for 638 CAGE total tracks over 896 bins (each bin corresponding to 128 base pairs)
|
| 62 |
-
totaling over ~70 GB. In the interest of dataset size and user
|
|
|
|
| 63 |
From the 638 CAGE tracks, 50 of these tracks are selected with the following criteria:
|
| 64 |
|
| 65 |
1. Only select one cell line
|
|
@@ -67,6 +190,7 @@ From the 638 CAGE tracks, 50 of these tracks are selected with the following cri
|
|
| 67 |
3. Only select one donor
|
| 68 |
|
| 69 |
The [896 bins, 50 tracks] labels total in at ~7 GB. A description of the 50 included CAGE tracks can be found here `cage_prediction/label_mapping.csv`.
|
|
|
|
| 70 |
|
| 71 |
#### Task Structure
|
| 72 |
|
|
@@ -75,7 +199,7 @@ Because this task involves predicting expression levels for 128bp bins and there
|
|
| 75 |
you request a sequence length smaller than 114,688 bps than the labels will be subsetted.
|
| 76 |
|
| 77 |
Task Args:<br>
|
| 78 |
-
`sequence_length`: an
|
| 79 |
|
| 80 |
Input: a genomic nucleotide sequence<br>
|
| 81 |
Output: a variable length vector depending on the requested sequence length [requested_sequence_length / 128, 50]
|
|
@@ -84,30 +208,36 @@ Output: a variable length vector depending on the requested sequence length [req
|
|
| 84 |
Train/Test splits were maintained from Basenji and Enformer where randomly sampling was used to generate the splits. Note that for this dataset a validation set is also returned. In practice we merged the validation
|
| 85 |
set with the train set and use cross validation to select a new train and validation set from this combined set.
|
| 86 |
|
| 87 |
-
#### Metrics
|
| 88 |
-
Mean Pearson correlation across tracks - compute Pearson correlation for a track using all positions for all genes in the test set, then mean over all tracks <br>
|
| 89 |
-
Mean Pearson correlation across genes - compute Pearson correlation for a gene using all positions and all tracks, then mean over all genes in the test set <br>
|
| 90 |
-
R<sup>2</sup>
|
| 91 |
-
|
| 92 |
|
| 93 |
---
|
| 94 |
|
| 95 |
-
###
|
| 96 |
-
|
|
|
|
|
|
|
| 97 |
|
| 98 |
#### Source
|
| 99 |
Original data comes from GTEx. We use processed data files from the [ExPecto paper](https://www.nature.com/articles/s41588-018-0160-6) found
|
| 100 |
[here](https://github.com/FunctionLab/ExPecto/tree/master/resources). Sequence data originates from the GRCh37/hg19 genome assembly.
|
| 101 |
|
| 102 |
#### Data Processing
|
| 103 |
-
The
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
#### Task Structure
|
| 106 |
|
| 107 |
Type: Multi-variable regression<br>
|
| 108 |
|
| 109 |
Task Args:<br>
|
| 110 |
-
`sequence_length`: an
|
| 111 |
|
| 112 |
Input: a genomic nucleotide sequence centered around the CAGE representative trancription start site<br>
|
| 113 |
Output: a 218 length vector of continuous values corresponding to the bulk RNA expression levels in 218 different tissue types
|
|
@@ -116,42 +246,70 @@ Output: a 218 length vector of continuous values corresponding to the bulk RNA e
|
|
| 116 |
Train: chromosomes 1-7,9-22,X,Y<br>
|
| 117 |
Test: chromosome 8
|
| 118 |
|
| 119 |
-
#### Metrics
|
| 120 |
-
Mean Spearman correlation across tissues <br>
|
| 121 |
-
Mean Spearman correlation across genes <br>
|
| 122 |
-
R<sup>2</sup>
|
| 123 |
-
|
| 124 |
---
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
In genomics, a key objective is to predict how genetic variants affect gene expression in specific cell types.
|
| 128 |
|
| 129 |
#### Source
|
| 130 |
-
Original data comes from
|
| 131 |
-
Sequence data originates from the
|
| 132 |
|
| 133 |
#### Data Processing
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
#### Task Structure
|
| 141 |
|
| 142 |
-
Type:
|
| 143 |
|
| 144 |
Task Args:<br>
|
| 145 |
-
`sequence_length`: an
|
|
|
|
| 146 |
|
| 147 |
-
Input: a genomic nucleotide sequence centered on the
|
| 148 |
-
Output: a
|
| 149 |
|
| 150 |
#### Splits
|
| 151 |
-
Train: chromosomes 1-
|
| 152 |
-
Test: chromosomes 9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
-
####
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
tags:
|
| 6 |
+
- Genomics
|
| 7 |
+
- Benchmarks
|
| 8 |
+
- Language Models
|
| 9 |
+
- DNA
|
| 10 |
+
pretty_name: Genomics Long-Range Benchmark
|
| 11 |
viewer: false
|
| 12 |
---
|
| 13 |
|
| 14 |
## Summary
|
| 15 |
+
The motivation of the genomics long-range benchmark (LRB) is to compile a set of
|
| 16 |
+
biologically relevant genomic tasks requiring long-range dependencies which will act as a robust evaluation tool for genomic language models.
|
| 17 |
While serving as a strong basis of evaluation, the benchmark must also be efficient and user-friendly.
|
| 18 |
To achieve this we strike a balance between task complexity and computational cost through strategic decisions, such as down-sampling or combining datasets.
|
| 19 |
|
| 20 |
+
## Benchmark Tasks
|
| 21 |
+
The Genomics LRB is a collection of nine tasks which can be loaded by passing in the
|
| 22 |
+
corresponding `task_name` into the `load_dataset` function. All of the following datasets
|
| 23 |
+
allow the user to specify an arbitrarily long sequence length, giving more context
|
| 24 |
+
to the task, by passing the `sequence_length` kwarg to `load_dataset`. Additional task
|
| 25 |
+
specific kwargs, if applicable, are mentioned in the sections below.<br>
|
| 26 |
*Note that as you increase the context length to very large numbers you may start to reduce the size of the dataset since a large context size may
|
| 27 |
cause indexing outside the boundaries of chromosomes.
|
| 28 |
|
| 29 |
+
| Task | `task_name` | Sample Output | ML Task Type | # Outputs | # Train Seqs | # Test Seqs | Data Source |
|
| 30 |
+
|-------|-------------|-------------------------------------------------------------------------------------------|-------------------------|-------------|--------------|----------- |----------- |
|
| 31 |
+
| Variant Effect Causal eQTL | `variant_effect_causal_eqtl` | {ref sequence, alt sequence, label, tissue, chromosome,position, distance to nearest TSS} | SNP Classification | 1 | 88717 | 8846 | GTEx (via [Enformer](https://www.nature.com/articles/s41592-021-01252-x)) |
|
| 32 |
+
| Variant Effect Pathogenic ClinVar | `variant_effect_pathogenic_clinvar` | {ref sequence, alt sequence, label, chromosome, position} | SNP Classification | 1 | 38634 | 1018 | ClinVar, gnomAD (via [GPN-MSA](https://www.biorxiv.org/content/10.1101/2023.10.10.561776v1)) |
|
| 33 |
+
| Variant Effect Pathogenic OMIM | `variant_effect_pathogenic_omim` | {ref sequence, alt sequence, label,chromosome, position} | SNP Classification | 1 | - | 2321473 |OMIM, gnomAD (via [GPN-MSA](https://www.biorxiv.org/content/10.1101/2023.10.10.561776v1)) |
|
| 34 |
+
| CAGE Prediction | `cage_prediction` | {sequence, labels, chromosome,label_start_position,label_stop_position} | Binned Regression | 50 per bin | 33891 | 1922 | FANTOM5 (via [Basenji](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1008050)) |
|
| 35 |
+
| Bulk RNA Expression | `bulk_rna_expression` | {sequence, labels, chromosome,position} | Seq-wise Regression | 218 | 22827 | 990 | GTEx, FANTOM5 (via [ExPecto](https://www.nature.com/articles/s41588-018-0160-6)) |
|
| 36 |
+
| Chromatin Features Histone_Marks | `chromatin_features_histone_marks` | {sequence, labels,chromosome, position, label_start_position,label_stop_position} | Seq-wise Classification | 20 | 2203689 | 227456 | ENCODE, Roadmap Epigenomics (via [DeepSea](https://pubmed.ncbi.nlm.nih.gov/30013180/) |
|
| 37 |
+
| Chromatin Features DNA_Accessibility | `chromatin_features_dna_accessibility` | {sequence, labels,chromosome, position, label_start_position,label_stop_position} | Seq-wise Classification | 20 | 2203689 | 227456 | ENCODE, Roadmap Epigenomics (via [DeepSea](https://pubmed.ncbi.nlm.nih.gov/30013180/)) |
|
| 38 |
+
| Regulatory Elements Promoter | `regulatory_element_promoter` | {sequence, label,chromosome, start, stop, label_start_position,label_stop_position} | Seq-wise Classification | 1| 953376 | 96240 | SCREEN |
|
| 39 |
+
| Regulatory Elements Enhancer | `regulatory_element_enhancer` | {sequence, label,chromosome, start, stop, label_start_position,label_stop_position} | Seq-wise Classification | 1| 1914575 | 192201 | SCREEN |
|
| 40 |
|
| 41 |
## Usage Example
|
| 42 |
```python
|
|
|
|
| 45 |
# Use this parameter to download sequences of arbitrary length (see docs below for edge cases)
|
| 46 |
sequence_length=2048
|
| 47 |
|
| 48 |
+
# One of:
|
| 49 |
+
# ["variant_effect_causal_eqtl","variant_effect_pathogenic_clinvar",
|
| 50 |
+
# "variant_effect_pathogenic_omim","cage_prediction", "bulk_rna_expression",
|
| 51 |
+
# "chromatin_features_histone_marks","chromatin_features_dna_accessibility",
|
| 52 |
+
# "regulatory_element_promoter","regulatory_element_enhancer"]
|
| 53 |
+
|
| 54 |
+
task_name = "variant_effect_causal_eqtl"
|
| 55 |
|
| 56 |
dataset = load_dataset(
|
| 57 |
"InstaDeepAI/genomics-long-range-benchmark",
|
|
|
|
| 61 |
|
| 62 |
```
|
| 63 |
|
| 64 |
+
### 1. Variant Effect Causal eQTL
|
| 65 |
+
Predicting the effects of genetic variants, particularly expression quantitative trait loci (eQTLs), is essential for understanding the molecular basis of several diseases.
|
| 66 |
+
eQTLs are genomic loci that are associated with variations in mRNA expression levels among individuals.
|
| 67 |
+
By linking genetic variants to causal changes in mRNA expression, researchers can
|
| 68 |
+
uncover how certain variants contribute to disease development.
|
| 69 |
+
|
| 70 |
+
#### Source
|
| 71 |
+
Original data comes from GTEx. Processed data in the form of vcf files for positive
|
| 72 |
+
and negative variants across 49 different tissue types were obtained from the
|
| 73 |
+
[Enformer paper](https://www.nature.com/articles/s41592-021-01252-x) located [here](https://console.cloud.google.com/storage/browser/dm-enformer/data/gtex_fine/vcf?pageState=%28%22StorageObjectListTable%22:%28%22f%22:%22%255B%255D%22%29%29&prefix=&forceOnObjectsSortingFiltering=false).
|
| 74 |
+
Sequence data originates from the GRCh38 genome assembly.
|
| 75 |
+
|
| 76 |
+
#### Data Processing
|
| 77 |
+
Fine-mapped GTEx eQTLs originate from [Wang et al](https://www.nature.com/articles/s41467-021-23134-8), while the negative matched set of
|
| 78 |
+
variants comes from [Avsec et al](https://www.nature.com/articles/s41592-021-01252-x)
|
| 79 |
+
. The statistical fine-mapping tool SuSiE was used to label variants.
|
| 80 |
+
Variants from the fine-mapped eQTL set were selected and given positive labels if
|
| 81 |
+
their posterior inclusion probability was > 0.9,
|
| 82 |
+
as assigned by SuSiE. Variants from the matched negative set were given negative labels if their
|
| 83 |
+
posterior inclusion probability was < 0.01.
|
| 84 |
+
|
| 85 |
+
#### Task Structure
|
| 86 |
+
|
| 87 |
+
Type: Binary classification<br>
|
| 88 |
+
|
| 89 |
+
Task Args:<br>
|
| 90 |
+
`sequence_length`: an integer type, the desired final sequence length<br>
|
| 91 |
+
|
| 92 |
+
Input: a genomic nucleotide sequence centered on the SNP with the reference allele at the SNP location, a genomic nucleotide sequence centered on the SNP with the alternative allele at the SNP location, and tissue type<br>
|
| 93 |
+
Output: a binary value referring to whether the variant has a causal effect on gene
|
| 94 |
+
expression
|
| 95 |
+
|
| 96 |
+
#### Splits
|
| 97 |
+
Train: chromosomes 1-8, 11-22, X, Y<br>
|
| 98 |
+
Test: chromosomes 9,10
|
| 99 |
+
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
### 2. Variant Effect Pathogenic ClinVar
|
| 103 |
+
A coding variant refers to a genetic alteration that occurs within the protein-coding regions of the genome, also known as exons.
|
| 104 |
+
Such alterations can impact protein structure, function, stability, and interactions
|
| 105 |
+
with other molecules, ultimately influencing cellular processes and potentially contributing to the development of genetic diseases.
|
| 106 |
+
Predicting variant pathogenicity is crucial for guiding research into disease mechanisms and personalized treatment strategies, enhancing our ability to understand and manage genetic disorders effectively.
|
| 107 |
+
|
| 108 |
+
#### Source
|
| 109 |
+
Original data comes from ClinVar and gnomAD. However, we use processed data files
|
| 110 |
+
from the [GPN-MSA paper](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC10592768/)
|
| 111 |
+
located [here](https://huggingface.co/datasets/songlab/human_variants/blob/main/test.parquet).
|
| 112 |
+
Sequence data originates from the GRCh38 genome assembly.
|
| 113 |
+
|
| 114 |
+
#### Data Processing
|
| 115 |
+
Positive labels correspond to pathogenic variants originating from ClinVar whose review status was
|
| 116 |
+
described as having at least a single submitted record with a classification but without assertion criteria.
|
| 117 |
+
The negative set are variants that are defined as common from gnomAD. gnomAD version 3.1.2 was downloaded and filtered to variants with allele number of at least 25,000. Common
|
| 118 |
+
variants were defined as those with MAF > 5%.
|
| 119 |
+
|
| 120 |
+
#### Task Structure
|
| 121 |
+
|
| 122 |
+
Type: Binary classification<br>
|
| 123 |
+
|
| 124 |
+
Task Args:<br>
|
| 125 |
+
`sequence_length`: an integer type, the desired final sequence length<br>
|
| 126 |
+
|
| 127 |
+
Input: a genomic nucleotide sequence centered on the SNP with the reference allele at the SNP location, a genomic nucleotide sequence centered on the SNP with the alternative allele at the SNP location<br>
|
| 128 |
+
Output: a binary value referring to whether the variant is pathogenic or not
|
| 129 |
+
|
| 130 |
+
#### Splits
|
| 131 |
+
Train: chromosomes 1-7, 9-22, X, Y<br>
|
| 132 |
+
Test: chromosomes 8
|
| 133 |
+
|
| 134 |
+
---
|
| 135 |
+
|
| 136 |
+
### 3. Variant Effect Pathogenic OMIM
|
| 137 |
+
Predicting the effects of regulatory variants on pathogenicity is crucial for understanding disease mechanisms.
|
| 138 |
+
Elements that regulate gene expression are often located in non-coding regions, and variants in these areas can disrupt normal cellular function, leading to disease.
|
| 139 |
+
Accurate predictions can identify biomarkers and therapeutic targets, enhancing personalized medicine and genetic risk assessment.
|
| 140 |
+
|
| 141 |
+
#### Source
|
| 142 |
+
Original data comes from the Online Mendelian Inheritance in Man (OMIM) and gnomAD
|
| 143 |
+
databases.
|
| 144 |
+
However, we use processed data files from the
|
| 145 |
+
[GPN-MSA paper](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC10592768/) located [here](
|
| 146 |
+
https://huggingface.co/datasets/songlab/omim/blob/main/test.parquet).
|
| 147 |
+
Sequence data originates from the GRCh38 genome assembly.
|
| 148 |
+
|
| 149 |
+
#### Data Processing
|
| 150 |
+
Positive labeled data originates from a curated set of pathogenic variants located
|
| 151 |
+
in the Online Mendelian Inheritance in Man (OMIM) catalog. The negative set is
|
| 152 |
+
composed of variants that are defined as common from gnomAD. gnomAD version 3.1.2 was downloaded and filtered to variants with
|
| 153 |
+
allele number of at least 25,000. Common variants were defined as those with minor allele frequency
|
| 154 |
+
(MAF) > 5%.
|
| 155 |
|
| 156 |
+
#### Task Structure
|
| 157 |
|
| 158 |
+
Type: Binary classification<br>
|
| 159 |
+
|
| 160 |
+
Task Args:<br>
|
| 161 |
+
`sequence_length`: an integer type, the desired final sequence length<br>
|
| 162 |
+
`subset`: a boolean type, whether to use the full dataset or a subset of the dataset (we provide this option as the full dataset has millions of samples)
|
| 163 |
+
|
| 164 |
+
Input: a genomic nucleotide sequence centered on the SNP with the reference allele at the SNP location, a genomic nucleotide sequence centered on the SNP with the alternative allele at the SNP location<br>
|
| 165 |
+
Output: a binary value referring to whether the variant is pathogenic or not
|
| 166 |
+
|
| 167 |
+
#### Splits
|
| 168 |
+
Test: all chromosomes
|
| 169 |
+
|
| 170 |
+
---
|
| 171 |
+
|
| 172 |
+
### 4. CAGE Prediction
|
| 173 |
+
CAGE provides accurate high-throughput measurements of RNA expression by mapping TSSs at a nucleotide-level resolution.
|
| 174 |
+
This is vital for detailed mapping of TSSs, understanding gene regulation mechanisms, and obtaining quantitative expression data to study gene activity comprehensively.
|
| 175 |
|
| 176 |
#### Source
|
| 177 |
+
Original CAGE data comes from FANTOM5. We used processed labeled data obtained from
|
| 178 |
+
the [Basenji paper](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5932613/) which
|
| 179 |
+
also used to train Enformer and is located [here](https://console.cloud.google.com/storage/browser/basenji_barnyard/data/human?pageState=%28%22StorageObjectListTable%22:%28%22f%22:%22%255B%255D%22%29%29&prefix=&forceOnObjectsSortingFiltering=false).
|
| 180 |
Sequence data originates from the GRCh38 genome assembly.
|
| 181 |
|
| 182 |
#### Data Processing
|
| 183 |
The original dataset from the Basenji paper includes labels for 638 CAGE total tracks over 896 bins (each bin corresponding to 128 base pairs)
|
| 184 |
+
totaling over ~70 GB. In the interest of dataset size and user-friendliness, only a
|
| 185 |
+
subset of the labels are selected.
|
| 186 |
From the 638 CAGE tracks, 50 of these tracks are selected with the following criteria:
|
| 187 |
|
| 188 |
1. Only select one cell line
|
|
|
|
| 190 |
3. Only select one donor
|
| 191 |
|
| 192 |
The [896 bins, 50 tracks] labels total in at ~7 GB. A description of the 50 included CAGE tracks can be found here `cage_prediction/label_mapping.csv`.
|
| 193 |
+
*Note the data in this repository for this task has not already been log(1+x) normalized.
|
| 194 |
|
| 195 |
#### Task Structure
|
| 196 |
|
|
|
|
| 199 |
you request a sequence length smaller than 114,688 bps than the labels will be subsetted.
|
| 200 |
|
| 201 |
Task Args:<br>
|
| 202 |
+
`sequence_length`: an integer type, the desired final sequence length, *must be a multiple of 128 given the binned nature of labels<br>
|
| 203 |
|
| 204 |
Input: a genomic nucleotide sequence<br>
|
| 205 |
Output: a variable length vector depending on the requested sequence length [requested_sequence_length / 128, 50]
|
|
|
|
| 208 |
Train/Test splits were maintained from Basenji and Enformer where randomly sampling was used to generate the splits. Note that for this dataset a validation set is also returned. In practice we merged the validation
|
| 209 |
set with the train set and use cross validation to select a new train and validation set from this combined set.
|
| 210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
---
|
| 213 |
|
| 214 |
+
### 5. Bulk RNA Expression
|
| 215 |
+
Gene expression involves the process by which information encoded in a gene directs the synthesis of a functional gene product, typically a protein, through transcription and translation.
|
| 216 |
+
Transcriptional regulation determines the amount of mRNA produced, which is then translated into proteins. Developing a model that can predict RNA expression levels solely from sequence
|
| 217 |
+
data is crucial for advancing our understanding of gene regulation, elucidating disease mechanisms, and identifying functional sequence variants.
|
| 218 |
|
| 219 |
#### Source
|
| 220 |
Original data comes from GTEx. We use processed data files from the [ExPecto paper](https://www.nature.com/articles/s41588-018-0160-6) found
|
| 221 |
[here](https://github.com/FunctionLab/ExPecto/tree/master/resources). Sequence data originates from the GRCh37/hg19 genome assembly.
|
| 222 |
|
| 223 |
#### Data Processing
|
| 224 |
+
The authors of ExPecto determined representative TSS for Pol II transcribed genes
|
| 225 |
+
based on quantification of CAGE reads from the FANTOM5 project. The specific procedure they used is as
|
| 226 |
+
follows, a CAGE peak was associated to a GENCODE gene if it was withing 1000 bps from a
|
| 227 |
+
GENCODE v24 annotated TSS. The most abundant CAGE peak for each gene was then selected
|
| 228 |
+
as the representative TSS. When no CAGE peak could be assigned to a gene, the annotated gene
|
| 229 |
+
start position was used as the representative TSS. We log(1 + x) normalized then standardized the
|
| 230 |
+
RNA-seq counts before training models. A list of names of tissues corresponding to
|
| 231 |
+
the labels can be found here: `bulk_rna_expression/label_mapping.csv`. *Note the
|
| 232 |
+
data in this repository for this task has already been log(1+x) normalized and
|
| 233 |
+
standardized to mean 0 and unit variance.
|
| 234 |
|
| 235 |
#### Task Structure
|
| 236 |
|
| 237 |
Type: Multi-variable regression<br>
|
| 238 |
|
| 239 |
Task Args:<br>
|
| 240 |
+
`sequence_length`: an integer type, the desired final sequence length<br>
|
| 241 |
|
| 242 |
Input: a genomic nucleotide sequence centered around the CAGE representative trancription start site<br>
|
| 243 |
Output: a 218 length vector of continuous values corresponding to the bulk RNA expression levels in 218 different tissue types
|
|
|
|
| 246 |
Train: chromosomes 1-7,9-22,X,Y<br>
|
| 247 |
Test: chromosome 8
|
| 248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
---
|
| 250 |
+
### 6. Chromatin Features
|
| 251 |
+
Predicting chromatin features, such as histone marks and DNA accessibility, is crucial for understanding gene regulation, as these features indicate chromatin state and are essential for transcription activation.
|
|
|
|
| 252 |
|
| 253 |
#### Source
|
| 254 |
+
Original data used to generate labels for histone marks and DNase profiles comes from the ENCODE and Roadmap Epigenomics project. We used processed data files from the [Deep Sea paper](https://www.nature.com/articles/nmeth.3547) to build this dataset.
|
| 255 |
+
Sequence data originates from the GRCh37/hg19 genome assembly.
|
| 256 |
|
| 257 |
#### Data Processing
|
| 258 |
+
The authors of DeepSea processed the data by chunking the human genome
|
| 259 |
+
into 200 bp bins where for each bin labels were determined for hundreds of different chromatin
|
| 260 |
+
features. Only bins with at least one transcription factor binding event were
|
| 261 |
+
considered for the dataset. If the bin overlapped with a peak region of the specific
|
| 262 |
+
chromatin profile by more than half of the
|
| 263 |
+
sequence, a positive label was assigned. DNA sequences were obtained from the human reference
|
| 264 |
+
genome assembly GRCh37. To make the dataset more accessible, we randomly sub-sampled the
|
| 265 |
+
chromatin profiles from 125 to 20 tracks for the histones dataset and from 104 to 20 tracks for the
|
| 266 |
+
DNA accessibility dataset.
|
| 267 |
|
| 268 |
#### Task Structure
|
| 269 |
|
| 270 |
+
Type: Multi-label binary classification
|
| 271 |
|
| 272 |
Task Args:<br>
|
| 273 |
+
`sequence_length`: an integer type, the desired final sequence length<br>
|
| 274 |
+
`subset`: a boolean type, whether to use the full dataset or a subset of the dataset (we provide this option as the full dataset has millions of samples)
|
| 275 |
|
| 276 |
+
Input: a genomic nucleotide sequence centered on the 200 base pair bin that is associated with the labels<br>
|
| 277 |
+
Output: a vector of length 20 with binary entries
|
| 278 |
|
| 279 |
#### Splits
|
| 280 |
+
Train set: chromosomes 1-7,10-22<br>
|
| 281 |
+
Test set: chromosomes 8,9
|
| 282 |
+
|
| 283 |
+
---
|
| 284 |
+
### 7. Regulatory Elements
|
| 285 |
+
Cis-regulatory elements, such as promoters and enhancers, control the spatial and temporal expression of genes.
|
| 286 |
+
These elements are essential for understanding gene regulation mechanisms and how genetic variations can lead to differences in gene expression.
|
| 287 |
+
|
| 288 |
+
#### Source
|
| 289 |
+
Original data annotations to build labels came from the Search Candidate cis-Regulatory Elements by ENCODE project. Sequence data originates from the GRCh38
|
| 290 |
+
genome assembly.
|
| 291 |
|
| 292 |
+
#### Data Processing
|
| 293 |
+
The data is processed as follows, we break the human
|
| 294 |
+
reference genome into 200 bp non-overlapping chunks. If the 200 bp chunk overlaps by at least 50%
|
| 295 |
+
or more with a contiguous region from the set of annotated cis-regulatory elements (promoters or
|
| 296 |
+
enhancers), we label them as positive, else the chunk is labeled as negative. The resulting dataset
|
| 297 |
+
was composed of ∼15M negative samples and ∼50k positive promoter samples and ∼1M positive
|
| 298 |
+
enhancer samples. We randomly sub-sampled the negative set to 1M samples, and kept
|
| 299 |
+
all positive
|
| 300 |
+
samples, to make this dataset more manageable in size.
|
| 301 |
+
|
| 302 |
+
#### Task Structure
|
| 303 |
+
|
| 304 |
+
Type: Binary classification
|
| 305 |
+
|
| 306 |
+
Task Args:<br>
|
| 307 |
+
`sequence_length`: an integer type, the desired final sequence length<br>
|
| 308 |
+
`subset`: a boolean type, whether to use the full dataset or a subset of the dataset (we provide this option as the full dataset has millions of samples)
|
| 309 |
+
|
| 310 |
+
Input: a genomic nucleotide sequence centered on the 200 base pair bin that is associated with the label<br>
|
| 311 |
+
Output: a single binary value
|
| 312 |
+
|
| 313 |
+
#### Splits
|
| 314 |
+
Train set: chromosomes 1-7,10-22<br>
|
| 315 |
+
Test set: chromosomes 8,9
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d6cc04691aca70c876018f15463ba697ddd790af8acda7bbdf14417a3032d153
|
| 3 |
+
size 356382794
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e5a63d4067cd0f1da65aecb6b1ed0a2e1beb19a104f61bfc06ca401b0c14dc14
|
| 3 |
+
size 47732536
|
|
@@ -14,14 +14,12 @@ import pandas as pd
|
|
| 14 |
from datasets import DatasetInfo
|
| 15 |
from pyfaidx import Fasta
|
| 16 |
from abc import ABC, abstractmethod
|
| 17 |
-
|
| 18 |
-
from Bio import SeqIO
|
| 19 |
-
import pysam
|
| 20 |
|
| 21 |
"""
|
| 22 |
-
|
| 23 |
Reference Genome URLS:
|
| 24 |
-
|
| 25 |
"""
|
| 26 |
H38_REFERENCE_GENOME_URL = (
|
| 27 |
"https://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/" "hg38.fa.gz"
|
|
@@ -31,9 +29,9 @@ H19_REFERENCE_GENOME_URL = (
|
|
| 31 |
)
|
| 32 |
|
| 33 |
"""
|
| 34 |
-
|
| 35 |
Task Specific Handlers:
|
| 36 |
-
|
| 37 |
"""
|
| 38 |
|
| 39 |
class GenomicLRATaskHandler(ABC):
|
|
@@ -97,8 +95,8 @@ class GenomicLRATaskHandler(ABC):
|
|
| 97 |
|
| 98 |
def download_and_extract_gz(self, file_url, cache_dir_root):
|
| 99 |
"""
|
| 100 |
-
Downloads and extracts a gz file into the given cache directory. Returns the
|
| 101 |
-
of the extracted gz file.
|
| 102 |
Args:
|
| 103 |
file_url: url of the gz file to be downloaded and extracted.
|
| 104 |
cache_dir_root: Directory to extract file into.
|
|
@@ -138,29 +136,30 @@ class CagePredictionHandler(GenomicLRATaskHandler):
|
|
| 138 |
50,
|
| 139 |
) # 50 is a subset of CAGE tracks from the original enformer dataset
|
| 140 |
NPZ_SPLIT = 1000 # number of files per npz file.
|
| 141 |
-
NUM_BP_PER_BIN = 128
|
| 142 |
|
| 143 |
def __init__(self, sequence_length=DEFAULT_LENGTH, **kwargs):
|
| 144 |
"""
|
| 145 |
Creates a new handler for the CAGE task.
|
| 146 |
Args:
|
| 147 |
-
sequence_length: allows for increasing sequence context. Sequence length
|
| 148 |
-
|
|
|
|
| 149 |
"""
|
| 150 |
self.reference_genome = None
|
| 151 |
self.coordinate_csv_file = None
|
| 152 |
self.target_files_by_split = {}
|
| 153 |
|
|
|
|
| 154 |
assert (sequence_length // 128) % 2 == 0, (
|
| 155 |
-
f"Requested sequence length must be an even multuple of 128 to align
|
|
|
|
| 156 |
)
|
| 157 |
|
| 158 |
self.sequence_length = sequence_length
|
| 159 |
|
| 160 |
if self.sequence_length < self.DEFAULT_LENGTH:
|
| 161 |
-
|
| 162 |
-
self.TARGET_SHAPE = (self.sequence_length//128,50)
|
| 163 |
-
|
| 164 |
|
| 165 |
def get_info(self, description: str) -> DatasetInfo:
|
| 166 |
"""
|
|
@@ -174,7 +173,11 @@ class CagePredictionHandler(GenomicLRATaskHandler):
|
|
| 174 |
# array of sequence length x num_labels
|
| 175 |
"labels": datasets.Array2D(shape=self.TARGET_SHAPE, dtype="float32"),
|
| 176 |
# chromosome number
|
| 177 |
-
"chromosome":datasets.Value(dtype="string")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
}
|
| 179 |
)
|
| 180 |
return datasets.DatasetInfo(
|
|
@@ -192,7 +195,7 @@ class CagePredictionHandler(GenomicLRATaskHandler):
|
|
| 192 |
"""
|
| 193 |
|
| 194 |
# Manually download the reference genome since there are difficulties when
|
| 195 |
-
# streaming
|
| 196 |
reference_genome_file = self.download_and_extract_gz(
|
| 197 |
H38_REFERENCE_GENOME_URL, cache_dir_root
|
| 198 |
)
|
|
@@ -225,7 +228,6 @@ class CagePredictionHandler(GenomicLRATaskHandler):
|
|
| 225 |
self.target_files_by_split["test"] = test_file_dict
|
| 226 |
self.target_files_by_split["validation"] = valid_file_dict
|
| 227 |
|
| 228 |
-
|
| 229 |
return [
|
| 230 |
datasets.SplitGenerator(
|
| 231 |
name=datasets.Split.TRAIN,
|
|
@@ -241,7 +243,6 @@ class CagePredictionHandler(GenomicLRATaskHandler):
|
|
| 241 |
),
|
| 242 |
]
|
| 243 |
|
| 244 |
-
|
| 245 |
def generate_examples(self, split):
|
| 246 |
"""
|
| 247 |
A generator which produces examples for the given split, each with a sequence
|
|
@@ -250,24 +251,28 @@ class CagePredictionHandler(GenomicLRATaskHandler):
|
|
| 250 |
"""
|
| 251 |
|
| 252 |
target_files = self.target_files_by_split[split]
|
| 253 |
-
sequence_length = self.sequence_length
|
| 254 |
|
| 255 |
key = 0
|
| 256 |
coordinates_dataframe = pd.read_csv(self.coordinate_csv_file)
|
| 257 |
filtered = coordinates_dataframe[coordinates_dataframe["split"] == split]
|
| 258 |
for sequential_idx, row in filtered.iterrows():
|
| 259 |
start, stop = int(row["start"]) - 1, int(
|
| 260 |
-
row["stop"]) - 1 # -1 since
|
| 261 |
|
| 262 |
chromosome = row['chrom']
|
| 263 |
-
|
| 264 |
-
padded_sequence = pad_sequence(
|
| 265 |
chromosome=self.reference_genome[chromosome],
|
| 266 |
start=start,
|
| 267 |
-
sequence_length=sequence_length,
|
| 268 |
end=stop,
|
|
|
|
| 269 |
)
|
| 270 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
# floor npy_idx to the nearest 1000
|
| 272 |
npz_file = np.load(
|
| 273 |
target_files[int((row["npy_idx"] // self.NPZ_SPLIT) * self.NPZ_SPLIT)]
|
|
@@ -277,21 +282,22 @@ class CagePredictionHandler(GenomicLRATaskHandler):
|
|
| 277 |
split == "validation"
|
| 278 |
): # npy files are keyed by ["train", "test", "valid"]
|
| 279 |
split = "valid"
|
| 280 |
-
targets = npz_file[f"target-{split}-{row['npy_idx']}.npy"][
|
| 281 |
-
|
| 282 |
-
|
| 283 |
# subset the targets if sequence length is smaller than 114688 (
|
| 284 |
# DEFAULT_LENGTH)
|
| 285 |
if self.sequence_length < self.DEFAULT_LENGTH:
|
| 286 |
idx_diff = (self.DEFAULT_LENGTH - self.sequence_length) // 2 // 128
|
| 287 |
targets = targets[idx_diff:-idx_diff]
|
| 288 |
|
| 289 |
-
|
| 290 |
if padded_sequence:
|
| 291 |
yield key, {
|
| 292 |
"labels": targets,
|
| 293 |
"sequence": standardize_sequence(padded_sequence),
|
| 294 |
-
"chromosome": re.sub("chr","",chromosome)
|
|
|
|
|
|
|
| 295 |
}
|
| 296 |
key += 1
|
| 297 |
|
|
@@ -325,7 +331,7 @@ class BulkRnaExpressionHandler(GenomicLRATaskHandler):
|
|
| 325 |
Handler for the Bulk RNA Expression task.
|
| 326 |
"""
|
| 327 |
|
| 328 |
-
DEFAULT_LENGTH =
|
| 329 |
|
| 330 |
def __init__(self, sequence_length=DEFAULT_LENGTH, **kwargs):
|
| 331 |
"""
|
|
@@ -351,7 +357,9 @@ class BulkRnaExpressionHandler(GenomicLRATaskHandler):
|
|
| 351 |
# list of expression values in each tissue
|
| 352 |
"labels": datasets.Sequence(datasets.Value("float32")),
|
| 353 |
# chromosome number
|
| 354 |
-
"chromosome":datasets.Value(dtype="string")
|
|
|
|
|
|
|
| 355 |
}
|
| 356 |
)
|
| 357 |
return datasets.DatasetInfo(
|
|
@@ -368,7 +376,7 @@ class BulkRnaExpressionHandler(GenomicLRATaskHandler):
|
|
| 368 |
The Bulk RNA Expression dataset requires the reference hg19 genome, coordinate
|
| 369 |
csv file,and label csv file to be saved.
|
| 370 |
"""
|
| 371 |
-
|
| 372 |
reference_genome_file = self.download_and_extract_gz(
|
| 373 |
H19_REFERENCE_GENOME_URL, cache_dir_root
|
| 374 |
)
|
|
@@ -398,7 +406,7 @@ class BulkRnaExpressionHandler(GenomicLRATaskHandler):
|
|
| 398 |
key = 0
|
| 399 |
for idx, coordinates_row in coordinates_split_df.iterrows():
|
| 400 |
start = coordinates_row[
|
| 401 |
-
"CAGE_representative_TSS"] - 1 # -1 since
|
| 402 |
|
| 403 |
chromosome = coordinates_row["chrom"]
|
| 404 |
labels_row = labels_df.loc[idx].values
|
|
@@ -412,21 +420,22 @@ class BulkRnaExpressionHandler(GenomicLRATaskHandler):
|
|
| 412 |
yield key, {
|
| 413 |
"labels": labels_row,
|
| 414 |
"sequence": standardize_sequence(padded_sequence),
|
| 415 |
-
"chromosome":re.sub("chr","",chromosome)
|
|
|
|
| 416 |
}
|
| 417 |
key += 1
|
| 418 |
|
| 419 |
|
| 420 |
-
class
|
| 421 |
"""
|
| 422 |
-
Handler for the Variant Effect
|
| 423 |
"""
|
| 424 |
|
| 425 |
-
DEFAULT_LENGTH =
|
| 426 |
|
| 427 |
def __init__(self, sequence_length=DEFAULT_LENGTH, **kwargs):
|
| 428 |
"""
|
| 429 |
-
Creates a new handler for the Variant Effect
|
| 430 |
Args:
|
| 431 |
sequence_length: Length of the sequence to pad around the SNP position
|
| 432 |
|
|
@@ -436,9 +445,9 @@ class VariantEffectPredictionHandler(GenomicLRATaskHandler):
|
|
| 436 |
|
| 437 |
def get_info(self, description: str) -> DatasetInfo:
|
| 438 |
"""
|
| 439 |
-
Returns the DatasetInfo for the Variant Effect
|
| 440 |
-
includes a genomic sequence with the reference allele as well as the genomic
|
| 441 |
-
and a binary label.
|
| 442 |
"""
|
| 443 |
features = datasets.Features(
|
| 444 |
{
|
|
@@ -451,8 +460,10 @@ class VariantEffectPredictionHandler(GenomicLRATaskHandler):
|
|
| 451 |
"tissue": datasets.Value(dtype="string"),
|
| 452 |
# chromosome number
|
| 453 |
"chromosome": datasets.Value(dtype="string"),
|
|
|
|
|
|
|
| 454 |
# distance to nearest tss
|
| 455 |
-
"distance_to_nearest_tss":datasets.Value(dtype="int32")
|
| 456 |
}
|
| 457 |
)
|
| 458 |
|
|
@@ -478,7 +489,7 @@ class VariantEffectPredictionHandler(GenomicLRATaskHandler):
|
|
| 478 |
|
| 479 |
self.reference_genome = Fasta(reference_genome_file, one_based_attributes=False)
|
| 480 |
self.coordinates_labels_csv_file = dl_manager.download_and_extract(
|
| 481 |
-
f"
|
| 482 |
)
|
| 483 |
|
| 484 |
return super().split_generators(dl_manager, cache_dir_root)
|
|
@@ -496,7 +507,7 @@ class VariantEffectPredictionHandler(GenomicLRATaskHandler):
|
|
| 496 |
|
| 497 |
key = 0
|
| 498 |
for idx, row in coordinates_split_df.iterrows():
|
| 499 |
-
start = row["POS"] - 1 # sub 1 to create idx since
|
| 500 |
alt_allele = row["ALT"]
|
| 501 |
label = row["label"]
|
| 502 |
tissue = row['tissue']
|
|
@@ -513,8 +524,8 @@ class VariantEffectPredictionHandler(GenomicLRATaskHandler):
|
|
| 513 |
|
| 514 |
# only if a valid sequence returned
|
| 515 |
if ref_forward:
|
| 516 |
-
# Mutate sequence with the alt allele at the SNP position,
|
| 517 |
-
# centered in the string returned from pad_sequence
|
| 518 |
alt_forward = list(ref_forward)
|
| 519 |
alt_forward[self.sequence_length // 2] = alt_allele
|
| 520 |
alt_forward = "".join(alt_forward)
|
|
@@ -525,14 +536,354 @@ class VariantEffectPredictionHandler(GenomicLRATaskHandler):
|
|
| 525 |
"chromosome": re.sub("chr", "", chromosome),
|
| 526 |
"ref_forward_sequence": standardize_sequence(ref_forward),
|
| 527 |
"alt_forward_sequence": standardize_sequence(alt_forward),
|
| 528 |
-
"distance_to_nearest_tss": distance
|
|
|
|
| 529 |
}
|
| 530 |
key += 1
|
| 531 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
"""
|
| 533 |
-
|
| 534 |
Dataset loader:
|
| 535 |
-
|
| 536 |
"""
|
| 537 |
|
| 538 |
_DESCRIPTION = """
|
|
@@ -542,7 +893,13 @@ Dataset for benchmark of genomic deep learning models.
|
|
| 542 |
_TASK_HANDLERS = {
|
| 543 |
"cage_prediction": CagePredictionHandler,
|
| 544 |
"bulk_rna_expression": BulkRnaExpressionHandler,
|
| 545 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 546 |
}
|
| 547 |
|
| 548 |
|
|
@@ -558,7 +915,7 @@ class GenomicsLRAConfig(datasets.BuilderConfig):
|
|
| 558 |
**kwargs: keyword arguments forwarded to super.
|
| 559 |
"""
|
| 560 |
super().__init__()
|
| 561 |
-
self.handler = _TASK_HANDLERS[task_name](task_name=task_name
|
| 562 |
|
| 563 |
|
| 564 |
# DatasetBuilder
|
|
@@ -592,9 +949,9 @@ class GenomicsLRATasks(datasets.GeneratorBasedBuilder):
|
|
| 592 |
|
| 593 |
|
| 594 |
"""
|
| 595 |
-
|
| 596 |
Global Utils:
|
| 597 |
-
|
| 598 |
"""
|
| 599 |
|
| 600 |
|
|
@@ -613,7 +970,8 @@ def standardize_sequence(sequence: str):
|
|
| 613 |
return sequence
|
| 614 |
|
| 615 |
|
| 616 |
-
def pad_sequence(chromosome, start, sequence_length, end=None, negative_strand=False
|
|
|
|
| 617 |
"""
|
| 618 |
Extends a given sequence to length sequence_length. If
|
| 619 |
padding to the given length is outside the gene, returns
|
|
@@ -625,7 +983,8 @@ def pad_sequence(chromosome, start, sequence_length, end=None, negative_strand=F
|
|
| 625 |
remainder is added to the end of the sequence.
|
| 626 |
end: End index of original sequence. If no end is specified, it creates a
|
| 627 |
centered sequence around the start index.
|
| 628 |
-
negative_strand: If negative_strand, returns the reverse compliment of the
|
|
|
|
| 629 |
"""
|
| 630 |
if end:
|
| 631 |
pad = (sequence_length - (end - start)) // 2
|
|
@@ -639,5 +998,12 @@ def pad_sequence(chromosome, start, sequence_length, end=None, negative_strand=F
|
|
| 639 |
if start < 0 or end >= len(chromosome):
|
| 640 |
return
|
| 641 |
if negative_strand:
|
|
|
|
|
|
|
|
|
|
| 642 |
return chromosome[start:end].reverse.complement.seq
|
|
|
|
|
|
|
|
|
|
|
|
|
| 643 |
return chromosome[start:end].seq
|
|
|
|
| 14 |
from datasets import DatasetInfo
|
| 15 |
from pyfaidx import Fasta
|
| 16 |
from abc import ABC, abstractmethod
|
| 17 |
+
|
|
|
|
|
|
|
| 18 |
|
| 19 |
"""
|
| 20 |
+
----------------------------------------------------------------------------------------
|
| 21 |
Reference Genome URLS:
|
| 22 |
+
----------------------------------------------------------------------------------------
|
| 23 |
"""
|
| 24 |
H38_REFERENCE_GENOME_URL = (
|
| 25 |
"https://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/" "hg38.fa.gz"
|
|
|
|
| 29 |
)
|
| 30 |
|
| 31 |
"""
|
| 32 |
+
----------------------------------------------------------------------------------------
|
| 33 |
Task Specific Handlers:
|
| 34 |
+
----------------------------------------------------------------------------------------
|
| 35 |
"""
|
| 36 |
|
| 37 |
class GenomicLRATaskHandler(ABC):
|
|
|
|
| 95 |
|
| 96 |
def download_and_extract_gz(self, file_url, cache_dir_root):
|
| 97 |
"""
|
| 98 |
+
Downloads and extracts a gz file into the given cache directory. Returns the
|
| 99 |
+
full file path of the extracted gz file.
|
| 100 |
Args:
|
| 101 |
file_url: url of the gz file to be downloaded and extracted.
|
| 102 |
cache_dir_root: Directory to extract file into.
|
|
|
|
| 136 |
50,
|
| 137 |
) # 50 is a subset of CAGE tracks from the original enformer dataset
|
| 138 |
NPZ_SPLIT = 1000 # number of files per npz file.
|
| 139 |
+
NUM_BP_PER_BIN = 128 # number of base pairs per bin in labels
|
| 140 |
|
| 141 |
def __init__(self, sequence_length=DEFAULT_LENGTH, **kwargs):
|
| 142 |
"""
|
| 143 |
Creates a new handler for the CAGE task.
|
| 144 |
Args:
|
| 145 |
+
sequence_length: allows for increasing sequence context. Sequence length
|
| 146 |
+
must be an even multiple of 128 to align with binned labels. Note:
|
| 147 |
+
increasing sequence length may decrease the number of usable samples.
|
| 148 |
"""
|
| 149 |
self.reference_genome = None
|
| 150 |
self.coordinate_csv_file = None
|
| 151 |
self.target_files_by_split = {}
|
| 152 |
|
| 153 |
+
|
| 154 |
assert (sequence_length // 128) % 2 == 0, (
|
| 155 |
+
f"Requested sequence length must be an even multuple of 128 to align "
|
| 156 |
+
f"with the binned labels."
|
| 157 |
)
|
| 158 |
|
| 159 |
self.sequence_length = sequence_length
|
| 160 |
|
| 161 |
if self.sequence_length < self.DEFAULT_LENGTH:
|
| 162 |
+
self.TARGET_SHAPE = (self.sequence_length // 128, 50)
|
|
|
|
|
|
|
| 163 |
|
| 164 |
def get_info(self, description: str) -> DatasetInfo:
|
| 165 |
"""
|
|
|
|
| 173 |
# array of sequence length x num_labels
|
| 174 |
"labels": datasets.Array2D(shape=self.TARGET_SHAPE, dtype="float32"),
|
| 175 |
# chromosome number
|
| 176 |
+
"chromosome": datasets.Value(dtype="string"),
|
| 177 |
+
# start
|
| 178 |
+
"labels_start": datasets.Value(dtype="int32"),
|
| 179 |
+
# stop
|
| 180 |
+
"labels_stop": datasets.Value(dtype="int32")
|
| 181 |
}
|
| 182 |
)
|
| 183 |
return datasets.DatasetInfo(
|
|
|
|
| 195 |
"""
|
| 196 |
|
| 197 |
# Manually download the reference genome since there are difficulties when
|
| 198 |
+
# streaming
|
| 199 |
reference_genome_file = self.download_and_extract_gz(
|
| 200 |
H38_REFERENCE_GENOME_URL, cache_dir_root
|
| 201 |
)
|
|
|
|
| 228 |
self.target_files_by_split["test"] = test_file_dict
|
| 229 |
self.target_files_by_split["validation"] = valid_file_dict
|
| 230 |
|
|
|
|
| 231 |
return [
|
| 232 |
datasets.SplitGenerator(
|
| 233 |
name=datasets.Split.TRAIN,
|
|
|
|
| 243 |
),
|
| 244 |
]
|
| 245 |
|
|
|
|
| 246 |
def generate_examples(self, split):
|
| 247 |
"""
|
| 248 |
A generator which produces examples for the given split, each with a sequence
|
|
|
|
| 251 |
"""
|
| 252 |
|
| 253 |
target_files = self.target_files_by_split[split]
|
|
|
|
| 254 |
|
| 255 |
key = 0
|
| 256 |
coordinates_dataframe = pd.read_csv(self.coordinate_csv_file)
|
| 257 |
filtered = coordinates_dataframe[coordinates_dataframe["split"] == split]
|
| 258 |
for sequential_idx, row in filtered.iterrows():
|
| 259 |
start, stop = int(row["start"]) - 1, int(
|
| 260 |
+
row["stop"]) - 1 # -1 since coords are 1-based
|
| 261 |
|
| 262 |
chromosome = row['chrom']
|
| 263 |
+
|
| 264 |
+
padded_sequence,new_start,new_stop = pad_sequence(
|
| 265 |
chromosome=self.reference_genome[chromosome],
|
| 266 |
start=start,
|
| 267 |
+
sequence_length=self.sequence_length,
|
| 268 |
end=stop,
|
| 269 |
+
return_new_start_stop=True
|
| 270 |
)
|
| 271 |
|
| 272 |
+
if self.sequence_length >= self.DEFAULT_LENGTH:
|
| 273 |
+
new_start = start
|
| 274 |
+
new_stop = stop
|
| 275 |
+
|
| 276 |
# floor npy_idx to the nearest 1000
|
| 277 |
npz_file = np.load(
|
| 278 |
target_files[int((row["npy_idx"] // self.NPZ_SPLIT) * self.NPZ_SPLIT)]
|
|
|
|
| 282 |
split == "validation"
|
| 283 |
): # npy files are keyed by ["train", "test", "valid"]
|
| 284 |
split = "valid"
|
| 285 |
+
targets = npz_file[f"target-{split}-{row['npy_idx']}.npy"][
|
| 286 |
+
0] # select 0 since there is extra dimension
|
| 287 |
+
|
| 288 |
# subset the targets if sequence length is smaller than 114688 (
|
| 289 |
# DEFAULT_LENGTH)
|
| 290 |
if self.sequence_length < self.DEFAULT_LENGTH:
|
| 291 |
idx_diff = (self.DEFAULT_LENGTH - self.sequence_length) // 2 // 128
|
| 292 |
targets = targets[idx_diff:-idx_diff]
|
| 293 |
|
|
|
|
| 294 |
if padded_sequence:
|
| 295 |
yield key, {
|
| 296 |
"labels": targets,
|
| 297 |
"sequence": standardize_sequence(padded_sequence),
|
| 298 |
+
"chromosome": re.sub("chr", "", chromosome),
|
| 299 |
+
"labels_start": new_start,
|
| 300 |
+
"labels_stop": new_stop
|
| 301 |
}
|
| 302 |
key += 1
|
| 303 |
|
|
|
|
| 331 |
Handler for the Bulk RNA Expression task.
|
| 332 |
"""
|
| 333 |
|
| 334 |
+
DEFAULT_LENGTH = 100000
|
| 335 |
|
| 336 |
def __init__(self, sequence_length=DEFAULT_LENGTH, **kwargs):
|
| 337 |
"""
|
|
|
|
| 357 |
# list of expression values in each tissue
|
| 358 |
"labels": datasets.Sequence(datasets.Value("float32")),
|
| 359 |
# chromosome number
|
| 360 |
+
"chromosome": datasets.Value(dtype="string"),
|
| 361 |
+
# position
|
| 362 |
+
"position": datasets.Value(dtype="int32"),
|
| 363 |
}
|
| 364 |
)
|
| 365 |
return datasets.DatasetInfo(
|
|
|
|
| 376 |
The Bulk RNA Expression dataset requires the reference hg19 genome, coordinate
|
| 377 |
csv file,and label csv file to be saved.
|
| 378 |
"""
|
| 379 |
+
|
| 380 |
reference_genome_file = self.download_and_extract_gz(
|
| 381 |
H19_REFERENCE_GENOME_URL, cache_dir_root
|
| 382 |
)
|
|
|
|
| 406 |
key = 0
|
| 407 |
for idx, coordinates_row in coordinates_split_df.iterrows():
|
| 408 |
start = coordinates_row[
|
| 409 |
+
"CAGE_representative_TSS"] - 1 # -1 since coords are 1-based
|
| 410 |
|
| 411 |
chromosome = coordinates_row["chrom"]
|
| 412 |
labels_row = labels_df.loc[idx].values
|
|
|
|
| 420 |
yield key, {
|
| 421 |
"labels": labels_row,
|
| 422 |
"sequence": standardize_sequence(padded_sequence),
|
| 423 |
+
"chromosome": re.sub("chr", "", chromosome),
|
| 424 |
+
"position": coordinates_row["CAGE_representative_TSS"]
|
| 425 |
}
|
| 426 |
key += 1
|
| 427 |
|
| 428 |
|
| 429 |
+
class VariantEffectCausalEqtl(GenomicLRATaskHandler):
|
| 430 |
"""
|
| 431 |
+
Handler for the Variant Effect Causal eQTL task.
|
| 432 |
"""
|
| 433 |
|
| 434 |
+
DEFAULT_LENGTH = 100000
|
| 435 |
|
| 436 |
def __init__(self, sequence_length=DEFAULT_LENGTH, **kwargs):
|
| 437 |
"""
|
| 438 |
+
Creates a new handler for the Variant Effect Causal eQTL Task.
|
| 439 |
Args:
|
| 440 |
sequence_length: Length of the sequence to pad around the SNP position
|
| 441 |
|
|
|
|
| 445 |
|
| 446 |
def get_info(self, description: str) -> DatasetInfo:
|
| 447 |
"""
|
| 448 |
+
Returns the DatasetInfo for the Variant Effect Causal eQTL dataset. Each example
|
| 449 |
+
includes a genomic sequence with the reference allele as well as the genomic
|
| 450 |
+
sequence with the alternative allele, and a binary label.
|
| 451 |
"""
|
| 452 |
features = datasets.Features(
|
| 453 |
{
|
|
|
|
| 460 |
"tissue": datasets.Value(dtype="string"),
|
| 461 |
# chromosome number
|
| 462 |
"chromosome": datasets.Value(dtype="string"),
|
| 463 |
+
# variant position
|
| 464 |
+
"position": datasets.Value(dtype="int32"),
|
| 465 |
# distance to nearest tss
|
| 466 |
+
"distance_to_nearest_tss": datasets.Value(dtype="int32")
|
| 467 |
}
|
| 468 |
)
|
| 469 |
|
|
|
|
| 489 |
|
| 490 |
self.reference_genome = Fasta(reference_genome_file, one_based_attributes=False)
|
| 491 |
self.coordinates_labels_csv_file = dl_manager.download_and_extract(
|
| 492 |
+
f"variant_effect_causal_eqtl/All_Tissues.csv"
|
| 493 |
)
|
| 494 |
|
| 495 |
return super().split_generators(dl_manager, cache_dir_root)
|
|
|
|
| 507 |
|
| 508 |
key = 0
|
| 509 |
for idx, row in coordinates_split_df.iterrows():
|
| 510 |
+
start = row["POS"] - 1 # sub 1 to create idx since coords are 1-based
|
| 511 |
alt_allele = row["ALT"]
|
| 512 |
label = row["label"]
|
| 513 |
tissue = row['tissue']
|
|
|
|
| 524 |
|
| 525 |
# only if a valid sequence returned
|
| 526 |
if ref_forward:
|
| 527 |
+
# Mutate sequence with the alt allele at the SNP position,
|
| 528 |
+
# which is always centered in the string returned from pad_sequence
|
| 529 |
alt_forward = list(ref_forward)
|
| 530 |
alt_forward[self.sequence_length // 2] = alt_allele
|
| 531 |
alt_forward = "".join(alt_forward)
|
|
|
|
| 536 |
"chromosome": re.sub("chr", "", chromosome),
|
| 537 |
"ref_forward_sequence": standardize_sequence(ref_forward),
|
| 538 |
"alt_forward_sequence": standardize_sequence(alt_forward),
|
| 539 |
+
"distance_to_nearest_tss": distance,
|
| 540 |
+
"position": row["POS"]
|
| 541 |
}
|
| 542 |
key += 1
|
| 543 |
|
| 544 |
+
|
| 545 |
+
class VariantEffectPathogenicHandler(GenomicLRATaskHandler):
|
| 546 |
+
"""
|
| 547 |
+
Handler for the Variant Effect Pathogenic Prediction tasks.
|
| 548 |
+
"""
|
| 549 |
+
|
| 550 |
+
DEFAULT_LENGTH = 100000
|
| 551 |
+
|
| 552 |
+
def __init__(self, sequence_length=DEFAULT_LENGTH, task_name=None, subset=False,
|
| 553 |
+
**kwargs):
|
| 554 |
+
"""
|
| 555 |
+
Creates a new handler for the Variant Effect Pathogenic Tasks.
|
| 556 |
+
Args:
|
| 557 |
+
sequence_length: Length of the sequence to pad around the SNP position
|
| 558 |
+
subset: Whether to return a pre-determined subset of the data.
|
| 559 |
+
|
| 560 |
+
"""
|
| 561 |
+
self.sequence_length = sequence_length
|
| 562 |
+
|
| 563 |
+
if task_name == 'variant_effect_pathogenic_clinvar':
|
| 564 |
+
self.data_file_name = "variant_effect_pathogenic/vep_pathogenic_coding.csv"
|
| 565 |
+
elif task_name == 'variant_effect_pathogenic_omim':
|
| 566 |
+
self.data_file_name = "variant_effect_pathogenic/" \
|
| 567 |
+
"vep_pathogenic_non_coding_subset.csv" \
|
| 568 |
+
if subset else "variant_effect_pathogenic/vep_pathogenic_non_coding.csv"
|
| 569 |
+
|
| 570 |
+
def get_info(self, description: str) -> DatasetInfo:
|
| 571 |
+
"""
|
| 572 |
+
Returns the DatasetInfo for the Variant Effect Pathogenic datasets. Each example
|
| 573 |
+
includes a genomic sequence with the reference allele as well as the genomic
|
| 574 |
+
sequence with the alternative allele, and a binary label.
|
| 575 |
+
"""
|
| 576 |
+
features = datasets.Features(
|
| 577 |
+
{
|
| 578 |
+
# DNA sequence
|
| 579 |
+
"ref_forward_sequence": datasets.Value("string"),
|
| 580 |
+
"alt_forward_sequence": datasets.Value("string"),
|
| 581 |
+
# binary label
|
| 582 |
+
"label": datasets.Value(dtype="int8"),
|
| 583 |
+
# chromosome number
|
| 584 |
+
"chromosome": datasets.Value(dtype="string"),
|
| 585 |
+
# position
|
| 586 |
+
"position": datasets.Value(dtype="int32")
|
| 587 |
+
}
|
| 588 |
+
)
|
| 589 |
+
|
| 590 |
+
return datasets.DatasetInfo(
|
| 591 |
+
# This is the description that will appear on the datasets page.
|
| 592 |
+
description=description,
|
| 593 |
+
# This defines the different columns of the dataset and their types
|
| 594 |
+
features=features,
|
| 595 |
+
)
|
| 596 |
+
|
| 597 |
+
def split_generators(self, dl_manager, cache_dir_root):
|
| 598 |
+
"""
|
| 599 |
+
Separates files by split and stores filenames in instance variables.
|
| 600 |
+
The variant effect prediction datasets require the reference hg38 genome and
|
| 601 |
+
coordinates_labels_csv_file to be saved.
|
| 602 |
+
"""
|
| 603 |
+
|
| 604 |
+
reference_genome_file = self.download_and_extract_gz(
|
| 605 |
+
H38_REFERENCE_GENOME_URL, cache_dir_root
|
| 606 |
+
)
|
| 607 |
+
|
| 608 |
+
self.reference_genome = Fasta(reference_genome_file, one_based_attributes=False)
|
| 609 |
+
self.coordinates_labels_csv_file = dl_manager.download_and_extract(
|
| 610 |
+
self.data_file_name)
|
| 611 |
+
|
| 612 |
+
if 'non_coding' in self.data_file_name:
|
| 613 |
+
return [
|
| 614 |
+
datasets.SplitGenerator(
|
| 615 |
+
name=datasets.Split.TEST,
|
| 616 |
+
gen_kwargs={"handler": self, "split": "test"}
|
| 617 |
+
), ]
|
| 618 |
+
else:
|
| 619 |
+
return super().split_generators(dl_manager, cache_dir_root)
|
| 620 |
+
|
| 621 |
+
def generate_examples(self, split):
|
| 622 |
+
"""
|
| 623 |
+
A generator which produces examples each with ref/alt allele
|
| 624 |
+
and corresponding binary label. The sequences are extended to
|
| 625 |
+
the desired sequence length and standardized before returning.
|
| 626 |
+
"""
|
| 627 |
+
|
| 628 |
+
coordinates_df = pd.read_csv(self.coordinates_labels_csv_file)
|
| 629 |
+
coordinates_split_df = coordinates_df[coordinates_df["split"] == split]
|
| 630 |
+
|
| 631 |
+
key = 0
|
| 632 |
+
for idx, row in coordinates_split_df.iterrows():
|
| 633 |
+
start = row["POS"] - 1 # sub 1 to create idx since coords are 1-based
|
| 634 |
+
alt_allele = row["ALT"]
|
| 635 |
+
label = row["INT_LABEL"]
|
| 636 |
+
chromosome = row["CHROM"]
|
| 637 |
+
|
| 638 |
+
# get reference forward sequence
|
| 639 |
+
ref_forward = pad_sequence(
|
| 640 |
+
chromosome=self.reference_genome[chromosome],
|
| 641 |
+
start=start,
|
| 642 |
+
sequence_length=self.sequence_length,
|
| 643 |
+
negative_strand=False,
|
| 644 |
+
)
|
| 645 |
+
|
| 646 |
+
# only if a valid sequence returned
|
| 647 |
+
if ref_forward:
|
| 648 |
+
# Mutate sequence with the alt allele at the SNP position,
|
| 649 |
+
# which is always centered in the string returned from pad_sequence
|
| 650 |
+
alt_forward = list(ref_forward)
|
| 651 |
+
alt_forward[self.sequence_length // 2] = alt_allele
|
| 652 |
+
alt_forward = "".join(alt_forward)
|
| 653 |
+
|
| 654 |
+
yield key, {
|
| 655 |
+
"label": label,
|
| 656 |
+
"chromosome": re.sub("chr", "", chromosome),
|
| 657 |
+
"ref_forward_sequence": standardize_sequence(ref_forward),
|
| 658 |
+
"alt_forward_sequence": standardize_sequence(alt_forward),
|
| 659 |
+
"position": row['POS']
|
| 660 |
+
}
|
| 661 |
+
key += 1
|
| 662 |
+
|
| 663 |
+
|
| 664 |
+
class ChromatinFeaturesHandler(GenomicLRATaskHandler):
|
| 665 |
+
"""
|
| 666 |
+
Handler for the histone marks and DNA accessibility tasks also referred to
|
| 667 |
+
collectively as Chromatin features.
|
| 668 |
+
"""
|
| 669 |
+
|
| 670 |
+
DEFAULT_LENGTH = 100000
|
| 671 |
+
|
| 672 |
+
def __init__(self, task_name=None, sequence_length=DEFAULT_LENGTH, subset=False,
|
| 673 |
+
**kwargs):
|
| 674 |
+
"""
|
| 675 |
+
Creates a new handler for the Deep Sea Histone and DNase tasks.
|
| 676 |
+
Args:
|
| 677 |
+
sequence_length: Length of the sequence around and including the
|
| 678 |
+
annotated 200bp bin
|
| 679 |
+
subset: Whether to return a pre-determined subset of the entire dataset.
|
| 680 |
+
|
| 681 |
+
"""
|
| 682 |
+
self.sequence_length = sequence_length
|
| 683 |
+
|
| 684 |
+
if sequence_length < 200:
|
| 685 |
+
raise ValueError(
|
| 686 |
+
'Sequence length for this task must be greater or equal to 200 bp')
|
| 687 |
+
|
| 688 |
+
if 'histone' in task_name:
|
| 689 |
+
self.label_name = 'HISTONES'
|
| 690 |
+
elif 'dna' in task_name:
|
| 691 |
+
self.label_name = 'DNASE'
|
| 692 |
+
|
| 693 |
+
self.data_file_name = "chromatin_features/histones_and_dnase_subset.csv" if \
|
| 694 |
+
subset else "chromatin_features/histones_and_dnase.csv"
|
| 695 |
+
|
| 696 |
+
def get_info(self, description: str) -> DatasetInfo:
|
| 697 |
+
"""
|
| 698 |
+
Returns the DatasetInfo for the histone marks and dna accessibility datasets.
|
| 699 |
+
Each example includes a genomic sequence and a list of label values.
|
| 700 |
+
"""
|
| 701 |
+
features = datasets.Features(
|
| 702 |
+
{
|
| 703 |
+
# DNA sequence
|
| 704 |
+
"sequence": datasets.Value("string"),
|
| 705 |
+
# list of binary chromatin marks
|
| 706 |
+
"labels": datasets.Sequence(datasets.Value("int8")),
|
| 707 |
+
# chromosome number
|
| 708 |
+
"chromosome": datasets.Value(dtype="string"),
|
| 709 |
+
# starting position in genome which corresponds to label
|
| 710 |
+
"label_start": datasets.Value(dtype="int32"),
|
| 711 |
+
# end position in genome which corresponds to label
|
| 712 |
+
"label_stop": datasets.Value(dtype="int32"),
|
| 713 |
+
}
|
| 714 |
+
)
|
| 715 |
+
return datasets.DatasetInfo(
|
| 716 |
+
# This is the description that will appear on the datasets page.
|
| 717 |
+
description=description,
|
| 718 |
+
# This defines the different columns of the dataset and their types
|
| 719 |
+
features=features,
|
| 720 |
+
|
| 721 |
+
)
|
| 722 |
+
|
| 723 |
+
def split_generators(self, dl_manager, cache_dir_root):
|
| 724 |
+
"""
|
| 725 |
+
Separates files by split and stores filenames in instance variables.
|
| 726 |
+
The histone marks and dna accessibility datasets require the reference hg19
|
| 727 |
+
genome and coordinate csv file to be saved.
|
| 728 |
+
"""
|
| 729 |
+
reference_genome_file = self.download_and_extract_gz(
|
| 730 |
+
H19_REFERENCE_GENOME_URL, cache_dir_root
|
| 731 |
+
)
|
| 732 |
+
self.reference_genome = Fasta(reference_genome_file, one_based_attributes=False)
|
| 733 |
+
|
| 734 |
+
self.coordinate_csv_file = dl_manager.download_and_extract(self.data_file_name)
|
| 735 |
+
|
| 736 |
+
return super().split_generators(dl_manager, cache_dir_root)
|
| 737 |
+
|
| 738 |
+
def generate_examples(self, split):
|
| 739 |
+
"""
|
| 740 |
+
A generator which produces examples for the given split, each with a sequence
|
| 741 |
+
and the corresponding labels. The sequences are padded to the correct sequence
|
| 742 |
+
length and standardized before returning.
|
| 743 |
+
"""
|
| 744 |
+
coordinates_df = pd.read_csv(self.coordinate_csv_file)
|
| 745 |
+
coordinates_split_df = coordinates_df[coordinates_df["split"] == split]
|
| 746 |
+
|
| 747 |
+
key = 0
|
| 748 |
+
for idx, coordinates_row in coordinates_split_df.iterrows():
|
| 749 |
+
start = coordinates_row['POS'] - 1 # -1 since saved coords are 1-based
|
| 750 |
+
chromosome = coordinates_row["CHROM"]
|
| 751 |
+
|
| 752 |
+
# literal eval used since lists are saved as strings in csv
|
| 753 |
+
labels_row = literal_eval(coordinates_row[self.label_name])
|
| 754 |
+
|
| 755 |
+
padded_sequence = pad_sequence(
|
| 756 |
+
chromosome=self.reference_genome[chromosome],
|
| 757 |
+
start=start,
|
| 758 |
+
sequence_length=self.sequence_length,
|
| 759 |
+
)
|
| 760 |
+
if padded_sequence:
|
| 761 |
+
yield key, {
|
| 762 |
+
"labels": labels_row,
|
| 763 |
+
"sequence": standardize_sequence(padded_sequence),
|
| 764 |
+
"chromosome": re.sub("chr", "", chromosome),
|
| 765 |
+
"label_start": coordinates_row['POS']-100,
|
| 766 |
+
"label_stop": coordinates_row['POS'] + 99,
|
| 767 |
+
}
|
| 768 |
+
key += 1
|
| 769 |
+
|
| 770 |
+
|
| 771 |
+
class RegulatoryElementHandler(GenomicLRATaskHandler):
|
| 772 |
+
"""
|
| 773 |
+
Handler for the Regulatory Element Prediction tasks.
|
| 774 |
+
"""
|
| 775 |
+
DEFAULT_LENGTH = 100000
|
| 776 |
+
|
| 777 |
+
def __init__(self, task_name=None, sequence_length=DEFAULT_LENGTH, subset=False,
|
| 778 |
+
**kwargs):
|
| 779 |
+
"""
|
| 780 |
+
Creates a new handler for the Regulatory Element Prediction tasks.
|
| 781 |
+
Args:
|
| 782 |
+
sequence_length: Length of the sequence around the element/non-element
|
| 783 |
+
subset: Whether to return a pre-determined subset of the entire dataset.
|
| 784 |
+
|
| 785 |
+
"""
|
| 786 |
+
|
| 787 |
+
if sequence_length < 200:
|
| 788 |
+
raise ValueError(
|
| 789 |
+
'Sequence length for this task must be greater or equal to 200 bp')
|
| 790 |
+
|
| 791 |
+
self.sequence_length = sequence_length
|
| 792 |
+
|
| 793 |
+
if 'promoter' in task_name:
|
| 794 |
+
self.data_file_name = 'regulatory_elements/promoter_dataset'
|
| 795 |
+
|
| 796 |
+
elif 'enhancer' in task_name:
|
| 797 |
+
self.data_file_name = 'regulatory_elements/enhancer_dataset'
|
| 798 |
+
|
| 799 |
+
if subset:
|
| 800 |
+
self.data_file_name += '_subset.csv'
|
| 801 |
+
else:
|
| 802 |
+
self.data_file_name += '.csv'
|
| 803 |
+
|
| 804 |
+
def get_info(self, description: str) -> DatasetInfo:
|
| 805 |
+
"""
|
| 806 |
+
Returns the DatasetInfo for the Regulatory Element Prediction Tasks.
|
| 807 |
+
Each example includes a genomic sequence and a label.
|
| 808 |
+
"""
|
| 809 |
+
features = datasets.Features(
|
| 810 |
+
{
|
| 811 |
+
# DNA sequence
|
| 812 |
+
"sequence": datasets.Value("string"),
|
| 813 |
+
# label corresponding to whether the sequence has
|
| 814 |
+
# the regulatory element of interest or not
|
| 815 |
+
"labels": datasets.Value("int8"),
|
| 816 |
+
# chromosome number
|
| 817 |
+
"chromosome": datasets.Value(dtype="string"),
|
| 818 |
+
# start
|
| 819 |
+
"label_start": datasets.Value(dtype="int32"),
|
| 820 |
+
# stop
|
| 821 |
+
"label_stop": datasets.Value(dtype="int32"),
|
| 822 |
+
}
|
| 823 |
+
)
|
| 824 |
+
return datasets.DatasetInfo(
|
| 825 |
+
# This is the description that will appear on the datasets page.
|
| 826 |
+
description=description,
|
| 827 |
+
# This defines the different columns of the dataset and their types
|
| 828 |
+
features=features,
|
| 829 |
+
|
| 830 |
+
)
|
| 831 |
+
|
| 832 |
+
def split_generators(self, dl_manager, cache_dir_root):
|
| 833 |
+
"""
|
| 834 |
+
Separates files by split and stores filenames in instance variables.
|
| 835 |
+
"""
|
| 836 |
+
reference_genome_file = self.download_and_extract_gz(
|
| 837 |
+
H38_REFERENCE_GENOME_URL, cache_dir_root
|
| 838 |
+
)
|
| 839 |
+
self.reference_genome = Fasta(reference_genome_file, one_based_attributes=False)
|
| 840 |
+
|
| 841 |
+
self.coordinate_csv_file = dl_manager.download_and_extract(
|
| 842 |
+
self.data_file_name
|
| 843 |
+
)
|
| 844 |
+
|
| 845 |
+
return super().split_generators(dl_manager, cache_dir_root)
|
| 846 |
+
|
| 847 |
+
def generate_examples(self, split):
|
| 848 |
+
"""
|
| 849 |
+
A generator which produces examples for the given split, each with a sequence
|
| 850 |
+
and the corresponding label. The sequences are padded to the correct sequence
|
| 851 |
+
length and standardized before returning.
|
| 852 |
+
"""
|
| 853 |
+
coordinates_df = pd.read_csv(self.coordinate_csv_file)
|
| 854 |
+
|
| 855 |
+
coordinates_split_df = coordinates_df[coordinates_df["split"] == split]
|
| 856 |
+
|
| 857 |
+
key = 0
|
| 858 |
+
for _, coordinates_row in coordinates_split_df.iterrows():
|
| 859 |
+
start = coordinates_row["START"] - 1 # -1 since vcf coords are 1-based
|
| 860 |
+
end = coordinates_row["STOP"] - 1 # -1 since vcf coords are 1-based
|
| 861 |
+
chromosome = coordinates_row["CHROM"]
|
| 862 |
+
|
| 863 |
+
label = coordinates_row['label']
|
| 864 |
+
|
| 865 |
+
padded_sequence = pad_sequence(
|
| 866 |
+
chromosome=self.reference_genome[chromosome],
|
| 867 |
+
start=start,
|
| 868 |
+
end=end,
|
| 869 |
+
sequence_length=self.sequence_length,
|
| 870 |
+
)
|
| 871 |
+
|
| 872 |
+
if padded_sequence:
|
| 873 |
+
yield key, {
|
| 874 |
+
"labels": label,
|
| 875 |
+
"sequence": standardize_sequence(padded_sequence),
|
| 876 |
+
"chromosome": re.sub("chr", "", chromosome),
|
| 877 |
+
"label_start": coordinates_row["START"],
|
| 878 |
+
"label_stop": coordinates_row["STOP"]
|
| 879 |
+
}
|
| 880 |
+
key += 1
|
| 881 |
+
|
| 882 |
+
|
| 883 |
"""
|
| 884 |
+
----------------------------------------------------------------------------------------
|
| 885 |
Dataset loader:
|
| 886 |
+
----------------------------------------------------------------------------------------
|
| 887 |
"""
|
| 888 |
|
| 889 |
_DESCRIPTION = """
|
|
|
|
| 893 |
_TASK_HANDLERS = {
|
| 894 |
"cage_prediction": CagePredictionHandler,
|
| 895 |
"bulk_rna_expression": BulkRnaExpressionHandler,
|
| 896 |
+
"variant_effect_causal_eqtl": VariantEffectCausalEqtl,
|
| 897 |
+
"variant_effect_pathogenic_clinvar": VariantEffectPathogenicHandler,
|
| 898 |
+
"variant_effect_pathogenic_omim": VariantEffectPathogenicHandler,
|
| 899 |
+
"chromatin_features_histone_marks": ChromatinFeaturesHandler,
|
| 900 |
+
"chromatin_features_dna_accessibility": ChromatinFeaturesHandler,
|
| 901 |
+
"regulatory_element_promoter": RegulatoryElementHandler,
|
| 902 |
+
"regulatory_element_enhancer": RegulatoryElementHandler,
|
| 903 |
}
|
| 904 |
|
| 905 |
|
|
|
|
| 915 |
**kwargs: keyword arguments forwarded to super.
|
| 916 |
"""
|
| 917 |
super().__init__()
|
| 918 |
+
self.handler = _TASK_HANDLERS[task_name](task_name=task_name, **kwargs)
|
| 919 |
|
| 920 |
|
| 921 |
# DatasetBuilder
|
|
|
|
| 949 |
|
| 950 |
|
| 951 |
"""
|
| 952 |
+
----------------------------------------------------------------------------------------
|
| 953 |
Global Utils:
|
| 954 |
+
----------------------------------------------------------------------------------------
|
| 955 |
"""
|
| 956 |
|
| 957 |
|
|
|
|
| 970 |
return sequence
|
| 971 |
|
| 972 |
|
| 973 |
+
def pad_sequence(chromosome, start, sequence_length, end=None, negative_strand=False,
|
| 974 |
+
return_new_start_stop=False):
|
| 975 |
"""
|
| 976 |
Extends a given sequence to length sequence_length. If
|
| 977 |
padding to the given length is outside the gene, returns
|
|
|
|
| 983 |
remainder is added to the end of the sequence.
|
| 984 |
end: End index of original sequence. If no end is specified, it creates a
|
| 985 |
centered sequence around the start index.
|
| 986 |
+
negative_strand: If negative_strand, returns the reverse compliment of the
|
| 987 |
+
sequence
|
| 988 |
"""
|
| 989 |
if end:
|
| 990 |
pad = (sequence_length - (end - start)) // 2
|
|
|
|
| 998 |
if start < 0 or end >= len(chromosome):
|
| 999 |
return
|
| 1000 |
if negative_strand:
|
| 1001 |
+
if return_new_start_stop:
|
| 1002 |
+
return chromosome[start:end].reverse.complement.seq ,start, end
|
| 1003 |
+
|
| 1004 |
return chromosome[start:end].reverse.complement.seq
|
| 1005 |
+
|
| 1006 |
+
if return_new_start_stop:
|
| 1007 |
+
return chromosome[start:end].seq , start, end
|
| 1008 |
+
|
| 1009 |
return chromosome[start:end].seq
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8a511212c76aba8c25ecd372531fe78767cbd4065ce72d4899dcb4ba1429750c
|
| 3 |
+
size 66953920
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7af8aef4a6c15a4be5d752f8a638f2ab88be42476f9da59732f892273d58078f
|
| 3 |
+
size 11241394
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ddaaa24bee906885033fb4f75097797c3aed3557b3fb09a202f50d4e99e3a2b
|
| 3 |
+
size 33319573
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4a5ccb2bf002dc504f6c40550acd5a99d2edfa587403d7cf23a1b965df74c51b
|
| 3 |
+
size 7479637
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d85df2b982e57866fb6efcd78dd0316c4005a0fea72322c3fe6c3188772558ae
|
| 3 |
+
size 7081158
|
|
The diff for this file is too large to render.
See raw diff
|
|
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e75b0b9c374e2cea972cb2c6246c7cc21c1c92e6b97cc597baf20b8d9462acb9
|
| 3 |
+
size 6576847
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5ab457120792566dcfaeeaf06c9af32c19ddcff4d2f62fb034b95450622f9966
|
| 3 |
+
size 369157498
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:24127410937b99d41d0ad0b3b1e2e260b27ee20d00695caf6cbb48842a411a1f
|
| 3 |
+
size 33142664
|