def singleTablePlot_mpl(parser, args): ''' kmerdict is a defaultdict(int) It can take both empty and non-empty kmerdicts returns update of the input kmerdict given the input string and k''' kmerdict = kmercount_in_table(args.table1) data = defaultdict(list) numKmers = len(kmerdict) for k in sorted(kmerdict.keys()): data['kmers'].append(k) data['counts'].append(kmerdict[k]) plt.bar(left=range(1,numKmers+1), height=data['counts'], width=1.0) plt.show()
def singleTablePlot_mpl(parser, args): ''' kmerdict is a defaultdict(int) It can take both empty and non-empty kmerdicts returns update of the input kmerdict given the input string and k''' kmerdict = kmercount_in_table(args.table1) data = defaultdict(list) numKmers = len(kmerdict) for k in sorted(kmerdict.keys()): data['kmers'].append(k) data['counts'].append(kmerdict[k]) plt.bar(left=range(1, numKmers + 1), height=data['counts'], width=1.0) plt.show()
def singleTablePlot_gg(parser, args): ''' kmerdict is a defaultdict(int) It can take both empty and non-empty kmerdicts returns update of the input kmerdict given the input string and k''' r = robjects.r r.library("ggplot2") grdevices = importr('grDevices') kmerdict = kmercount_in_table(args.table1) data = defaultdict(list) numKmers = len(kmerdict) for k in sorted(kmerdict.keys()): data['kmers'].append(k) data['counts'].append(kmerdict[k]) df = robjects.DataFrame(data) gp = ggplot2.ggplot(df) ## pp = gp + ggplot2.geom_bar(stat="identity") pp = gp + ggplot2.aes_string(x=range(1,numKmers+1),y=data['counts']) \ + ggplot2.geom_bar(stat="identity") \ + ggplot2.scale_x_continuous(name="kmer", breaks=0.5+(range(1,numKmers+1)), labels=kmers) pp.plot() print('Type enter to exit.') raw_input()
def readInTwoKmerTables(parser, args): kmerdict1 = kmercount_in_table(args.table1) kmerdict2 = kmercount_in_table(args.table2) ## ensure equal kmer sets kmerdict1, kmerdict2 = ensureEqualKmerSets(kmerdict1, kmerdict2) return kmerdict1, kmerdict2