Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
hiding trees when they haven not been reconciled yet. updated names i…
…n plot
  • Loading branch information
proost committed Nov 16, 2017
1 parent 8c35158 commit bd6b2e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
18 changes: 10 additions & 8 deletions conekt/models/expression/networks.py
Expand Up @@ -72,7 +72,7 @@ def update_count():

@staticmethod
@benchmark
def calculate_ecc(network_method_ids, gene_family_method_id):
def calculate_ecc(network_method_ids, gene_family_method_id, max_size=100):
"""
Function to calculate the ECC scores in and between genes of different networks
Expand All @@ -94,12 +94,13 @@ def calculate_ecc(network_method_ids, gene_family_method_id):
ExpressionNetwork.__table__.c.network,
ExpressionNetwork.__table__.c.method_id]).
where(ExpressionNetwork.__table__.c.method_id == n).
where(ExpressionNetwork.__table__.c.sequence_id is not None)
where(ExpressionNetwork.__table__.c.sequence_id.isnot(None))
).fetchall()

for sequence, network, network_method_id in current_network:
sequence_network[int(sequence)] = network
sequence_network_method[int(sequence)] = int(network_method_id)
if sequence is not None:
sequence_network[int(sequence)] = network
sequence_network_method[int(sequence)] = int(network_method_id)

# Get family data and store in dictionary
current_families = db.engine.execute(db.select([SequenceFamilyAssociation.__table__.c.sequence_id,
Expand Down Expand Up @@ -141,7 +142,7 @@ def calculate_ecc(network_method_ids, gene_family_method_id):
for m in network_method_ids:
thresholds[n][m] = ExpressionNetworkMethod.__set_thresholds(network_families[n],
network_families[m],
max_size=30)
max_size=max_size)

# Data loaded start calculating ECCs
new_ecc_scores = []
Expand All @@ -157,7 +158,7 @@ def calculate_ecc(network_method_ids, gene_family_method_id):
sequence_family,
thresholds[sequence_network_method[query]][sequence_network_method[target]],
family,
max_size=30)
max_size=max_size)
if significant:
new_ecc_scores.append({
'query_id': query,
Expand Down Expand Up @@ -238,7 +239,7 @@ def __set_thresholds(families_a, families_b, max_size=30, iterations=1000):
new_threshholds = []
for j in range(max_size):
scores = []
for iterations in range(iterations):
for _ in range(iterations):
if i+1 < len(families_a) and j+1 < len(families_b):
i_fams = random.sample(families_a, i+1)
j_fams = random.sample(families_b, j+1)
Expand All @@ -247,8 +248,9 @@ def __set_thresholds(families_a, families_b, max_size=30, iterations=1000):
# Cannot calculate threshold with these families, add 1
scores.append(1)

scores = sorted(scores)
# TODO (maybe?): cutoff is hard coded here, replace ?
print(iterations, len(scores), scores)
scores = sorted(scores)
new_threshholds.append(scores[int(iterations*0.95)])
thresholds.append(new_threshholds)

Expand Down
11 changes: 10 additions & 1 deletion conekt/static/js/planet_graph.js
Expand Up @@ -78,6 +78,7 @@ $(function () { // on dom ready
ready: function () {
window.cy = this;

var has_ecc = false;
initial_json = JSON.stringify(cy.json(), null, '\t');

cy.nodes('[^compound]').forEach(function (n) {
Expand Down Expand Up @@ -186,6 +187,7 @@ $(function () { // on dom ready

if (e.data('ecc_score') !== undefined) {
content.push({ value: 'ECC: ' + e.data('ecc_score').toFixed(2) });
has_ecc = true;
}

e.qtip({
Expand Down Expand Up @@ -313,7 +315,14 @@ $(function () { // on dom ready
if (Object.keys(svg_spm).length > 0) { generate_legend(svg_spm, 'spm_color', 'spm'); }
if (Object.keys(svg_species).length > 0) { generate_legend(svg_species, 'species_color', 'species'); }

$('.cy-node-color[attr="family_color"]').click();
if (has_ecc) {
$('.cy-node-color[attr="species_color"]').click();
$('.cy-edge-color[attr="ecc_type"]').click();
} else {
$('.cy-node-color[attr="family_color"]').click();
}


$('#loading').addClass('loaded');
$('#legend').show();

Expand Down

0 comments on commit bd6b2e2

Please sign in to comment.