dataframe-toolkit 0.25.1__tar.gz → 0.27.0__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.
Files changed (66) hide show
  1. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/PKG-INFO +29 -8
  2. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/README.md +28 -7
  3. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/pyproject.toml +1 -1
  4. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/pyproject.toml.orig +1 -1
  5. dataframe_toolkit-0.27.0/src/dftk/commands/phewas_cmd.py +703 -0
  6. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/query_cmd.py +8 -5
  7. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/skills/dftk/SKILL.md +8 -2
  8. dataframe_toolkit-0.25.1/src/dftk/commands/phewas_cmd.py +0 -421
  9. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/__init__.py +0 -0
  10. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/cli.py +0 -0
  11. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/__init__.py +0 -0
  12. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/annotate_cmd.py +0 -0
  13. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/append_cmd.py +0 -0
  14. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/base.py +0 -0
  15. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/binx_cmd.py +0 -0
  16. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/box_cmd.py +0 -0
  17. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/chi_cmd.py +0 -0
  18. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/clean_cmd.py +0 -0
  19. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/cleannames_cmd.py +0 -0
  20. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/concat_cmd.py +0 -0
  21. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/corr_cmd.py +0 -0
  22. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/dataset_cmd.py +0 -0
  23. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/describe_cmd.py +0 -0
  24. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/eval_cmd.py +0 -0
  25. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/explode_cmd.py +0 -0
  26. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/fit_cmd.py +0 -0
  27. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/forest_cmd.py +0 -0
  28. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/func_cmd.py +0 -0
  29. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/heatmap_cmd.py +0 -0
  30. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/help.py +0 -0
  31. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/hist_cmd.py +0 -0
  32. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/implode_cmd.py +0 -0
  33. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/info_cmd.py +0 -0
  34. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/interp_cmd.py +0 -0
  35. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/line_cmd.py +0 -0
  36. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/locus_cmd.py +0 -0
  37. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/manhattan_cmd.py +0 -0
  38. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/melt_cmd.py +0 -0
  39. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/merge_cmd.py +0 -0
  40. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/pairs_cmd.py +0 -0
  41. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/pivot_cmd.py +0 -0
  42. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/print_cmd.py +0 -0
  43. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/qq_cmd.py +0 -0
  44. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/randvar_cmd.py +0 -0
  45. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/sample_cmd.py +0 -0
  46. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/scale_cmd.py +0 -0
  47. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/scat_cmd.py +0 -0
  48. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/segid_cmd.py +0 -0
  49. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/skill_cmd.py +0 -0
  50. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/split_cmd.py +0 -0
  51. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/stat_cmd.py +0 -0
  52. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/test_cmd.py +0 -0
  53. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/transpose_cmd.py +0 -0
  54. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/commands/wstat_cmd.py +0 -0
  55. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/common/__init__.py +0 -0
  56. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/common/copula.py +0 -0
  57. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/common/docformats.py +0 -0
  58. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/common/evalfuncs.py +0 -0
  59. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/common/gwas.py +0 -0
  60. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/common/io.py +0 -0
  61. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/common/plot.py +0 -0
  62. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/common/seed.py +0 -0
  63. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/common/seq.py +0 -0
  64. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/common/stats.py +0 -0
  65. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/io.py +0 -0
  66. {dataframe_toolkit-0.25.1 → dataframe_toolkit-0.27.0}/src/dftk/skills/dftk/references/snakemake.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dataframe-toolkit
3
- Version: 0.25.1
3
+ Version: 0.27.0
4
4
  Summary: A command-line toolkit for DataFrame analysis and manipulation
5
5
  Keywords: dataframe,statistics,data analysis,CLI,TSV,pandas
6
6
  Author: Gunnar Pálsson
@@ -170,7 +170,7 @@ publication-quality output.
170
170
  | `pairs` | Scatter-plot matrix with KDEs (or histograms) on the diagonal; `-g` colours groups, `--upper corr` puts r in the upper triangle |
171
171
  | `qq` | QQ plot of p-values: observed against expected -log10(p), confidence band, genomic inflation λ; `-g` one curve and λ per group |
172
172
  | `forest` | Forest plot: one row per estimate with its interval (`--se` or `--ci lo,hi`), `--exp` for odds/hazard ratios on a log axis, `--text`/`--textcol` numbers on the right, `-g` several series per row, `--section` headers |
173
- | `phewas` | PheWAS plot: -log10(p) of each phenotype grouped by category (one colour each), ▲/▼ by the sign of `--betacol`, Bonferroni line, hits labelled |
173
+ | `phewas` | PheWAS plot: -log10(p) of each phenotype grouped by category (one colour each), ▲/▼ by the sign of `--betacol`, Bonferroni line, hits labelled; `--subgraphcol` stacks one panel per model or gene |
174
174
  | `locus` | Regional association plot: -log10(p) in one region coloured by r² with the lead variant (`--ldcol`), lead as a diamond, `--lead`/`--label` by ID or `chr:pos` |
