diffbio 0.1.0__py3-none-any.whl
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.
- diffbio/__init__.py +39 -0
- diffbio/configs.py +75 -0
- diffbio/constants.py +204 -0
- diffbio/core/__init__.py +127 -0
- diffbio/core/base_operators.py +612 -0
- diffbio/core/data_types.py +260 -0
- diffbio/core/gnn_components.py +629 -0
- diffbio/core/graph_utils.py +149 -0
- diffbio/core/neural_components.py +270 -0
- diffbio/core/optimal_transport.py +133 -0
- diffbio/core/soft_ops/__init__.py +216 -0
- diffbio/core/soft_ops/_projections_permutahedron.py +1864 -0
- diffbio/core/soft_ops/_projections_simplex.py +240 -0
- diffbio/core/soft_ops/_projections_transport.py +508 -0
- diffbio/core/soft_ops/_sorting_network.py +204 -0
- diffbio/core/soft_ops/_types.py +15 -0
- diffbio/core/soft_ops/_utils.py +342 -0
- diffbio/core/soft_ops/autograd_safe.py +120 -0
- diffbio/core/soft_ops/comparison.py +235 -0
- diffbio/core/soft_ops/elementwise.py +309 -0
- diffbio/core/soft_ops/logical.py +146 -0
- diffbio/core/soft_ops/quantile.py +376 -0
- diffbio/core/soft_ops/selection.py +236 -0
- diffbio/core/soft_ops/sorting.py +926 -0
- diffbio/core/soft_ops/straight_through.py +261 -0
- diffbio/core/uncertainty.py +279 -0
- diffbio/evaluation/__init__.py +42 -0
- diffbio/evaluation/adapters.py +409 -0
- diffbio/evaluation/graders.py +223 -0
- diffbio/evaluation/problem.py +157 -0
- diffbio/evaluation/runner.py +277 -0
- diffbio/losses/__init__.py +59 -0
- diffbio/losses/alignment_losses.py +222 -0
- diffbio/losses/biological_regularization.py +288 -0
- diffbio/losses/metric_losses.py +139 -0
- diffbio/losses/singlecell_losses.py +387 -0
- diffbio/losses/statistical_losses.py +345 -0
- diffbio/operators/__init__.py +60 -0
- diffbio/operators/_count_vae.py +197 -0
- diffbio/operators/_loss_balancing.py +65 -0
- diffbio/operators/_masked_gene_transformer.py +118 -0
- diffbio/operators/_transformer_validation.py +50 -0
- diffbio/operators/alignment/__init__.py +51 -0
- diffbio/operators/alignment/profile_hmm.py +350 -0
- diffbio/operators/alignment/scoring.py +127 -0
- diffbio/operators/alignment/smith_waterman.py +261 -0
- diffbio/operators/alignment/soft_msa.py +419 -0
- diffbio/operators/assembly/__init__.py +27 -0
- diffbio/operators/assembly/gnn_assembly.py +252 -0
- diffbio/operators/assembly/metagenomic_binning.py +296 -0
- diffbio/operators/crispr/__init__.py +17 -0
- diffbio/operators/crispr/guide_scoring.py +269 -0
- diffbio/operators/drug_discovery/__init__.py +133 -0
- diffbio/operators/drug_discovery/_graph_utils.py +142 -0
- diffbio/operators/drug_discovery/admet_predictor.py +285 -0
- diffbio/operators/drug_discovery/attentive_fp.py +411 -0
- diffbio/operators/drug_discovery/dti.py +261 -0
- diffbio/operators/drug_discovery/fingerprint.py +490 -0
- diffbio/operators/drug_discovery/maccs_keys.py +267 -0
- diffbio/operators/drug_discovery/message_passing.py +200 -0
- diffbio/operators/drug_discovery/primitives.py +242 -0
- diffbio/operators/drug_discovery/property_predictor.py +163 -0
- diffbio/operators/drug_discovery/similarity.py +193 -0
- diffbio/operators/epigenomics/__init__.py +35 -0
- diffbio/operators/epigenomics/chromatin_state.py +491 -0
- diffbio/operators/epigenomics/contextual.py +288 -0
- diffbio/operators/epigenomics/fno_peak_calling.py +153 -0
- diffbio/operators/epigenomics/peak_calling.py +555 -0
- diffbio/operators/foundation_models/__init__.py +119 -0
- diffbio/operators/foundation_models/adapters.py +114 -0
- diffbio/operators/foundation_models/contracts.py +245 -0
- diffbio/operators/foundation_models/embedding_probe.py +83 -0
- diffbio/operators/foundation_models/experimental.py +128 -0
- diffbio/operators/foundation_models/foundation_model.py +332 -0
- diffbio/operators/foundation_models/frozen.py +59 -0
- diffbio/operators/foundation_models/precomputed.py +270 -0
- diffbio/operators/foundation_models/transformer_encoder.py +564 -0
- diffbio/operators/mapping/__init__.py +17 -0
- diffbio/operators/mapping/neural_mapper.py +493 -0
- diffbio/operators/metabolomics/__init__.py +39 -0
- diffbio/operators/metabolomics/spectral_similarity.py +315 -0
- diffbio/operators/molecular_dynamics/__init__.py +51 -0
- diffbio/operators/molecular_dynamics/force_field.py +265 -0
- diffbio/operators/molecular_dynamics/integrator.py +304 -0
- diffbio/operators/molecular_dynamics/primitives.py +115 -0
- diffbio/operators/multiomics/__init__.py +38 -0
- diffbio/operators/multiomics/hic_contact.py +377 -0
- diffbio/operators/multiomics/multiomics_vae.py +325 -0
- diffbio/operators/multiomics/spatial_deconvolution.py +316 -0
- diffbio/operators/multiomics/spatial_gene_detection.py +493 -0
- diffbio/operators/normalization/__init__.py +42 -0
- diffbio/operators/normalization/embedding.py +222 -0
- diffbio/operators/normalization/phate.py +400 -0
- diffbio/operators/normalization/umap.py +261 -0
- diffbio/operators/normalization/vae_normalizer.py +258 -0
- diffbio/operators/population/__init__.py +17 -0
- diffbio/operators/population/ancestry_estimation.py +274 -0
- diffbio/operators/preprocessing/__init__.py +76 -0
- diffbio/operators/preprocessing/adapter_removal.py +311 -0
- diffbio/operators/preprocessing/duplicate_filter.py +317 -0
- diffbio/operators/preprocessing/error_correction.py +287 -0
- diffbio/operators/protein/__init__.py +31 -0
- diffbio/operators/protein/secondary_structure.py +509 -0
- diffbio/operators/quality_filter.py +128 -0
- diffbio/operators/rna_structure/__init__.py +35 -0
- diffbio/operators/rna_structure/rna_folding.py +509 -0
- diffbio/operators/rnaseq/__init__.py +23 -0
- diffbio/operators/rnaseq/motif_discovery.py +251 -0
- diffbio/operators/rnaseq/splicing_psi.py +216 -0
- diffbio/operators/singlecell/__init__.py +193 -0
- diffbio/operators/singlecell/ambient_removal.py +333 -0
- diffbio/operators/singlecell/archetypes.py +191 -0
- diffbio/operators/singlecell/batch_correction.py +288 -0
- diffbio/operators/singlecell/cell_annotation.py +519 -0
- diffbio/operators/singlecell/communication.py +704 -0
- diffbio/operators/singlecell/differential_distribution.py +243 -0
- diffbio/operators/singlecell/doublet_detection.py +657 -0
- diffbio/operators/singlecell/downsampling.py +166 -0
- diffbio/operators/singlecell/enhanced_batch_correction.py +519 -0
- diffbio/operators/singlecell/grn_inference.py +336 -0
- diffbio/operators/singlecell/imputation.py +429 -0
- diffbio/operators/singlecell/knockdown_filter.py +176 -0
- diffbio/operators/singlecell/ot_trajectory.py +277 -0
- diffbio/operators/singlecell/simulation.py +444 -0
- diffbio/operators/singlecell/sindy_grn.py +247 -0
- diffbio/operators/singlecell/soft_clustering.py +211 -0
- diffbio/operators/singlecell/spatial_domains.py +677 -0
- diffbio/operators/singlecell/switch_de.py +184 -0
- diffbio/operators/singlecell/trajectory.py +447 -0
- diffbio/operators/singlecell/velocity.py +361 -0
- diffbio/operators/statistical/__init__.py +35 -0
- diffbio/operators/statistical/em_quantification.py +260 -0
- diffbio/operators/statistical/hmm.py +234 -0
- diffbio/operators/statistical/nb_glm.py +272 -0
- diffbio/operators/variant/__init__.py +64 -0
- diffbio/operators/variant/classifier.py +333 -0
- diffbio/operators/variant/cnn_classifier.py +255 -0
- diffbio/operators/variant/cnv_segmentation.py +678 -0
- diffbio/operators/variant/deepvariant_pileup.py +426 -0
- diffbio/operators/variant/pileup.py +240 -0
- diffbio/operators/variant/quality_recalibration.py +274 -0
- diffbio/pipelines/__init__.py +65 -0
- diffbio/pipelines/differential_expression.py +279 -0
- diffbio/pipelines/enhanced_variant_calling.py +326 -0
- diffbio/pipelines/perturbation.py +407 -0
- diffbio/pipelines/preprocessing.py +267 -0
- diffbio/pipelines/single_cell.py +366 -0
- diffbio/pipelines/variant_calling.py +490 -0
- diffbio/samplers/__init__.py +9 -0
- diffbio/samplers/perturbation_sampler.py +142 -0
- diffbio/sequences/__init__.py +34 -0
- diffbio/sequences/dna.py +239 -0
- diffbio/sources/__init__.py +149 -0
- diffbio/sources/_anndata_shared.py +89 -0
- diffbio/sources/_batch_iteration.py +37 -0
- diffbio/sources/_benchmark_source.py +152 -0
- diffbio/sources/_indexed_batch_source.py +38 -0
- diffbio/sources/_utils.py +45 -0
- diffbio/sources/anndata_interop.py +387 -0
- diffbio/sources/anndata_source.py +361 -0
- diffbio/sources/archive_ii.py +174 -0
- diffbio/sources/balifam.py +207 -0
- diffbio/sources/bam.py +265 -0
- diffbio/sources/bengrn_ground_truth.py +306 -0
- diffbio/sources/contextual_epigenomics.py +242 -0
- diffbio/sources/dti.py +359 -0
- diffbio/sources/embeddings.py +203 -0
- diffbio/sources/encode_peaks.py +223 -0
- diffbio/sources/fasta.py +226 -0
- diffbio/sources/immune_human.py +172 -0
- diffbio/sources/indexed_embeddings.py +128 -0
- diffbio/sources/indexed_view.py +191 -0
- diffbio/sources/molnet.py +493 -0
- diffbio/sources/multiomics.py +279 -0
- diffbio/sources/pancreas.py +108 -0
- diffbio/sources/perturbation/__init__.py +69 -0
- diffbio/sources/perturbation/_types.py +51 -0
- diffbio/sources/perturbation/_utils.py +125 -0
- diffbio/sources/perturbation/concat_source.py +115 -0
- diffbio/sources/perturbation/control_mapping.py +215 -0
- diffbio/sources/perturbation/experiment_config.py +261 -0
- diffbio/sources/perturbation/h5_metadata_cache.py +218 -0
- diffbio/sources/perturbation/output_space.py +52 -0
- diffbio/sources/perturbation/perturbation_source.py +513 -0
- diffbio/sources/seqfish.py +145 -0
- diffbio/sources/sequence_foundation.py +68 -0
- diffbio/sources/singlecell_foundation.py +68 -0
- diffbio/splitters/__init__.py +63 -0
- diffbio/splitters/base.py +251 -0
- diffbio/splitters/molecular.py +330 -0
- diffbio/splitters/perturbation.py +199 -0
- diffbio/splitters/random.py +217 -0
- diffbio/splitters/sequence.py +201 -0
- diffbio/utils/__init__.py +55 -0
- diffbio/utils/dependency_runtime.py +115 -0
- diffbio/utils/nn_utils.py +157 -0
- diffbio/utils/quality.py +45 -0
- diffbio/utils/training.py +585 -0
- diffbio-0.1.0.dist-info/METADATA +480 -0
- diffbio-0.1.0.dist-info/RECORD +202 -0
- diffbio-0.1.0.dist-info/WHEEL +4 -0
- diffbio-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"""Differentiable soft operations for DiffBio.
|
|
2
|
+
|
|
3
|
+
Provides smooth relaxations of discrete, piecewise-linear, and sharp
|
|
4
|
+
operations, enabling end-to-end gradient-based optimization through
|
|
5
|
+
operations that are normally non-differentiable.
|
|
6
|
+
|
|
7
|
+
Built on JAX and integrated with the DiffBio/Flax NNX ecosystem.
|
|
8
|
+
|
|
9
|
+
.. warning::
|
|
10
|
+
Several names (``abs``, ``all``, ``any``, ``round``, ``max``, ``min``)
|
|
11
|
+
shadow Python builtins. Use qualified imports::
|
|
12
|
+
|
|
13
|
+
from diffbio.core import soft_ops
|
|
14
|
+
soft_ops.max(x, softness=0.1)
|
|
15
|
+
|
|
16
|
+
or alias on import::
|
|
17
|
+
|
|
18
|
+
from diffbio.core.soft_ops import max as soft_max
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
# --- Types ---
|
|
22
|
+
from diffbio.core.soft_ops._types import SoftBool, SoftIndex
|
|
23
|
+
|
|
24
|
+
# --- Autograd-safe math ---
|
|
25
|
+
from diffbio.core.soft_ops.autograd_safe import arccos, arcsin, div, log, norm, sqrt
|
|
26
|
+
|
|
27
|
+
# --- Elementwise ---
|
|
28
|
+
from diffbio.core.soft_ops.elementwise import (
|
|
29
|
+
abs,
|
|
30
|
+
clip,
|
|
31
|
+
heaviside,
|
|
32
|
+
relu,
|
|
33
|
+
round,
|
|
34
|
+
sign,
|
|
35
|
+
sigmoidal,
|
|
36
|
+
softrelu,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# --- Comparison ---
|
|
40
|
+
from diffbio.core.soft_ops.comparison import (
|
|
41
|
+
equal,
|
|
42
|
+
greater,
|
|
43
|
+
greater_equal,
|
|
44
|
+
isclose,
|
|
45
|
+
less,
|
|
46
|
+
less_equal,
|
|
47
|
+
not_equal,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# --- Logical ---
|
|
51
|
+
from diffbio.core.soft_ops.logical import (
|
|
52
|
+
all,
|
|
53
|
+
any,
|
|
54
|
+
logical_and,
|
|
55
|
+
logical_not,
|
|
56
|
+
logical_or,
|
|
57
|
+
logical_xor,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# --- Selection ---
|
|
61
|
+
from diffbio.core.soft_ops.selection import (
|
|
62
|
+
choose,
|
|
63
|
+
dynamic_index_in_dim,
|
|
64
|
+
dynamic_slice,
|
|
65
|
+
dynamic_slice_in_dim,
|
|
66
|
+
take,
|
|
67
|
+
take_along_axis,
|
|
68
|
+
where,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# --- Sorting / Ordering ---
|
|
72
|
+
from diffbio.core.soft_ops.sorting import (
|
|
73
|
+
argmax,
|
|
74
|
+
argmin,
|
|
75
|
+
argsort,
|
|
76
|
+
max,
|
|
77
|
+
min,
|
|
78
|
+
rank,
|
|
79
|
+
sort,
|
|
80
|
+
top_k,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# --- Quantile ---
|
|
84
|
+
from diffbio.core.soft_ops.quantile import (
|
|
85
|
+
argmedian,
|
|
86
|
+
argpercentile,
|
|
87
|
+
argquantile,
|
|
88
|
+
median,
|
|
89
|
+
percentile,
|
|
90
|
+
quantile,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# --- Straight-through estimators ---
|
|
94
|
+
from diffbio.core.soft_ops.straight_through import (
|
|
95
|
+
abs_st,
|
|
96
|
+
argmax_st,
|
|
97
|
+
argmedian_st,
|
|
98
|
+
argmin_st,
|
|
99
|
+
argpercentile_st,
|
|
100
|
+
argquantile_st,
|
|
101
|
+
argsort_st,
|
|
102
|
+
clip_st,
|
|
103
|
+
equal_st,
|
|
104
|
+
grad_replace,
|
|
105
|
+
greater_equal_st,
|
|
106
|
+
greater_st,
|
|
107
|
+
heaviside_st,
|
|
108
|
+
isclose_st,
|
|
109
|
+
less_equal_st,
|
|
110
|
+
less_st,
|
|
111
|
+
max_st,
|
|
112
|
+
median_st,
|
|
113
|
+
min_st,
|
|
114
|
+
not_equal_st,
|
|
115
|
+
percentile_st,
|
|
116
|
+
quantile_st,
|
|
117
|
+
rank_st,
|
|
118
|
+
relu_st,
|
|
119
|
+
round_st,
|
|
120
|
+
sign_st,
|
|
121
|
+
sort_st,
|
|
122
|
+
st,
|
|
123
|
+
top_k_st,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
__all__ = [
|
|
127
|
+
# Types
|
|
128
|
+
"SoftBool",
|
|
129
|
+
"SoftIndex",
|
|
130
|
+
# Autograd-safe
|
|
131
|
+
"arccos",
|
|
132
|
+
"arcsin",
|
|
133
|
+
"div",
|
|
134
|
+
"log",
|
|
135
|
+
"norm",
|
|
136
|
+
"sqrt",
|
|
137
|
+
# Elementwise
|
|
138
|
+
"abs",
|
|
139
|
+
"clip",
|
|
140
|
+
"heaviside",
|
|
141
|
+
"relu",
|
|
142
|
+
"round",
|
|
143
|
+
"sign",
|
|
144
|
+
"sigmoidal",
|
|
145
|
+
"softrelu",
|
|
146
|
+
# Comparison
|
|
147
|
+
"equal",
|
|
148
|
+
"greater",
|
|
149
|
+
"greater_equal",
|
|
150
|
+
"isclose",
|
|
151
|
+
"less",
|
|
152
|
+
"less_equal",
|
|
153
|
+
"not_equal",
|
|
154
|
+
# Logical
|
|
155
|
+
"all",
|
|
156
|
+
"any",
|
|
157
|
+
"logical_and",
|
|
158
|
+
"logical_not",
|
|
159
|
+
"logical_or",
|
|
160
|
+
"logical_xor",
|
|
161
|
+
# Selection
|
|
162
|
+
"choose",
|
|
163
|
+
"dynamic_index_in_dim",
|
|
164
|
+
"dynamic_slice",
|
|
165
|
+
"dynamic_slice_in_dim",
|
|
166
|
+
"take",
|
|
167
|
+
"take_along_axis",
|
|
168
|
+
"where",
|
|
169
|
+
# Sorting
|
|
170
|
+
"argmax",
|
|
171
|
+
"argmin",
|
|
172
|
+
"argsort",
|
|
173
|
+
"max",
|
|
174
|
+
"min",
|
|
175
|
+
"rank",
|
|
176
|
+
"sort",
|
|
177
|
+
"top_k",
|
|
178
|
+
# Quantile
|
|
179
|
+
"argmedian",
|
|
180
|
+
"argpercentile",
|
|
181
|
+
"argquantile",
|
|
182
|
+
"median",
|
|
183
|
+
"percentile",
|
|
184
|
+
"quantile",
|
|
185
|
+
# Straight-through decorators
|
|
186
|
+
"grad_replace",
|
|
187
|
+
"st",
|
|
188
|
+
# Straight-through variants
|
|
189
|
+
"abs_st",
|
|
190
|
+
"argmax_st",
|
|
191
|
+
"argmedian_st",
|
|
192
|
+
"argmin_st",
|
|
193
|
+
"argpercentile_st",
|
|
194
|
+
"argquantile_st",
|
|
195
|
+
"argsort_st",
|
|
196
|
+
"clip_st",
|
|
197
|
+
"equal_st",
|
|
198
|
+
"greater_equal_st",
|
|
199
|
+
"greater_st",
|
|
200
|
+
"heaviside_st",
|
|
201
|
+
"isclose_st",
|
|
202
|
+
"less_equal_st",
|
|
203
|
+
"less_st",
|
|
204
|
+
"max_st",
|
|
205
|
+
"median_st",
|
|
206
|
+
"min_st",
|
|
207
|
+
"not_equal_st",
|
|
208
|
+
"percentile_st",
|
|
209
|
+
"quantile_st",
|
|
210
|
+
"rank_st",
|
|
211
|
+
"relu_st",
|
|
212
|
+
"round_st",
|
|
213
|
+
"sign_st",
|
|
214
|
+
"sort_st",
|
|
215
|
+
"top_k_st",
|
|
216
|
+
]
|