def get_common_parser(include_pathway=True): parser = MyParser(fromfile_prefix_chars='@') group = parser.add_mutually_exclusive_group() group.add_argument("-v", "--verbose", action="count", default=0, help="increase output verbosity") group.add_argument("-q", "--quiet", action="count", default=0, help="decrease output verbosity") parser.add_argument('--dataset', default='both', help='Default: both', choices=known_datasets) if include_pathway: parser.add_argument('--pathway', default='serotonin', help='Default: serotonin' ) #, choices=['all'] + cfg.pathways.keys()) parser.add_argument( '--from_age', help= 'Use only data points with larger ages than this. Default: all ages', choices=dct_ages.keys()) parser.add_argument('--scaling', help='What scaling to use for ages. Default: log', default='log', choices=allowed_scaler_names()) parser.add_argument('--shuffle', help='Shuffle the y-values of the data', action='store_true') parser.add_argument('-s', '--shape', help='The shape to use for fitting. Default: sigslope', default='sigslope', choices=allowed_shape_names()) parser.add_argument( '--sigma_prior', help='Prior to use for 1/sigma when fitting. Default: normal', default='normal', choices=get_allowed_priors(is_sigma=True)) parser.add_argument( '--priors', help='Priors to use for theta when fitting. Default: sigslope80', default='sigslope80', choices=get_allowed_priors()) return parser
NOT_USED = (None,) parser = get_common_parser() parser.add_argument('--part', help='Compute only part of the genes. format: <k>/<n> e.g. 1/4. (k=1..n)') parser.add_argument('--html', nargs='?', metavar='DIR', default=NOT_USED, help='Create html for the fits. Optionally override output directory.') parser.add_argument('--mat', action='store_true', help='Save the fits also as matlab .mat file.') parser.add_argument('--text', action='store_true', help='Save the theta parameters also to a text file (spline only).') parser.add_argument('--correlations', action='store_true', help='Use correlations between genes for prediction') parser.add_argument('--correlations_part', help='Compute only part of the correlations. format: <k>/<n> e.g. 1/4. (k=1..n)') parser.add_argument('--onset', action='store_true', help='Show onset times and not R2 scores in HTML table (sigmoid only)') parser.add_argument('--dont_show_change_dist', action='store_true', help="Don't show change distribution in the figures (only relevant for sigmoids and together with --html)") parser.add_argument('--no_legend', action='store_true', help="Don't show the legend in the figures (only relevant together with --html)") parser.add_argument('--change_dist', action='store_true', help='Compute change distributions and related measures (sigmoid only)') parser.add_argument('--exons_layout', action='store_true', default = False, help='Adjust plotting and html layout to exon-level data') parser.add_argument('--exons_same_scale',action='store_true',default = False, help='Set y axis range to be the same for all exons in multi-exons subplots') parser.add_argument('--exons_plots_from_series',action='store_true',default = False, help='Build multi-exons plots from series plots') parser.add_argument('--plots_scaling',default = 'none', help = 'What scaling to use for expression levels when plotting. Currently affects only exons plots. Default: none.', choices=allowed_scaler_names()) args = parser.parse_args() if args.part is not None and args.mat: abort('--mat cannot be used with --part') is_sigmoid = args.shape in ['sigmoid','sigslope'] if args.correlations: if args.part: abort('--correlations cannot be used with --part') if args.mat: abort('--correlations not compatible with --mat') if args.correlations_part: if not args.correlations: abort('--correlations_part cannot should not used with also specifying --correlations') if args.html != NOT_USED:
plt.scatter(scores1, scores2, alpha=0.5) plt.plot([-1, 1], [-1, 1],'k--') plt.xlim(-1,1) plt.ylim(-1,1) ttl1 = r'Comparison of scores using {} vs. {}'.format(fitter1.shape,fitter2.shape) ttl2 = r'{}, {}'.format(data1.name, data1.pathway) plt.title('\n'.join([ttl1, ttl2]), fontsize=cfg.fontsize) plt.xlabel('R2 for {}'.format(fitter1.shape), fontsize=cfg.fontsize) plt.ylabel('R2 for {}'.format(fitter2.shape), fontsize=cfg.fontsize) return fig if __name__ == '__main__': disable_all_warnings() parser = get_common_parser() parser.add_argument('--shape2', required=True, help='The shape to compare against', choices=allowed_shape_names()) parser.add_argument('--scaling2', help='The scaling used when fitting shape2. Default: none', choices=allowed_scaler_names()) parser.add_argument('--sigma_prior2', help='Prior to use for 1/sigma when fitting shape2. Default: None', choices=get_allowed_priors(is_sigma=True)) parser.add_argument('--priors2', help='The priors used for theta when fitting shape2. Default: None', choices=get_allowed_priors()) parser.add_argument('--filename', help='Where to save the figure. Default: results/comparison.png') parser.add_argument('--show', help='Show figure and wait before exiting', action='store_true') parser.add_argument('--ndiffs', type=int, default=5, help='Number of top diffs to show. Default=5.') args = parser.parse_args() data1, fitter1 = process_common_inputs(args) data2 = get_data_from_args(args.dataset, args.pathway, args.from_age, args.scaling2, args.shuffle) fitter2 = get_fitter_from_args(args.shape2, args.priors2, args.sigma_prior2) fits1 = get_all_fits(data1,fitter1) fits2 = get_all_fits(data2,fitter2) print_diff_points(data1,fitter1,fits1, data2,fitter2,fits2, args.ndiffs)
def get_common_parser(include_pathway=True): parser = MyParser(fromfile_prefix_chars='@') group = parser.add_mutually_exclusive_group() group.add_argument("-v", "--verbose", action="count", default=0, help="increase output verbosity") group.add_argument("-q", "--quiet", action="count", default=0, help="decrease output verbosity") parser.add_argument('--dataset', default='both', help='Default: both', choices=known_datasets) if include_pathway: parser.add_argument('--pathway', default='serotonin', help='Default: serotonin') #, choices=['all'] + cfg.pathways.keys()) parser.add_argument('--from_age', help='Use only data points with larger ages than this. Default: all ages', choices=dct_ages.keys()) parser.add_argument('--scaling', help='What scaling to use for ages. Default: none', default='none', choices=allowed_scaler_names()) parser.add_argument('--shuffle', help='Shuffle the y-values of the data', action='store_true') parser.add_argument('-s', '--shape', help='The shape to use for fitting. Default: sigslope', default='sigslope', choices=allowed_shape_names()) parser.add_argument('--sigma_prior', help='Prior to use for 1/sigma when fitting. Default: None', choices=get_allowed_priors(is_sigma=True)) parser.add_argument('--priors', help='Priors to use for theta when fitting. Default: None', choices=get_allowed_priors()) return parser