• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python matplotlib_venn.venn3函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib_venn.venn3函数的典型用法代码示例。如果您正苦于以下问题:Python venn3函数的具体用法?Python venn3怎么用?Python venn3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了venn3函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: plotVennDiagram

    def plotVennDiagram(fdr_threshold):
        groundtruth = pd.read_csv(groundtruth_fn, names=['formula', 'adduct'])
        sim_layer_formulas = groundtruth.groupby('adduct')

        def top_results(df, threshold, adduct):
            """
            results with estimated FDR < threshold and positive MSM
            """
            fdr = df['fdr'] if 'fdr' in df else df['est_fdr']
            return df[(fdr < threshold) & (df['adduct'] == adduct) &
                      (df['img'] * df['iso'] * df['moc'] > 0)]

        for i, adduct in enumerate(orig['fdr'].keys()):
            plt.subplot(len(orig['fdr']), 1, i + 1)
            plt.title("Annotation overlap for {} (FDR threshold = {})"
                      .format(adduct, fdr_threshold))
            orig_res = pd.read_csv(orig['fdr'][adduct])
            sim_res = pd.read_csv(sim['fdr'][adduct])
            db = set(orig_res['formula'])

            orig_top = set(top_results(orig_res, fdr_threshold, adduct)['formula'])
            sim_top = set(top_results(sim_res, fdr_threshold, adduct)['formula'])
            venn3([orig_top, sim_top,
                   set(sim_layer_formulas.get_group(adduct)['formula']) & db],
                  ("Orig. annotations", "Sim. annotations", "Sim. groundtruth & DB"))
开发者ID:SpatialMetabolomics,项目名称:ims-simulator,代码行数:25,代码来源:pipeline.py


示例2: plot_venn

def plot_venn(t1=None, t2=None, t3=None, ax=None, set_colors=('r', 'b', 'k')):
	"""input: 2 or 3 tuples: (list/set, name_to_display) """
	assert len(t1) == len(t2) == 2
	if t3:
		venn3( [set(t[0]) for t in [t1,t2,t3]], tuple( ['%s\n(%s)'%(t[1], len(set(t[0])) ) for t in [t1,t2,t3]]) , set_colors=set_colors, alpha=0.5,ax=ax)
	else:
		venn2( [set(t[0]) for t in [t1,t2]], tuple( ['%s\n(%s)'%(t[1], len(set(t[0])) ) for t in [t1,t2]]), set_colors=set_colors[0:2],alpha=0.5, ax=ax)
开发者ID:MaayanLab,项目名称:Zika-RNAseq-Pipeline,代码行数:7,代码来源:plots.py


示例3: mi_venn_snps

def mi_venn_snps(df_snp_1, df_snp_2, df_snp_3, file='venn_snp.png'):
	import matplotlib_venn
	from matplotlib import pyplot as plt

	n_A = len( set(df_snp_1[df_snp_1['SNP'].isin([1,2])].FID.tolist() ) ) 
	n_B = len( set(df_snp_2[df_snp_2['SNP'].isin([1,2])].FID.tolist() ) )
	n_C = len( set(df_snp_3[df_snp_3['SNP'].isin([1,2])].FID.tolist() ) ) 
	n_AB =  len( set(df_snp_1[df_snp_1['SNP'].isin([1,2])].FID.tolist() ) \
			   & set(df_snp_2[df_snp_2['SNP'].isin([1,2])].FID.tolist() ) )
	n_AC =  len( set(df_snp_1[df_snp_1['SNP'].isin([1,2])].FID.tolist() ) \
			   & set(df_snp_3[df_snp_3['SNP'].isin([1,2])].FID.tolist() ) )
	n_BC =  len( set(df_snp_2[df_snp_2['SNP'].isin([1,2])].FID.tolist() ) \
			   & set(df_snp_3[df_snp_3['SNP'].isin([1,2])].FID.tolist() ) )
	n_ABC = len( set(df_snp_1[df_snp_1['SNP'].isin([1,2])].FID.tolist() ) \
			   & set(df_snp_2[df_snp_2['SNP'].isin([1,2])].FID.tolist() ) \
			   & set(df_snp_3[df_snp_3['SNP'].isin([1,2])].FID.tolist() ) )
	n_Abc = n_A - n_AC - n_AB + n_ABC
	n_aBc = n_B - n_BC - n_AB + n_ABC
	n_ABc = n_AB - n_ABC
	n_abC = n_C - n_BC - n_AC + n_ABC
	n_AbC = n_AC - n_ABC
	n_aBC = n_BC - n_ABC
	n_ABC = n_ABC
	
	print n_Abc, n_aBc, n_ABc, n_abC, n_AbC, n_aBC, n_ABC
	
	#  (Abc, aBc, ABc, abC, AbC, aBC, ABC)

	matplotlib_venn.venn3(subsets = (n_Abc, n_aBc, n_ABc, n_abC, n_AbC, n_aBC, n_ABC), set_labels = ('SNP_1', 'SNP_2', 'SNP_3'))

	plt.savefig(file)
	plt.close()
开发者ID:sonasi,项目名称:scratchpad,代码行数:32,代码来源:mutual_info.py


示例4: plot_venn3

def plot_venn3(cp,nc,bx,cp_nc,cp_bx,nc_bx,cnb,plotName=None) :
    fig = plt.figure()
    venn3(subsets={'100':cp,'010':nc,'001':bx,'110':cp_nc,'101':cp_bx,'011':nc_bx,'111':cnb},set_labels = ('Salmonella enterica', 'Escherichia coli', 'Staphylococcus aureus'))
    plt.title("Venn diagram")
    if plotName :
        plt.savefig(plotName)
    else :
        plt.show()
开发者ID:Raphael-De-Wang,项目名称:Semestre03,代码行数:8,代码来源:venn_hist.py


示例5: main

def main():
    """ main function """
    args = parse_args()

    f_chimp = pysam.Samfile(args.f_chimp, "rb")
    f_bono = pysam.Samfile(args.f_bono, "rb")
    f_human = pysam.Samfile(args.f_human, "rb")
    
    # stores the ID of each mapped reads in each samfile in a list
    reads_chimp = list()
    reads_bono = list()
    reads_human = list()

    for read in f_chimp:
        reads_chimp.append(read.qname)

    for read in f_bono:
        reads_bono.append(read.qname)

    for read in f_human:
        reads_human.append(read.qname)

    # find out if there is duplicate in the read IDs
    




    # find the intersections between the three
    overlap_bono_chimp = set(reads_bono).intersection(set(reads_chimp))
    overlap_bono_human = set(reads_bono).intersection(set(reads_human))
    overlap_chimp_human = set(reads_chimp).intersection(set(reads_human))
    overlap_bono_chimp_human = (set(reads_bono).
                                intersection(set(reads_chimp)).
                                intersection(set(reads_human)))

    #venn3() takes a list of 7 numbers:
    #venn[6] -> number of reads mapped to human, chimp and bonobo  
    #venn[5] -> number of reads mapped to chimp and human but not bonobo
    #venn[4] -> number of reads mapped to bonobo and human but not chimp
    #venn[3] -> number of reads mapped to chimp and bonobo but not human
    #venn[2] -> number of reads mapped only to human
    #venn[1] -> number of reads mapped only to chimp
    #venn[0] -> number of reads mapped only to bonobo

    venn = [0]*7
    venn[6] = overlap_bono_chimp_human
    venn[5] = overlap_chimp_human - overlap_bono_chimp_human
    venn[4] = overlap_bono_human - overlap_bono_chimp_human
    venn[3] = overlap_bono_chimp - overlap_bono_chimp_human
    venn[2] = f_human.mapped - venn[4] - venn[5] - overlap_bono_chimp_human
    venn[1] = f_chimp.mapped - venn[3] - venn[5] - overlap_bono_chimp_human
    venn[0] = f_bono.mapped - venn[3] - venn[4] - overlap_bono_chimp_human

    #plot and save venn diagrams   
    venn3(subsets=venn, set_labels = ("Bonobo", "Chimpanzee", "Human"))
    plt.title(args.plot_title)
    plt.show()
开发者ID:MollyZhang,项目名称:chonobo_read_labeling,代码行数:58,代码来源:venn_diagram.py


示例6: mi_venn

