def compare_variant_type_plot(data):
    """ Return HTML for the Variant Counts barplot """
    keys = OrderedDict()
    keys['snps'] = {'name': 'SNPs', 'color': '#7cb5ec'}
    keys['indels'] = {'name': 'InDels', 'color': '#90ed7d'}
    keys['multiallelic_snps'] = {'name': 'multi-allelic SNP', 'color': 'orange'}
    keys['complex_indels'] = {'name': 'Complex InDels', 'color': '#8085e9'}

    total_variants = dict()
    known_variants = dict()
    novel_variants = dict()
    for s_name, values in data.items():
        total_variants[s_name] = {
            'snps': values['TOTAL_SNPS'],
            'indels': values['TOTAL_INDELS'],
            'multiallelic_snps': values['TOTAL_MULTIALLELIC_SNPS'],
            'complex_indels': values['TOTAL_COMPLEX_INDELS'],
        }

        known_variants[s_name] = {
            'snps': values['NUM_IN_DB_SNP'],
            'indels': int(values['TOTAL_INDELS'])-int(values['NOVEL_INDELS']),
            'multiallelic_snps': values['NUM_IN_DB_SNP_MULTIALLELIC'],
            'complex_indels': values['NUM_IN_DB_SNP_COMPLEX_INDELS'],
        }

        novel_variants[s_name] = {
            'snps': values['NOVEL_SNPS'],
            'indels': values['NOVEL_INDELS'],
            'multiallelic_snps': int(values['TOTAL_MULTIALLELIC_SNPS'])-int(values['NUM_IN_DB_SNP_MULTIALLELIC']),
            'complex_indels': int(values['TOTAL_COMPLEX_INDELS'])-int(values['NUM_IN_DB_SNP_COMPLEX_INDELS']),
        }

    plot_conf = {
        'id': 'picard_variantCallingMetrics_variant_type',
        'title': 'Picard: Variants Called',
        'ylab': 'Counts of Variants',
        'hide_zero_cats': False,
        'data_labels': [
            {'name': 'Total'},
            {'name': 'Known'},
            {'name': 'Novel'}
        ],
    }
    return bargraph.plot(data=[total_variants, known_variants, novel_variants],
                         cats=[keys, keys, keys],
                         pconfig=plot_conf)
def compare_variant_type_plot ( data ) : keys = OrderedDict ( ) keys [ 'snps' ] = { 'name' : 'SNPs' , 'color' : '#7cb5ec' } keys [ 'indels' ] = { 'name' : 'InDels' , 'color' : '#90ed7d' } keys [ 'multiallelic_snps' ] = { 'name' : 'multi-allelic SNP' , 'color' : 'orange' } keys [ 'complex_indels' ] = { 'name' : 'Complex InDels' , 'color' : '#8085e9' } total_variants = dict ( ) known_variants = dict ( ) novel_variants = dict ( ) for s_name , values in data . items ( ) : total_variants [ s_name ] = { 'snps' : values [ 'TOTAL_SNPS' ] , 'indels' : values [ 'TOTAL_INDELS' ] , 'multiallelic_snps' : values [ 'TOTAL_MULTIALLELIC_SNPS' ] , 'complex_indels' : values [ 'TOTAL_COMPLEX_INDELS' ] , } known_variants [ s_name ] = { 'snps' : values [ 'NUM_IN_DB_SNP' ] , 'indels' : int ( values [ 'TOTAL_INDELS' ] ) - int ( values [ 'NOVEL_INDELS' ] ) , 'multiallelic_snps' : values [ 'NUM_IN_DB_SNP_MULTIALLELIC' ] , 'complex_indels' : values [ 'NUM_IN_DB_SNP_COMPLEX_INDELS' ] , } novel_variants [ s_name ] = { 'snps' : values [ 'NOVEL_SNPS' ] , 'indels' : values [ 'NOVEL_INDELS' ] , 'multiallelic_snps' : int ( values [ 'TOTAL_MULTIALLELIC_SNPS' ] ) - int ( values [ 'NUM_IN_DB_SNP_MULTIALLELIC' ] ) , 'complex_indels' : int ( values [ 'TOTAL_COMPLEX_INDELS' ] ) - int ( values [ 'NUM_IN_DB_SNP_COMPLEX_INDELS' ] ) , } plot_conf = { 'id' : 'picard_variantCallingMetrics_variant_type' , 'title' : 'Picard: Variants Called' , 'ylab' : 'Counts of Variants' , 'hide_zero_cats' : False , 'data_labels' : [ { 'name' : 'Total' } , { 'name' : 'Known' } , { 'name' : 'Novel' } ] , } return bargraph . plot ( data = [ total_variants , known_variants , novel_variants ] , cats = [ keys , keys , keys ] , pconfig = plot_conf )
Return HTML for the Variant Counts barplot