pyprobound.rounds.ExponentialRound
- class ExponentialRound(aggregate, reference_round, train_depth=True, log_depth=0, library_concentration=-1, delta=-15, train_delta=True, name='')
Bases:
RoundExponential enrichment round used for modeling catalytic experiments.
\[\frac{f_{i,r}}{f_{i,r-1}} = \sigma(\delta) \times e^{-Z_{i,r}} + \sigma(-\delta) \times \left( 1 - e^{-Z_{i,r}} \right)\]- log_depth
The sequencing depth \(\eta\) in log space.
- Type:
Tensor
- log_delta
The parameter \(\log\delta\) in log space.
- Type:
Tensor
- __init__(aggregate, reference_round, train_depth=True, log_depth=0, library_concentration=-1, delta=-15, train_delta=True, name='')
Initializes the round.
- Parameters:
aggregate (
Aggregate) – The binding components driving enrichment.reference_round (
BaseRound|None) – The previous round used in cumulative enrichment.train_depth (
bool) – Whether to train the sequencing depth \(\eta\).log_depth (
float) – The initial value of log_depth.library_concentration (
float) – The total library concentration, used for estimating the free protein concentration.delta (
float) – The initial value of \(\delta\).train_delta (
bool) – Whether to train the delta parameter.name (
str) – A string used to describe the round.
Methods
cache(fun)Decorator for a function to cache its output.
check_length_consistency()Checks that input lengths of Binding components are consistent.
components()Iterator of child components.
forward(seqs)Predicts the log relative count.
freeze()Turns off gradient calculation for all parameters.
from_binding(binding, reference_round[, ...])Creates a new instance from binding components and reference round.
from_round(base_round[, reference_round, ...])Creates a new instance from another round at a different timepoint.
log_aggregate(seqs)Predicts the log aggregate \(\log Z_i\).
log_cumulative_enrichment(seqs)Predicts the log cumulative enrichment.
log_enrichment(seqs)Predicts the log enrichment ratio.
max_embedding_size()The maximum number of bytes needed to encode a sequence.
optim_procedure([ancestry, current_order])The sequential optimization procedure for all Binding components.
reload(checkpoint)Loads the model from a checkpoint file.
reload_from_state_dict(state_dict)Loads the model from a state dict.
save(checkpoint[, flank_lengths])Saves the model to a file with "state_dict" and "metadata" fields.
unfreeze([parameter])Turns on gradient calculation for the specified parameter.
Attributes
library_concentrationThe total library concentration \([\text{library}]\).
alias of
Literal['all', 'depth', 'delta']Non-Inherited Members
- unfreezable
alias of
Literal[‘all’, ‘depth’, ‘delta’]
- classmethod from_round(base_round, reference_round=None, train_depth=True, target_concentration=1, name='')
Creates a new instance from another round at a different timepoint.
The resulting round has the same aggregate and delta as base_round.
- Parameters:
base_round (
Self) – The binding components driving enrichment.reference_round (
BaseRound|None) – The previous round used in cumulative enrichment.train_depth (
bool) – Whether to train the sequencing depth \(\eta\).name (
str) – A string used to describe the round.
- Return type:
Self
- classmethod from_binding(binding, reference_round, train_depth=True, log_depth=0, train_concentration=False, target_concentration=1, library_concentration=-1, activity_heuristic=0.05, name='', delta=-15, train_delta=True)
Creates a new instance from binding components and reference round.
- Parameters:
binding (
Iterable[Binding]) – The binding components driving enrichment.reference_round (
BaseRound|None) – The previous round used in cumulative enrichment.train_depth (
bool) – Whether to train the sequencing depth \(\eta\).log_depth (
float) – The initial value of log_depth.train_concentration (
bool) – Whether to train the protein concentration.target_concentration (
float) – Protein concentration, used for estimating the free protein concentration.library_concentration (
float) – Library concentration, used for estimating the free protein concentration.activity_heuristic (
float) – The fraction of the total aggregate that the contribution will be set to when it is first optimized.name (
str) – A string used to describe the round.delta (
float) – The initial value of \(\delta\).train_delta (
bool) – Whether to train the delta parameter.
- Return type:
Self
- unfreeze(parameter='all')
Turns on gradient calculation for the specified parameter.
- Parameters:
parameter (unfreezable) – Parameter to be unfrozen, defaults to all parameters.
- Return type:
None
- log_enrichment(seqs)
Predicts the log enrichment ratio.
\[\log \frac{f_{i,r}}{f_{i,r-1}}\]- Parameters:
seqs (
Tensor) – A sequence tensor of shape \((\text{minibatch},\text{length})\) or \((\text{minibatch},\text{in_channels},\text{length})\).- Return type:
Tensor- Returns:
The log enrichment ratio tensor of shape \((\text{minibatch},)\).