def mi_venn(df_snp_1, df_snp_2, df_pheno, file='venn.png'):
	import matplotlib_venn
	from matplotlib import pyplot as plt
	
	pheno = df_pheno.pheno_name

	pheno_total = float(len(set(df_pheno[df_pheno['pheno_'+pheno]==2].FID.tolist()) )  )
	
	snp_codes = [1,2]
	
	print "Venn Diagram"
	
	
	p_1 = float( len( set(df_snp_1[df_snp_1['SNP'].isin([1,2])].FID.tolist())   \
				& set(df_pheno[df_pheno['pheno_'+pheno]==2].FID.tolist()) )  )

	p_2 = float( len( set(df_snp_2[df_snp_2['SNP'].isin([1,2])].FID.tolist())   \
				& set(df_pheno[df_pheno['pheno_'+pheno]==2].FID.tolist()) )  )
				

	n_ABC = float( len( set(df_snp_1[df_snp_1['SNP'].isin([1,2])].FID.tolist() ) \
						  &  	  set(df_snp_2[df_snp_2['SNP'].isin([1,2])].FID.tolist() ) \
						  &  	  set(df_pheno[df_pheno['pheno_'+pheno]==2].FID.tolist())
						  )  )
	
	n_AB =  len( set(df_snp_1[df_snp_1['SNP'].isin([1,2])].FID.tolist() ) \
				&  	   set(df_snp_2[df_snp_2['SNP'].isin([1,2])].FID.tolist() ) )
	
	n_AC =  len( set(df_snp_1[df_snp_1['SNP'].isin([1,2])].FID.tolist() ) \
						  &  	  set(df_pheno[df_pheno['pheno_'+pheno]==2].FID.tolist())
						  )  
	
	n_BC =  len( set(df_snp_2[df_snp_2['SNP'].isin([1,2])].FID.tolist() ) \
						  &  	  set(df_pheno[df_pheno['pheno_'+pheno]==2].FID.tolist())
						  )
	n_A = len( set(df_snp_1[df_snp_1['SNP'].isin([1,2])].FID.tolist() ) ) 
	n_B = len( set(df_snp_2[df_snp_2['SNP'].isin([1,2])].FID.tolist() ) )
	
	n_Abc = n_A - n_AC - n_AB + n_ABC
	n_aBc = n_B - n_BC - n_AB + n_ABC
	n_ABc = n_AB - n_ABC
	n_abC = pheno_total - n_BC - n_AC + n_ABC
	n_AbC = n_AC - n_ABC
	n_aBC = n_BC - n_ABC
	n_ABC = n_ABC

	print "n_pheno: {}\t n_SNP_common: {}\t n_SNP_rare: {}\n".format(pheno_total, n_A, n_B)


	print n_Abc, n_aBc, n_ABc, n_abC, n_AbC, n_aBC, n_ABC
	
	#  (Abc, aBc, ABc, abC, AbC, aBC, ABC)

	matplotlib_venn.venn3(subsets = (n_Abc, n_aBc, n_ABc, n_abC, n_AbC, n_aBC, n_ABC), set_labels = ('SNP_common', 'SNP_rare', 'Pheno'))

	plt.savefig(file)
	plt.close()
开发者ID:sonasi,项目名称:scratchpad,代码行数:57,代码来源:mutual_info.py


示例7: venn3_sets

def venn3_sets(set_a, set_b, set_c, set_labels, ax):
    # order of values for Venn diagram: (Abc, aBc, ABc, abC, AbC, aBC, ABC)
    Abc = len(set_a.difference(set_b.union(set_c)))
    aBc = len(set_b.difference(set_a.union(set_c)))
    abC = len(set_c.difference(set_a.union(set_b)))
    ABc = len(set_a.intersection(set_b).difference(set_c))
    AbC = len(set_a.intersection(set_c).difference(set_b))
    aBC = len(set_b.intersection(set_c).difference(set_a))
    ABC = len(set_a.intersection(set_b).intersection(set_c))
    venn3(subsets = (Abc, aBc, ABc, abC, AbC, aBC, ABC),
          set_labels=set_labels, ax=ax)
开发者ID:eladnoor,项目名称:small-molecule-regulation,代码行数:11,代码来源:inhibitor_statistics.py


示例8: plot_venn

