scBasset¶
Disclaimer¶
This is an UNOFFICIAL implementation of scBasset: sequence-based modeling of single-cell ATAC-seq using convolutional neural networks by Han Yuan et al.
The OFFICIAL repository of scBasset is at calico/scBasset.
Tip
The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
The team releasing scBasset did not write this model card for this model so this model card has been written by the MultiMolecule team.
Model Details¶
scBasset is a convolutional neural network (CNN) that predicts per-cell chromatin accessibility of a DNA peak sequence. The model consumes a fixed-length 1344 bp one-hot encoded DNA sequence and applies a pre-activation convolution stem, a reducing convolution tower, a pointwise convolution, and a dense bottleneck before a final cell-embedding layer that produces one accessibility logit per single cell.
scBasset uses a pre-activation block layout: each convolution block applies the activation (the sigmoid approximation of GELU, sigmoid(1.702 * x) * x) before the convolution, then batch normalization and max pooling. The dense bottleneck flattens the convolution output in Keras channels-last (length-major) order; this ordering is load-bearing and is reconciled in the MultiMolecule implementation.
Important
The final cell-embedding (dense) layer of scBasset is dataset-specific: it has one row per single cell in the training atlas, so there is no dataset-independent foundation checkpoint. The default scBasset variant uses the Buenrostro2018 hematopoiesis tutorial dataset distributed by the scBasset authors, which has 2034 single cells (so num_labels = 2034). A different scBasset dataset would have a different number of cells and a differently sized cell-embedding layer.
The cell-embedding layer is exposed through the shared SequencePredictionHead; the per-cell accessibility task is modeled as a binary problem (problem_type="binary").
Model Specification¶
| Num Conv Layers | Hidden Size | Num Cells | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
|---|---|---|---|---|---|---|
| 8 | 32 | 2034 | 4.59 | 0.95 | 0.47 | 1344 |
Links¶
- Code: multimolecule.scbasset
- Weights: multimolecule/scbasset
- Data: scBasset Buenrostro2018 tutorial data
- Paper: scBasset: sequence-based modeling of single-cell ATAC-seq using convolutional neural networks
- Developed by: Han Yuan, David R. Kelley
- Model type: 1D CNN backbone with learned per-cell embedding head for single-cell ATAC-seq accessibility prediction
- Original Repository: calico/scBasset
Usage¶
The model file depends on the multimolecule library. You can install it using pip:
| Bash | |
|---|---|
Direct Use¶
Single-Cell Chromatin Accessibility Prediction¶
You can use this model directly to predict per-cell chromatin accessibility of a DNA peak sequence:
Each of the 2034 logits is a per-cell accessibility score for the Buenrostro2018 hematopoiesis atlas.
Interface¶
- Input length: fixed 1344 bp DNA peak window
- Output: per-cell accessibility logits (2034 cells in the default Buenrostro2018 hematopoiesis atlas; cell count is dataset-specific)
Training Details¶
scBasset was trained to predict the per-cell chromatin accessibility of DNA peak sequences across a single-cell ATAC-seq atlas.
Training Data¶
The scBasset model uses the Buenrostro2018 hematopoiesis tutorial model trained on the Buenrostro et al. 2018 single-cell ATAC-seq hematopoiesis dataset (2034 single cells). Each 1344 bp peak is associated with a per-cell binary accessibility vector.
Training Procedure¶
Pre-training¶
The model was trained to minimize a per-cell binary cross-entropy loss, comparing its predicted per-cell accessibility probabilities (sigmoid of the cell-embedding logits) against the observed single-cell ATAC-seq accessibility labels.
- Optimizer: Adam
- Loss: Per-cell binary cross-entropy
- Regularization: Batch normalization and dropout
Citation¶
Note
The artifacts distributed in this repository are part of the MultiMolecule project. If you use MultiMolecule in your research, you must cite the MultiMolecule project as follows:
| BibTeX | |
|---|---|
Contact¶
Please use GitHub issues of MultiMolecule for any questions or comments on the model card.
Please contact the authors of the scBasset paper for questions or comments on the paper/model.
License¶
This model implementation is licensed under the GNU Affero General Public License.
For additional terms and clarifications, please refer to our License FAQ.
| Text Only | |
|---|---|
multimolecule.models.scbasset
¶
DnaTokenizer
¶
Bases: Tokenizer
Tokenizer for DNA sequences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Alphabet | str | List[str] | None
|
alphabet to use for tokenization.
|
None
|
|
int
|
Size of kmer to tokenize. |
1
|
|
bool
|
Whether to tokenize into codons. |
False
|
|
bool
|
Whether to replace U with T. |
True
|
|
bool
|
Whether to convert input to uppercase. |
True
|
Examples:
Source code in multimolecule/tokenisers/dna/tokenization_dna.py
ScBassetConfig
¶
Bases: PreTrainedConfig
This is the configuration class to store the configuration of a
ScBassetModel. It is used to instantiate a scBasset model according to the
specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a
similar configuration to that of the scBasset calico/scBasset architecture as
distributed for the Buenrostro2018 hematopoiesis tutorial checkpoint.
Configuration objects inherit from PreTrainedConfig and can be used to
control the model outputs. Read the documentation from PreTrainedConfig
for more information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
Vocabulary size of the scBasset model. scBasset consumes a one-hot encoding of DNA nucleotides, so this
also defines the number of input channels of the first convolution. Defaults to 5 to match the
MultiMolecule |
5
|
|
int
|
The fixed length of the input DNA peak sequence in base pairs. Defaults to 1344. |
1344
|
|
int
|
Number of filters in the stem (first) convolution. Defaults to 288. |
288
|
|
int
|
Kernel size of the stem convolution. Defaults to 17. |
17
|
|
int
|
Max-pool size applied after the stem convolution. Defaults to 3. |
3
|
|
list[int] | None
|
Number of filters for each convolution in the reducing tower. The upstream architecture derives these
from |
None
|
|
int
|
Kernel size for each tower convolution. Defaults to 5. |
5
|
|
int
|
Max-pool size applied after each tower convolution. Defaults to 2. |
2
|
|
int
|
Number of filters in the final pointwise (kernel size 1) convolution. Defaults to 256. |
256
|
|
int
|
Dimensionality of the dense bottleneck embedding. This is the model’s hidden size. Defaults to 32. |
32
|
|
str
|
The non-linear activation function (function or string) in the encoder. scBasset uses the sigmoid
approximation of GELU ( |
'quick_gelu'
|
|
float
|
The dropout probability for the bottleneck. |
0.2
|
|
float
|
The epsilon used by the batch normalization layers. |
0.001
|
|
float
|
The momentum used by the batch normalization layers. |
0.1
|
|
int
|
Number of output labels. scBasset predicts per-cell chromatin accessibility, so this equals the number of single cells in the training atlas and is dataset-specific. The shipped Buenrostro2018 hematopoiesis checkpoint has 2034 cells. Defaults to 2034. |
2034
|
|
HeadConfig | None
|
The configuration of the prediction head. Defaults to a per-cell binary accessibility head
( |
None
|
Examples:
Source code in multimolecule/models/scbasset/configuration_scbasset.py
| Python | |
|---|---|
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
ScBassetForSequencePrediction
¶
Bases: ScBassetPreTrainedModel
The cell-embedding (final dense) layer of scBasset is dataset-specific: it has one row per single cell in
the training atlas. num_labels therefore equals the number of cells in the chosen dataset (2034 for the
shipped Buenrostro2018 hematopoiesis checkpoint) and is exposed through the shared
SequencePredictionHead decoder.
Examples:
Source code in multimolecule/models/scbasset/modeling_scbasset.py
ScBassetModel
¶
Bases: ScBassetPreTrainedModel
Examples:
Source code in multimolecule/models/scbasset/modeling_scbasset.py
ScBassetPreTrainedModel
¶
Bases: PreTrainedModel
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models.