Diff of /docs/usage/usage.md [000000] .. [e5f1db]

Switch to unified view

a b/docs/usage/usage.md
1
# API
2
3
Import the ehrapy API as follows:
4
5
```python
6
import ehrapy as ep
7
```
8
9
You can then access the respective modules like:
10
11
```python
12
ep.pl.cool_fancy_plot()
13
```
14
15
```{eval-rst}
16
.. currentmodule:: ehrapy
17
```
18
19
## Reading and writing
20
21
```{eval-rst}
22
.. module:: ehrapy
23
```
24
25
```{eval-rst}
26
.. autosummary::
27
    :toctree: io
28
    :nosignatures:
29
30
    io.read_csv
31
    io.read_h5ad
32
    io.read_fhir
33
    io.write
34
```
35
36
## Data
37
38
```{eval-rst}
39
.. autosummary::
40
    :toctree: data
41
    :nosignatures:
42
43
    data.mimic_2
44
    data.mimic_2_preprocessed
45
    data.mimic_3_demo
46
    data.diabetes_130_raw
47
    data.diabetes_130_fairlearn
48
    data.heart_failure
49
    data.chronic_kidney_disease
50
    data.breast_tissue
51
    data.cervical_cancer_risk_factors
52
    data.dermatology
53
    data.echocardiogram
54
    data.heart_disease
55
    data.hepatitis
56
    data.statlog_heart
57
    data.thyroid
58
    data.breast_cancer_coimbra
59
    data.parkinson_dataset_with_replicated_acoustic_features
60
    data.parkinsons
61
    data.parkinsons_disease_classification
62
    data.parkinsons_telemonitoring
63
```
64
65
## Preprocessing
66
67
Any transformation of the data matrix that is not a tool.
68
Other than tools, preprocessing steps usually don’t return an easily interpretable annotation, but perform a basic transformation on the data matrix.
69
70
### Basic preprocessing
71
72
```{eval-rst}
73
.. autosummary::
74
    :toctree: preprocessing
75
    :nosignatures:
76
77
    preprocessing.encode
78
    preprocessing.pca
79
    preprocessing.regress_out
80
    preprocessing.subsample
81
    preprocessing.balanced_sample
82
    preprocessing.highly_variable_features
83
    preprocessing.winsorize
84
    preprocessing.clip_quantile
85
    preprocessing.summarize_measurements
86
```
87
88
### Quality control
89
90
```{eval-rst}
91
.. autosummary::
92
    :toctree: preprocessing
93
    :nosignatures:
94
95
    preprocessing.qc_metrics
96
    preprocessing.qc_lab_measurements
97
    preprocessing.mcar_test
98
    preprocessing.detect_bias
99
```
100
101
### Imputation
102
103
```{eval-rst}
104
.. autosummary::
105
    :toctree: preprocessing
106
    :nosignatures:
107
108
    preprocessing.explicit_impute
109
    preprocessing.simple_impute
110
    preprocessing.knn_impute
111
    preprocessing.miss_forest_impute
112
    preprocessing.mice_forest_impute
113
```
114
115
### Normalization
116
117
```{eval-rst}
118
.. autosummary::
119
    :toctree: preprocessing
120
    :nosignatures:
121
122
    preprocessing.log_norm
123
    preprocessing.maxabs_norm
124
    preprocessing.minmax_norm
125
    preprocessing.power_norm
126
    preprocessing.quantile_norm
127
    preprocessing.robust_scale_norm
128
    preprocessing.scale_norm
129
    preprocessing.offset_negative_values
130
```
131
132
### Dataset Shift Correction
133
134
Partially overlaps with dataset integration. Note that a simple batch correction method is available via `pp.regress_out()`.
135
136
```{eval-rst}
137
.. autosummary::
138
    :toctree: preprocessing
139
    :nosignatures:
140
141
    preprocessing.combat
142
```
143
144
### Neighbors
145
146
```{eval-rst}
147
.. autosummary::
148
    :toctree: preprocessing
149
    :nosignatures:
150
151
    preprocessing.neighbors
152
```
153
154
## Tools
155
156
Any transformation of the data matrix that is not preprocessing.
157
In contrast to a preprocessing function, a tool usually adds an easily interpretable annotation to the data matrix, which can then be visualized with a corresponding plotting function.
158
159
### Embeddings
160
161
```{eval-rst}
162
.. autosummary::
163
    :toctree: tools
164
    :nosignatures:
165
166
    tools.tsne
167
    tools.umap
168
    tools.draw_graph
169
    tools.diffmap
170
    tools.embedding_density
171
```
172
173
### Clustering and trajectory inference
174
175
```{eval-rst}
176
.. autosummary::
177
    :toctree: tools
178
    :nosignatures:
179
180
    tools.leiden
181
    tools.dendrogram
182
    tools.dpt
183
    tools.paga
184
```
185
186
### Feature Ranking
187
188
```{eval-rst}
189
.. autosummary::
190
    :toctree: tools
191
    :nosignatures:
192
193
    tools.rank_features_groups
194
    tools.filter_rank_features_groups
195
    tools.rank_features_supervised
196
```
197
198
### Dataset integration
199
200
```{eval-rst}
201
.. autosummary::
202
    :toctree: tools
203
    :nosignatures:
204
205
    tools.ingest
206
```
207
208
### Natural language processing
209
210
```{eval-rst}
211
.. autosummary::
212
    :toctree: tools
213
    :nosignatures:
214
215
    tools.annotate_text
216
    tools.get_medcat_annotation_overview
217
    tools.add_medcat_annotation_to_obs
218
```
219
220
### Survival Analysis
221
222
```{eval-rst}
223
.. autosummary::
224
    :toctree: tools
225
    :nosignatures:
226
227
    tools.ols
228
    tools.glm
229
    tools.kaplan_meier
230
    tools.test_kmf_logrank
231
    tools.test_nested_f_statistic
232
    tools.cox_ph
233
    tools.weibull_aft
234
    tools.log_logistic_aft
235
    tools.nelson_aalen
236
    tools.weibull
237
238
```
239
240
### Causal Inference
241
242
```{eval-rst}
243
.. autosummary::
244
    :toctree: tools
245
    :nosignatures:
246
247
    tools.causal_inference
248
```
249
250
### Cohort Tracking
251
252
```{eval-rst}
253
.. autosummary::
254
    :toctree: tools
255
    :nosignatures:
256
257
    tools.CohortTracker
258
```
259
260
## Plotting
261
262
The plotting module `ehrapy.pl.\*` largely parallels the `tl.\*` and a few of the `pp.\*` functions.
263
For most tools and for some preprocessing functions, you will find a plotting function with the same name.
264
265
### Generic
266
267
```{eval-rst}
268
.. autosummary::
269
    :toctree: plot
270
    :nosignatures:
271
272
    plot.scatter
273
    plot.heatmap
274
    plot.dotplot
275
    plot.tracksplot
276
    plot.violin
277
    plot.stacked_violin
278
    plot.matrixplot
279
    plot.clustermap
280
    plot.ranking
281
    plot.dendrogram
282
    plot.catplot
283
```
284
285
### Quality Control and missing values
286
287
```{eval-rst}
288
.. autosummary::
289
    :toctree: plot
290
    :nosignatures:
291
292
    plot.missing_values_matrix
293
    plot.missing_values_barplot
294
    plot.missing_values_heatmap
295
    plot.missing_values_dendrogram
296
```
297
298
### Classes
299
300
Please refer to [Scanpy's plotting classes documentation](https://scanpy.readthedocs.io/en/stable/api.html#classes).
301
302
### Tools
303
304
Methods that extract and visualize tool-specific annotation in an AnnData object. For any method in module `tl`, there is a method with the same name in `pl`.
305
306
```{eval-rst}
307
.. autosummary::
308
    :toctree: plot
309
    :nosignatures:
310
311
    plot.pca
312
    plot.pca_loadings
313
    plot.pca_variance_ratio
314
    plot.pca_overview
315
```
316
317
### Embeddings
318
319
```{eval-rst}
320
.. autosummary::
321
    :toctree: plot
322
    :nosignatures:
323
324
    plot.tsne
325
    plot.umap
326
    plot.diffmap
327
    plot.draw_graph
328
    plot.embedding
329
    plot.embedding_density
330
```
331
332
### Branching trajectories and pseudotime
333
334
```{eval-rst}
335
.. autosummary::
336
    :toctree: plot
337
    :nosignatures:
338
339
    plot.dpt_groups_pseudotime
340
    plot.dpt_timeseries
341
    plot.paga
342
    plot.paga_path
343
    plot.paga_compare
344
```
345
346
### Feature Ranking
347
348
```{eval-rst}
349
.. autosummary::
350
    :toctree: plot
351
    :nosignatures:
352
353
    plot.rank_features_groups
354
    plot.rank_features_groups_violin
355
    plot.rank_features_groups_stacked_violin
356
    plot.rank_features_groups_heatmap
357
    plot.rank_features_groups_dotplot
358
    plot.rank_features_groups_matrixplot
359
    plot.rank_features_groups_tracksplot
360
    plot.rank_features_supervised
361
```
362
363
### Survival Analysis
364
365
```{eval-rst}
366
.. autosummary::
367
    :toctree: plot
368
    :nosignatures:
369
370
    plot.ols
371
    plot.kaplan_meier
372
    plot.cox_ph_forestplot
373
```
374
375
### Causal Inference
376
377
```{eval-rst}
378
.. autosummary::
379
    :toctree: plot
380
    :nosignatures:
381
382
    plot.causal_effect
383
```
384
385
## AnnData utilities
386
387
```{eval-rst}
388
.. autosummary::
389
    :toctree: anndata
390
    :nosignatures:
391
392
    anndata.infer_feature_types
393
    anndata.feature_type_overview
394
    anndata.replace_feature_types
395
    anndata.df_to_anndata
396
    anndata.anndata_to_df
397
    anndata.move_to_obs
398
    anndata.delete_from_obs
399
    anndata.move_to_x
400
    anndata.get_obs_df
401
    anndata.get_var_df
402
    anndata.get_rank_features_df
403
```
404
405
## Settings
406
407
A convenience object for setting some default {obj}`matplotlib.rcParams` and a
408
high-resolution jupyter display backend useful for use in notebooks.
409
410
An instance of the {class}`~scanpy._settings.ScanpyConfig` is available as `ehrapy.settings` and allows configuring ehrapy.
411
412
```python
413
import ehrapy as ep
414
415
ep.settings.set_figure_params(dpi=150)
416
```
417
418
Please refer to the [Scanpy settings documentation](https://scanpy.readthedocs.io/en/stable/api.html#settings)
419
for configuration options. ehrapy will adapt these in the future and update the documentation.
420
421
## Dependency Versions
422
423
ehrapy is complex software with many dependencies. To ensure a consistent runtime environment you should save all
424
versions that were used for an analysis. This comes in handy when trying to diagnose issues and to reproduce results.
425
426
Call the function via:
427
428
```python
429
import ehrapy as ep
430
431
ep.print_versions()
432
```