def plot_venn(List_of_sets,
              Set_labels,
              Main = "I forgot to give this plot a name.",
              Out_File = "",
              Custom_overlap_numbers = []):
    """
        Given a list of sets, generate a venn diagram in Out_Dir.
        
        Arguments:
            List_of_sets (two or three only!)
            Set_labels: Label for each circle
            Main: Title of plot
            Out_File: Where should plot be saved? And what should the file be named?
                Parent directory expected to already exist...
                This will overwrite plots if they already exist
            Custom_overlap_numbers: optional. If you want to supply your own 3 overlap sets:
                [# in first, # in second, # in both]
    """
    if not os.path.isdir(os.path.dirname(Out_File)):
        raise ValueError(os.path.dirname(Out_File)+" <--- PATH DOESN'T EXIST")
    
    if len(Custom_overlap_numbers) != 0 and len(Custom_overlap_numbers) != 3:
        raise ValueError("Custom overlap only works for 2 circle venn diagrams at the moment...")
    
    if len(Custom_overlap_numbers) == 3:
        plt.figure()
        venn2(subsets={'10': Custom_overlap_numbers[0], '01': Custom_overlap_numbers[1], '11': Custom_overlap_numbers[2]}, set_labels = Set_labels)
        plt.title(Main)
        plt.savefig(Out_File)
        return
                
    if len(List_of_sets) == 2:
        if len(Set_labels) != 2:
            raise ValueError("Set_labels needs to be the same length as the number of sets...")
        # Default figure dimensions...
        plt.figure()
        venn2(List_of_sets,Set_labels)
        plt.title(Main)
        plt.savefig(Out_File)
        
    elif len(List_of_sets) == 3:
        if len(Set_labels) != 3:
            raise ValueError("Set_labels needs to be the same length as the number of sets...")
        # Default figure dimensions...
        plt.figure()
        venn3(List_of_sets,Set_labels)
        plt.title(Main)
        plt.savefig(Out_File)
    else:
        raise ValueError("List_of_sets needs to be of length 2 or 3.")   
开发者ID:radlinsky,项目名称:splicing,代码行数:50,代码来源:splicing_fun.py


示例9: main

def main(list_sequence_names, output_prefix):

    sequence_list = []
    labels = []

    for [filename, label] in list_sequence_names:
        sequence_list.append(set(seq_IO.read_sequences(filename)))
        labels.append(label) 

    fig, ax = pconv.create_ax(1, 1)

    venn3(sequence_list, set_labels = labels, ax=ax[0,0]) 
    
    pconv.save_fig(fig, output_prefix, '_'.join(labels)+"_venn", 10, 10, size=12)
开发者ID:arubenstein,项目名称:deep_seq,代码行数:14,代码来源:VennDiagram.py


示例10: test_pr_28

def test_pr_28():
    import matplotlib_venn as mv
    v = mv.venn3((1, 2, 3, 4, 5, 6, 7), subset_label_formatter = None)
    assert v.get_label_by_id('010').get_text() == '2'
    v = mv.venn3((1, 2, 3, 4, 5, 6, 7), subset_label_formatter = lambda x: 'Value: %+0.3f' % (x / 100.0))
    assert v.get_label_by_id('010').get_text() == 'Value: +0.020'
    v = mv.venn2((1, 2, 3), subset_label_formatter = None)
    assert v.get_label_by_id('01').get_text() == '2'
    v = mv.venn2((1, 2, 3), subset_label_formatter = lambda x: 'Value: %+0.3f' % (x / 100.0))
    assert v.get_label_by_id('01').get_text() == 'Value: +0.020'
    
    v = mv.venn3_unweighted((1, 2, 3, 4, 5, 6, 7), subset_label_formatter = lambda x: 'Value: %+0.3f' % (x / 100.0))
    assert v.get_label_by_id('010').get_text() == 'Value: +0.020'
    v = mv.venn2_unweighted((1, 2, 3), subset_label_formatter = lambda x: 'Value: %+0.3f' % (x / 100.0))
    assert v.get_label_by_id('01').get_text() == 'Value: +0.020'
开发者ID:konstantint,项目名称:matplotlib-venn,代码行数:15,代码来源:issues_test.py


示例11: draw_venn3

def draw_venn3(A, B, C, sets):
    venn = [0]*7
    venn[2] = len(sets["AB"]) - len(sets["ABC"])
    venn[4] = len(sets["AC"]) - len(sets["ABC"])
    venn[5] = len(sets["BC"]) - len(sets["ABC"])
    venn[6] = len(sets["ABC"])
    venn[0] = len(sets["A"]) - venn[2] - venn[4] - venn[6]
    venn[1] = len(sets["B"]) - venn[2] - venn[5] - venn[6]
    venn[3] = len(sets["C"]) - venn[4] - venn[5] - venn[6]

    labelA = A + " (" + str(len(sets["A"])) + ")"
    labelB = B + " (" + str(len(sets["B"])) + ")"
    labelC = C + " (" + str(len(sets["C"])) + ")"
    venn3(subsets=venn, set_labels = (labelA, labelB, labelC))
    plt.show()
