dataframe-toolkit 0.22.0__tar.gz → 0.23.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 (63) hide show
  1. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/PKG-INFO +19 -3
  2. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/README.md +18 -2
  3. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/pyproject.toml +1 -1
  4. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/pyproject.toml.orig +1 -1
  5. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/__init__.py +1 -0
  6. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/dataset_cmd.py +9 -0
  7. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/eval_cmd.py +10 -8
  8. dataframe_toolkit-0.23.0/src/dftk/commands/forest_cmd.py +706 -0
  9. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/line_cmd.py +35 -5
  10. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/manhattan_cmd.py +3 -3
  11. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/scat_cmd.py +3 -3
  12. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/stat_cmd.py +7 -2
  13. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/common/evalfuncs.py +93 -27
  14. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/common/gwas.py +102 -0
  15. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/skills/dftk/SKILL.md +5 -1
  16. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/__init__.py +0 -0
  17. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/cli.py +0 -0
  18. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/annotate_cmd.py +0 -0
  19. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/append_cmd.py +0 -0
  20. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/base.py +0 -0
  21. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/binx_cmd.py +0 -0
  22. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/chi_cmd.py +0 -0
  23. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/clean_cmd.py +0 -0
  24. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/cleannames_cmd.py +0 -0
  25. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/concat_cmd.py +0 -0
  26. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/corr_cmd.py +0 -0
  27. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/describe_cmd.py +0 -0
  28. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/explode_cmd.py +0 -0
  29. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/fit_cmd.py +0 -0
  30. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/func_cmd.py +0 -0
  31. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/heatmap_cmd.py +0 -0
  32. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/help.py +0 -0
  33. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/hist_cmd.py +0 -0
  34. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/implode_cmd.py +0 -0
  35. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/info_cmd.py +0 -0
  36. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/interp_cmd.py +0 -0
  37. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/locus_cmd.py +0 -0
  38. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/melt_cmd.py +0 -0
  39. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/merge_cmd.py +0 -0
  40. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/pairs_cmd.py +0 -0
  41. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/pivot_cmd.py +0 -0
  42. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/print_cmd.py +0 -0
  43. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/qq_cmd.py +0 -0
  44. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/query_cmd.py +0 -0
  45. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/randvar_cmd.py +0 -0
  46. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/sample_cmd.py +0 -0
  47. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/scale_cmd.py +0 -0
  48. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/segid_cmd.py +0 -0
  49. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/skill_cmd.py +0 -0
  50. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/split_cmd.py +0 -0
  51. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/test_cmd.py +0 -0
  52. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/transpose_cmd.py +0 -0
  53. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/commands/wstat_cmd.py +0 -0
  54. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/common/__init__.py +0 -0
  55. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/common/copula.py +0 -0
  56. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/common/docformats.py +0 -0
  57. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/common/io.py +0 -0
  58. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/common/plot.py +0 -0
  59. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/common/seed.py +0 -0
  60. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/common/seq.py +0 -0
  61. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/common/stats.py +0 -0
  62. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.0}/src/dftk/io.py +0 -0
  63. {dataframe_toolkit-0.22.0 → dataframe_toolkit-0.23.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.22.0
3
+ Version: 0.23.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
@@ -44,7 +44,7 @@ statistical modelling and publication-quality figures.
44
44
  small, real dataset, so you can copy-paste any of them and run them right
45
45
  now. Run `dftk dataset --list` to browse everything available (dozens of
46
46
  datasets from seaborn, statsmodels, and pydataset, plus `gwas`, a synthetic
47
- association scan made by dftk). `dftk dataset NAME` searches dftk, seaborn,
47
+ association scan, and `phewas`, a synthetic phenome-wide scan, both made by dftk). `dftk dataset NAME` searches dftk, seaborn,
48
48
  statsmodels and pydataset in that order and returns the first match, so
49
49
  `--source` is optional — pass it only to disambiguate a name that exists in
50
50
  more than one source, or to restrict the search.
@@ -162,12 +162,13 @@ publication-quality output.
162
162
  | Command | Description |
163
163
  |---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
164
164
  | `scat` | Scatter plot; OLS/robust or LOWESS fit (`--fit lowess`, one per group with `-g`), hexagonal binning for large tables (`--hexbin`), bubble size (`--sizecol`), colour (`--colorcol`) |
