File size: 9,420 Bytes
dfda0f1
 
a987ef3
 
 
 
 
 
 
 
 
 
 
6c41d74
cca1a99
6c41d74
cca1a99
 
 
 
 
 
 
 
 
a987ef3
 
 
313f7f4
a987ef3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313f7f4
a987ef3
 
 
 
 
2b47c97
 
 
 
 
 
a987ef3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313f7f4
a987ef3
 
 
 
 
2b47c97
 
 
 
 
 
a987ef3
 
 
 
 
 
2b47c97
a987ef3
 
 
2b47c97
a987ef3
 
 
 
 
313f7f4
a987ef3
 
 
 
 
2b47c97
a987ef3
2b47c97
 
 
 
a987ef3
 
2b47c97
 
a987ef3
2b47c97
 
 
a987ef3
2b47c97
 
 
a987ef3
2b47c97
 
 
 
 
 
 
dfda0f1
 
 
 
 
 
a987ef3
 
 
dfda0f1
acb3acd
 
dfda0f1
acb3acd
 
dfda0f1
a987ef3
 
acb3acd
dfda0f1
acb3acd
 
 
 
 
a987ef3
acb3acd
be161bd
acb3acd
 
 
 
 
be161bd
acb3acd
be161bd
acb3acd
 
 
 
a987ef3
acb3acd
a987ef3
acb3acd
 
a987ef3
acb3acd
 
 
a987ef3
acb3acd
a987ef3
acb3acd
 
a987ef3
acb3acd
 
a987ef3
acb3acd
 
be161bd
acb3acd
 
be161bd
 
 
 
 
 
 
 
 
 
acb3acd
be161bd
 
 
acb3acd
be161bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
acb3acd
be161bd
 
 
 
 
 
 
acb3acd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b47c97
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
---
license: mit
language:
- en
tags:
- transcription-factor
- binding
- chec-seq
- genomics
- biology
pretty_name: Barkai ChEC-seq Compendium
size_categories:
  - 100M<n<1B
experimental_conditions:
  temperature_celsius: 30
  cultivation_method: liquid_culture
  growth_phase_at_harvest:
    od600: 4.0
    stage: overnight_stationary_phase
  media:
    name: synthetic_complete_dextrose
    carbon_source:
      - compound: D-dextrose
        concentration_percent: unspecified
    nitrogen_source: unspecified
