Mismatch Scoring¶
Score CRISPR guide mismatch variants using a position-weighted linear
model. score_mismatches() generates single-nucleotide variants for
each guide and predicts their activity using a mismatch weight matrix.
mismatch
¶
Mismatch variant scorer for CRISPR guide spacers.
Predicts relative activity of single-nucleotide mismatch variants
using a linear model. Matches the scoring logic from
legacy/crispr_experiment/assets/mismatch.py.
score_mismatches
¶
score_mismatches(regions: Iterable[Region], weights: dict[str, float], *, num_variants: int = 10) -> Iterator[Region]
Score regions that have a spacer tag.
For each Region with a spacer tag, yields the original
unchanged, then yields num_variants variant Regions with
tags: variant_spacer, change_description, y_pred,
mismatches.
Regions without a spacer tag pass through unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regions
|
Iterable[Region]
|
Input regions to score. |
required |
weights
|
dict[str, float]
|
Dict from |
required |
num_variants
|
int
|
Variants to select per guide. Defaults to 10. |
10
|
Yields:
| Type | Description |
|---|---|
Region
|
Original region followed by variant regions. |
Examples:
Source code in src/seqchain/operations/score/mismatch.py
score_variant
¶
Score one variant against the original spacer.
Pure function matching legacy calculate_y_pred().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original
|
str
|
Original spacer sequence. |
required |
variant
|
str
|
Variant spacer sequence. |
required |
weights
|
dict[str, float]
|
Mismatch weight parameters. |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
Predicted relative activity, or |
float | None
|
identical, different length, or either is |
Examples:
Source code in src/seqchain/operations/score/mismatch.py
generate_variants
¶
Generate mismatch variants and select a spread across the score range.
Creates all possible single-nucleotide variants, scores each, then
selects num_variants evenly spread across the score range using
greedy closest-to-desired without replacement (matching legacy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spacer
|
str
|
Original spacer sequence. |
required |
weights
|
dict[str, float]
|
Mismatch weight parameters. |
required |
num_variants
|
int
|
Number of variants to select. Defaults to 10. |
10
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of dicts with keys |
list[dict]
|
|
Examples:
Source code in src/seqchain/operations/score/mismatch.py
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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |