10 import matplotlib.axes
18 print "plotnomogram: version 1.2"
26 print "usage: python %s maxdev xreads infile outpng" % argv[0]
29 maxdev = float(argv[1])
30 xreads = float(argv[2])
34 plotnomogram(maxdev, xreads, infilename, outfilename)
37 def plotnomogram(maxdev, xreads, infilename, outfilename):
39 infile = open(infilename)
40 line = infile.readline().strip()
42 percentages = line.split()
45 listWidth = len(percentages)
50 fields = line.strip().split()
51 geneValues[fields[0]] = []
52 for pos in range(listWidth):
53 geneValues[fields[0]].append(float(fields[1 + pos]))
55 # categories here are: 3000+, 2999-300, 299-30, 29-3
61 for gene in geneValues:
62 finalLevel = geneValues[gene][0]
63 if finalLevel >= 3000:
64 genes3000p.append(gene)
65 elif finalLevel >= 300:
66 genes300p.append(gene)
67 elif finalLevel >= 30:
72 organizedList = [genes3000p, genes300p, genes30p, genes3p]
73 listNames = ["3000+ RPKM ", "300-2999 RPKM", "30-299 RPKM ", "3-29 RPKM "]
74 listColors = ["k", "c", "m", "r"]
78 for name in listNames:
79 newscores[name] = [0.]
82 for percent in percentages[1:]:
83 oldscores.append(xreads * float(percent) / 100.)
86 for geneList in organizedList:
87 geneCount = len(geneList)
90 finalVal = geneValues[gene][0]
91 currentVal = geneValues[gene][index]
92 if abs((currentVal - finalVal) / finalVal) > maxdev:
95 fraction = 1. - numOver / geneCount
96 print "%s %s %d %.2f" % (percent, listNames[listindex], geneCount, fraction)
97 newscores[listNames[listindex]].append(fraction)
98 geneCounts[listNames[listindex]] = geneCount
101 matplotlib.axes._process_plot_var_args.defaultColors = ["k", "y", "m", "c", "b", "g", "r"]
103 oldscores.append(xreads)
108 for name in listNames:
109 newscores[name].append(1.0)
110 plots.append(plot(oldscores, newscores[name], listColors[index], linewidth=2))
111 plot(oldscores[1:-1], newscores[name][1:-1], listColors[index] + "^")
112 plotsColors.append(plots[-1][0])
113 plotsLegend.append("%s n = %d" % (name, geneCounts[name]))
116 legend(plotsColors, plotsLegend, loc=0)
118 locs, labels = xticks()
119 setp(labels, rotation="vertical")
121 xlim(-0.1, xreads + .1)
125 if __name__ == "__main__":