开发者ID:BD2KGenomics,项目名称:brca-pipeline,代码行数:15,代码来源:venn_diagram.py


示例12: venn3_plot

def venn3_plot(sets, set_labels=('A', 'B', 'C'), 
    set_colors=None, alpha=1.0, circle_on=False):
    """
    venn3 plot based on venn3 and venn3_circles from matplotlib_venn.

    Example:
    --------
    set1 = set(['A', 'B', 'C', 'D'])
    set2 = set(['B', 'C', 'D', 'E'])
    set3 = set(['C', 'D',' E', 'F', 'G'])
    venn3_plot([set1, set2, set3], ('Set1', 'Set2', 'Set3'))
    """
    from matplotlib_venn import venn3, venn3_circles

    if circle_on:
        v = venn3_circles(subsets=(1,1,1,1,1,1,1), alpha=0.8, color="r")
    if set_colors is None: 
        set_colors = favorite_colors[:3]
    v = venn3(subsets=(1,1,1,1,1,1,1), set_labels=set_labels, 
        set_colors=set_colors, alpha=alpha)
    v.get_label_by_id('111').set_text(len(sets[0]&sets[1]&sets[2]))
    v.get_label_by_id('110').set_text(len(sets[0]&sets[1]-sets[2]))
    v.get_label_by_id('101').set_text(len(sets[0]-sets[1]&sets[2]))
    v.get_label_by_id('100').set_text(len(sets[0]-sets[1]-sets[2]))
    v.get_label_by_id('011').set_text(len(sets[2]&sets[1]-sets[0]))
    v.get_label_by_id('010').set_text(len(sets[1]-sets[2]-sets[0]))
    v.get_label_by_id('001').set_text(len(sets[2]-sets[1]-sets[0]))

    return v
开发者ID:huangyh09,项目名称:hilearn,代码行数:29,代码来源:base_plot.py


示例13: draw

def draw(set1, set2, set3, label1, label2, label3):
  set1 = set(set1)
  set2 = set(set2)
  if label3:
    set3 = set(set3)
    v = venn3([set1,set2, set3], (label1, label2, label3))
    plt.title('Venn diagram for hubs: ' + label1 + "," + label2 +"," + label3, fontsize=20)
  else:
    v = venn2([set1, set2], (label1, label2))
    plt.title('Venn diagram for hubs:' + label1 + "," + label2, fontsize=20)
#   if v.get_label_by_id('110'):
#     plt.annotate(percent_of(set1,set2)+"% of " +label1 , xy=v.get_label_by_id('110').get_position() - np.array([0.15, 0.10]))
#     plt.annotate(percent_of(set2,set1)+"% of " +label2 , xy=v.get_label_by_id('110').get_position() - np.array([0.15, 0.15]))
  if v.get_patch_by_id('100'):
    v.get_patch_by_id('100').set_color("blue")
  if v.get_patch_by_id('010'):
    v.get_patch_by_id('010').set_color("red")
  if v.get_patch_by_id('110'):
    v.get_patch_by_id('110').set_color("purple")
  if label3 and v.get_patch_by_id('001'):
    v.get_patch_by_id('001').set_color("green") 
    if v.get_patch_by_id('111'):
      v.get_patch_by_id('111').set_color("black") 
  gca().set_axis_bgcolor('white')
  gca().set_axis_on()
  plt.show()
开发者ID:GulyaevB,项目名称:HabraAnalyticsTools,代码行数:26,代码来源:draw.py


示例14: makeVenn3

    def makeVenn3(self,truthDict,snr,addon=''):
        type1 = '.svg'
        type2 = '.png'
        f = \
            os.path.join(self.destDir,self.fname+'.c'+str(self.ch)+'.snr_'+str(snr)+addon)


        reqdVennOrder = [('map','not','not'),
                         ('not','map','not'),
                         ('map','map','not'),
                         ('not','not','map'),
                         ('map','not','map'),
                         ('not','map','map'),
                         ('map','map','map')]
        valSet = list()
        for vSet in reqdVennOrder:
            val = truthDict[vSet]
            valSet.append(val)
        
        unmapped = truthDict[('not','not','not')]
        # Making venn diagram
        plt.figure(figsize=( 5,5))
        v = \
            venn3(subsets=valSet,set_labels=('Cycle1:Mock','Cycle2:Mock','Cycle3:Edman'))
        c = venn3_circles(subsets=valSet,ls='solid')
        txt = 'unmapped='+str(unmapped)+'\n SNR='+str(snr)
        plt.title('Peak Mapping :'+self.fname + '.'+self.frame+'\n channel:'+str(self.ch))
        plt.figtext( 0.7,0.1,txt)
        plt.savefig(f+type1,dpi=300)        
        plt.savefig(f+type2,dpi=300)
        plt.close()
