Exemple #1
0
def study_type(study):
    ancestor_dict = {}
    exps = v5.study_to_exps(study)
    for exp in exps:
        ancestors = v5.exp_to_celltypes(exp)
        for celltype in v5.exp_to_celltypes(exp):
            ancestors += co.get_ancestors(celltype)
        ancestor_dict[exp] = ancestors

    if len(exps) == 1:
        ancestors = ancestor_dict[exps[0]]
    else:
        first = True
        for exp in ancestor_dict:
            if first:
                ancestors = set(ancestor_dict[exp])
                first = False
                continue
            ancestors = ancestors | set(ancestor_dict[exp])
        ancestors = list(ancestors)

    common = []
    for term_id in co.get_terms_without_children(list(ancestors)):
        common.append(co.get_term_name(term_id))
    common = '; '.join(common)

    return common
Exemple #2
0
def get_proportion(exp, nonzero, singleExp):
    labels = v5.exp_to_celltypes(exp)
    celltypes = []

    for label in labels:
        celltypes.append(co.get_term_name(label))
        for descendant in co.get_descendents(label):
            celltypes.append(co.get_term_name(descendant))
#     print(nonzero.columns)
    expright = 0
    ll = 0
    #     print(nonzero)
    for i in range(ll, len(nonzero['0'])):
        if nonzero['0'][i] == exp and nonzero['1'][i] in celltypes:
            expright += nonzero['2'][i]
            ll = i

    if singleExp:
        expright = expright / 2


#     if expright > 1:
#         expright = expright/2

    return expright
Exemple #3
0
def is_type_available(celltype, study):
    study = v5.study_to_exps(study)
    for exp in v5.get_exps():
        if exp in study:
            continue
        else:
            if celltype in v5.exp_to_celltypes(exp):
                return True
    return False
Exemple #4
0
def exp_to_celltypes(exp):
    ids = v5.exp_to_celltypes(exp)
    celltypes = [co.get_term_name(id) for id in ids]
    return '; '.join(celltypes)