def plotjson(fn,dbscan_rank_eps): """ plotjson: make plots from json output of fiedler.py fn: the filename of the json file """ fo=open(fn) data=json.load(fo) fo.close() #fiedler.doPlots(numpy.array(data["f1"]),numpy.array(data["f2"]),numpy.array(data["d"]),data["adj"],fn,widths=[64],vsdeg=False,nByi=data["nByi"]) fiedler.plotFiedvsFied(numpy.array(data["f1"]),numpy.array(data["f2"]),fn+".dbscan.%s."%(dbscan_rank_eps),width=64,nByi=data["nByi"],dbscan_eps=.001,dbscan_rank_eps=dbscan_rank_eps,enrichdb="../GraphSpec/h**o-sapiens-9606-gene-symbol.gmt")
def plotPair(fn1,fn2): outfn=".vs.".join([fn1,fn2]) data = [] for i,fn in enumerate([fn1,fn2]): fo = open(fn) data.append(json.load(fo)) data[i]["f1"]=numpy.array(data[i]["f1"]) data[i]["r1"]=numpy.array(data[i]["r1"]) fo.close() print "Comparing data set with %i nodes with data set with %i nodes."%(len(data[0]["nByi"]),len(data[1]["nByi"])) #fiedler.PlotEdgeVvsEdgeV(data[0]["adj"],data[1]["adj"],data[0]["nByi"],data[1]["nByi"],outfn,width=64) d0index = [] d1index = [] nByi=[] newi=0 newiByold=[{},{}] for feature in data[0]["iByn"]: if feature in data[1]["iByn"]: d0index.append(data[0]["iByn"][feature]) d1index.append(data[1]["iByn"][feature]) nByi.append(feature) newiByold[0][data[0]["iByn"][feature]]=newi newiByold[1][data[1]["iByn"][feature]]=newi newi+=1 adjs=[[],[]] for i,datum in enumerate(data): for e in datum["adj"]: [e0,e1,v]=e if e0 in newiByold[i] and e1 in newiByold[i]: e[0]=newiByold[i][e0] e[1]=newiByold[i][e1] adjs[i].append(e) d0index=numpy.array(d0index,dtype="int") d1index=numpy.array(d1index,dtype="int") fiedler.plotFiedvsFied(data[0]["r1"][d0index],data[1]["r1"][d1index],outfn,adj_list=adjs[0],adj_list2=adjs[1],width=32)#nByi=nByi)#,dbscan_eps=.0005,dbscan_rank_eps=64,enrichdb="../GraphSpec/h**o-sapiens-9606-gene-symbol.gmt",clust_x=.00005,clust_y=.00005)
def plotPair(fn1,fn2): outfn=".vs.".join([fn1,fn2]) data = [] for i,fn in enumerate([fn1,fn2]): fo = open(fn) data.append(json.load(fo)) data[i]["f1"]=numpy.array(data[i]["f1"]) fo.close() print "Comparing data set with %i nodes with data set with %i nodes."%(len(data[0]["nByi"]),len(data[1]["nByi"])) #fiedler.PlotEdgeVvsEdgeV(data[0]["adj"],data[1]["adj"],data[0]["nByi"],data[1]["nByi"],outfn,width=64) d0index = [] d1index = [] nByi=[] newi=0 newiByold=[{},{}] for feature in data[0]["iByn"]: if feature in data[1]["iByn"]: d0index.append(data[0]["iByn"][feature]) d1index.append(data[1]["iByn"][feature]) nByi.append(feature) newiByold[0][data[0]["iByn"][feature]]=newi newiByold[1][data[1]["iByn"][feature]]=newi newi+=1 adjs=[[],[]] for i,datum in enumerate(data): for e in datum["adj"]: [e0,e1,v]=e if e0 in newiByold[i] and e1 in newiByold[i]: e[0]=newiByold[i][e0] e[1]=newiByold[i][e1] adjs[i].append(e) d0index=numpy.array(d0index,dtype="int") d1index=numpy.array(d1index,dtype="int") fiedler.plotFiedvsFied(data[0]["f1"][d0index],data[1]["f1"][d1index],outfn,adj_list=adjs[0],adj_list2=adjs[1],width=80)