Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support and testing for MNPs #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions spliceai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ def get_delta_scores(record, ann, dist_var, mask):
if '<' in record.alts[j] or '>' in record.alts[j]:
continue

if len(record.ref) > 1 and len(record.alts[j]) > 1:
delta_scores.append("{}|{}|.|.|.|.|.|.|.|.".format(record.alts[j], genes[i]))
continue

dist_ann = ann.get_pos_data(idxs[i], record.pos)
pad_size = [max(wid//2+dist_ann[0], 0), max(wid//2-dist_ann[1], 0)]
ref_len = len(record.ref)
Expand Down Expand Up @@ -174,6 +170,15 @@ def get_delta_scores(record, ann, dist_var, mask):
np.max(y_alt[:, cov//2:cov//2+alt_len], axis=1)[:, None, :],
y_alt[:, cov//2+alt_len:]],
axis=1)
#MNP handling
elif ref_len > 1 and alt_len > 1:
zblock = np.zeros((1,ref_len-1,3))
y_alt = np.concatenate([
y_alt[:, :cov//2],
np.max(y_alt[:, cov//2:cov//2+alt_len], axis=1)[:, None, :],
zblock,
y_alt[:, cov//2+alt_len:]],
axis=1)

y = np.concatenate([y_ref, y_alt])

Expand Down
14 changes: 14 additions & 0 deletions tests/test_delta_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,17 @@ def test_get_delta_score_donor(self):
self.assertEqual(scores, ['T|TUBB8|0.01|0.18|0.15|0.62|-2|110|-190|0'])
scores = get_delta_scores(record, self.ann_without_prefix, 500, 0)
self.assertEqual(scores, ['T|TUBB8|0.01|0.18|0.15|0.62|-2|110|-190|0'])

def test_get_delta_score_mnp(self):

record = Record('10', 94077, 'ACT', ['CCT'])
scores = get_delta_scores(record, self.ann, 50, 0)
self.assertEqual(scores, ['CCT|TUBB8|0.07|0.27|0.00|0.01|0|-23|19|-22'])
scores = get_delta_scores(record, self.ann_without_prefix, 50, 0)
self.assertEqual(scores, ['CCT|TUBB8|0.07|0.27|0.00|0.01|0|-23|19|-22'])

record = Record('10', 94555, 'CGA', ['TGA'])
scores = get_delta_scores(record, self.ann, 50, 0)
self.assertEqual(scores, ['TGA|TUBB8|0.01|0.00|0.11|0.62|-2|-6|-23|0'])
scores = get_delta_scores(record, self.ann_without_prefix, 50, 0)
self.assertEqual(scores, ['TGA|TUBB8|0.01|0.00|0.11|0.62|-2|-6|-23|0'])