snailz 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snailz-0.1.3/LICENSE.md +22 -0
- snailz-0.1.3/MANIFEST.in +4 -0
- snailz-0.1.3/PKG-INFO +258 -0
- snailz-0.1.3/README.md +232 -0
- snailz-0.1.3/img/.$db-schema.svg.bkp +4 -0
- snailz-0.1.3/img/.$workflow.svg.bkp +4 -0
- snailz-0.1.3/img/db-schema.svg +4 -0
- snailz-0.1.3/img/snail-logo.svg +1109 -0
- snailz-0.1.3/img/survey.png +0 -0
- snailz-0.1.3/img/workflow.svg +4 -0
- snailz-0.1.3/pyproject.toml +49 -0
- snailz-0.1.3/setup.cfg +4 -0
- snailz-0.1.3/snailz/Makefile +109 -0
- snailz-0.1.3/snailz/__init__.py +85 -0
- snailz-0.1.3/snailz/assays.py +161 -0
- snailz-0.1.3/snailz/clui.py +108 -0
- snailz-0.1.3/snailz/db.py +34 -0
- snailz-0.1.3/snailz/genomes.py +120 -0
- snailz-0.1.3/snailz/grid.py +137 -0
- snailz-0.1.3/snailz/mangle.py +109 -0
- snailz-0.1.3/snailz/params/assays.json +18 -0
- snailz-0.1.3/snailz/params/genomes.json +8 -0
- snailz-0.1.3/snailz/params/grids.json +6 -0
- snailz-0.1.3/snailz/params/samples.json +7 -0
- snailz-0.1.3/snailz/params/sites.csv +5 -0
- snailz-0.1.3/snailz/params/surveys.csv +7 -0
- snailz-0.1.3/snailz/params.py +104 -0
- snailz-0.1.3/snailz/plates.py +111 -0
- snailz-0.1.3/snailz/samples.py +96 -0
- snailz-0.1.3/snailz/survey.py +26 -0
- snailz-0.1.3/snailz.egg-info/PKG-INFO +258 -0
- snailz-0.1.3/snailz.egg-info/SOURCES.txt +34 -0
- snailz-0.1.3/snailz.egg-info/dependency_links.txt +1 -0
- snailz-0.1.3/snailz.egg-info/entry_points.txt +2 -0
- snailz-0.1.3/snailz.egg-info/requires.txt +15 -0
- snailz-0.1.3/snailz.egg-info/top_level.txt +1 -0
snailz-0.1.3/LICENSE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
|
4
|
+
obtaining a copy of this software and associated documentation
|
|
5
|
+
files (the "Software"), to deal in the Software without
|
|
6
|
+
restriction, including without limitation the rights to use,
|
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the
|
|
9
|
+
Software is furnished to do so, subject to the following
|
|
10
|
+
conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
snailz-0.1.3/MANIFEST.in
ADDED
snailz-0.1.3/PKG-INFO
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: snailz
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Synthetic data generator for snail mutation survey
|
|
5
|
+
Author-email: Greg Wilson <gvwilson@third-bit.com>
|
|
6
|
+
Maintainer-email: Greg Wilson <gvwilson@third-bit.com>
|
|
7
|
+
Keywords: open science,synthetic data
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE.md
|
|
13
|
+
Requires-Dist: faker>=26.0
|
|
14
|
+
Requires-Dist: geopy>=2.4
|
|
15
|
+
Requires-Dist: kaleido>=0.2
|
|
16
|
+
Requires-Dist: pandas>=2.2
|
|
17
|
+
Requires-Dist: plotly>=5.22
|
|
18
|
+
Requires-Dist: polars>=1.1
|
|
19
|
+
Requires-Dist: pyarrow>=16.1
|
|
20
|
+
Requires-Dist: sqlalchemy>=2.0
|
|
21
|
+
Provides-Extra: tests
|
|
22
|
+
Requires-Dist: pytest; extra == "tests"
|
|
23
|
+
Requires-Dist: pytest-cov; extra == "tests"
|
|
24
|
+
Provides-Extra: lint
|
|
25
|
+
Requires-Dist: ruff; extra == "lint"
|
|
26
|
+
|
|
27
|
+
# Snailz
|
|
28
|
+
|
|
29
|
+
<img src="https://raw.githubusercontent.com/gvwilson/snailz/main/img/snail-logo.svg" alt="snail logo" width="200px">
|
|
30
|
+
|
|
31
|
+
These data generators model genomic analysis of snails in the Pacific Northwest
|
|
32
|
+
that are growing to unusual size as a result of exposure to pollution.
|
|
33
|
+
|
|
34
|
+
- One or more *surveys* are conducted at one or more *sites*.
|
|
35
|
+
- Each survey collects *genomes* and *sizes* of snails.
|
|
36
|
+
- A *grid* at each site is marked out to show the presence or absence of pollution.
|
|
37
|
+
- *Laboratory staff* perform *assays* of the snails' genetic material.
|
|
38
|
+
- Each assay plate has a *design* showing the material applied and *readings* showing the measured response.
|
|
39
|
+
- Plates may be *invalidated* after the fact if a staff member believes it is contaminated.
|
|
40
|
+
|
|
41
|
+
<img src="https://raw.githubusercontent.com/gvwilson/snailz/main/img/survey.png" alt="survey sites">
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
1. Create a fresh Python environment: `mamba create -y -n snailz python=3.12`
|
|
46
|
+
2. Activate that environment: `mamba activate snailz`
|
|
47
|
+
3. Build development version of package: `pip install -e .`
|
|
48
|
+
4. View available commands: `snailz --help`
|
|
49
|
+
5. Copy default parameter files: `snailz params --outdir .`
|
|
50
|
+
6. See how to regenerate datasets: `python -c 'import snailz; help(snailz)'`
|
|
51
|
+
|
|
52
|
+
This project also includes a Makefile that will re-execute commands as needed.
|
|
53
|
+
To see available commands, run:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
make DATA=data PARAMS=snailz/params commands
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
(To keep the Makefile simple,
|
|
60
|
+
`DATA` and `PARAMS` must be defined even for commands that don't need them.)
|
|
61
|
+
To regenerate all of the datasets, run:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
make DATA=data PARAMS=snailz/params datasets
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| command | action |
|
|
68
|
+
| ---------- | -------------------------------------- |
|
|
69
|
+
| `dev` | rebuild development version of package |
|
|
70
|
+
| `lint` | check code using ruff |
|
|
71
|
+
| `clean` | remove datafiles |
|
|
72
|
+
| `commands` | show available commands |
|
|
73
|
+
| `datasets` | make all datasets |
|
|
74
|
+
| `survey` | generate survey map |
|
|
75
|
+
| `mangled` | create inconsistent plate files |
|
|
76
|
+
| `db` | generate database |
|
|
77
|
+
| `plates` | generate plate files |
|
|
78
|
+
| `assays` | generate assay files |
|
|
79
|
+
| `samples` | sample snails from survey sites |
|
|
80
|
+
| `genomes` | synthesize genomes |
|
|
81
|
+
| `grids` | synthesize pollution grids |
|
|
82
|
+
|
|
83
|
+
## Database
|
|
84
|
+
|
|
85
|
+
The final database `data/lab.db` is structured as shown below.
|
|
86
|
+
Note that the data from the file `assays.json` is split between several tables.
|
|
87
|
+
Note also that the SQLite database file is *not* included in this repository
|
|
88
|
+
because its binary representation changes each time it is regenerated
|
|
89
|
+
(even though the values it contains stay the same).
|
|
90
|
+
The map of survey locations in `data/survey.png` is not included in the repository for the same reason,
|
|
91
|
+
but a duplicate is manually saved in `img/survey.png`.
|
|
92
|
+
|
|
93
|
+
<img src="https://raw.githubusercontent.com/gvwilson/snailz/main/img/db-schema.svg" alt="database schema">
|
|
94
|
+
|
|
95
|
+
- `site`: survey site
|
|
96
|
+
- `site_id`: primary key (text)
|
|
97
|
+
- `lon`: longitude of site reference marker (float deg)
|
|
98
|
+
- `lat`: latitude of site reference marker (float deg)
|
|
99
|
+
- `survey`
|
|
100
|
+
- `survey_id`: primary key (text)
|
|
101
|
+
- `site_id`: foreign key of site where survey was conducted (text)
|
|
102
|
+
- `date`: date that survey was conducted (date, YYYY-MM-DD)
|
|
103
|
+
- `sample`: sample taken from survey
|
|
104
|
+
- `sample_id`: primary key (int, 1-1 with `experiment.sample_id`)
|
|
105
|
+
- `survey_id`: foreign key of survey (int)
|
|
106
|
+
- `lon`: longitude of sample site (float deg)
|
|
107
|
+
- `lat`: latitude of sample site (float deg)
|
|
108
|
+
- `sequence`: genome sequence of sample (text)
|
|
109
|
+
- `size`: snail size (float)
|
|
110
|
+
- `experiment`: experiment done on sample
|
|
111
|
+
- `sample_id`: primary key (int, 1-1 with `sample.sample_id`)
|
|
112
|
+
- `kind`: kind of experiment (text, either 'ELISA' or 'JESS')
|
|
113
|
+
- `start`: start date (date, YYYY-MM-DD)
|
|
114
|
+
- `end`: end date (date, YYYY-MM-DD, null if experiment is ongoing)
|
|
115
|
+
- `staff`
|
|
116
|
+
- `staff_id`: primary key (int)
|
|
117
|
+
- `personal`: personal name (text)
|
|
118
|
+
- `family`: family name (text)
|
|
119
|
+
- `performed`: join table showing which staff members performed which experiments
|
|
120
|
+
- `staff_id`: foreign key of staff member
|
|
121
|
+
- `sample_id`: foreign key of sample/experiment
|
|
122
|
+
- `plate`: information about single assay plate
|
|
123
|
+
- `plate_id`: primary key (int)
|
|
124
|
+
- `sample_id`: foreign key of sample/experiment (int)
|
|
125
|
+
- `date`: date that plate was run (date, YYYY-MM-DD)
|
|
126
|
+
- `filename`: filename of design/results file (text)
|
|
127
|
+
- `invalidated`: invalidated plates
|
|
128
|
+
- `plate_id`: foreign key of plate (int)
|
|
129
|
+
- `staff_id`: foreign key of staff member who did invalidation (int)
|
|
130
|
+
- `date`: when plate was invalidated
|
|
131
|
+
|
|
132
|
+
## Data Files
|
|
133
|
+
|
|
134
|
+
`./data` contains a generated dataset for reference.
|
|
135
|
+
As noted above,
|
|
136
|
+
it does *not* contain the SQLite database file `lab.db`;
|
|
137
|
+
run `snailz db` to regenerate it.
|
|
138
|
+
(See `help(snailz)` for an example invocation.)
|
|
139
|
+
|
|
140
|
+
- Genomes: `genomes.json`
|
|
141
|
+
- `length`: number of base pairs (int > 0)
|
|
142
|
+
- `reference`: the unmutated reference genome (text)
|
|
143
|
+
- `individuals`: sequences for individuals (list of text)
|
|
144
|
+
- `locations`: locations of mutations (list of int)
|
|
145
|
+
- `susceptible_loc`: location of mutation of interest (int >= 0)
|
|
146
|
+
- `susceptible_base`: mutated base responsible for size change (char)
|
|
147
|
+
- Grids: `grids/*.csv` (one file per site)
|
|
148
|
+
- 1/0: presence/absence of contamination at sample location
|
|
149
|
+
- Samples: `grids/samples.csv`
|
|
150
|
+
- `sample_id`: unique ID for genetic sample (text)
|
|
151
|
+
- `survey_id`: which survey it was taken in (text)
|
|
152
|
+
- `lon`: longitude of sample site (float)
|
|
153
|
+
- `lat`: latitude of sample site (float)
|
|
154
|
+
- `sequence`: sampled gene sequence (text)
|
|
155
|
+
- `size`: snail weight (float, grams)
|
|
156
|
+
- Assays: `assays.json`
|
|
157
|
+
- `staff`:
|
|
158
|
+
- `staff_id`: unique staff member identifier (int > 0)
|
|
159
|
+
- `personal`: personal name (text)
|
|
160
|
+
- `family`: family name (text)
|
|
161
|
+
- `experiment`: experiment details
|
|
162
|
+
- `sample_id`: sample that experiment used (int > 0)
|
|
163
|
+
- `kind`: "ELISA" or "JESS" (text)
|
|
164
|
+
- `start`: start date (date, YYYY-MM-DD)
|
|
165
|
+
- `end`: end date (date, YYYY-MM-DD or None if experiment incomplete)
|
|
166
|
+
- `performed`: join table showing who performed which experiments
|
|
167
|
+
- `staff_id`: foreign key to `staff`
|
|
168
|
+
- `sample_id`: foreign key to `experiment`
|
|
169
|
+
- `plate`: details of assay plates used in experiments
|
|
170
|
+
- `plate_id`: unique plate identifier (int > 0)
|
|
171
|
+
- `sample_id`: foreign key to `sample` (text)
|
|
172
|
+
- `date`: date plate was run (date, YYYY-MM-DD)
|
|
173
|
+
- `filename`: name of design and results files (text)
|
|
174
|
+
- `invalidated`: which plates have been invalidated
|
|
175
|
+
- `plate_id`: foreign key to plate (text)
|
|
176
|
+
- `staff_id`: foreign key to staff member responsible (text)
|
|
177
|
+
- `date`: invalidation date (date, YYYY-MM-DD)
|
|
178
|
+
- Plates are represented by matching files in the `designs` and `readings` directories
|
|
179
|
+
- `designs/*.csv`: assay plate designs
|
|
180
|
+
- header: machine type, file type ("design" or "readings"), staff ID
|
|
181
|
+
- blank line
|
|
182
|
+
- table with column and row titles showing material in each well
|
|
183
|
+
- `readings/*.csv`: assay plate readings
|
|
184
|
+
- header: machine type, file type ("design" or "readings"), staff ID
|
|
185
|
+
- blank line
|
|
186
|
+
- table with column and row titles showing reading from each well
|
|
187
|
+
- To simulate the messiness of real experimental data,
|
|
188
|
+
the tidy assay plate files in `readings/*.csv` are copied to `mangled/*.csv`
|
|
189
|
+
with random changes:
|
|
190
|
+
- Some files have a staff member's name added in the first row.
|
|
191
|
+
- Some have an extra header row containing the experiment date.
|
|
192
|
+
- Some have a footer with the staff member's ID.
|
|
193
|
+
- In some, the values are offset one column to the right.
|
|
194
|
+
|
|
195
|
+
## Workflow
|
|
196
|
+
|
|
197
|
+
The workflow used to generate the database and data files is shown below:
|
|
198
|
+
|
|
199
|
+
- `snailz` or `snailz --help`: show available commands
|
|
200
|
+
- `snailz all`: make all datasets
|
|
201
|
+
- `snailz map`: generate SVG map of sample locations (in progress)
|
|
202
|
+
- `snailz mangle`: create mangled plate reading files
|
|
203
|
+
- `snailz db`: generate database
|
|
204
|
+
- `snailz plates`: generate plate files
|
|
205
|
+
- `snailz assays`: generate assay files
|
|
206
|
+
- `snailz samples`: sample snails from survey sites
|
|
207
|
+
- `snailz genomes`: synthesize genomes
|
|
208
|
+
- `snailz grids`: synthesize pollution grids
|
|
209
|
+
- `snailz clean`: remove all datasets
|
|
210
|
+
|
|
211
|
+
<img src="https://raw.githubusercontent.com/gvwilson/snailz/main/img/workflow.svg" alt="data generation workflow">
|
|
212
|
+
|
|
213
|
+
## Parameters
|
|
214
|
+
|
|
215
|
+
`./snailz/params` contains the parameter files used to control generation of the reference dataset.
|
|
216
|
+
These are included in the package and can be copied into the current directory using `snailz params --outdir .`
|
|
217
|
+
(replace `.` with another directory name as desired).
|
|
218
|
+
`snailz params` also copies a Makefile that can re-run commands with appropriate parameters;
|
|
219
|
+
see the table of commands given earlier for options.
|
|
220
|
+
|
|
221
|
+
- Sites: `sites.csv`
|
|
222
|
+
- `site_id`: unique label for site (text)
|
|
223
|
+
- `lon`: longitude of site reference marker (deg)
|
|
224
|
+
- `lat`: latitude of site reference marker (deg)
|
|
225
|
+
- Surveys: `surveys.csv`
|
|
226
|
+
- `survey_id`: unique label for survey (text)
|
|
227
|
+
- `site_id`: ID of site where survey was conducted (text)
|
|
228
|
+
- `date`: date that survey was conducted (date, YYYY-MM-DD)
|
|
229
|
+
- `spacing`: spacing of measurement point (float, meters)
|
|
230
|
+
- Genomes: `genomes.json`
|
|
231
|
+
- `length`: number of base pairs in sequences (int > 0)
|
|
232
|
+
- `num_genomes`: how many individuals to generate (int > 0)
|
|
233
|
+
- `num_snp`: number of single nucleotide polymorphisms (int > 0)
|
|
234
|
+
- `prob_other`: probability of non-significant mutations (float in 0..1)
|
|
235
|
+
- `seed`: RNG seed (int > 0)
|
|
236
|
+
- `snp_probs`: probability of selecting various bases (list of 4 float summing to 1.0)
|
|
237
|
+
- Grids: `grids.json`
|
|
238
|
+
- `depth`: range of random values per cell (int > 0)
|
|
239
|
+
- `height`: number of cells on Y axis (int > 0)
|
|
240
|
+
- `seed`: RNG seed (int > 0)
|
|
241
|
+
- `width`: number of cells on X axis (int > 0)
|
|
242
|
+
- Assays: `assays.json`
|
|
243
|
+
- `assay_duration`: range of days for each assay (ordered pair of int >= 0)
|
|
244
|
+
- `assay_plates`: range of plates per assay (ordered pair of int >= 1)
|
|
245
|
+
- `assay_staff`: range of staff in each assay (ordered pair of int > 0)
|
|
246
|
+
- `assay_types`: types of assays (list of text)
|
|
247
|
+
- `control_val`: nominal reading value for control wells (float > 0)
|
|
248
|
+
- `controls`: labels to used for control wells (list of text)
|
|
249
|
+
- `enddate`: end of all experiments
|
|
250
|
+
- `filename_length`: length of stem of design/readings filenames (int > 0)
|
|
251
|
+
- `invalid`: probability of plate being invalidted (float in 0..1)
|
|
252
|
+
- `locale`: locale to use when generating staff names (text)
|
|
253
|
+
- `seed`: RNG seed (int > 0)
|
|
254
|
+
- `staff`: number of staff (int > 0)
|
|
255
|
+
- `startdate`: start of all experiments
|
|
256
|
+
- `stdev`: standard deviation on readings (float > 0)
|
|
257
|
+
- `treated_val`: nominal reading value for treated well (float > 0)
|
|
258
|
+
- `treatment`: label to use for treated wells (text)
|
snailz-0.1.3/README.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Snailz
|
|
2
|
+
|
|
3
|
+
<img src="https://raw.githubusercontent.com/gvwilson/snailz/main/img/snail-logo.svg" alt="snail logo" width="200px">
|
|
4
|
+
|
|
5
|
+
These data generators model genomic analysis of snails in the Pacific Northwest
|
|
6
|
+
that are growing to unusual size as a result of exposure to pollution.
|
|
7
|
+
|
|
8
|
+
- One or more *surveys* are conducted at one or more *sites*.
|
|
9
|
+
- Each survey collects *genomes* and *sizes* of snails.
|
|
10
|
+
- A *grid* at each site is marked out to show the presence or absence of pollution.
|
|
11
|
+
- *Laboratory staff* perform *assays* of the snails' genetic material.
|
|
12
|
+
- Each assay plate has a *design* showing the material applied and *readings* showing the measured response.
|
|
13
|
+
- Plates may be *invalidated* after the fact if a staff member believes it is contaminated.
|
|
14
|
+
|
|
15
|
+
<img src="https://raw.githubusercontent.com/gvwilson/snailz/main/img/survey.png" alt="survey sites">
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
1. Create a fresh Python environment: `mamba create -y -n snailz python=3.12`
|
|
20
|
+
2. Activate that environment: `mamba activate snailz`
|
|
21
|
+
3. Build development version of package: `pip install -e .`
|
|
22
|
+
4. View available commands: `snailz --help`
|
|
23
|
+
5. Copy default parameter files: `snailz params --outdir .`
|
|
24
|
+
6. See how to regenerate datasets: `python -c 'import snailz; help(snailz)'`
|
|
25
|
+
|
|
26
|
+
This project also includes a Makefile that will re-execute commands as needed.
|
|
27
|
+
To see available commands, run:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
make DATA=data PARAMS=snailz/params commands
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
(To keep the Makefile simple,
|
|
34
|
+
`DATA` and `PARAMS` must be defined even for commands that don't need them.)
|
|
35
|
+
To regenerate all of the datasets, run:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
make DATA=data PARAMS=snailz/params datasets
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
| command | action |
|
|
42
|
+
| ---------- | -------------------------------------- |
|
|
43
|
+
| `dev` | rebuild development version of package |
|
|
44
|
+
| `lint` | check code using ruff |
|
|
45
|
+
| `clean` | remove datafiles |
|
|
46
|
+
| `commands` | show available commands |
|
|
47
|
+
| `datasets` | make all datasets |
|
|
48
|
+
| `survey` | generate survey map |
|
|
49
|
+
| `mangled` | create inconsistent plate files |
|
|
50
|
+
| `db` | generate database |
|
|
51
|
+
| `plates` | generate plate files |
|
|
52
|
+
| `assays` | generate assay files |
|
|
53
|
+
| `samples` | sample snails from survey sites |
|
|
54
|
+
| `genomes` | synthesize genomes |
|
|
55
|
+
| `grids` | synthesize pollution grids |
|
|
56
|
+
|
|
57
|
+
## Database
|
|
58
|
+
|
|
59
|
+
The final database `data/lab.db` is structured as shown below.
|
|
60
|
+
Note that the data from the file `assays.json` is split between several tables.
|
|
61
|
+
Note also that the SQLite database file is *not* included in this repository
|
|
62
|
+
because its binary representation changes each time it is regenerated
|
|
63
|
+
(even though the values it contains stay the same).
|
|
64
|
+
The map of survey locations in `data/survey.png` is not included in the repository for the same reason,
|
|
65
|
+
but a duplicate is manually saved in `img/survey.png`.
|
|
66
|
+
|
|
67
|
+
<img src="https://raw.githubusercontent.com/gvwilson/snailz/main/img/db-schema.svg" alt="database schema">
|
|
68
|
+
|
|
69
|
+
- `site`: survey site
|
|
70
|
+
- `site_id`: primary key (text)
|
|
71
|
+
- `lon`: longitude of site reference marker (float deg)
|
|
72
|
+
- `lat`: latitude of site reference marker (float deg)
|
|
73
|
+
- `survey`
|
|
74
|
+
- `survey_id`: primary key (text)
|
|
75
|
+
- `site_id`: foreign key of site where survey was conducted (text)
|
|
76
|
+
- `date`: date that survey was conducted (date, YYYY-MM-DD)
|
|
77
|
+
- `sample`: sample taken from survey
|
|
78
|
+
- `sample_id`: primary key (int, 1-1 with `experiment.sample_id`)
|
|
79
|
+
- `survey_id`: foreign key of survey (int)
|
|
80
|
+
- `lon`: longitude of sample site (float deg)
|
|
81
|
+
- `lat`: latitude of sample site (float deg)
|
|
82
|
+
- `sequence`: genome sequence of sample (text)
|
|
83
|
+
- `size`: snail size (float)
|
|
84
|
+
- `experiment`: experiment done on sample
|
|
85
|
+
- `sample_id`: primary key (int, 1-1 with `sample.sample_id`)
|
|
86
|
+
- `kind`: kind of experiment (text, either 'ELISA' or 'JESS')
|
|
87
|
+
- `start`: start date (date, YYYY-MM-DD)
|
|
88
|
+
- `end`: end date (date, YYYY-MM-DD, null if experiment is ongoing)
|
|
89
|
+
- `staff`
|
|
90
|
+
- `staff_id`: primary key (int)
|
|
91
|
+
- `personal`: personal name (text)
|
|
92
|
+
- `family`: family name (text)
|
|
93
|
+
- `performed`: join table showing which staff members performed which experiments
|
|
94
|
+
- `staff_id`: foreign key of staff member
|
|
95
|
+
- `sample_id`: foreign key of sample/experiment
|
|
96
|
+
- `plate`: information about single assay plate
|
|
97
|
+
- `plate_id`: primary key (int)
|
|
98
|
+
- `sample_id`: foreign key of sample/experiment (int)
|
|
99
|
+
- `date`: date that plate was run (date, YYYY-MM-DD)
|
|
100
|
+
- `filename`: filename of design/results file (text)
|
|
101
|
+
- `invalidated`: invalidated plates
|
|
102
|
+
- `plate_id`: foreign key of plate (int)
|
|
103
|
+
- `staff_id`: foreign key of staff member who did invalidation (int)
|
|
104
|
+
- `date`: when plate was invalidated
|
|
105
|
+
|
|
106
|
+
## Data Files
|
|
107
|
+
|
|
108
|
+
`./data` contains a generated dataset for reference.
|
|
109
|
+
As noted above,
|
|
110
|
+
it does *not* contain the SQLite database file `lab.db`;
|
|
111
|
+
run `snailz db` to regenerate it.
|
|
112
|
+
(See `help(snailz)` for an example invocation.)
|
|
113
|
+
|
|
114
|
+
- Genomes: `genomes.json`
|
|
115
|
+
- `length`: number of base pairs (int > 0)
|
|
116
|
+
- `reference`: the unmutated reference genome (text)
|
|
117
|
+
- `individuals`: sequences for individuals (list of text)
|
|
118
|
+
- `locations`: locations of mutations (list of int)
|
|
119
|
+
- `susceptible_loc`: location of mutation of interest (int >= 0)
|
|
120
|
+
- `susceptible_base`: mutated base responsible for size change (char)
|
|
121
|
+
- Grids: `grids/*.csv` (one file per site)
|
|
122
|
+
- 1/0: presence/absence of contamination at sample location
|
|
123
|
+
- Samples: `grids/samples.csv`
|
|
124
|
+
- `sample_id`: unique ID for genetic sample (text)
|
|
125
|
+
- `survey_id`: which survey it was taken in (text)
|
|
126
|
+
- `lon`: longitude of sample site (float)
|
|
127
|
+
- `lat`: latitude of sample site (float)
|
|
128
|
+
- `sequence`: sampled gene sequence (text)
|
|
129
|
+
- `size`: snail weight (float, grams)
|
|
130
|
+
- Assays: `assays.json`
|
|
131
|
+
- `staff`:
|
|
132
|
+
- `staff_id`: unique staff member identifier (int > 0)
|
|
133
|
+
- `personal`: personal name (text)
|
|
134
|
+
- `family`: family name (text)
|
|
135
|
+
- `experiment`: experiment details
|
|
136
|
+
- `sample_id`: sample that experiment used (int > 0)
|
|
137
|
+
- `kind`: "ELISA" or "JESS" (text)
|
|
138
|
+
- `start`: start date (date, YYYY-MM-DD)
|
|
139
|
+
- `end`: end date (date, YYYY-MM-DD or None if experiment incomplete)
|
|
140
|
+
- `performed`: join table showing who performed which experiments
|
|
141
|
+
- `staff_id`: foreign key to `staff`
|
|
142
|
+
- `sample_id`: foreign key to `experiment`
|
|
143
|
+
- `plate`: details of assay plates used in experiments
|
|
144
|
+
- `plate_id`: unique plate identifier (int > 0)
|
|
145
|
+
- `sample_id`: foreign key to `sample` (text)
|
|
146
|
+
- `date`: date plate was run (date, YYYY-MM-DD)
|
|
147
|
+
- `filename`: name of design and results files (text)
|
|
148
|
+
- `invalidated`: which plates have been invalidated
|
|
149
|
+
- `plate_id`: foreign key to plate (text)
|
|
150
|
+
- `staff_id`: foreign key to staff member responsible (text)
|
|
151
|
+
- `date`: invalidation date (date, YYYY-MM-DD)
|
|
152
|
+
- Plates are represented by matching files in the `designs` and `readings` directories
|
|
153
|
+
- `designs/*.csv`: assay plate designs
|
|
154
|
+
- header: machine type, file type ("design" or "readings"), staff ID
|
|
155
|
+
- blank line
|
|
156
|
+
- table with column and row titles showing material in each well
|
|
157
|
+
- `readings/*.csv`: assay plate readings
|
|
158
|
+
- header: machine type, file type ("design" or "readings"), staff ID
|
|
159
|
+
- blank line
|
|
160
|
+
- table with column and row titles showing reading from each well
|
|
161
|
+
- To simulate the messiness of real experimental data,
|
|
162
|
+
the tidy assay plate files in `readings/*.csv` are copied to `mangled/*.csv`
|
|
163
|
+
with random changes:
|
|
164
|
+
- Some files have a staff member's name added in the first row.
|
|
165
|
+
- Some have an extra header row containing the experiment date.
|
|
166
|
+
- Some have a footer with the staff member's ID.
|
|
167
|
+
- In some, the values are offset one column to the right.
|
|
168
|
+
|
|
169
|
+
## Workflow
|
|
170
|
+
|
|
171
|
+
The workflow used to generate the database and data files is shown below:
|
|
172
|
+
|
|
173
|
+
- `snailz` or `snailz --help`: show available commands
|
|
174
|
+
- `snailz all`: make all datasets
|
|
175
|
+
- `snailz map`: generate SVG map of sample locations (in progress)
|
|
176
|
+
- `snailz mangle`: create mangled plate reading files
|
|
177
|
+
- `snailz db`: generate database
|
|
178
|
+
- `snailz plates`: generate plate files
|
|
179
|
+
- `snailz assays`: generate assay files
|
|
180
|
+
- `snailz samples`: sample snails from survey sites
|
|
181
|
+
- `snailz genomes`: synthesize genomes
|
|
182
|
+
- `snailz grids`: synthesize pollution grids
|
|
183
|
+
- `snailz clean`: remove all datasets
|
|
184
|
+
|
|
185
|
+
<img src="https://raw.githubusercontent.com/gvwilson/snailz/main/img/workflow.svg" alt="data generation workflow">
|
|
186
|
+
|
|
187
|
+
## Parameters
|
|
188
|
+
|
|
189
|
+
`./snailz/params` contains the parameter files used to control generation of the reference dataset.
|
|
190
|
+
These are included in the package and can be copied into the current directory using `snailz params --outdir .`
|
|
191
|
+
(replace `.` with another directory name as desired).
|
|
192
|
+
`snailz params` also copies a Makefile that can re-run commands with appropriate parameters;
|
|
193
|
+
see the table of commands given earlier for options.
|
|
194
|
+
|
|
195
|
+
- Sites: `sites.csv`
|
|
196
|
+
- `site_id`: unique label for site (text)
|
|
197
|
+
- `lon`: longitude of site reference marker (deg)
|
|
198
|
+
- `lat`: latitude of site reference marker (deg)
|
|
199
|
+
- Surveys: `surveys.csv`
|
|
200
|
+
- `survey_id`: unique label for survey (text)
|
|
201
|
+
- `site_id`: ID of site where survey was conducted (text)
|
|
202
|
+
- `date`: date that survey was conducted (date, YYYY-MM-DD)
|
|
203
|
+
- `spacing`: spacing of measurement point (float, meters)
|
|
204
|
+
- Genomes: `genomes.json`
|
|
205
|
+
- `length`: number of base pairs in sequences (int > 0)
|
|
206
|
+
- `num_genomes`: how many individuals to generate (int > 0)
|
|
207
|
+
- `num_snp`: number of single nucleotide polymorphisms (int > 0)
|
|
208
|
+
- `prob_other`: probability of non-significant mutations (float in 0..1)
|
|
209
|
+
- `seed`: RNG seed (int > 0)
|
|
210
|
+
- `snp_probs`: probability of selecting various bases (list of 4 float summing to 1.0)
|
|
211
|
+
- Grids: `grids.json`
|
|
212
|
+
- `depth`: range of random values per cell (int > 0)
|
|
213
|
+
- `height`: number of cells on Y axis (int > 0)
|
|
214
|
+
- `seed`: RNG seed (int > 0)
|
|
215
|
+
- `width`: number of cells on X axis (int > 0)
|
|
216
|
+
- Assays: `assays.json`
|
|
217
|
+
- `assay_duration`: range of days for each assay (ordered pair of int >= 0)
|
|
218
|
+
- `assay_plates`: range of plates per assay (ordered pair of int >= 1)
|
|
219
|
+
- `assay_staff`: range of staff in each assay (ordered pair of int > 0)
|
|
220
|
+
- `assay_types`: types of assays (list of text)
|
|
221
|
+
- `control_val`: nominal reading value for control wells (float > 0)
|
|
222
|
+
- `controls`: labels to used for control wells (list of text)
|
|
223
|
+
- `enddate`: end of all experiments
|
|
224
|
+
- `filename_length`: length of stem of design/readings filenames (int > 0)
|
|
225
|
+
- `invalid`: probability of plate being invalidted (float in 0..1)
|
|
226
|
+
- `locale`: locale to use when generating staff names (text)
|
|
227
|
+
- `seed`: RNG seed (int > 0)
|
|
228
|
+
- `staff`: number of staff (int > 0)
|
|
229
|
+
- `startdate`: start of all experiments
|
|
230
|
+
- `stdev`: standard deviation on readings (float > 0)
|
|
231
|
+
- `treated_val`: nominal reading value for treated well (float > 0)
|
|
232
|
+
- `treatment`: label to use for treated wells (text)
|