def CF_plot(args): try: import locale import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import pylab as P from matplotlib.lines import Line2D from matplotlib.patches import Rectangle _ = locale.setlocale(locale.LC_ALL, '') except: print "[ERROR] One or more of the required modules for plotting cannot be loaded! Are matplotlib and pylab installed?" sys.exit(0) chr, start, stop = cf.parseLocString(args.region) r = cf.rpkm_reader(args.input) data = r.getExonValuesByRegion(chr,start,stop) _ = data.smooth() plt.gcf().clear() fig = plt.figure(figsize=(10,5)) ax = fig.add_subplot(111) ax.plot(data.rpkm, linewidth = 0.3, c='k') if args.sample != 'none': cnt = 1 coloriter = iter(['r','b','g','y']) for sample in args.sample: try: color, sampleID = sample.split(":") except: color =coloriter.next() sampleID = sample ax.plot(data.getSample([sampleID]), linewidth = 1, c=color, label = sampleID) if cnt == 1: cf.plotRawData(ax, r.getExonValuesByRegion(chr,start,stop,sampleList=[sampleID]).getSample([sampleID]),color=color) cnt +=1 plt.legend(prop={'size':10},frameon=False) cf.plotGenes(ax, data) cf.plotGenomicCoords(plt,data) plt.xlim(0,data.shape[1]) plt.ylim(-3,3) plt.title("%s: %s - %s" % (cf.chrInt2Str(chr),locale.format("%d",start, grouping=True),locale.format("%d",stop, grouping=True))) plt.xlabel("Position") plt.ylabel("SVD-ZRPKM Values") plt.savefig(args.output) sys.exit(0)