165
- | `line` | Line plot; optional error bars (`--yerr`) or CI bands (`--yci lo,hi`) and fit overlay |
165
+ | `line` | Line plot; optional error bars (`--yerr`) or intervals (`--yci lo,hi`), `-ls none -m o` for points only, and fit overlay |
166
166
  | `hist` | Histogram or KDE (`--kde`); normalisation, cumulative mode, mean±σ annotation (`--stats`) |
167
167
  | `chi` | Corner-resolved chi-plot: whether tail dependence sits in the lower or upper corner |
168
168
  | `heatmap` | Coloured grid of values from a long (`-x -y -v`) or wide (`-y`) table; correlograms from `corr --all`, `--annot`, `--lower` |
169
169
  | `pairs` | Scatter-plot matrix with KDEs (or histograms) on the diagonal; `-g` colours groups, `--upper corr` puts r in the upper triangle |
170
170
  | `qq` | QQ plot of p-values: observed against expected -log10(p), confidence band, genomic inflation λ; `-g` one curve and λ per group |
171
+ | `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 |
171
172
  | `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` |
172
173
  | `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 |
173
174
 
@@ -517,6 +518,21 @@ dftk dataset gwas -o | dftk query -q "Chr == '6' and pos > 31.6e6 and pos < 33.6
517
518
  | dftk locus --ldcol r2 -f locus.png
518
519
  ```
519
520
 
521
+ `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`:
522
+
523
+ `dataset phewas` is a simulated phenome-wide scan of loss-of-function carriers (heterozygous and homozygous rows per phenotype, log odds ratios, five real effects) to try it on:
524
+
525
+ ```bash
526
+ dftk dataset phewas -o | dftk query -q "genotype == 'het' and Pval < 0.01" --sortasc Pval -o \
527
+ | dftk forest -y phenotype -x beta --se se --exp --text --textcol Pval -xl "odds ratio" -f top.png
528
+ ```
529
+
530
+ ```bash
531
+ dftk dataset tips -o \
532
+ | dftk fit -f "tip ~ total_bill + size + C(day) + C(smoker)" --postquery "marker != 'Intercept'" -o \
533
+ | dftk forest -y marker -x effect --ci cilo,cihi --text -f coef.png
534
+ ```
535
+
520
536
  ### Bootstrap confidence intervals
521
537
 
522
538
  Bootstrap mode repeats the full stat computation N times on resampled data
@@ -14,7 +14,7 @@ statistical modelling and publication-quality figures.
14
14
  small, real dataset, so you can copy-paste any of them and run them right
15
15
  now. Run `dftk dataset --list` to browse everything available (dozens of
16
16
  datasets from seaborn, statsmodels, and pydataset, plus `gwas`, a synthetic
17
- association scan made by dftk). `dftk dataset NAME` searches dftk, seaborn,
17
+ association scan, and `phewas`, a synthetic phenome-wide scan, both made by dftk). `dftk dataset NAME` searches dftk, seaborn,
18
18
  statsmodels and pydataset in that order and returns the first match, so
19
19
  `--source` is optional — pass it only to disambiguate a name that exists in
20
20
  more than one source, or to restrict the search.
@@ -132,12 +132,13 @@ publication-quality output.
132
132
  | Command | Description |
133
133
  |---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
134
134
  | `scat` | Scatter plot; OLS/robust or LOWESS fit (`--fit lowess`, one per group with `-g`), hexagonal binning for large tables (`--hexbin`), bubble size (`--sizecol`), colour (`--colorcol`) |
135
- | `line` | Line plot; optional error bars (`--yerr`) or CI bands (`--yci lo,hi`) and fit overlay |
135
+ | `line` | Line plot; optional error bars (`--yerr`) or intervals (`--yci lo,hi`), `-ls none -m o` for points only, and fit overlay |
136
136
  | `hist` | Histogram or KDE (`--kde`); normalisation, cumulative mode, mean±σ annotation (`--stats`) |
137
137
  | `chi` | Corner-resolved chi-plot: whether tail dependence sits in the lower or upper corner |
138
138
  | `heatmap` | Coloured grid of values from a long (`-x -y -v`) or wide (`-y`) table; correlograms from `corr --all`, `--annot`, `--lower` |
139
139
  | `pairs` | Scatter-plot matrix with KDEs (or histograms) on the diagonal; `-g` colours groups, `--upper corr` puts r in the upper triangle |
140
140
  | `qq` | QQ plot of p-values: observed against expected -log10(p), confidence band, genomic inflation λ; `-g` one curve and λ per group |
141
+ | `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 |
141
142
  | `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` |
142
143
  | `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 |
143
144
 
@@ -487,6 +488,21 @@ dftk dataset gwas -o | dftk query -q "Chr == '6' and pos > 31.6e6 and pos < 33.6
487
488
  | dftk locus --ldcol r2 -f locus.png
488
489
  ```
489
490
 
491
+ `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`:
492
+
493
+ `dataset phewas` is a simulated phenome-wide scan of loss-of-function carriers (heterozygous and homozygous rows per phenotype, log odds ratios, five real effects) to try it on:
494
+
495
+ ```bash
496
+ dftk dataset phewas -o | dftk query -q "genotype == 'het' and Pval < 0.01" --sortasc Pval -o \
497
+ | dftk forest -y phenotype -x beta --se se --exp --text --textcol Pval -xl "odds ratio" -f top.png
498
+ ```
499
+
500
+ ```bash
501
+ dftk dataset tips -o \
502
+ | dftk fit -f "tip ~ total_bill + size + C(day) + C(smoker)" --postquery "marker != 'Intercept'" -o \
503
+ | dftk forest -y marker -x effect --ci cilo,cihi --text -f coef.png
504
+ ```
505
+
490
506
  ### Bootstrap confidence intervals
491
507
 
492
508
  Bootstrap mode repeats the full stat computation N times on resampled data
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dataframe-toolkit"
3
- version = "0.22.0"
3
+ version = "0.23.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.22.0"
3
+ version = "0.23.0"
4
4
  description = "A command-line toolkit for DataFrame analysis and manipulation"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -68,6 +68,7 @@ COMMAND_GROUPS: list[tuple[str, list[tuple[str, str]]]] = [
68
68
  ("manhattan", "manhattan_cmd:ManhattanCommand"),
69
69
  ("qq", "qq_cmd:QqCommand"),
70
70
  ("locus", "locus_cmd:LocusCommand"),
71
+ ("forest", "forest_cmd:ForestCommand"),
71
72
  ],
72
73
  ),
73
74
  (
@@ -34,6 +34,11 @@ _DFTK_DATASETS = {
34
34
  "synthetic association scan: SNP, Chr, pos, Pval, Chisq, r2 "
35
35
  "(~121k variants, six peaks)"
36
36
  ),
37
+ "phewas": (
38
+ "synthetic PheWAS of loss-of-function carriers: category, phenotype, "
39
+ "prevalence, genotype (het/hom), n_carriers, beta (log OR), se, Pval "
40
+ "(74 phenotypes, five real effects)"
41
+ ),
37
42
  }
38
43
 
39
44
 
@@ -42,6 +47,10 @@ def _load_dftk(name: str) -> pd.DataFrame:
42
47
  from dftk.common.gwas import simulate_gwas
43
48
 
44
49
  return simulate_gwas()
50
+ if name == "phewas":
51
+ from dftk.common.gwas import simulate_phewas
52
+
53
+ return simulate_phewas()
45
54
  raise ValueError(f"dftk dataset {name!r} not found")
46
55
 
47
56
 
@@ -109,14 +109,16 @@ Available special functions:
109
109
  sum mean std min max median
110
110
 
111
111
  Conditional assignment:
112
- where(cond_col, true_val, false_val)
113
- — np.where-style conditional; cond_col must be a boolean column.
114
- true_val and false_val can each be: a column name, a quoted
115
- string literal ("foo"), or a numeric literal.
116
- Example:
117
- dftk dataset tips -o | dftk eval \
118
- -f "big = total_bill > 30" \
119
- -f "label = where(big, \"large\", \"small\")"
112
+ where(condition, value if true, value if false)
113
+ — np.where-style. Each argument is a column, a quoted string
114
+ ("foo"), a number, or a pandas expression of the columns
115
+ (-tip, tip * 2). The condition must be true or false (or 0
116
+ and 1), e.g. a true/false column or tip > 3; missing counts as
117
+ false. An unquoted word that is not a column is an error.
118
+ Examples:
119
+ dftk dataset tips -o \\
120
+ | dftk eval -f 'label = where(total_bill > 30, "large", "small")'
121
+ dftk dataset tips -o | dftk eval -f "signed = where(sex == 'Male', -tip, tip)"
120
122
 
121
123
  Bitwise:
122
124
  applymask(col, mask_col) — col & mask_col