common.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:cellranger 作者: 10XGenomics 项目源码 文件源码
def plot_histogram_metric(chart, sample_properties, sample_data, **kwargs):
    """ Plot a HistogramMetric from the summary json """
    summary_data = sample_data.summary
    items = summary_data.get(kwargs['metric_name'], {}).items()
    if len(items) < 1:
        return None

    ordering = kwargs.get('order_by', shared_constants.HISTOGRAM_METRIC_DEFAULT_ORDERING)

    if ordering == shared_constants.HISTOGRAM_METRIC_ORDER_INTEGER_BIN:
        items.sort(key=lambda x: convert_to_int_gracefully(x[0]))

    elif ordering == shared_constants.HISTOGRAM_METRIC_ORDER_DECREASING_FREQUENCY:
        items.sort(key=lambda x: -convert_to_int_gracefully(x[1]))

    elif ordering == shared_constants.HISTOGRAM_METRIC_ORDER_DECREASING_PROPORTION:
        items.sort(key=lambda x: -convert_to_float_gracefully(x[1]))

    x, y = zip(*items)
    chart['data'][0].update({'x': x, 'y': y})

    return chart
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号