Upload 3 files
Browse files- .gitattributes +2 -0
- jolma_subset.py +165 -0
- min_count_10.gz.csv +3 -0
- min_count_3.gz.csv +3 -0
.gitattributes
CHANGED
@@ -52,3 +52,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
52 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
53 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
52 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
53 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
55 |
+
min_count_10.gz.csv filter=lfs diff=lfs merge=lfs -text
|
56 |
+
min_count_3.gz.csv filter=lfs diff=lfs merge=lfs -text
|
jolma_subset.py
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import re
|
3 |
+
import pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
import datasets
|
6 |
+
|
7 |
+
|
8 |
+
logger = datasets.logging.get_logger(__name__)
|
9 |
+
|
10 |
+
|
11 |
+
_CITATION = """\
|
12 |
+
@article{jolma2010multiplexed,
|
13 |
+
title={Multiplexed massively parallel SELEX for characterization of human transcription factor binding specificities},
|
14 |
+
author={Jolma, Arttu and Kivioja, Teemu and Toivonen, Jarkko and Cheng, Lu and Wei, Gonghong and Enge, Martin and \
|
15 |
+
Taipale, Mikko and Vaquerizas, Juan M and Yan, Jian and Sillanp{\"a}{\"a}, Mikko J and others},
|
16 |
+
journal={Genome research},
|
17 |
+
volume={20},
|
18 |
+
number={6},
|
19 |
+
pages={861--873},
|
20 |
+
year={2010},
|
21 |
+
publisher={Cold Spring Harbor Lab}
|
22 |
+
}
|
23 |
+
"""
|
24 |
+
|
25 |
+
_DESCRIPTION = """\
|
26 |
+
PRJEB3289
|
27 |
+
https://www.ebi.ac.uk/ena/browser/view/PRJEB3289
|
28 |
+
Data that has been generated by HT-SELEX experiments (see Jolma et al. 2010. PMID: 20378718 for description of method) \
|
29 |
+
that has been now used to generate transcription factor binding specificity models for most of the high confidence \
|
30 |
+
human transcription factors. Sequence data is composed of reads generated with Illumina Genome Analyzer IIX and \
|
31 |
+
HiSeq2000 instruments. Samples are composed of single read sequencing of synthetic DNA fragments with a fixed length \
|
32 |
+
randomized region or samples derived from such a initial library by selection with a sequence specific DNA binding \
|
33 |
+
protein. Originally multiple samples with different "barcode" tag sequences were run on the same Illumina sequencing \
|
34 |
+
lane but the released files have been already de-multiplexed, and the constant regions and "barcodes" of each sequence \
|
35 |
+
have been cut out of the sequencing reads to facilitate the use of data. Some of the files are composed of reads from \
|
36 |
+
multiple different sequencing lanes and due to this each of the names of the individual reads have been edited to show \
|
37 |
+
the flowcell and lane that was used to generate it. Barcodes and oligonucleotide designs are indicated in the names of \
|
38 |
+
individual entries. Depending of the selection ligand design, the sequences in each of these fastq-files are either \
|
39 |
+
14, 20, 30 or 40 bases long and had different flanking regions in both sides of the sequence. Each run entry is named \
|
40 |
+
in either of the following ways: Example 1) "BCL6B_DBD_AC_TGCGGG20NGA_1", where name is composed of following fields \
|
41 |
+
ProteinName_CloneType_Batch_BarcodeDesign_SelectionCycle. This experiment used barcode ligand TGCGGG20NGA, where both \
|
42 |
+
of the variable flanking constant regions are indicated as they were on the original sequence-reads. This ligand has \
|
43 |
+
been selected for one round of HT-SELEX using recombinant protein that contained the DNA binding domain of \
|
44 |
+
human transcription factor BCL6B. It also tells that the experiment was performed on batch of experiments named as "AC".\
|
45 |
+
Example 2) 0_TGCGGG20NGA_0 where name is composed of (zero)_BarcodeDesign_(zero) These sequences have been generated \
|
46 |
+
from sequencing of the initial non-selected pool. Same initial pools have been used in multiple experiments that were \
|
47 |
+
on different batches, thus for example this background sequence pool is the shared background for all of the following \
|
48 |
+
samples. BCL6B_DBD_AC_TGCGGG20NGA_1, ZNF784_full_AE_TGCGGG20NGA_3, DLX6_DBD_Y_TGCGGG20NGA_4 and MSX2_DBD_W_TGCGGG20NGA_2
|
49 |
+
"""
|
50 |
+
|
51 |
+
_URL = "ftp://ftp.sra.ebi.ac.uk/vol1/run/"
|
52 |
+
"ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR173/ERR173154/CTCF_full_AJ_TAGCGA20NGCT_1.fastq.gz"
|
53 |
+
# _FORWARD_PRIMER = "TAATACGACTCACTATAGGGAGCAGGAGAGAGGTCAGATG"
|
54 |
+
# _REVERSE_PRIMER = "CCTATGCGTGCTAGTGTGA"
|
55 |
+
# _DESIGN_LENGTH = 30
|
56 |
+
|
57 |
+
import datasets
|
58 |
+
|
59 |
+
config = datasets.load_dataset(path="thewall/deepbindweight", split="all")
|
60 |
+
info = pd.read_excel(config['selex'][0])
|
61 |
+
protein_info = pd.read_excel(config['tf'][0], index_col=0)
|
62 |
+
_URLS = {"min_count_10": "",
|
63 |
+
"min_count_3": ""}
|
64 |
+
_DESIGN_LENGTH = {"min_count_10": None,
|
65 |
+
"min_count_3": None}
|
66 |
+
pattern = re.compile("(\d+)")
|
67 |
+
for idx, row in info.iterrows():
|
68 |
+
sra_id = row["SRA ID"]
|
69 |
+
file = row["file"]
|
70 |
+
_URLS[sra_id] = "/".join([_URL, sra_id[:6], sra_id, file])
|
71 |
+
_DESIGN_LENGTH[sra_id] = int(pattern.search(row["Ligand"]).group(0))
|
72 |
+
|
73 |
+
URL = "https://huggingface.co/datasets/thewall/jolma_subset/resolve/main"
|
74 |
+
|
75 |
+
class JolmaSubsetConfig(datasets.BuilderConfig):
|
76 |
+
def __init__(self, length_match=True, design_length=None, filter_N=True,
|
77 |
+
protein_prefix="1", protein_suffix="2", max_length=1000, max_gene_num=1,
|
78 |
+
aptamer_prefix="[BOS]", aptamer_suffix="[EOS]", **kwargs):
|
79 |
+
super(JolmaSubsetConfig, self).__init__(**kwargs)
|
80 |
+
self.length_match = length_match
|
81 |
+
self.design_length = design_length
|
82 |
+
self.filter_N = filter_N
|
83 |
+
self.data_dir = kwargs.get("data_dir")
|
84 |
+
self.protein_prefix = protein_prefix
|
85 |
+
self.protein_suffix = protein_suffix
|
86 |
+
self.aptamer_prefix = aptamer_prefix
|
87 |
+
self.aptamer_suffix = aptamer_suffix
|
88 |
+
self.max_length = max_length
|
89 |
+
self.max_gene_num = max_gene_num
|
90 |
+
|
91 |
+
|
92 |
+
class JolmaSubset(datasets.GeneratorBasedBuilder):
|
93 |
+
BUILDER_CONFIGS = [
|
94 |
+
JolmaSubsetConfig(name=key, design_length=_DESIGN_LENGTH[key]) for key in ["min_count_3", "min_count_10"]
|
95 |
+
]
|
96 |
+
|
97 |
+
DEFAULT_CONFIG_NAME = "min_count_10"
|
98 |
+
|
99 |
+
def _info(self):
|
100 |
+
return datasets.DatasetInfo(
|
101 |
+
description=_DESCRIPTION,
|
102 |
+
features=datasets.Features(
|
103 |
+
{
|
104 |
+
"id": datasets.Value("int32"),
|
105 |
+
"identifier": datasets.Value("string"),
|
106 |
+
"seq": datasets.Value("string"),
|
107 |
+
"quality": datasets.Value("string"),
|
108 |
+
"count": datasets.Value("int32"),
|
109 |
+
"protein": datasets.Value("string"),
|
110 |
+
"protein_id": datasets.Value("string"),
|
111 |
+
}
|
112 |
+
),
|
113 |
+
homepage="https://www.ebi.ac.uk/ena/browser/view/PRJEB3289",
|
114 |
+
citation=_CITATION,
|
115 |
+
)
|
116 |
+
|
117 |
+
def _split_generators(self, dl_manager):
|
118 |
+
# downloaded_files = dl_manager.download_and_extract(self.config.url)
|
119 |
+
# logger.info(f"Download from {self.config.url}")
|
120 |
+
file = dl_manager.download(f"{URL}/{self.config.name}.gz.csv")
|
121 |
+
# file = os.path.join(filepath, os.listdir(filepath)[0])
|
122 |
+
return [
|
123 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": file}),
|
124 |
+
]
|
125 |
+
|
126 |
+
def _generate_examples(self, filepath):
|
127 |
+
"""This function returns the examples in the raw (text) form."""
|
128 |
+
logger.info("generating examples from = %s", filepath)
|
129 |
+
proteins = protein_info["Sequence"]
|
130 |
+
protein_id = protein_info["Entry"]
|
131 |
+
gene_num = protein_info["Unique Gene"]
|
132 |
+
data = pd.read_csv(filepath)
|
133 |
+
for key, row in data.iterrows():
|
134 |
+
sra_id = row["identifier"].split(":")[0]
|
135 |
+
protein_seq = f"{self.config.protein_prefix}{proteins.loc[sra_id]}{self.config.protein_suffix}"
|
136 |
+
aptamer_seq = f'{self.config.aptamer_prefix}{row["seq"]}{self.config.aptamer_suffix}'
|
137 |
+
if len(protein_seq)>self.config.max_length:
|
138 |
+
continue
|
139 |
+
if gene_num.loc[sra_id]>self.config.max_gene_num:
|
140 |
+
continue
|
141 |
+
if str(proteins.loc[sra_id])=="nan":
|
142 |
+
continue
|
143 |
+
ans = {"id": key,
|
144 |
+
"protein": protein_seq,
|
145 |
+
"protein_id": protein_id.loc[sra_id],
|
146 |
+
"seq": aptamer_seq,
|
147 |
+
"identifier": row["identifier"],
|
148 |
+
"count": int(row["count"]),
|
149 |
+
"quality": row['quality']}
|
150 |
+
yield key, ans
|
151 |
+
|
152 |
+
|
153 |
+
def filter_fn(self, example):
|
154 |
+
seq = example["seq"]
|
155 |
+
if self.config.length_match and len(seq)!=self.config.design_length:
|
156 |
+
return False
|
157 |
+
if self.config.filter_N and "N" in seq:
|
158 |
+
return False
|
159 |
+
return True
|
160 |
+
|
161 |
+
|
162 |
+
if __name__=="__main__":
|
163 |
+
from datasets import load_dataset
|
164 |
+
dataset = load_dataset("jolma_subset.py", split="all")
|
165 |
+
|
min_count_10.gz.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1c00b5be7a892592b04442dacd1933484dd9eef411d712be9a4d36fa9a05b30e
|
3 |
+
size 4734761
|
min_count_3.gz.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:40974c75ea46e0e728af19a8b6955502495e97838c543b5110ef0b0b3dbccc67
|
3 |
+
size 31087291
|