175
175
  | `manhattan` | Genome-wide -log10(p) by position (`Chr`, `pos`, `Pval`, or `--mlogpcol`/`--chi2col`); significance lines, thinning for millions of variants, `-g`/`--subgraphcol` for several scans |
176
176
 
@@ -245,15 +245,28 @@ dftk query --sql "
245
245
  # ATXN7 chr3:30-42
246
246
  ```
247
247
 
248
- To get JSON back, write `-o FILE.json` or `.jsonl`, or `--format json` for stdout (see [Output formats](#output-formats)). Nested values and mixed fields are written as JSON again; a key missing from a record is written as `null`:
248
+ dftk reads JSON as a table, and a table has every column in every row: a record without a key gets an empty cell, and JSON output (`-o FILE.json`, `.jsonl`, `--format json`; see [Output formats](#output-formats)) writes that cell as `null`. So dftk is the tool for getting a table out of JSON, not for filtering JSON and keeping it JSON. With a third record `{"locus": "ATXN8"}` in `catalog.jsonl`:
249
249
 
250
250
  ```bash
251
- dftk query --sql "SELECT * FROM 'catalog.jsonl' WHERE locus LIKE 'ATXN%'" --format json
252
- # [
253
- # {"locus": "ATXN7", "region": ["chr3:1-30", "chr3:30-42"]}
254
- # ]
251
+ dftk query --sql "SELECT * FROM 'catalog.jsonl' WHERE locus LIKE 'ATXN%'" --format jsonl
252
+ # {"locus": "ATXN7", "region": ["chr3:1-30", "chr3:30-42"]}
253
+ # {"locus": "ATXN8", "region": null}
254
+ ```
255
+
256
+ [jq](https://jqlang.org/) filters records without making a table, so each comes out as it went in, and can also write TSV for a dftk pipeline:
257
+
258
+ ```bash
259
+ jq -c 'select(.locus | startswith("ATXN"))' catalog.jsonl
260
+ # {"locus":"ATXN7","region":["chr3:1-30","chr3:30-42"]}
261
+ # {"locus":"ATXN8"}
262
+ jq -r '[.locus, (.region // "" | tostring)] | @tsv' catalog.jsonl
263
+ # AFF2 chrX:1-60
264
+ # ATXN7 ["chr3:1-30","chr3:30-42"]
265
+ # ATXN8
255
266
  ```
256
267
 
268
+ JSON output is for tables: results, small records (`append`, below), input for tools that want JSON. Nested values and mixed fields are written as JSON again.
269
+
257
270
  ### One row: status logs and small records
258
271
 
259
272
  `append` adds one row from `-c COL=VALUE` values; columns not given stay empty. Numbers and `true`/`false` are typed, a quoted value (`'"007"'`) stays text and `note=` is empty. Without input it makes a one-row table, a quick way to write a small JSON record:
@@ -530,10 +543,18 @@ dftk dataset gwas -o | dftk query -q "Chr == '6' and pos > 31.6e6 and pos < 33.6
530
543
  | dftk locus --ldcol r2 -f locus.png
531
544
  ```
532
545
 
533
- `phewas` draws a phenome-wide scan: -log10(p) of each phenotype, the phenotypes grouped by category along the x axis in one colour per category (columns `category`, `phenotype` and `Pval` unless named with `-c`, `-l` and the p-value options of `manhattan`). With `--betacol beta` the points are triangles pointing up or down with the sign of the effect. The significance line is Bonferroni (0.05 / number of tests) unless `--sig` gives a p-value, and the phenotypes above it are labelled, at most `--label N` (default 10). One row per phenotype: pick one genotype or mask with `query` first.
546
+ `phewas` draws a phenome-wide scan: -log10(p) of each phenotype, the phenotypes grouped by category along the x axis in one colour per category (columns `category`, `phenotype` and `Pval` unless named with `-c`, `-l` and the p-value options of `manhattan`). With `--betacol beta` the points are triangles pointing up or down with the sign of the effect. The significance line is Bonferroni (0.05 / number of tests) unless `--sig` gives a p-value, and the phenotypes above it are labelled, at most `--label N` (default 10). `--labelpercat 1` labels only the strongest hit of each category, and `--labelnumbers` writes numbers instead of names, left to right, with the key on stdout for a caption. Every category is as wide on the x axis (`--catwidth count` makes a category as wide as its number of phenotypes). One row per phenotype: pick one genotype or mask with `query` first, or draw one panel each with `--subgraphcol`.
534
547
 
