Skip to content

Commit

Permalink
merged in parallel branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Kahles committed Mar 4, 2016
2 parents e8e7b29 + 3f2f53c commit 1ab054c
Show file tree
Hide file tree
Showing 15 changed files with 671 additions and 453 deletions.
2 changes: 1 addition & 1 deletion python/examples/result_tiny.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
982fa94cb258c5784da03a4539ca97e0 examples/result_tiny/merge_graphs_exon_skip_C3.confirmed.txt
eec37bd7274a67c542eced649c7caf1e examples/result_tiny/merge_graphs_exon_skip_C3.confirmed.txt
61 changes: 29 additions & 32 deletions python/modules/alt_splice/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def collect_events(CFG):
### detect intron retentions from splicegraph
if do_intron_retention:
if not os.path.exists(fn_out_ir):
idx_intron_reten, intron_intron_reten = detect_intronreten(genes, sp.where([x.is_alt for x in genes])[0])
idx_intron_reten, intron_intron_reten = detect_events(genes, 'intron_retention', sp.where([x.is_alt for x in genes])[0], CFG)
for k in range(len(idx_intron_reten)):
gene = genes[idx_intron_reten[k]]

Expand Down Expand Up @@ -142,7 +142,7 @@ def collect_events(CFG):
### detect exon_skips from splicegraph
if do_exon_skip:
if not os.path.exists(fn_out_es):
idx_exon_skip, exon_exon_skip = detect_exonskips(genes, sp.where([x.is_alt for x in genes])[0])
idx_exon_skip, exon_exon_skip = detect_events(genes, 'exon_skip', sp.where([x.is_alt for x in genes])[0], CFG)
for k in range(len(idx_exon_skip)):
gene = genes[idx_exon_skip[k]]

Expand Down Expand Up @@ -175,7 +175,7 @@ def collect_events(CFG):
### detect alternative intron_ends from splicegraph
if do_alt_3prime or do_alt_5prime:
if not os.path.exists(fn_out_a5) or not os.path.exists(fn_out_a3):
idx_alt_end_5prime, exon_alt_end_5prime, idx_alt_end_3prime, exon_alt_end_3prime = detect_altprime(genes, sp.where([x.is_alt for x in genes])[0])
idx_alt_end_5prime, exon_alt_end_5prime, idx_alt_end_3prime, exon_alt_end_3prime = detect_events(genes, 'alt_prime', sp.where([x.is_alt for x in genes])[0], CFG)
### handle 5 prime events
for k in range(len(idx_alt_end_5prime)):
gene = genes[idx_alt_end_5prime[k]]
Expand Down Expand Up @@ -280,43 +280,40 @@ def collect_events(CFG):
### detect multiple_exon_skips from splicegraph
if do_mult_exon_skip:
if not os.path.exists(fn_out_mes):
idx_mult_exon_skip, exon_mult_exon_skip, id_mult_exon_skip = detect_multipleskips(genes, sp.where([x.is_alt for x in genes])[0])
if len(id_mult_exon_skip) > 0:
for k in id_mult_exon_skip:
#k_ = sp.where(sp.array(id_mult_exon_skip) == k)[0]
#gene = genes[idx_mult_exon_skip[k_[0]]]
gene = genes[idx_mult_exon_skip[k]]
idx_mult_exon_skip, exon_mult_exon_skip = detect_events(genes, 'mult_exon_skip', sp.where([x.is_alt for x in genes])[0], CFG)
for k, gidx in enumerate(idx_mult_exon_skip):
gene = genes[gidx]

### perform liftover between strains if necessary
exons = gene.splicegraph.vertices
if not 'reference_strain' in CFG:
exons_col = exons
exons_col_pos = exons
else:
exons_col = convert_strain_pos_intervals(gene.chr, gene.splicegraph.vertices.T, strain, CFG['reference_strain']).T
exons_col_pos = convert_strain_pos(gene.chr, gene.splicegraph.vertices.T, strain, CFG['reference_strain']).T
if exons_col.shape != exons_col_pos.shape:
print 'skipping non-mappable multiple exon skip event'
continue
### perform liftover between strains if necessary
exons = gene.splicegraph.vertices
if not 'reference_strain' in CFG:
exons_col = exons
exons_col_pos = exons
else:
exons_col = convert_strain_pos_intervals(gene.chr, gene.splicegraph.vertices.T, strain, CFG['reference_strain']).T
exons_col_pos = convert_strain_pos(gene.chr, gene.splicegraph.vertices.T, strain, CFG['reference_strain']).T
if exons_col.shape != exons_col_pos.shape:
print 'skipping non-mappable multiple exon skip event'
continue

### build multiple exon skip data structure
event = Event('mult_exon_skip', gene.chr, gene.strand)
event.strain = sp.array([strain])
event.exons1 = sp.c_[exons[:, exon_mult_exon_skip[k][0]], exons[:, exon_mult_exon_skip[k][2]]].T
event.exons2 = sp.c_[exons[:, exon_mult_exon_skip[k][0]], exons[:, exon_mult_exon_skip[k][1]], exons[:, exon_mult_exon_skip[k][2]]].T
event.exons1_col = sp.c_[exons_col[:, exon_mult_exon_skip[k][0]], exons_col[:, exon_mult_exon_skip[k][2]]].T
event.exons2_col = sp.c_[exons_col[:, exon_mult_exon_skip[k][0]], exons_col[:, exon_mult_exon_skip[k][1]], exons_col[:, exon_mult_exon_skip[k][2]]].T
event.gene_name = sp.array([gene.name])
event.gene_idx = idx_mult_exon_skip[k]
#event.transcript_type = sp.array([gene.transcript_type])
mult_exon_skip_pos[ridx, i].append(event)
### build multiple exon skip data structure
event = Event('mult_exon_skip', gene.chr, gene.strand)
event.strain = sp.array([strain])
event.exons1 = sp.c_[exons[:, exon_mult_exon_skip[k][0]], exons[:, exon_mult_exon_skip[k][2]]].T
event.exons2 = sp.c_[exons[:, exon_mult_exon_skip[k][0]], exons[:, exon_mult_exon_skip[k][1]], exons[:, exon_mult_exon_skip[k][2]]].T
event.exons1_col = sp.c_[exons_col[:, exon_mult_exon_skip[k][0]], exons_col[:, exon_mult_exon_skip[k][2]]].T
event.exons2_col = sp.c_[exons_col[:, exon_mult_exon_skip[k][0]], exons_col[:, exon_mult_exon_skip[k][1]], exons_col[:, exon_mult_exon_skip[k][2]]].T
event.gene_name = sp.array([gene.name])
event.gene_idx = gidx
#event.transcript_type = sp.array([gene.transcript_type])
mult_exon_skip_pos[ridx, i].append(event)
else:
print '%s already exists' % fn_out_mes

### detect mutually exclusive exons from splicegraph
if do_mutex_exons:
if not os.path.exists(fn_out_mex):
idx_mutex_exons, exon_mutex_exons = detect_xorexons(genes, sp.where([x.is_alt for x in genes])[0])
idx_mutex_exons, exon_mutex_exons = detect_events(genes, 'mutex_exons', sp.where([x.is_alt for x in genes])[0], CFG)
if len(idx_mutex_exons) > 0:
for k in range(len(exon_mutex_exons)):
gene = genes[idx_mutex_exons[k]]
Expand Down
Loading

0 comments on commit 1ab054c

Please sign in to comment.