def plotDETagStats(infile, outfile_prefix,
                   additional_file=None,
                   join_columns=None,
                   additional_columns=None):
    '''provide summary plots for tag data.

    Stratify boxplots and densities according to differential
    expression calls.

    The input file is the output of any of the DE
    tools, see GeneExpressionResults for column names.

    Additional file will be joined with infile and any additional
    columns will be output as well.
    '''

    table = pandas.read_csv(IOTools.openFile(infile),
                            sep="\t")

    if additional_file is not None:
        additional_table = pandas.read_csv(
            IOTools.openFile(additional_file),
            sep="\t")
        table = pandas.merge(table,
                             additional_table,
                             on=join_columns,
                             how="left",
                             sort=False)

    # remove index. If it is numbered starting from 1, there is a bug
    # in ggplot, see https://github.com/yhat/ggplot/pull/384
    table.reset_index(inplace=True)

    # add log-transformed count data
    table['log10_treatment_mean'] = numpy.log10(table['treatment_mean'] + 1)
    table['log10_control_mean'] = numpy.log10(table['control_mean'] + 1)
    table['dmr'] = numpy.array(["insignicant"] * len(table))
    table.loc[
        (table["l2fold"] > 0) & (table["significant"] == 1), "dmr"] = "up"
    table.loc[
        (0 < table["l2fold"]) & (table["significant"] == 1), "dmr"] = "down"

    def _dplot(table, outfile, column):

        plot = ggplot.ggplot(
            ggplot.aes(column,
                       colour='dmr',
                       fill='dmr'),
            data=table) + \
            ggplot.geom_density(alpha=0.5)

        try:
            ggplot.ggsave(filename=outfile, plot=plot)
        except Exception, msg:
            E.warn("no plot for %s: %s" % (column, msg))

    def _bplot(table, outfile, column):

        plot = ggplot.ggplot(
            ggplot.aes(x=column, y='dmr'),
            data=table) + \
            ggplot.geom_boxplot()

        try:
            ggplot.ggsave(filename=outfile, plot=plot)
        except ValueError, msg:
            # boxplot fails if all values are the same
            # see https://github.com/yhat/ggplot/issues/393
            E.warn(msg)

    _dplot(table,
           outfile_prefix + ".densities_tags_control.png",
           "log10_control_mean")
    _dplot(table,
           outfile_prefix + ".densities_tags_treatment.png",
           "log10_treatment_mean")
    _bplot(table,
           outfile_prefix + ".boxplot_tags_control.png",
           "log10_control_mean")
    _bplot(table,
           outfile_prefix + ".boxplot_tags_treatment.png",
           "log10_treatment_mean")

    if additional_columns:
        for column in additional_columns:
            _dplot(table,
                   outfile_prefix + ".densities_%s.png" % column,
                   column)
            _bplot(table,
                   outfile_prefix + ".boxplot_%s.png" % column,
                   column)
    return
dataset/ETHPy150Open CGATOxford/cgat/CGAT/Expression.py/plotDETagStats/swapped operands of `<`