开发者ID:jagannath,项目名称:imageAnalysis,代码行数:31,代码来源:followPeptides.py


示例15: venn

def venn(df1, df2, df3=None, labels=None, ix1=None, ix2=None, ix3=None, return_intersection=False):
    try:
        import matplotlib_venn as mplv
    except:
        ImportError("To plot venn diagrams, install matplotlib-venn package: pip install matplotlib-venn")
    
    if labels is None:
        labels = ["A", "B", "C"]
        
    s1 = _process_ix(df1.index, ix1)
    s2 = _process_ix(df2.index, ix2)
    if df3 is not None:
        s3 = _process_ix(df3.index, ix3)
        
        
    if df3 is not None:
        vn = mplv.venn3([s1,s2,s3], set_labels=labels)
        intersection = s1 & s2 & s3
    else:
        vn = mplv.venn2([s1,s2], set_labels=labels)
        intersection = s1 & s2

    ax = plt.gca()

    if return_intersection:
        return ax, intersection
    else:
        return ax
开发者ID:WMGoBuffs,项目名称:pymaxquant,代码行数:28,代码来源:visualize.py


示例16: draw_venn

def draw_venn(title, names, numbers, out):
  
  if len(numbers) == 7:
    if numbers[0] + numbers[2] + numbers[4] + numbers[6] == 0:
      numbers = [ numbers[1], numbers[3], numbers[5] ];
      names   = [ names[1], names[2] ];
    elif numbers[1] + numbers[2] + numbers[5] + numbers[6] == 0:
      numbers = [ numbers[0], numbers[3], numbers[4] ];
      names   = [ names[0], names[2] ];
    elif numbers[3] + numbers[4] + numbers[5] + numbers[6] == 0:
      numbers = [ numbers[0], numbers[1], numbers[2] ];
      names   = [ names[0], names[1] ];
    #fi
  #fi
  
  plt.cla();
  plt.figure(figsize=(10,10))
  if len(numbers) == 7:
    plt.cla();
    plt.figure(figsize=(10,10))
    v = venn3(subsets=numbers, set_labels = names)
    c = venn3_circles(subsets=numbers, linestyle='dashed')
  else:
    v = venn2(subsets = numbers, set_labels = names);
    c = venn2_circles(subsets = numbers, linestyle='dashed');
  #fi
  
  plt.title(title)
  plt.savefig(out);
开发者ID:WenchaoLin,项目名称:delftrnaseq,代码行数:29,代码来源:analysis_figures.py


示例17: create_venn

def create_venn(three_col_array, col_names):
    """
    create venn diagram from an array where rows are entries and columns are sets.
     if i,j is true then entry i has label j
     make sure exactly three columns
    """
    num_cols = three_col_array.shape[1]
    assert num_cols  == 3, "do not have three columns"
    assert len(three_col_array.shape) == 2, "not 2d"

    sets = []
    for col in three_col_array.T:
        sets.append(set(np.nonzero(col)[0].tolist()))

    venn_input = _create_ven_numbers(sets)
    venn3(subsets = tuple(venn_input), set_labels = col_names)
    plt.show()
开发者ID:john-bradshaw,项目名称:mtl_caffe,代码行数:17,代码来源:visualise_data.py


示例18: process_multiple

