# Path: pyproteome/levels.py
# LOGGER = logging.getLogger('pyproteome.levels')
# WARN_PEP_CUTOFF = 50
# REL_CUTOFF = 5
# LEVELS_DPI = 90
# def kde_max(points):
# def get_channel_levels(
#     data,
#     norm_channels=None,
#     method='median',
#     cols=2,
# ):


from pyproteome import levels
import logging
import numpy as np
structured format.
'''

# Built-ins
from __future__ import absolute_import, division



# Core data analysis libraries


LOGGER = logging.getLogger('pyproteome.constand')
CONSTAND_METHODS = {
    'mean': np.nanmean,
    'median': np.nanmedian,

    # Fit a gaussian function to each row/column and select its max point
    'kde': lambda k, **kw: np.apply_along_axis(levels.kde_max, kw['axis'], k),
}
'''
Methods to estimate the center of a data set's rows or columns.

One of ['mean', 'median', 'kde']. 'mean': applies :func:`numpy.nanmean`,
'median' applies :func:`numpy.nanmedian`, and 'kde' applies
:func:`.levels.kde_max`.
'''

CONSTAND_ERR_METHODS = {
    'mean': lambda x, **kw: np.sqrt(abs(np.nanmean(x, **kw) - 1)).sum() / 2,
    'median': lambda x, **kw: np.sqrt(abs(np.nanmedian(x, **kw) - 1)).sum() / 2,

# Path: pyproteome/levels.py
# LOGGER = logging.getLogger('pyproteome.levels')
# WARN_PEP_CUTOFF = 50
# REL_CUTOFF = 5
# LEVELS_DPI = 90
# def kde_max(points):
# def get_channel_levels(
#     data,
#     norm_channels=None,
#     method='median',
#     cols=2,
# ):


# Path: pyproteome/data_sets/constand.py
from pyproteome import levels
import logging
import numpy as np

structured format.
'''

# Built-ins
from __future__ import absolute_import, division



# Core data analysis libraries


LOGGER = logging.getLogger('pyproteome.constand')
CONSTAND_METHODS = {
    'mean': np.nanmean,
    'median': np.nanmedian,

    # Fit a gaussian function to each row/column and select its max point
    'kde': lambda k, **kw: np.apply_along_axis(levels.kde_max, kw['axis'], k),
}
'''
Methods to estimate the center of a data set's rows or columns.

One of ['mean', 'median', 'kde']. 'mean': applies :func:`numpy.nanmean`,
'median' applies :func:`numpy.nanmedian`, and 'kde' applies
:func:`.levels.kde_max`.
'''

CONSTAND_ERR_METHODS = {
    'mean': lambda x, **kw: np.sqrt(abs(np.nanmean(x, **kw) - 1)).sum() / 2,
    'median': lambda x, **kw: np.sqrt(abs(np.nanmedian(x, **kw) - 1)).sum() / 2,

    'kde': lambda x, **kw: np.sqrt(abs(np.apply_along_axis(levels.kde_max, kw['axis'], x) - 1)).sum() / 2,