# Path: dms_tools2/plot.py
# COLOR_BLIND_PALETTE = ["#000000", "#E69F00", "#56B4E9", "#009E73",
#                        "#F0E442", "#0072B2", "#D55E00", "#CC79A7"]
# 
# Path: dms_tools2/plot.py
# COLOR_BLIND_PALETTE_GRAY = ["#999999", "#E69F00", "#56B4E9", "#009E73",
#                             "#F0E442", "#0072B2", "#D55E00", "#CC79A7"]


import os
import gzip
import re
import io
import math
import subprocess
import collections
import tempfile
import numbers
import regex
import numpy
import pandas
import pysam
import Bio.SeqFeature
import dms_tools2
import matplotlib.pyplot as plt
    import doctest
from dms_tools2.plot import COLOR_BLIND_PALETTE
from dms_tools2.plot import COLOR_BLIND_PALETTE_GRAY
from plotnine import *
    """
    if isinstance(ccslist, CCS):
        ccslist = [ccslist]
    assert all([isinstance(ccs, CCS) for ccs in ccslist]), \
            "`ccslist` not a list of `CCS` objects"

    assert report_type in ['zmw', 'subread']
    report = report_type + '_report'

    df = (pandas.concat([getattr(ccs, report).assign(sample=ccs.samplename)
                for ccs in ccslist])
          .sort_values(['sample', 'number'], ascending=False)
          [['sample', 'status', 'number', 'fraction']]
          )

    # version of df that only has categories with `plotminfrac`
    plot_df = (df.assign(maxfrac=lambda x: x.groupby('status')
                         .fraction.transform('max'))
                 .query('maxfrac >= @plotminfrac')
                 )
    nstatus = len(plot_df.status.unique())

    p = (ggplot(plot_df) +
            geom_col(aes(x='sample', y='number', fill='status'),
                     position='stack') +
            theme(axis_text_x=element_text(angle=90, vjust=1,
                  hjust=0.5)) +
            ylab({'zmw':'ZMWs', 'subread':'subreads'}[report_type])
            )
    

# Path: dms_tools2/plot.py
# COLOR_BLIND_PALETTE = ["#000000", "#E69F00", "#56B4E9", "#009E73",
#                        "#F0E442", "#0072B2", "#D55E00", "#CC79A7"]
# 
# Path: dms_tools2/plot.py
# COLOR_BLIND_PALETTE_GRAY = ["#999999", "#E69F00", "#56B4E9", "#009E73",
#                             "#F0E442", "#0072B2", "#D55E00", "#CC79A7"]


# Path: dms_tools2/pacbio.py
import os
import gzip
import re
import io
import math
import subprocess
import collections
import tempfile
import numbers
import regex
import numpy
import pandas
import pysam
import Bio.SeqFeature
import dms_tools2
import matplotlib.pyplot as plt
    import doctest
from dms_tools2.plot import COLOR_BLIND_PALETTE
from dms_tools2.plot import COLOR_BLIND_PALETTE_GRAY
from plotnine import *

    """
    if isinstance(ccslist, CCS):
        ccslist = [ccslist]
    assert all([isinstance(ccs, CCS) for ccs in ccslist]), \
            "`ccslist` not a list of `CCS` objects"

    assert report_type in ['zmw', 'subread']
    report = report_type + '_report'

    df = (pandas.concat([getattr(ccs, report).assign(sample=ccs.samplename)
                for ccs in ccslist])
          .sort_values(['sample', 'number'], ascending=False)
          [['sample', 'status', 'number', 'fraction']]
          )

    # version of df that only has categories with `plotminfrac`
    plot_df = (df.assign(maxfrac=lambda x: x.groupby('status')
                         .fraction.transform('max'))
                 .query('maxfrac >= @plotminfrac')
                 )
    nstatus = len(plot_df.status.unique())

    p = (ggplot(plot_df) +
            geom_col(aes(x='sample', y='number', fill='status'),
                     position='stack') +
            theme(axis_text_x=element_text(angle=90, vjust=1,
                  hjust=0.5)) +
            ylab({'zmw':'ZMWs', 'subread':'subreads'}[report_type])
            )
    

    if nstatus <= len(COLOR_BLIND_PALETTE):