causarray 0.0.5__tar.gz → 0.0.7__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.
- {causarray-0.0.5 → causarray-0.0.7}/.gitignore +26 -1
- {causarray-0.0.5 → causarray-0.0.7}/PKG-INFO +48 -10
- causarray-0.0.7/README.md +117 -0
- causarray-0.0.7/causarray/DR_estimation.py +500 -0
- {causarray-0.0.5 → causarray-0.0.7}/causarray/DR_inference.py +9 -3
- causarray-0.0.7/causarray/DR_learner.py +841 -0
- causarray-0.0.7/causarray/__about__.py +1 -0
- causarray-0.0.7/causarray/__init__.py +35 -0
- causarray-0.0.7/causarray/diagnostics.py +172 -0
- causarray-0.0.7/causarray/gcate.py +609 -0
- {causarray-0.0.5 → causarray-0.0.7}/causarray/gcate_glm.py +204 -7
- {causarray-0.0.5 → causarray-0.0.7}/causarray/gcate_opt.py +187 -20
- causarray-0.0.7/causarray/nb_glm_fast.py +777 -0
- {causarray-0.0.5 → causarray-0.0.7}/causarray/utils.py +102 -9
- {causarray-0.0.5 → causarray-0.0.7}/pyproject.toml +3 -3
- causarray-0.0.5/README.md +0 -79
- causarray-0.0.5/causarray/DR_estimation.py +0 -330
- causarray-0.0.5/causarray/DR_learner.py +0 -324
- causarray-0.0.5/causarray/__about__.py +0 -1
- causarray-0.0.5/causarray/__init__.py +0 -21
- causarray-0.0.5/causarray/gcate.py +0 -246
- {causarray-0.0.5 → causarray-0.0.7}/LICENSE +0 -0
- {causarray-0.0.5 → causarray-0.0.7}/causarray/gcate_likelihood.py +0 -0
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# Planning documents
|
|
2
|
+
plan/
|
|
3
|
+
|
|
4
|
+
# Local Codex project guidance
|
|
5
|
+
/AGENTS.md
|
|
6
|
+
|
|
1
7
|
# Byte-compiled / optimized / DLL files
|
|
2
8
|
__pycache__/
|
|
3
9
|
*.py[cod]
|
|
@@ -160,5 +166,24 @@ cython_debug/
|
|
|
160
166
|
#.idea/
|
|
161
167
|
|
|
162
168
|
|
|
163
|
-
|
|
169
|
+
# Generic module tests under tests/ ARE tracked (regression coverage for
|
|
170
|
+
# the causarray API). Exclude only benchmark / scratch files that are
|
|
171
|
+
# not part of the unit-test suite — add new exclusions here when
|
|
172
|
+
# benchmark or tutorial-coupled test files appear.
|
|
173
|
+
tests/benchmark_adamson.py
|
|
174
|
+
|
|
164
175
|
causarray/___*.py
|
|
176
|
+
|
|
177
|
+
# Adamson tutorial is currently a local analysis and is not part of the
|
|
178
|
+
# committed documentation.
|
|
179
|
+
/docs/source/tutorial/adamson/
|
|
180
|
+
|
|
181
|
+
# Replogle tutorial: large data files (regenerate with prep_tutorial_data.py or
|
|
182
|
+
# download from the project data repository; replogle_subset.h5ad is ~2 GB)
|
|
183
|
+
docs/source/tutorial/replogle/replogle_subset.h5ad
|
|
184
|
+
docs/source/tutorial/replogle/replogle_subset_norm*.h5ad
|
|
185
|
+
docs/source/tutorial/replogle/replogle_normed.h5ad
|
|
186
|
+
docs/source/tutorial/replogle/replogle_results.h5
|
|
187
|
+
|
|
188
|
+
# Unrelated tutorial directory (not part of causarray package docs)
|
|
189
|
+
docs/source/tutorial/scp/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: causarray
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.7
|
|
4
4
|
Summary: causarray is a Python module for simultaneous causal inference with an array of outcomes.
|
|
5
|
-
Author-email: Jin-Hong Du <jinhongd@
|
|
6
|
-
Maintainer-email: Jin-Hong Du <jinhongd@
|
|
5
|
+
Author-email: Jin-Hong Du <jinhongd@hku.hk>, Maya Shen <myshen@andrew.cmu.edu>, Hansruedi Mathys <mathysh@pitt.edu>, Kathryn Roeder <jinhongd@hku.hk>
|
|
6
|
+
Maintainer-email: Jin-Hong Du <jinhongd@hku.hk>
|
|
7
7
|
License: MIT License
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
Classifier: Intended Audience :: Developers
|
|
@@ -30,7 +30,7 @@ Description-Content-Type: text/markdown
|
|
|
30
30
|
|
|
31
31
|
# causarray
|
|
32
32
|
|
|
33
|
-
Advances in single-cell sequencing and CRISPR technologies have enabled detailed case-control comparisons and experimental perturbations at single-cell resolution. However, uncovering causal relationships in observational genomic data remains challenging due to selection bias and inadequate adjustment for unmeasured confounders, particularly in heterogeneous datasets. To address these challenges, we introduce `causarray` [
|
|
33
|
+
Advances in single-cell sequencing and CRISPR technologies have enabled detailed case-control comparisons and experimental perturbations at single-cell resolution. However, uncovering causal relationships in observational genomic data remains challenging due to selection bias and inadequate adjustment for unmeasured confounders, particularly in heterogeneous datasets. To address these challenges, we introduce `causarray` [Du26], a doubly robust causal inference framework for analyzing array-based genomic data at both bulk-cell and single-cell levels. `causarray` integrates a generalized confounder adjustment method to account for unmeasured confounders and employs semiparametric inference with flexible machine learning techniques to ensure robust statistical estimation of treatment effects.
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
## Usage
|
|
@@ -49,17 +49,49 @@ The module can be installed via PyPI:
|
|
|
49
49
|
pip install causarray
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
For optimal parallel performance, we recommend installing `llvm-openmp` if using conda:
|
|
53
|
+
```cmd
|
|
54
|
+
conda install -c conda-forge llvm-openmp
|
|
55
|
+
```
|
|
56
|
+
|
|
52
57
|
For `R` users, `reticulate` can be used to call `causarray` from `R`.
|
|
53
58
|
The documentation and tutorials using both `Python` and `R` are available at [causarray.readthedocs.io](https://causarray.readthedocs.io/en/latest/).
|
|
54
59
|
|
|
55
60
|
|
|
56
61
|
|
|
57
|
-
##
|
|
62
|
+
## Tutorials
|
|
63
|
+
|
|
64
|
+
| Tutorial | Language | Description | Link |
|
|
65
|
+
|----------|----------|-------------|------|
|
|
66
|
+
| Perturb-seq [Jin20] | Python | CRISPR screen analysis on excitatory neurons | [Notebook](https://causarray.readthedocs.io/en/latest/tutorial/perturbseq/perturbseq-py.html) |
|
|
67
|
+
| Perturb-seq [Jin20] | R | Same analysis using `reticulate` | [Notebook](https://causarray.readthedocs.io/en/latest/tutorial/perturbseq/perturbseq-r.html) |
|
|
68
|
+
| Genome-wide CRISPRi screen [Replogle22] | Python | Batch fitting on 200 perturbations from a K562 genome-wide CRISPRi screen | [Notebook](https://causarray.readthedocs.io/en/latest/tutorial/replogle/replogle-py.html) |
|
|
69
|
+
| Case-control: SEA-AD [Gabitto24] | Python | Causal inference on observational single-cell data (Alzheimer's disease) | [Notebook](https://causarray.readthedocs.io/en/latest/tutorial/case_control/sea_ad_case_control.html) |
|
|
70
|
+
|
|
71
|
+
### Batch fitting API
|
|
72
|
+
|
|
73
|
+
For screens with hundreds to thousands of perturbations, use `gcate_lfc_batch` so
|
|
74
|
+
that peak memory is bounded by one batch at a time:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from causarray import gcate_lfc_batch
|
|
58
78
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
df_res = gcate_lfc_batch(
|
|
80
|
+
Y, X, A, r,
|
|
81
|
+
batch_size=10, # perturbations per batch (or use n_batches= for a fixed count)
|
|
82
|
+
max_cells=2000, # max pert cells per batch (ctrl added on top)
|
|
83
|
+
n_ctrl=2000, # fixed ctrl subsample shared across batches
|
|
84
|
+
cache_path='results.h5', # resume if interrupted
|
|
85
|
+
verbose=True,
|
|
86
|
+
)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
See the [Replogle-E-K562 tutorial](https://causarray.readthedocs.io/en/latest/tutorial/replogle/replogle-py.html)
|
|
90
|
+
for a demonstration on 200 perturbations from a genome-wide CRISPRi screen.
|
|
91
|
+
|
|
92
|
+
## Changelog
|
|
93
|
+
|
|
94
|
+
See [CHANGELOG](https://causarray.readthedocs.io/en/latest/changelog.html) for a full version history.
|
|
63
95
|
|
|
64
96
|
|
|
65
97
|
<!--
|
|
@@ -101,4 +133,10 @@ rmarkdown::render("perturbseq.Rmd", rmarkdown::md_document(variant = "markdown_g
|
|
|
101
133
|
|
|
102
134
|
|
|
103
135
|
## References
|
|
104
|
-
[
|
|
136
|
+
[Du26] Jin-Hong Du, Maya Shen, Hansruedi Mathys, and Kathryn Roeder. "Uncovering causal relationships in single cell omic studies with causarray". In: Briefings in Bioinformatics (2026).
|
|
137
|
+
|
|
138
|
+
[Gabitto24] Mariano I. Gabitto et al. "Integrated multimodal cell atlas of Alzheimer's disease". In: Nature Neuroscience (2024).
|
|
139
|
+
|
|
140
|
+
[Jin20] Xin Jin et al. "In vivo Perturb-seq reveals neuronal and glial abnormalities associated with autism risk genes". In: Nature Neuroscience (2020).
|
|
141
|
+
|
|
142
|
+
[Replogle22] Joseph M. Replogle et al. "Mapping information-rich genotype-phenotype landscapes with genome-scale Perturb-seq". In: Cell (2022).
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
[](https://causarray.readthedocs.io/en/latest/?badge=latest)
|
|
2
|
+
[](https://pypi.org/project/causarray)
|
|
3
|
+
[](https://pepy.tech/project/causarray)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# causarray
|
|
7
|
+
|
|
8
|
+
Advances in single-cell sequencing and CRISPR technologies have enabled detailed case-control comparisons and experimental perturbations at single-cell resolution. However, uncovering causal relationships in observational genomic data remains challenging due to selection bias and inadequate adjustment for unmeasured confounders, particularly in heterogeneous datasets. To address these challenges, we introduce `causarray` [Du26], a doubly robust causal inference framework for analyzing array-based genomic data at both bulk-cell and single-cell levels. `causarray` integrates a generalized confounder adjustment method to account for unmeasured confounders and employs semiparametric inference with flexible machine learning techniques to ensure robust statistical estimation of treatment effects.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
We recommend using `causarray` in a conda environment:
|
|
14
|
+
```cmd
|
|
15
|
+
# create a new conda environment and install the necessary packages
|
|
16
|
+
conda create -n causarray python=3.12 -y
|
|
17
|
+
|
|
18
|
+
# activate the environment
|
|
19
|
+
conda activate causarray
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The module can be installed via PyPI:
|
|
23
|
+
```cmd
|
|
24
|
+
pip install causarray
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
For optimal parallel performance, we recommend installing `llvm-openmp` if using conda:
|
|
28
|
+
```cmd
|
|
29
|
+
conda install -c conda-forge llvm-openmp
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
For `R` users, `reticulate` can be used to call `causarray` from `R`.
|
|
33
|
+
The documentation and tutorials using both `Python` and `R` are available at [causarray.readthedocs.io](https://causarray.readthedocs.io/en/latest/).
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Tutorials
|
|
38
|
+
|
|
39
|
+
| Tutorial | Language | Description | Link |
|
|
40
|
+
|----------|----------|-------------|------|
|
|
41
|
+
| Perturb-seq [Jin20] | Python | CRISPR screen analysis on excitatory neurons | [Notebook](https://causarray.readthedocs.io/en/latest/tutorial/perturbseq/perturbseq-py.html) |
|
|
42
|
+
| Perturb-seq [Jin20] | R | Same analysis using `reticulate` | [Notebook](https://causarray.readthedocs.io/en/latest/tutorial/perturbseq/perturbseq-r.html) |
|
|
43
|
+
| Genome-wide CRISPRi screen [Replogle22] | Python | Batch fitting on 200 perturbations from a K562 genome-wide CRISPRi screen | [Notebook](https://causarray.readthedocs.io/en/latest/tutorial/replogle/replogle-py.html) |
|
|
44
|
+
| Case-control: SEA-AD [Gabitto24] | Python | Causal inference on observational single-cell data (Alzheimer's disease) | [Notebook](https://causarray.readthedocs.io/en/latest/tutorial/case_control/sea_ad_case_control.html) |
|
|
45
|
+
|
|
46
|
+
### Batch fitting API
|
|
47
|
+
|
|
48
|
+
For screens with hundreds to thousands of perturbations, use `gcate_lfc_batch` so
|
|
49
|
+
that peak memory is bounded by one batch at a time:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from causarray import gcate_lfc_batch
|
|
53
|
+
|
|
54
|
+
df_res = gcate_lfc_batch(
|
|
55
|
+
Y, X, A, r,
|
|
56
|
+
batch_size=10, # perturbations per batch (or use n_batches= for a fixed count)
|
|
57
|
+
max_cells=2000, # max pert cells per batch (ctrl added on top)
|
|
58
|
+
n_ctrl=2000, # fixed ctrl subsample shared across batches
|
|
59
|
+
cache_path='results.h5', # resume if interrupted
|
|
60
|
+
verbose=True,
|
|
61
|
+
)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
See the [Replogle-E-K562 tutorial](https://causarray.readthedocs.io/en/latest/tutorial/replogle/replogle-py.html)
|
|
65
|
+
for a demonstration on 200 perturbations from a genome-wide CRISPRi screen.
|
|
66
|
+
|
|
67
|
+
## Changelog
|
|
68
|
+
|
|
69
|
+
See [CHANGELOG](https://causarray.readthedocs.io/en/latest/changelog.html) for a full version history.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
<!--
|
|
73
|
+
# Development
|
|
74
|
+
|
|
75
|
+
The dependencies for running `causarray` method are listed in `environment.yml` and can be installed by running
|
|
76
|
+
|
|
77
|
+
```cmd
|
|
78
|
+
PIP_NO_DEPS=1 conda env create -f environment.yml
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## Build
|
|
83
|
+
```cmd
|
|
84
|
+
git tag 0.0.0
|
|
85
|
+
git tag --delete 1.0.0
|
|
86
|
+
python -m pip install .
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Testing
|
|
90
|
+
```cmd
|
|
91
|
+
python -m pytest tests/test_gcate.py
|
|
92
|
+
python -m pytest tests/test_DR_learner.py
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Documentation
|
|
96
|
+
|
|
97
|
+
```cmd
|
|
98
|
+
mkdir docs
|
|
99
|
+
cd docs
|
|
100
|
+
sphinx-quickstart
|
|
101
|
+
|
|
102
|
+
make html # sphinx-build source build
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
rmarkdown::render("perturbseq.Rmd", rmarkdown::md_document(variant = "markdown_github"))
|
|
106
|
+
```
|
|
107
|
+
-->
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## References
|
|
111
|
+
[Du26] Jin-Hong Du, Maya Shen, Hansruedi Mathys, and Kathryn Roeder. "Uncovering causal relationships in single cell omic studies with causarray". In: Briefings in Bioinformatics (2026).
|
|
112
|
+
|
|
113
|
+
[Gabitto24] Mariano I. Gabitto et al. "Integrated multimodal cell atlas of Alzheimer's disease". In: Nature Neuroscience (2024).
|
|
114
|
+
|
|
115
|
+
[Jin20] Xin Jin et al. "In vivo Perturb-seq reveals neuronal and glial abnormalities associated with autism risk genes". In: Nature Neuroscience (2020).
|
|
116
|
+
|
|
117
|
+
[Replogle22] Joseph M. Replogle et al. "Mapping information-rich genotype-phenotype landscapes with genome-scale Perturb-seq". In: Cell (2022).
|