From dc4bd95003d68b793a68cba869105c9f4686c51e Mon Sep 17 00:00:00 2001 From: Greg Zynda Date: Fri, 4 Dec 2015 15:54:03 -0600 Subject: [PATCH] Added tab output from RATtrap --- RATrap.py | 8 +++++++- repliscan.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/RATrap.py b/RATrap.py index 6c266de..fc0c358 100644 --- a/RATrap.py +++ b/RATrap.py @@ -159,17 +159,23 @@ def plotComp(segments, title, tileSize, chromDict, figExt): yHeight = 0.8 sortedChroms = sorted(chromDict.keys()) labels, inds, cinds = makeLabels() + OT = open("composition_%s.tab"%(title), 'w') + OT.write("Chr\t"+'\t \t'.join(labels)+'\t \tChr Length\n') for chrom in sortedChroms: - #xranges = [] + otStr = '%s\t'%(chrom) chromSize = chromDict[chrom] X = np.zeros(2**len(nameList)-1) for arrayStr, size in segments[chrom]: sortedInd = inds[int(arrayStr,2)-1] X[sortedInd] += size*tileSize percents = list(np.round(X/float(chromSize),3)) + sP = map(lambda x: str(x*100)+'%', percents) + otStr += '\t'.join([str(val) for tup in zip(X,sP) for val in tup])+'\t'+str(chromSize)+'\n' + OT.write(otStr) xranges = zip(np.cumsum([0]+percents[:-1]), percents) plt.broken_barh(xranges, (yIndex, yHeight), lw=0, color=[colors[i] for i in cinds]) yIndex += 1 + OT.close() plt.xlim((0,1)) plt.yticks(np.arange(0.5, len(sortedChroms)), sortedChroms) plt.ylabel("Chromosome") diff --git a/repliscan.py b/repliscan.py index 9f50927..8d42885 100755 --- a/repliscan.py +++ b/repliscan.py @@ -670,6 +670,7 @@ def mergeRegions(counter, distThresh=0): start1, end1 = bounds[i+1] if start1-end0-1 < distThresh: counter[start0:end1] = 1 + def calcRegionBounds(counter): ''' Returns the new lower and upper bounds over overlapped regions.