Skip to content

Commit 6754e48

Browse files
committed
Merge branch 'development'
2 parents f14984c + d61e34a commit 6754e48

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

spladder/alt_splice/detect.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from scipy.sparse import lil_matrix
2-
from numpy.matlib import repmat
32
import numpy as np
43
import sys
54
import operator
@@ -25,7 +24,7 @@ def detect_multipleskips(genes, gidx, log=False, edge_limit=300):
2524
genes[iix].from_sparse()
2625
num_exons = genes[iix].splicegraph.get_len()
2726
edges = genes[iix].splicegraph.edges.copy()
28-
labels = repmat(np.arange(num_exons), num_exons, 1).T
27+
labels = np.hstack([np.arange(num_exons)[:, np.newaxis]] * num_exons)
2928
genes[iix].to_sparse()
3029

3130
# adjecency matrix: upper half only
@@ -90,15 +89,15 @@ def detect_multipleskips(genes, gidx, log=False, edge_limit=300):
9089
backtrace = np.r_[backtrace, path[exon_idx_first, backtrace[-1]]]
9190
backtrace = backtrace[:-1]
9291
backtrace = backtrace[::-1]
93-
idx_multiple_skips.append(ix) #repmat(ix, 1, backtrace.shape[0] + 2))
92+
idx_multiple_skips.append(ix)
9493
exon_multiple_skips.append([exon_idx_first, backtrace, exon_idx_last])
9594
elif (long_exist_path[exon_idx_first, exon_idx_last] > 2) and np.isfinite(long_exist_path[exon_idx_first, exon_idx_last]):
9695
backtrace = np.array([long_path[exon_idx_first, exon_idx_last]])
9796
while backtrace[-1] > exon_idx_first:
9897
backtrace = np.r_[backtrace, long_path[exon_idx_first, backtrace[-1]]]
9998
backtrace = backtrace[:-1]
10099
backtrace = backtrace[::-1]
101-
idx_multiple_skips.append(ix) #repmat(ix, 1, backtrace.shape[0] + 2))
100+
idx_multiple_skips.append(ix)
102101
exon_multiple_skips.append([exon_idx_first, backtrace, exon_idx_last])
103102

104103
if log:

spladder/alt_splice/verify.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def verify_mult_exon_skip(event, gene, counts_segments, counts_edges, options):
1818
# (3) avg inclusion count inner exons >= threshold
1919
# (4) skip count >= threshold
2020

21-
info = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
21+
info = np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype='float')
2222
# (0) valid, (1) exon_pre_cov, (2) exons_cov, (3) exon_aft_cov
2323
# (4) exon_pre_exon_conf, (5) exon_exon_aft_conf, (6) exon_pre_exon_aft_conf
2424
# (7) sum_inner_exon_conf, (8) num_inner_exon, (9) len_inner_exon
@@ -102,7 +102,7 @@ def verify_intron_retention(event, gene, counts_segments, counts_edges, counts_s
102102
# (0) counts meet criteria for min_retention_cov, min_retention_region and min_retetion_rel_cov
103103
# (1) min_non_retention_count >= threshold
104104

105-
info = [1, 0, 0, 0, 0, 0]
105+
info = np.array([1, 0, 0, 0, 0, 0], dtype='float')
106106
# (0) valid, (1) intron_cov, (2) exon1_cov, (3), exon2_cov
107107
# (4) intron_conf, (5) intron_cov_region
108108

@@ -169,7 +169,7 @@ def verify_exon_skip(event, gene, counts_segments, counts_edges, options):
169169
# (2) inclusion count of second intron >= threshold
170170
# (3) skip count of exon >= threshold
171171

172-
info = [1, 0, 0, 0, 0, 0, 0]
172+
info = np.array([1, 0, 0, 0, 0, 0, 0], dtype='float')
173173
# (0) valid, (1) exon_cov, (2) exon_pre_cov, (3) exon_aft_cov,
174174
# (4) exon_pre_exon_conf, (5) exon_exon_aft_conf, (6) exon_pre_exon_aft_conf
175175

@@ -236,7 +236,7 @@ def verify_alt_prime(event, gene, counts_segments, counts_edges, options):
236236
# (0) coverage of diff region is at least FACTOR * coverage constant region
237237
# (1) both alternative introns are >= threshold
238238

239-
info = [1, 0, 0, 0, 0]
239+
info = np.array([1, 0, 0, 0, 0], dtype='float')
240240
# (0) valid, (1) exon_diff_cov, (2) exon_const_cov
241241
# (3) intron1_conf, (4) intron2_conf
242242

@@ -332,7 +332,7 @@ def verify_mutex_exons(event, gene, counts_segments, counts_edges, options):
332332
# (2) both introns neighboring first alt exon are confirmed >= threshold
333333
# (3) both introns neighboring second alt exon are confirmed >= threshold
334334

335-
info = [1, 0, 0, 0, 0, 0, 0, 0, 0]
335+
info = np.array([1, 0, 0, 0, 0, 0, 0, 0, 0], dtype='float')
336336
# (0) valid, (1) exon_pre_cov, (2) exon1_cov, (3) exon2_cov, (4) exon_aft_cov,
337337
# (5) exon_pre_exon1_conf, (6) exon_pre_exon2_conf, (7) exon1_exon_aft_conf, (8) exon2_exon_aft_conf
338338

@@ -513,9 +513,9 @@ def verify_all_events(ev, strain_idx=None, list_bam=None, event_type=None, optio
513513

514514
ev[i].verified.append(ver)
515515
if s_idx == 0:
516-
counts.append(np.array([info], dtype='float'))
516+
counts.append(info[np.newaxis, :])
517517
else:
518-
counts[-1] = np.r_[counts[-1], np.array([info], dtype='float')]
518+
counts[-1] = np.append(counts[-1], info[np.newaxis, :], axis=0)
519519
ev[i].verified = np.array(ev[i].verified, dtype='bool')
520520

521521
IN.close()
@@ -532,18 +532,18 @@ def verify_empty(event_type):
532532

533533
if event_type == 'exon_skip':
534534
verified = [0, 0, 0, 0]
535-
info = [1, 0, 0, 0, 0, 0, 0]
535+
info = np.array([1, 0, 0, 0, 0, 0, 0], dtype='float')
536536
elif event_type in ['alt_3prime', 'alt_5prime']:
537537
verified = [0, 0]
538-
info = [1, 0, 0, 0, 0]
538+
info = np.array([1, 0, 0, 0, 0], dtype='float')
539539
elif event_type == 'intron_retention':
540540
verified = [0, 0]
541-
info = [1, 0, 0, 0, 0, 0]
541+
info = np.array([1, 0, 0, 0, 0, 0], dtype='float')
542542
elif event_type == 'mult_exon_skip':
543543
verified = [0, 0, 0, 0, 0]
544-
info = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
544+
info = np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype='float')
545545
elif event_type == 'mutex_exons':
546546
verified = [0, 0, 0, 0]
547-
info = [1, 0, 0, 0, 0, 0, 0, 0, 0]
547+
info = np.array([1, 0, 0, 0, 0, 0, 0, 0, 0], dtype='float')
548548

549549
return (verified, info)

0 commit comments

Comments
 (0)