Esempio n. 1
0
def ex2():
    """
    Answer to
    http://stackoverflow.com/questions/43059781/connecting-networks-by-adding-edge-between-same-items-in-the-networks
    """

    HH = ['GLI1', 'PTCH1', 'PTCH2', 'WNT5A', 'HHIP1', 'MYCN', 'CCND1', 'CCND2', 'BCL2', 'CFLAR', 'FOXF1', 'FOXL1', 'PRDM1', 'JAG2', 'GREM1']
    Wnt = ['GLI1', 'PTCH1', 'WNT5A', 'HHIP1', 'MYCN', 'CCND1', 'WNT7A', 'WNT2', 'CDK1', 'CK1']
    CC = ['GLI1', 'CCNDA', 'BMP4', 'BMP7', 'MTOC2', 'CCND1']

    venn3_wordcloud([set(HH), set(Wnt), set(CC)],
                    set_labels=['Hedgehog', 'Wnt', 'Cell Cycle'])

    return
Esempio n. 2
0
def main():
    gn = Granatum()

    set1 = gn.get_import('set1')
    set2 = gn.get_import('set2')
    set3 = gn.get_import('set3')

    maxScore = gn.get_arg('maxScore')
    minScore = gn.get_arg('minScore')

    labelSet1 = gn.get_arg("labelSet1")
    labelSet2 = gn.get_arg("labelSet2")
    labelSet3 = gn.get_arg("labelSet3")

    wordcloud = gn.get_arg("wordcloud")

    filtered_set1 = dict(filter(lambda elem: (isinstance(elem[1], numbers.Number) & (not isnan(elem[1]))) & (elem[1] >= minScore) & (elem[1] <= maxScore), set1.items()))
    filtered_set2 = dict(filter(lambda elem: (isinstance(elem[1], numbers.Number) & (not isnan(elem[1]))) & (elem[1] >= minScore) & (elem[1] <= maxScore), set2.items()))
    filtered_set3 = dict(filter(lambda elem: (isinstance(elem[1], numbers.Number) & (not isnan(elem[1]))) & (elem[1] >= minScore) & (elem[1] <= maxScore), set3.items()))
    merged_frequencies = {**filtered_set1, **filtered_set2, **filtered_set3}

    packedsets = [set(filtered_set1.keys()), set(filtered_set2.keys()), set(filtered_set3.keys())]

    fig, ax = plt.subplots(1,1)
    fig.set_size_inches(5,4)

    caption = (
        'The area weighted Venn diagram is shown for the gene sets matching the criteria'
    )

    if wordcloud:
        out = venn3_wordcloud(packedsets, set_labels=(labelSet1, labelSet2, labelSet3), wordcloud_kwargs=dict(max_font_size=36), word_to_frequency=merged_frequencies, ax=ax)
        for text in out.set_labels:
            if text:
                text.set_fontsize(18)
        for text in out.subset_labels:
            if text:
                text.set_fontsize(16)
                text.set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()])
    else:
        out = venn3(packedsets, set_labels=(labelSet1, labelSet2, labelSet3))
        venn3_circles(packedsets, linestyle='dashed', linewidth=1, color="black")
        for text in out.set_labels:
            if text:
                text.set_fontsize(18)
        for text in out.subset_labels:
            if text:
                text.set_fontsize(16)
                text.set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()])

    gn.add_current_figure_to_results(caption)

    gn.commit()
Esempio n. 3
0
def draw_word_venn_3(datasets, dataset_name1, dataset_name2, dataset_name3):
    fig, ax = plt.subplots(1, 1, figsize=(30, 30))
    set1 = set(get_names_from_files(datasets[dataset_name1]))
    set2 = set(get_names_from_files(datasets[dataset_name2]))
    set3 = set(get_names_from_files(datasets[dataset_name3]))
    v = venn3_wordcloud([set1, set2, set3], (dataset_name1, dataset_name2, dataset_name3), ax=ax,
                        set_colors=['blue', 'yellow', 'green'])
    for text in v.set_labels:
        text.set_fontsize(30)
    for text in v.subset_labels:
        text.set_fontsize(18)
    plt.show()
Esempio n. 4
0
def ex5():
    """
    Issue #4:
    https://github.com/paulbrodersen/matplotlib_venn_wordcloud/issues/4

    Handle non-overlapping sets gracefully.
    """
    from matplotlib import pyplot as plt
    from matplotlib_venn_wordcloud import venn2_wordcloud

    x = set('abcd')
    y = set('efgh')
    s2 = (x, y)

    v2 = venn2_wordcloud(s2)

    z = set('ijkl')
    s3 = (x, y, z)
    v3 = venn3_wordcloud(s3)
Esempio n. 5
0
    #    if(v.get_patch_by_id('101')):
    #        v.get_patch_by_id('101').set_color('#ff00ff')
    #    if(v.get_patch_by_id('111')):
    #        v.get_patch_by_id('111').set_color('#ffffff')

    path = './images/'
    if not os.path.exists(path):
        os.makedirs(path)

    path1 = path + x + y + z
    #c = venn3_circles(s, linestyle='solid')

    ## create venn sets filled with words
    plt.rcParams["figure.figsize"] = (39, 22)

    print('Generating Venn diagram with words for:', x, y, z)
    v = venn3_wordcloud(s,
                        set_labels=(x, y, z),
                        alpha=0.7,
                        word_to_frequency=frequencies,
                        wordcloud_kwargs={
                            'max_words': 1800,
                            'min_font_size': 9,
                            'width': 3840,
                            'height': 2160
                        })
    path3 = path1 + '_words'
    #plt.rcParams["figure.figsize"] = (20,11)
    plt.savefig(path3)
    plt.close()