def process_multiple(names):

  writer = pd.ExcelWriter('/Users/agatorano/Code/metascape/metascape.org/media/%s'%names[-1])
  files_=[]
  #print(names[:len(names)-1])
  for n in names[:len(names)-1]:
    files_.append(pd.ExcelFile('/Users/agatorano/Code/metascape/metascape.org/media/%s'%n))

  for f,i in zip(files_,range(len(files_))):
    df = f.parse(f.sheet_names[0])
    df.to_excel(writer,'Sheet%s'%i)
  writer.save()

  xls = xlrd.open_workbook(r'/Users/agatorano/Code/metascape/metascape.org/media/%s'%names[-1], on_demand=True)
  
  name = names[-1]
  data = []
  genes = []
  for sheet in xls.sheet_names():
    list_ = get_gid(name,sheet)
    list_ = add_annotation(list_)
    genes.append(set([x[0] for x in list_]))
    #print(genes)
    data.append(add_cols(list_,name,sheet))

  writer = pd.ExcelWriter('/Users/agatorano/Code/metascape/metascape.org/media/'+name)
  for i in range(len(data)):
    save_excel(data[i],writer,i+1)

  plt.figure(figsize=(7,7))
  now = datetime.datetime.now()
  path = 'img/'+now.strftime("%Y/%m/%d/venn%H_%M_%S.png")
  img = '/Users/agatorano/Code/metascape/metascape.org/media/'+path
  output_directory = os.path.dirname(img)
  if not os.path.exists(output_directory):
      os.makedirs(output_directory)
  if(len(genes)==3):
    venn3(genes, ('File1', 'File2', 'File3'))
    plt.savefig(img)
  elif(len(genes)==2):
    venn2(genes, ('File1', 'File2'))
    plt.savefig(img)

  writer.save()

  return data,path
开发者ID:agatorano,项目名称:IAV,代码行数:46,代码来源:pandas_sql.py


示例19: venn

def venn(data, names=None, fill="number", show_names=True, show_plot=True, outputDir=False, **kwds):
    """
data: a list
names: names of groups in data
fill = ["number"|"logic"|"both"], fill with number, logic label, or both
show_names = [True|False]
show_plot = [True|False]
"""

    if data is None:
        raise Exception("No data!")
    if len(data) == 2:
        venn2(data, names, fill, show_names, show_plot, outputDir, **kwds)
    elif len(data) == 3:
        venn3(data, names, fill, show_names, show_plot, outputDir, **kwds)
    elif len(data) == 4:
        venn4(data, names, fill, show_names, show_plot, outputDir, **kwds)
    else:
        print len(data), 'files submitted, must be less than 4 and greater than 1...'
开发者ID:venkatmi,项目名称:altanalyze,代码行数:19,代码来源:VennDiagram.py


示例20: SimpleMatplotVenn

def SimpleMatplotVenn(names,data,outputDir=False,display=True):
    """ Uses http://pypi.python.org/pypi/matplotlib-venn (code combined into one module) to export
    simple or complex, overlapp weighted venn diagrams as an alternative to the default methods in
    this module """

    import numpy as np
    pylab.figure(figsize=(11,7),facecolor='w')
    
    vd = get_labels(data, fill="number")
    set_labels=[]
    for i in names:
        set_labels.append(string.replace(i,'.txt',''))
        
    if len(set_labels)==2:
        from matplotlib_venn import venn2, venn2_circles
        set_colors = ('r', 'g')
        subsets = (vd['10'], vd['01'], vd['11'])
        v = venn2(subsets=subsets, set_labels = set_labels, set_colors=set_colors)
        c = venn2_circles(subsets=subsets, alpha=0.5, linewidth=1.5, linestyle='dashed')
        
    if len(set_labels)==3:
        from matplotlib_venn import venn3, venn3_circles
        set_colors = ('r', 'g', 'b')
        subsets = (vd['100'], vd['010'], vd['110'], vd['001'], vd['101'], vd['011'], vd['111'])
        v = venn3(subsets=subsets, set_labels = set_labels,set_colors=set_colors)
        c = venn3_circles(subsets=subsets, alpha=0.5, linewidth=1.5, linestyle='dashed')
        
    pylab.title("Overlap Weighted Venn Diagram",fontsize=24)

    try:
        if outputDir!=False:
            filename = outputDir+'/%s.pdf' % venn_export_weighted
            pylab.savefig(filename)
            filename = outputDir+'/%s.png' % venn_export_weighted
            pylab.savefig(filename, dpi=100) #,dpi=200
    except Exception:
        print 'Image file not saved...'
        
    if display:
        pylab.show()

    try:
        import gc
        fig.clf()
        pylab.close()
        gc.collect()
    except Exception:
        pass
开发者ID:venkatmi,项目名称:altanalyze,代码行数:48,代码来源:VennDiagram.py



注:本文中的matplotlib_venn.venn3函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python matplotlibwidget.MatplotlibWidget类代码示例发布时间:2022-05-27
下一篇:
Python matplotlib_venn.venn2函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap