dataframe-toolkit 0.5.0__tar.gz → 0.5.1__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.
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/PKG-INFO +76 -38
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/README.md +75 -37
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/pyproject.toml +1 -1
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/stat_cmd.py +10 -5
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/__init__.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/cli.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/__init__.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/annotate_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/base.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/binx_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/clean_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/concat_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/corr_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/dataset_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/describe_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/eval_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/fit_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/func_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/help.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/hist_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/info_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/interp_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/line_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/melt_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/merge_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/pivot_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/print_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/query_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/randvar_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/sample_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/scale_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/scat_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/segid_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/split_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/test_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/transpose_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/commands/wstat_cmd.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/common/__init__.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/common/io.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/common/plot.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/common/seed.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/common/seq.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/common/stats.py +0 -0
- {dataframe_toolkit-0.5.0 → dataframe_toolkit-0.5.1}/src/dftk/io.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: dataframe-toolkit
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.1
|
|
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
|
|
@@ -38,6 +38,14 @@ for analysts who live in the terminal and want a consistent, pipeable toolkit
|
|
|
38
38
|
for the full data analysis pipeline — from initial exploration through
|
|
39
39
|
statistical modelling and publication-quality figures.
|
|
40
40
|
|
|
41
|
+
**No data file handy?** Every example below uses `dftk dataset` to pull in a
|
|
42
|
+
small, real dataset, so you can copy-paste any of them and run them right
|
|
43
|
+
now. Run `dftk dataset --list` to browse everything available (dozens of
|
|
44
|
+
datasets from seaborn, statsmodels, and pydataset). `dftk dataset NAME`
|
|
45
|
+
searches all three sources in that order and returns the first match, so
|
|
46
|
+
`--source` is optional — pass it only to disambiguate a name that exists in
|
|
47
|
+
more than one source, or to restrict the search.
|
|
48
|
+
|
|
41
49
|
## Installation
|
|
42
50
|
|
|
43
51
|
```bash
|
|
@@ -68,28 +76,38 @@ uv tool install .
|
|
|
68
76
|
## Quick example
|
|
69
77
|
|
|
70
78
|
```bash
|
|
71
|
-
dftk stat
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
dftk dataset tips | dftk stat - -c tip total_bill -g day
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Chain commands with `-o` (write to a temp parquet, print its path) and `...`
|
|
83
|
+
(read a parquet path from stdin) instead of piping TSV text directly — faster
|
|
84
|
+
for large data, and the recommended pattern once a pipeline has more than one
|
|
85
|
+
step:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
dftk dataset tips -o \
|
|
89
|
+
| dftk pivot ... -i day -v tip -f mean -o \
|
|
90
|
+
| dftk print ...
|
|
75
91
|
```
|
|
76
92
|
|
|
77
93
|
## Subcommands
|
|
78
94
|
|
|
79
95
|
### Data transformation
|
|
80
96
|
|
|
81
|
-
| Command
|
|
82
|
-
|
|
83
|
-
| `eval`
|
|
84
|
-
| `query`
|
|
85
|
-
| `merge`
|
|
86
|
-
| `concat`
|
|
87
|
-
| `melt`
|
|
88
|
-
| `pivot`
|
|
89
|
-
| `func`
|
|
90
|
-
| `scale`
|
|
91
|
-
| `interp`
|
|
92
|
-
| `binx`
|
|
97
|
+
| Command | Description |
|
|
98
|
+
|-------------|---------------------------------------------------------------------------------------|
|
|
99
|
+
| `eval` | Add or modify columns: eval expressions, string/path functions, statistical ops |
|
|
100
|
+
| `query` | Filter rows with pandas query expressions or SQL (`--sql` via DuckDB) |
|
|
101
|
+
| `merge` | Join two tables on key columns (inner/left/right/outer) |
|
|
102
|
+
| `concat` | Concatenate two or more tables row-wise |
|
|
103
|
+
| `melt` | Reshape wide-to-long (`pd.melt`) |
|
|
104
|
+
| `pivot` | Reshape long-to-wide with per-cell aggregation |
|
|
105
|
+
| `func` | Column transforms: cumsum, group mean/sum/min/max/count/median/std, rank, qcut:N |
|
|
106
|
+
| `scale` | Normalise: z-score, min-shift, sum/max/mean scaling, Blom rank, regression residuals |
|
|
107
|
+
| `interp` | Interpolate values from a reference curve into a table (1-D lookup) |
|
|
108
|
+
| `binx` | Assign bin indices to a column based on explicit or generated edges |
|
|
109
|
+
| `transpose` | Flip rows and columns; original column names land in a new `--keycol` column |
|
|
110
|
+
| `segid` | Assign a segment ID that increments on each value change in a column |
|
|
93
111
|
|
|
94
112
|
### Statistics
|
|
95
113
|
|
|
@@ -101,6 +119,7 @@ dftk stat data.tsv -c value -g group -o \
|
|
|
101
119
|
| `test` | P-values between column pairs: t-test, Mann-Whitney, Wilcoxon, KS, correlations, bootstrap; groups |
|
|
102
120
|
| `corr` | Pairwise column correlations (Pearson/Spearman/Kendall) with optional BCa bootstrap CI |
|
|
103
121
|
| `describe` | Quick column-level summary (dtype, n, n_unique, n_null, sample values) |
|
|
122
|
+
| `info` | Per-column dtype, null counts, and memory usage; `--summary` for dataset-level totals |
|
|
104
123
|
| `randvar` | Sample from a distribution and append as a new column (norm, alpha, beta, …) |
|
|
105
124
|
|
|
106
125
|
### Plots
|
|
@@ -133,38 +152,48 @@ publication-quality output.
|
|
|
133
152
|
### Chaining commands
|
|
134
153
|
|
|
135
154
|
```bash
|
|
136
|
-
# z-score within
|
|
137
|
-
dftk
|
|
138
|
-
| dftk
|
|
155
|
+
# z-score sepal_length within species, then fit against petal_length
|
|
156
|
+
dftk dataset iris -o \
|
|
157
|
+
| dftk scale ... -c sepal_length -g species -o \
|
|
158
|
+
| dftk fit ... -f "sepal_length_scaled ~ petal_length" -g species
|
|
139
159
|
```
|
|
140
160
|
|
|
141
161
|
### Group summary then plot
|
|
142
162
|
|
|
143
163
|
```bash
|
|
144
|
-
dftk
|
|
145
|
-
| dftk
|
|
164
|
+
dftk dataset tips -o \
|
|
165
|
+
| dftk stat ... -c tip -g day -o \
|
|
166
|
+
| dftk line ... -x day -y mean --yerr sem -f fig.png
|
|
146
167
|
```
|
|
147
168
|
|
|
148
169
|
### Wide-to-long then plot overlaid histograms
|
|
149
170
|
|
|
150
171
|
```bash
|
|
151
|
-
dftk
|
|
152
|
-
| dftk
|
|
172
|
+
dftk dataset iris \
|
|
173
|
+
| dftk melt - -i species -d measurement -v value \
|
|
174
|
+
| dftk hist - -x value -g measurement -k -f dist.png
|
|
153
175
|
```
|
|
154
176
|
|
|
155
177
|
### Interpolation (standard curve lookup)
|
|
156
178
|
|
|
157
179
|
```bash
|
|
158
|
-
|
|
159
|
-
|
|
180
|
+
printf "conc\tfluor\n0\t5\n10\t52\n20\t98\n30\t151\n" > stdcurve.tsv
|
|
181
|
+
printf "sample\tfluor\ns1\t60\ns2\t110\n" \
|
|
182
|
+
| dftk interp - --ref stdcurve.tsv -x fluor --refx fluor -v conc -d conc_ng_ul
|
|
160
183
|
```
|
|
161
184
|
|
|
162
185
|
### Bootstrap confidence intervals
|
|
163
186
|
|
|
187
|
+
Bootstrap mode repeats the full stat computation N times on resampled data
|
|
188
|
+
and emits one row per resample (tagged with `samplenum`) — pipe into `pivot`
|
|
189
|
+
with percentile aggfuncs (`cilo`/`cihi`) to collapse that into an empirical
|
|
190
|
+
confidence interval:
|
|
191
|
+
|
|
164
192
|
```bash
|
|
165
|
-
dftk
|
|
166
|
-
| dftk
|
|
167
|
-
| dftk
|
|
193
|
+
dftk dataset tips -o \
|
|
194
|
+
| dftk stat ... -c tip -g day --bootstrap 1000 --randomseed 42 -o \
|
|
195
|
+
| dftk pivot ... -i day -v mean -f mean cilo cihi -o \
|
|
196
|
+
| dftk print ...
|
|
168
197
|
```
|
|
169
198
|
|
|
170
199
|
## Input/output
|
|
@@ -176,9 +205,19 @@ All commands accept:
|
|
|
176
205
|
- `...` to receive a parquet path from stdin (written by a previous `-o` command)
|
|
177
206
|
- A `.parquet` filename to read a named parquet file directly
|
|
178
207
|
|
|
208
|
+
> **`-` vs `...`** — these are not interchangeable. Use `-` when the previous
|
|
209
|
+
> command in the pipe wrote plain TSV to stdout (the default). Use `...` when
|
|
210
|
+
> the previous command used bare `-o` (pipe mode), which writes a temp
|
|
211
|
+
> parquet and prints *its path* to stdout — `-` would try to parse that path
|
|
212
|
+
> as TSV and fail.
|
|
213
|
+
|
|
179
214
|
Standard output options (available on all tabular commands):
|
|
180
215
|
|
|
181
|
-
- `-o` / `--output` —
|
|
216
|
+
- `-o` / `--output` — controls where output goes; takes an *optional* value:
|
|
217
|
+
- `-o` alone — write a temp parquet to pipe into the next command, printing its path to stdout (auto-deleted once read)
|
|
218
|
+
- `-o FILE.parquet` — write a named, reusable parquet, printing its path to stdout
|
|
219
|
+
- `-o FILE` (no `.parquet` extension) — write TSV to `FILE`, with no stdout output
|
|
220
|
+
- omit `-o` entirely — write TSV to stdout (the default)
|
|
182
221
|
- `--select col1 col2 …` — keep only these columns
|
|
183
222
|
- `--drop col1 col2 …` — remove these columns
|
|
184
223
|
- `--round N` — round numeric output
|
|
@@ -193,20 +232,19 @@ any new `--meta` values.
|
|
|
193
232
|
|
|
194
233
|
```bash
|
|
195
234
|
# Tag a file at creation
|
|
196
|
-
dftk
|
|
197
|
-
--meta genome=hg38 --meta source=gwas_2024
|
|
235
|
+
dftk dataset iris -o iris.parquet --meta source=seaborn --meta species_col=species
|
|
198
236
|
|
|
199
237
|
# Inspect annotations
|
|
200
|
-
dftk annotate
|
|
201
|
-
#
|
|
202
|
-
#
|
|
238
|
+
dftk annotate iris.parquet
|
|
239
|
+
# source seaborn
|
|
240
|
+
# species_col species
|
|
203
241
|
|
|
204
242
|
# Add or update an annotation in-place
|
|
205
|
-
dftk annotate
|
|
243
|
+
dftk annotate iris.parquet --set step=raw
|
|
206
244
|
|
|
207
245
|
# Annotations survive piping
|
|
208
|
-
dftk eval
|
|
209
|
-
dftk annotate
|
|
246
|
+
dftk eval iris.parquet -f "petal_area = petal_length * petal_width" -o iris2.parquet
|
|
247
|
+
dftk annotate iris2.parquet # source, species_col, and step all still present
|
|
210
248
|
```
|
|
211
249
|
|
|
212
250
|
## Figure options (plot commands)
|
|
@@ -10,6 +10,14 @@ for analysts who live in the terminal and want a consistent, pipeable toolkit
|
|
|
10
10
|
for the full data analysis pipeline — from initial exploration through
|
|
11
11
|
statistical modelling and publication-quality figures.
|
|
12
12
|
|
|
13
|
+
**No data file handy?** Every example below uses `dftk dataset` to pull in a
|
|
14
|
+
small, real dataset, so you can copy-paste any of them and run them right
|
|
15
|
+
now. Run `dftk dataset --list` to browse everything available (dozens of
|
|
16
|
+
datasets from seaborn, statsmodels, and pydataset). `dftk dataset NAME`
|
|
17
|
+
searches all three sources in that order and returns the first match, so
|
|
18
|
+
`--source` is optional — pass it only to disambiguate a name that exists in
|
|
19
|
+
more than one source, or to restrict the search.
|
|
20
|
+
|
|
13
21
|
## Installation
|
|
14
22
|
|
|
15
23
|
```bash
|
|
@@ -40,28 +48,38 @@ uv tool install .
|
|
|
40
48
|
## Quick example
|
|
41
49
|
|
|
42
50
|
```bash
|
|
43
|
-
dftk stat
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
dftk dataset tips | dftk stat - -c tip total_bill -g day
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Chain commands with `-o` (write to a temp parquet, print its path) and `...`
|
|
55
|
+
(read a parquet path from stdin) instead of piping TSV text directly — faster
|
|
56
|
+
for large data, and the recommended pattern once a pipeline has more than one
|
|
57
|
+
step:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
dftk dataset tips -o \
|
|
61
|
+
| dftk pivot ... -i day -v tip -f mean -o \
|
|
62
|
+
| dftk print ...
|
|
47
63
|
```
|
|
48
64
|
|
|
49
65
|
## Subcommands
|
|
50
66
|
|
|
51
67
|
### Data transformation
|
|
52
68
|
|
|
53
|
-
| Command
|
|
54
|
-
|
|
55
|
-
| `eval`
|
|
56
|
-
| `query`
|
|
57
|
-
| `merge`
|
|
58
|
-
| `concat`
|
|
59
|
-
| `melt`
|
|
60
|
-
| `pivot`
|
|
61
|
-
| `func`
|
|
62
|
-
| `scale`
|
|
63
|
-
| `interp`
|
|
64
|
-
| `binx`
|
|
69
|
+
| Command | Description |
|
|
70
|
+
|-------------|---------------------------------------------------------------------------------------|
|
|
71
|
+
| `eval` | Add or modify columns: eval expressions, string/path functions, statistical ops |
|
|
72
|
+
| `query` | Filter rows with pandas query expressions or SQL (`--sql` via DuckDB) |
|
|
73
|
+
| `merge` | Join two tables on key columns (inner/left/right/outer) |
|
|
74
|
+
| `concat` | Concatenate two or more tables row-wise |
|
|
75
|
+
| `melt` | Reshape wide-to-long (`pd.melt`) |
|
|
76
|
+
| `pivot` | Reshape long-to-wide with per-cell aggregation |
|
|
77
|
+
| `func` | Column transforms: cumsum, group mean/sum/min/max/count/median/std, rank, qcut:N |
|
|
78
|
+
| `scale` | Normalise: z-score, min-shift, sum/max/mean scaling, Blom rank, regression residuals |
|
|
79
|
+
| `interp` | Interpolate values from a reference curve into a table (1-D lookup) |
|
|
80
|
+
| `binx` | Assign bin indices to a column based on explicit or generated edges |
|
|
81
|
+
| `transpose` | Flip rows and columns; original column names land in a new `--keycol` column |
|
|
82
|
+
| `segid` | Assign a segment ID that increments on each value change in a column |
|
|
65
83
|
|
|
66
84
|
### Statistics
|
|
67
85
|
|
|
@@ -73,6 +91,7 @@ dftk stat data.tsv -c value -g group -o \
|
|
|
73
91
|
| `test` | P-values between column pairs: t-test, Mann-Whitney, Wilcoxon, KS, correlations, bootstrap; groups |
|
|
74
92
|
| `corr` | Pairwise column correlations (Pearson/Spearman/Kendall) with optional BCa bootstrap CI |
|
|
75
93
|
| `describe` | Quick column-level summary (dtype, n, n_unique, n_null, sample values) |
|
|
94
|
+
| `info` | Per-column dtype, null counts, and memory usage; `--summary` for dataset-level totals |
|
|
76
95
|
| `randvar` | Sample from a distribution and append as a new column (norm, alpha, beta, …) |
|
|
77
96
|
|
|
78
97
|
### Plots
|
|
@@ -105,38 +124,48 @@ publication-quality output.
|
|
|
105
124
|
### Chaining commands
|
|
106
125
|
|
|
107
126
|
```bash
|
|
108
|
-
# z-score within
|
|
109
|
-
dftk
|
|
110
|
-
| dftk
|
|
127
|
+
# z-score sepal_length within species, then fit against petal_length
|
|
128
|
+
dftk dataset iris -o \
|
|
129
|
+
| dftk scale ... -c sepal_length -g species -o \
|
|
130
|
+
| dftk fit ... -f "sepal_length_scaled ~ petal_length" -g species
|
|
111
131
|
```
|
|
112
132
|
|
|
113
133
|
### Group summary then plot
|
|
114
134
|
|
|
115
135
|
```bash
|
|
116
|
-
dftk
|
|
117
|
-
| dftk
|
|
136
|
+
dftk dataset tips -o \
|
|
137
|
+
| dftk stat ... -c tip -g day -o \
|
|
138
|
+
| dftk line ... -x day -y mean --yerr sem -f fig.png
|
|
118
139
|
```
|
|
119
140
|
|
|
120
141
|
### Wide-to-long then plot overlaid histograms
|
|
121
142
|
|
|
122
143
|
```bash
|
|
123
|
-
dftk
|
|
124
|
-
| dftk
|
|
144
|
+
dftk dataset iris \
|
|
145
|
+
| dftk melt - -i species -d measurement -v value \
|
|
146
|
+
| dftk hist - -x value -g measurement -k -f dist.png
|
|
125
147
|
```
|
|
126
148
|
|
|
127
149
|
### Interpolation (standard curve lookup)
|
|
128
150
|
|
|
129
151
|
```bash
|
|
130
|
-
|
|
131
|
-
|
|
152
|
+
printf "conc\tfluor\n0\t5\n10\t52\n20\t98\n30\t151\n" > stdcurve.tsv
|
|
153
|
+
printf "sample\tfluor\ns1\t60\ns2\t110\n" \
|
|
154
|
+
| dftk interp - --ref stdcurve.tsv -x fluor --refx fluor -v conc -d conc_ng_ul
|
|
132
155
|
```
|
|
133
156
|
|
|
134
157
|
### Bootstrap confidence intervals
|
|
135
158
|
|
|
159
|
+
Bootstrap mode repeats the full stat computation N times on resampled data
|
|
160
|
+
and emits one row per resample (tagged with `samplenum`) — pipe into `pivot`
|
|
161
|
+
with percentile aggfuncs (`cilo`/`cihi`) to collapse that into an empirical
|
|
162
|
+
confidence interval:
|
|
163
|
+
|
|
136
164
|
```bash
|
|
137
|
-
dftk
|
|
138
|
-
| dftk
|
|
139
|
-
| dftk
|
|
165
|
+
dftk dataset tips -o \
|
|
166
|
+
| dftk stat ... -c tip -g day --bootstrap 1000 --randomseed 42 -o \
|
|
167
|
+
| dftk pivot ... -i day -v mean -f mean cilo cihi -o \
|
|
168
|
+
| dftk print ...
|
|
140
169
|
```
|
|
141
170
|
|
|
142
171
|
## Input/output
|
|
@@ -148,9 +177,19 @@ All commands accept:
|
|
|
148
177
|
- `...` to receive a parquet path from stdin (written by a previous `-o` command)
|
|
149
178
|
- A `.parquet` filename to read a named parquet file directly
|
|
150
179
|
|
|
180
|
+
> **`-` vs `...`** — these are not interchangeable. Use `-` when the previous
|
|
181
|
+
> command in the pipe wrote plain TSV to stdout (the default). Use `...` when
|
|
182
|
+
> the previous command used bare `-o` (pipe mode), which writes a temp
|
|
183
|
+
> parquet and prints *its path* to stdout — `-` would try to parse that path
|
|
184
|
+
> as TSV and fail.
|
|
185
|
+
|
|
151
186
|
Standard output options (available on all tabular commands):
|
|
152
187
|
|
|
153
|
-
- `-o` / `--output` —
|
|
188
|
+
- `-o` / `--output` — controls where output goes; takes an *optional* value:
|
|
189
|
+
- `-o` alone — write a temp parquet to pipe into the next command, printing its path to stdout (auto-deleted once read)
|
|
190
|
+
- `-o FILE.parquet` — write a named, reusable parquet, printing its path to stdout
|
|
191
|
+
- `-o FILE` (no `.parquet` extension) — write TSV to `FILE`, with no stdout output
|
|
192
|
+
- omit `-o` entirely — write TSV to stdout (the default)
|
|
154
193
|
- `--select col1 col2 …` — keep only these columns
|
|
155
194
|
- `--drop col1 col2 …` — remove these columns
|
|
156
195
|
- `--round N` — round numeric output
|
|
@@ -165,20 +204,19 @@ any new `--meta` values.
|
|
|
165
204
|
|
|
166
205
|
```bash
|
|
167
206
|
# Tag a file at creation
|
|
168
|
-
dftk
|
|
169
|
-
--meta genome=hg38 --meta source=gwas_2024
|
|
207
|
+
dftk dataset iris -o iris.parquet --meta source=seaborn --meta species_col=species
|
|
170
208
|
|
|
171
209
|
# Inspect annotations
|
|
172
|
-
dftk annotate
|
|
173
|
-
#
|
|
174
|
-
#
|
|
210
|
+
dftk annotate iris.parquet
|
|
211
|
+
# source seaborn
|
|
212
|
+
# species_col species
|
|
175
213
|
|
|
176
214
|
# Add or update an annotation in-place
|
|
177
|
-
dftk annotate
|
|
215
|
+
dftk annotate iris.parquet --set step=raw
|
|
178
216
|
|
|
179
217
|
# Annotations survive piping
|
|
180
|
-
dftk eval
|
|
181
|
-
dftk annotate
|
|
218
|
+
dftk eval iris.parquet -f "petal_area = petal_length * petal_width" -o iris2.parquet
|
|
219
|
+
dftk annotate iris2.parquet # source, species_col, and step all still present
|
|
182
220
|
```
|
|
183
221
|
|
|
184
222
|
## Figure options (plot commands)
|
|
@@ -21,9 +21,11 @@ into ``dftk pivot`` to aggregate across samples.
|
|
|
21
21
|
Example
|
|
22
22
|
-------
|
|
23
23
|
dftk stat data.tsv -c height weight -g sex
|
|
24
|
+
|
|
25
|
+
# Empirical bootstrap CI: resample, then collapse with percentile aggfuncs
|
|
24
26
|
dftk stat data.tsv -c value -g group --bootstrap 1000 --randomseed 42 -o \\
|
|
25
|
-
| dftk pivot -i group -v
|
|
26
|
-
| dftk print
|
|
27
|
+
| dftk pivot ... -i group -v mean -f mean cilo cihi -o \\
|
|
28
|
+
| dftk print ...
|
|
27
29
|
"""
|
|
28
30
|
|
|
29
31
|
import argparse
|
|
@@ -278,9 +280,12 @@ class StatCommand(BaseCommand):
|
|
|
278
280
|
if args.groupcol is None:
|
|
279
281
|
sample = df.sample(**sample_kwargs)
|
|
280
282
|
else:
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
283
|
+
# [df.columns.tolist()] re-selection works around a pandas 3.0
|
|
284
|
+
# groupby(...).apply() change that otherwise drops the
|
|
285
|
+
# grouping column from the result.
|
|
286
|
+
sample = df.groupby(args.groupcol, group_keys=False)[
|
|
287
|
+
df.columns.tolist()
|
|
288
|
+
].apply(lambda x: x.sample(**sample_kwargs))
|
|
284
289
|
|
|
285
290
|
result = _compute_stats(sample, args)
|
|
286
291
|
result["samplenum"] = i
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|