535
548
  ```bash
536
549
  dftk dataset phewas -o | dftk query -q "genotype == 'het'" -o | dftk phewas --betacol beta -f phewas.png
550
+ dftk dataset phewas -o | dftk query -q "genotype == 'het'" -o \
551
+ | dftk phewas --betacol beta --labelpercat 1 --labelnumbers -f phewas.png > phewas_key.tsv
552
+ ```
553
+
554
+ `--subgraphcol COL` stacks one PheWAS per value of a column: burden models of one gene, genes within one model, or genotypes. A phenotype stands at the same x in every panel and the panels share one y axis. The Bonferroni line counts each panel's own tests; `--sig P` draws one line at P in all of them:
555
+
556
+ ```bash
557
+ dftk dataset phewas -o | dftk phewas --betacol beta --subgraphcol genotype -f phewas_by_genotype.png
537
558
  ```
538
559
 
539
560
  `forest` draws one row per estimate: a point with its interval, labels down the left, top to bottom in file order (sort first to order them), and a reference line at 0. Give the interval as two columns (`--ci lo,hi`) or a standard error (`--se se`, ± 1.96 SE, `--level` to change). `--exp` turns log odds ratios (or any log-scale estimate) into ratios on a log axis with the reference at 1; `--text` writes `estimate [lo, hi]` to the right and `--textcol` adds columns such as the p-value or the number of carriers. `-g` puts several series on each row (het and hom carriers, two cohorts), `--section` groups rows under bold headers, `--weighted` sizes the markers by 1/SE². Coefficients from `fit`:
@@ -140,7 +140,7 @@ publication-quality output.
140
140
  | `pairs` | Scatter-plot matrix with KDEs (or histograms) on the diagonal; `-g` colours groups, `--upper corr` puts r in the upper triangle |
141
141
  | `qq` | QQ plot of p-values: observed against expected -log10(p), confidence band, genomic inflation λ; `-g` one curve and λ per group |
142
142
  | `forest` | Forest plot: one row per estimate with its interval (`--se` or `--ci lo,hi`), `--exp` for odds/hazard ratios on a log axis, `--text`/`--textcol` numbers on the right, `-g` several series per row, `--section` headers |
143
- | `phewas` | PheWAS plot: -log10(p) of each phenotype grouped by category (one colour each), ▲/▼ by the sign of `--betacol`, Bonferroni line, hits labelled |
143
+ | `phewas` | PheWAS plot: -log10(p) of each phenotype grouped by category (one colour each), ▲/▼ by the sign of `--betacol`, Bonferroni line, hits labelled; `--subgraphcol` stacks one panel per model or gene |
144
144
  | `locus` | Regional association plot: -log10(p) in one region coloured by r² with the lead variant (`--ldcol`), lead as a diamond, `--lead`/`--label` by ID or `chr:pos` |
145
145
  | `manhattan` | Genome-wide -log10(p) by position (`Chr`, `pos`, `Pval`, or `--mlogpcol`/`--chi2col`); significance lines, thinning for millions of variants, `-g`/`--subgraphcol` for several scans |
146
146
 
@@ -215,15 +215,28 @@ dftk query --sql "
215
215
  # ATXN7 chr3:30-42
216
216
  ```
217
217
 
218
- To get JSON back, write `-o FILE.json` or `.jsonl`, or `--format json` for stdout (see [Output formats](#output-formats)). Nested values and mixed fields are written as JSON again; a key missing from a record is written as `null`:
218
+ dftk reads JSON as a table, and a table has every column in every row: a record without a key gets an empty cell, and JSON output (`-o FILE.json`, `.jsonl`, `--format json`; see [Output formats](#output-formats)) writes that cell as `null`. So dftk is the tool for getting a table out of JSON, not for filtering JSON and keeping it JSON. With a third record `{"locus": "ATXN8"}` in `catalog.jsonl`:
219
219
 
220
220
  ```bash
