crested.pl.patterns.contribution_scores

crested.pl.patterns.contribution_scores#

crested.pl.patterns.contribution_scores(scores, seqs_one_hot, sequence_labels=None, class_labels=None, zoom_n_bases=None, highlight_positions=None, ylim=None, method=None, **kwargs)#

Visualize interpretation scores with optional highlighted positions.

Contribution scores can be calculated using the calculate_contribution_scores() method.

Parameters:
  • scores (ndarray) – Contribution scores of shape (n_seqs, n_classes, n_bases, n_features).

  • seqs_one_hot (ndarray) – One-hot encoded corresponding sequences of shape (n_seqs, n_bases, n_features).

  • sequence_labels (Optional[list] (default: None)) – List of sequence labels (subplot titles) to add to the plot. Should have the same length as the number of sequences.

  • class_labels (Optional[list] (default: None)) – List of class labels to add to the plot. Should have the same length as the number of classes.

  • zoom_n_bases (Optional[int] (default: None)) – Number of center bases to zoom in on. Default is None (no zooming).

  • highlight_positions (Optional[list[tuple[int, int]]] (default: None)) – List of tuples with start and end positions to highlight. Default is None.

  • ylim (Optional[tuple] (default: None)) – Y-axis limits. Default is None.

  • method (Optional[str] (default: None)) – Method used for calculating contribution scores. If mutagenesis, specify.

Examples

>>> import numpy as np
>>> scores = np.random.rand(1, 1, 100, 4)
>>> seqs_one_hot = np.random.randint(0, 2, (1, 100, 4))
>>> class_labels = ["celltype_A"]
>>> sequence_labels = ["chr1:100-200"]
>>> crested.pl.patterns.contribution_scores(
...     scores, seqs_one_hot, sequence_labels, class_labels
... )
../../../_images/contribution_scores.png