Helical Base Models
helical.models.base_models.HelicalBaseFoundationModel
Bases: ABC
, Logger
Helical Base Foundation Model Class which serves as the base class for all foundation models in the helical package. Each new model should be a subclass of this class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logging_type
|
LoggingType
|
The logging type |
CONSOLE
|
level
|
LoggingLevel
|
The logging level |
INFO
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in helical/models/base_models.py
helical.models.base_models.HelicalRNAModel
Bases: HelicalBaseFoundationModel
Source code in helical/models/base_models.py
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 |
|
ensure_rna_data_validity(adata, gene_names, use_raw_counts=True)
Ensures that the data contains the gene_names and has integer counts for adata.X which is saved in 'total_counts'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adata
|
AnnData
|
The data to be checked. |
required |
gene_names
|
str
|
The name of the column containing gene names in adata.var. |
required |
use_raw_counts
|
bool
|
Whether to use raw counts or not. |
True
|
Raises:
Type | Description |
---|---|
KeyError
|
If the data is missing column names. |
Source code in helical/models/base_models.py
get_valid_rna_sequence(sequences)
Returns valid RNA sequences that only contain the characters A, C, U, G, N and E.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequences
|
List[str] or DataFrame
|
The RNA sequences to be checked. If a DataFrame is provided, it should have a column named 'Sequence'. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the sequences contain characters other than A, C, U, G, N and E. |
Returns:
Type | Description |
---|---|
List[str]
|
Valid RNA sequences. |
Source code in helical/models/base_models.py
helical.models.base_models.HelicalDNAModel
Bases: HelicalBaseFoundationModel
Source code in helical/models/base_models.py
get_valid_dna_sequence(sequences, enforce_characters=True)
Returns valid DNA sequences that only contain the characters A, C, T, G, N.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequences
|
List[str]
|
The DNA sequences to be checked. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the sequences contain characters other than A, C, T, G, N and E. |
Returns:
Type | Description |
---|---|
List[str]
|
Valid DNA sequences. |
Source code in helical/models/base_models.py
helical.models.base_models.HelicalBaseFineTuningModel
Bases: Module
Helical Base Fine-Tuning Model Class which serves as the base class for all fine-tuning models in the helical package. Each new fine-tuning model should be a subclass of this class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fine_tuning_head
|
Literal['classification', 'regression'] | HelicalBaseFineTuningHead
|
The fine-tuning head that is appended to the model. This can either be a string (options available: "classification" and "regression") specifying the task or a custom fine-tuning head inheriting from HelicalBaseFineTuningHead. |
required |
output_size
|
Optional[int]
|
The output size of the fine-tuning model. This is required if the fine_tuning_head is a string specified task. For a classification task this is number of unique classes. |
required |
Source code in helical/models/base_models.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
|
load_model(path)
Load the model from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to load the model from. |
required |
Source code in helical/models/base_models.py
save_model(path)
Save the model to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to save the model to. |
required |
helical.models.base_models.HelicalBaseFineTuningHead
Bases: Module
, ABC
Helical Fine-Tuning Head Class which serves as the base class for all fine-tuning heads in the helical package. Each new fine-tuning head should be a subclass of this class.