Skip to content

Commit

Permalink
Added tab output from RATtrap
Browse files Browse the repository at this point in the history
  • Loading branch information
zyndagj committed Dec 4, 2015
1 parent 1b805b1 commit dc4bd95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion RATrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions repliscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit dc4bd95

Please sign in to comment.