configs:
- config_name: genomic_coverage
  description: Genomic coverage data with pileup counts at specific positions
  dataset_type: genome_map
  default: true
  data_files:
  - split: train
    path: genome_map/*/*/part-0.parquet
  dataset_info:
    features:
    - name: seqnames
      dtype: string
      description: Chromosome or sequence name (e.g., chrI, chrII, etc.)
    - name: start
      dtype: int32
      description: Start position of the genomic interval (1-based coordinates)
    - name: end
      dtype: int32
      description: End position of the genomic interval (1-based coordinates)
    - name: pileup
      dtype: int32
      description: Number of tags (5' of read) at this genomic position
    partition_info:
    - name: Series
      dtype: string
      description: GEO series of the dataset
    - name: Accession
      dtype: string
      description: GEO accession of the specific sample
- config_name: GSE178430_metadata
  description: Metadata for GSE178430
  dataset_type: metadata
  data_files:
  - split: train
    path: GSE178430_metadata.parquet
  dataset_info:
    features:
    - name: sample_id
      dtype: integer
      description: Unique sample identifier. Uniquely identifies an accession
    - name: series
      dtype: string
      description: the GEO series to which this collection belongs
    - name: accession
      dtype: string
      description: Sample accession identifier
    - name: regulator_locus_tag
      dtype: string
      description: Systematic gene name (ORF identifier) of the tagged transcription factor
    - name: regulator_symbol
      dtype: string
      description: Standard gene symbol of the tagged transcription factor
    - name: strainid
      dtype: string
      description: Strain identifier used in the experiment
    - name: instrument
      dtype: string
      description: Sequencing instrument used for data generation
    - name: genotype
      dtype: string
      description: Full genotype description of the experimental strain
    - name: dbd_donor_symbol
      dtype: string
      description: Gene symbol of the DNA-binding domain donor (for chimeric constructs)
    - name: ortholog_donor
      dtype: string
      description: Ortholog donor information for cross-species constructs
    - name: paralog_deletion_symbol
      dtype: string
      description: Gene symbol of deleted paralog in the strain background
    - name: paralog_resistance_cassette
      dtype: string
      description: Antibiotic resistance cassette used for paralog deletion
- config_name: GSE209631_metadata
  description: ChEC-seq experiment metadata for transcription factor variant studies
  dataset_type: metadata
  data_files:
  - split: train
    path: GSE209631_metadata.parquet
  dataset_info:
    features:
    - name: sample_id
      dtype: integer
      description: Unique sample identifier. Uniquely identifies an accession
    - name: series
      dtype: string
      description: the GEO series to which this collection belongs
    - name: accession
      dtype: string
      description: Sample accession identifier
    - name: regulator_locus_tag
      dtype: string
      description: Systematic gene name (ORF identifier) of the tagged transcription factor
      role: regulator_identifier
    - name: regulator_symbol
      dtype: string
      description: Standard gene symbol of the tagged transcription factor
      role: regulator_identifier
    - name: variant_type
      dtype: string
      description: Type of transcription factor variant tested in the experiment
- config_name: GSE222268_metadata
  description: General experiment metadata for genomic studies
  dataset_type: metadata
  data_files:
  - split: train
    path: GSE222268_metadata.parquet
  dataset_info:
    features:
    - name: sample_id
      dtype: string
      description: Unique identifier for the experimental sample
    - name: series
      dtype: string
      description: Series or batch identifier grouping related samples
    - name: accession
      dtype: string
      description: Accession number from public database (e.g., SRA, GEO)
    - name: regulator_locus_tag
      dtype: string
      description: Systematic gene identifier for the transcription factor regulator
      role: regulator_identifier
    - name: regulator_symbol
      dtype: string
      description: Standard gene symbol for the transcription factor regulator
      role: regulator_identifier
    - name: experiment_details
      dtype: string
      description: Detailed description of experimental methods, parameters, or conditions
      role: experimental_condition 
    - name: description
      dtype:
        class_label:
          names: ["MNase", "ChEC-seq"]
      description: Experiment type, either MNase or ChEC-seq
---

# Barkai Compendium

This collects the ChEC-seq data from the following GEO series:

- [GSE179430](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE179430)
- [GSE209631](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE209631)
- [GSE222268](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE222268)

The metadata for each is parsed out from the SraRunTable, or in the case of GSE222268,
the NCBI series matrix file (the genotype isn't in the SraRunTable)

The [Barkai lab](https://barkailab.wixsite.com/barkai) refers to this set as their
binding compendium.

The genotypes for GSE222268 are not clear enough to me currently to parse well.

This repo provides 4 datasets:

- **GSE178430_metadata**: Metadata for GSE178430.
- **GSE209631_metadata**: ChEC-seq experiment metadata for transcription factor variant
  studies.
- **GSE222268_metadata**: General experiment metadata for genomic studies.
- **genome_map**: Genomic coverage data with pileup counts at specific positions.

## Usage

The python package `tfbpapi` provides an interface to this data which eases
examining the datasets, field definitions and other operations. You may also 
download the parquet datasets directly from hugging face by clicking on
"Files and Versions", or by using the huggingface_cli and duckdb directly.
In both cases, this provides a method of retrieving dataset and field definitions.

### `tfbpapi`

After [installing
tfbpapi](https://github.com/BrentLab/tfbpapi/?tab=readme-ov-file#installation), you can
adapt this [tutorial](https://brentlab.github.io/tfbpapi/tutorials/hfqueryapi_tutorial/)
in order to explore the contents of this repository.

### huggingface_cli/duckdb

You can retrieves and displays the file paths for each configuration of
the "BrentLab/barkai_compendium" dataset from Hugging Face Hub.

```python
from huggingface_hub import ModelCard
from pprint import pprint

card = ModelCard.load("BrentLab/barkai_compendium", repo_type="dataset")

# cast to dict
card_dict = card.data.to_dict()

# Get partition information
dataset_paths_dict = {d.get("config_name"): d.get("data_files")[0].get("path") for d in card_dict.get("configs")}

pprint(dataset_paths_dict)
```

The entire repository is large. It may be preferrable to only retrieve specific files or
partitions. You canuse the metadata files to choose which files to pull.

```python
from huggingface_hub import snapshot_download
import duckdb
import os

# Download only the partitioned dataset directory
repo_path = snapshot_download(
    repo_id="BrentLab/barkai_compendium",
    repo_type="dataset",
    allow_patterns="*metadata.parquet"
)

dataset_path = os.path.join(repo_path, "GSE178430_metadata.parquet")
conn = duckdb.connect()
meta_res = conn.execute("SELECT * FROM read_parquet(?) LIMIT 10", [dataset_path]).df()

print(meta_res)
```

We might choose to take a look at the file with accession `GSM5417602`

```python
# Download only the partitioned dataset directory
repo_path = snapshot_download(
    repo_id="BrentLab/barkai_compendium",
    repo_type="dataset",
    allow_patterns="genome_map/series=GSE179430/accession=GSM5417602/*parquet"  # Only the parquet data
)

# Query the specific partition
dataset_path = os.path.join(repo_path, "genome_map")
result = conn.execute("SELECT * FROM read_parquet(?) LIMIT 10", 
                     [f"{dataset_path}/**/*.parquet"]).df()

print(result)
```

If you wish to pull the entire repo, due to its size you may need to use an
[authentication token](https://huggingface.co/docs/hub/en/security-tokens).
If you do not have one, try omitting the token related code below and see if
it works. Else, create a token and provide it like so:

```python
repo_id = "BrentLab/barkai_compendium"

hf_token = os.getenv("HF_TOKEN")

# Download entire repo to local directory
repo_path = snapshot_download(
    repo_id=repo_id,
    repo_type="dataset",
    token=hf_token
)

print(f"\n✓ Repository downloaded to: {repo_path}")

# Construct path to the genome_map parquet file
parquet_path = os.path.join(repo_path, "genome_map.parquet")
print(f"✓ Parquet file at: {parquet_path}")
```