Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Individual gene-label font sizes can be provided by adding an
additional column inside the bed file
  • Loading branch information
akdemirlab committed Nov 2, 2016
1 parent defc534 commit c1e3519
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 10 additions & 6 deletions HiCPlotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ def read_genes(filename,resolution,chromosome,start,end):
if len(tags)>7:
hex = '#%02x%02x%02x' % (int(tags[7].split(',')[0]), int(tags[7].split(',')[1]), int(tags[7].split(',')[2]))
genes[tags[1]+'-'+tags[2]].append(hex)
if len(tags)>8:
genes[tags[1]+'-'+tags[2]].append(float(tags[8]))

prev_start = current_start

Expand Down Expand Up @@ -633,10 +635,10 @@ def HiCplotter(files=[],names=[],resolution=100000,chromosome='',output='',histo
if start > len(matrix): start = 0
size=end-start
if exp == 0 : mlength = len(matrix)
elif len(matrix) != mlength and not randomBins:
print len(matrix), mlength
print >>sys.stderr, 'unbalanced matrix size of '+files[exp]+' compared to '+files[0]+' ! matrix sizes should be equal'
raise SystemExit
# elif len(matrix) != mlength and not randomBins:
# print len(matrix), mlength
# print >>sys.stderr, 'unbalanced matrix size of '+files[exp]+' compared to '+files[0]+' ! matrix sizes should be equal'
# raise SystemExit

matrix=matrix[start:end,start:end]
else:
Expand Down Expand Up @@ -862,7 +864,8 @@ def HiCplotter(files=[],names=[],resolution=100000,chromosome='',output='',histo
elif plength <= 4: plength = 2
else : plength/1.5
gdist = min(abs(nearest[gtrack][gindex]-upgene),abs(nearest[gtrack][gindex]-downgene))
if len(nearest[gtrack])==1: ax3.text(gstart, trackCount-gtrack+0.5, genes[item][1], fontsize=4.5/plength)
if len(genes[item]) > 6: ax3.text(gstart, trackCount-gtrack+0.5, genes[item][1], fontsize=genes[item][6], color=genes[item][5])
elif len(nearest[gtrack])==1: ax3.text(gstart, trackCount-gtrack+0.5, genes[item][1], fontsize=4.5/plength)
elif float(gdist)/resolution >= 2 and len(genes[item][1])<=6: ax3.text(gstart, trackCount-gtrack+0.5, genes[item][1], fontsize=4.5/plength)
elif float(gdist)/resolution >= 2 and len(genes[item][1])>6: ax3.text(gstart, trackCount-gtrack+0.5, genes[item][1], fontsize=3/plength)
elif float(gdist)/resolution < 2 and float(gdist)/resolution > 1 and len(genes[item][1])<=6: ax3.text(gstart, trackCount-gtrack+0.5, genes[item][1], fontsize=2.5/plength)
Expand Down Expand Up @@ -1041,9 +1044,10 @@ def HiCplotter(files=[],names=[],resolution=100000,chromosome='',output='',histo
if len(histMax)==0:
ax3a.set_ylim(ymin,max(y_comps[ystart:yend])+max(y_comps[ystart:yend])/10)
ymaxlims.append(max(y_comps[ystart:yend]))
ax3a.text(int(start or 1)+length-length/6,max(y_comps[ystart:yend])-max(y_comps[ystart:yend])/10,histLabels[exp].split(',')[1],color=subcolor)
else:
ax3a.set_ylim(ymin,int(histMax[exp].split(',')[1])+int(histMax[exp].split(',')[1])/10)
ax3a.text(int(start or 1)+length-length/6,max(y_comps[ystart:yend])-max(y_comps[ystart:yend])/10,histLabels[exp].split(',')[1],color=subcolor)
ax3a.text(int(start or 1)+length-length/6,int(histMax[exp].split(',')[1])-int(histMax[exp].split(',')[1])/10,histLabels[exp].split(',')[1],color=subcolor)
#ax3a.set_ylabel(histLabels[exp].split(',')[1])
else:
if len(histMax)==0:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,15 @@ For annotating the interaction matrix, HiCPlotter requires the following format.
For plotting genes under the interaction matrix, HiCPlotter requires the following format.


chrom geneStart geneEnd geneName strand(optional) exonStarts(optional) exonEnds(optional) color (optional)
chr1 11873 14409 DDX11L1 + 11873,12645,13220, 12227,12697,14409, 250,13,27
chrom geneStart geneEnd geneName strand(optional) exonStarts(optional) exonEnds(optional) color (optional) fontSize (optional)
chr1 11873 14409 DDX11L1 + 11873,12645,13220, 12227,12697,14409, 250,13,27 15
chr1 14361 16765 WASH7P - 14361,14969,15795,16606, 14829,15038,15942,16765,
chr1 14361 19759 WASH7P - 14361,14969,15795,16606,16857,17232,17605,17914,18267,18912, 14829,15038,15947,16765,17055,17368,17742,18061,18366,19759,

This file should be sorted based on 2nd column (geneStart).

To specify specific gene label size, provide an integer at column 9 (a color should be provided at column 8th)

For 6th (exonStarts) and 7th (exonEnds) columns, there should be a comma at the very end.

If 5th column is provided then 6th and 7th columns should be provided as well.
Expand Down

0 comments on commit c1e3519

Please sign in to comment.