コード例 #1
0
ファイル: test_ddot.py プロジェクト: cthoyt/ddot
 def setUp(self):
     self.ont = Ontology(hierarchy, mapping)
コード例 #2
0
synapse_semantic = pd.DataFrame(columns=gene_name,
                                index=gene_name,
                                data=sim_score)
synapse_semantic.to_csv(path + 'GO_synapse_semantic_similarity_matrix.csv')

# adjacency list
with open(path + 'GO_synapse_semantic_similarity_list.txt', 'w') as f:
    for row in range((sim_score.shape[0])):
        for column in range((sim_score.shape[1])):
            if column > row:
                f.write(gene_name[column] + '\t' + gene_name[row] + '\t' +
                        str(sim_score[row, column]) + '\n')

# In[9]:

# Run CliXO on flattened hierarchy and time
CX_File = 'GO_synapse_semantic_similarity_list.txt'

t0 = timeit.default_timer()
CX.RunCliXO(CX_File, a_=0.01, b_=0.5, M_=0.0001, z_=0.05)
t1 = timeit.default_timer()
print('time: {:.1f}'.format(t1 - t0))

# In[14]:

# create ontology object from CliXO (useless for recreated, but similar code can be used in future for
# creating an ontology object from CliXO output on real data)
CX_ONT = 'RUN_' + CX_File[0:-4] + 'ONT'
hierarchy, mapping = CX.CliXO_Parser(CX_ONT)
ont_CX = Ontology(hierarchy, mapping, ignore_orphan_terms=True)
コード例 #3
0

# In[7]:


pc = pd.DataFrame(columns=['alpha', 'precision', 'recall'])
index = 0

alphas = [0.5,1,0.05,2,1.5,3,0.2]

for alpha in alphas:
    try:
        # run CliXO with specified alpha
        CX.RunCliXO(CX_File, a_ = alpha,b_ = 0.5, M_ = 0.0001,z_ = 0.05)
        t1 = timeit.default_timer()
        print('time: {:.1f}'.format(t1-t0))

        # generate ontology object from generated CliXO ontology
        hierarchy,mapping = CX.CliXO_Parser(CX_ONT)
        ontCX_synapse = Ontology(hierarchy, mapping, ignore_orphan_terms=True)

        # calculate precision recall and 
        precision, recall = precision_recall(ontCX_synapse, ontGO_synapse)
        row = [alpha, precision, recall]
        pc.loc[index, :] = row
        pc.to_csv(path + 'precision_recall_draft_1.csv', sep = '\t')
        index += 1
    except:
        pass