221
- dftk query --sql "SELECT * FROM 'catalog.jsonl' WHERE locus LIKE 'ATXN%'" --format json
222
- # [
223
- # {"locus": "ATXN7", "region": ["chr3:1-30", "chr3:30-42"]}
224
- # ]
221
+ dftk query --sql "SELECT * FROM 'catalog.jsonl' WHERE locus LIKE 'ATXN%'" --format jsonl
222
+ # {"locus": "ATXN7", "region": ["chr3:1-30", "chr3:30-42"]}
223
+ # {"locus": "ATXN8", "region": null}
224
+ ```
225
+
226
+ [jq](https://jqlang.org/) filters records without making a table, so each comes out as it went in, and can also write TSV for a dftk pipeline:
227
+
228
+ ```bash
229
+ jq -c 'select(.locus | startswith("ATXN"))' catalog.jsonl
230
+ # {"locus":"ATXN7","region":["chr3:1-30","chr3:30-42"]}
231
+ # {"locus":"ATXN8"}
232
+ jq -r '[.locus, (.region // "" | tostring)] | @tsv' catalog.jsonl
233
+ # AFF2 chrX:1-60
234
+ # ATXN7 ["chr3:1-30","chr3:30-42"]
235
+ # ATXN8
225
236
  ```
226
237
 
238
+ JSON output is for tables: results, small records (`append`, below), input for tools that want JSON. Nested values and mixed fields are written as JSON again.
239
+
227
240
  ### One row: status logs and small records
228
241
 
229
242
  `append` adds one row from `-c COL=VALUE` values; columns not given stay empty. Numbers and `true`/`false` are typed, a quoted value (`'"007"'`) stays text and `note=` is empty. Without input it makes a one-row table, a quick way to write a small JSON record:
@@ -500,10 +513,18 @@ dftk dataset gwas -o | dftk query -q "Chr == '6' and pos > 31.6e6 and pos < 33.6
500
513
  | dftk locus --ldcol r2 -f locus.png
501
514
  ```
502
515
 
503
- `phewas` draws a phenome-wide scan: -log10(p) of each phenotype, the phenotypes grouped by category along the x axis in one colour per category (columns `category`, `phenotype` and `Pval` unless named with `-c`, `-l` and the p-value options of `manhattan`). With `--betacol beta` the points are triangles pointing up or down with the sign of the effect. The significance line is Bonferroni (0.05 / number of tests) unless `--sig` gives a p-value, and the phenotypes above it are labelled, at most `--label N` (default 10). One row per phenotype: pick one genotype or mask with `query` first.
516
+ `phewas` draws a phenome-wide scan: -log10(p) of each phenotype, the phenotypes grouped by category along the x axis in one colour per category (columns `category`, `phenotype` and `Pval` unless named with `-c`, `-l` and the p-value options of `manhattan`). With `--betacol beta` the points are triangles pointing up or down with the sign of the effect. The significance line is Bonferroni (0.05 / number of tests) unless `--sig` gives a p-value, and the phenotypes above it are labelled, at most `--label N` (default 10). `--labelpercat 1` labels only the strongest hit of each category, and `--labelnumbers` writes numbers instead of names, left to right, with the key on stdout for a caption. Every category is as wide on the x axis (`--catwidth count` makes a category as wide as its number of phenotypes). One row per phenotype: pick one genotype or mask with `query` first, or draw one panel each with `--subgraphcol`.
504
517
 
505
518
  ```bash
506
519
  dftk dataset phewas -o | dftk query -q "genotype == 'het'" -o | dftk phewas --betacol beta -f phewas.png
520
+ dftk dataset phewas -o | dftk query -q "genotype == 'het'" -o \
521
+ | dftk phewas --betacol beta --labelpercat 1 --labelnumbers -f phewas.png > phewas_key.tsv
522
+ ```
523
+
524
+ `--subgraphcol COL` stacks one PheWAS per value of a column: burden models of one gene, genes within one model, or genotypes. A phenotype stands at the same x in every panel and the panels share one y axis. The Bonferroni line counts each panel's own tests; `--sig P` draws one line at P in all of them:
525
+
526
+ ```bash
527
+ dftk dataset phewas -o | dftk phewas --betacol beta --subgraphcol genotype -f phewas_by_genotype.png
507
528
  ```
508
529
 
509
530
  `forest` draws one row per estimate: a point with its interval, labels down the left, top to bottom in file order (sort first to order them), and a reference line at 0. Give the interval as two columns (`--ci lo,hi`) or a standard error (`--se se`, ± 1.96 SE, `--level` to change). `--exp` turns log odds ratios (or any log-scale estimate) into ratios on a log axis with the reference at 1; `--text` writes `estimate [lo, hi]` to the right and `--textcol` adds columns such as the p-value or the number of carriers. `-g` puts several series on each row (het and hom carriers, two cohorts), `--section` groups rows under bold headers, `--weighted` sizes the markers by 1/SE². Coefficients from `fit`:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dataframe-toolkit"
3
- version = "0.25.1"
3
+ version = "0.27.0"
4
4
  description = "A command-line toolkit for DataFrame analysis and manipulation"
5
5
  readme = "README.md"
6
6
  keywords = [
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dataframe-toolkit"
3
- version = "0.25.1"
3
+ version = "0.27.0"
4
4
  description = "A command-line toolkit for DataFrame analysis and manipulation"
5
5
  readme = "README.md"
6
6
  authors = [