python/methylnet/interpretation_classes.py
def return_binned_shapley_data(self, original_class_name, outcome_col, add_top_negative=False):
        """Converts existing shap data based on continuous variable predictions into categorical variable.

        Parameters
        ----------
        original_class_name : type
            Regression results were split into ClassName_pos and ClassName_neg, what is the ClassName?
        outcome_col : type
            Feed in from pheno sheet one the column to bin samples on.
        add_top_negative : type
            Looking to include negative SHAPs?

        Returns
        -------
        ShapleyData
            With new class labels, built from regression results.

        """
        class_names = outcome_col.unique()
        new_shapley_data = ShapleyData()
        new_shapley_data.shapley_values['overall']=self.shapley_data.shapley_values['overall']
        cpgs = new_shapley_data.shapley_values['overall'].index.values
        new_shapley_data.top_cpgs['overall']=self.shapley_data.top_cpgs['overall']
        n_top_cpgs = new_shapley_data.top_cpgs['overall'].shape[0]
        regression_classes = self.shapley_data.shapley_values['by_class'].keys()
        for regression_class in regression_classes:
            print(regression_class,original_class_name)
            if regression_class.startswith(original_class_name):
                shap_df = self.shapley_data.shapley_values['by_class'][regression_class]#['by_class'][regression_class]
                print(shap_df)
                for class_name in class_names:
                    print(class_name)
                    print(outcome_col[outcome_col==class_name])
                    idx = outcome_col[outcome_col==class_name].index.values
                    new_shapley_data.add_class(class_name,shap_df.loc[idx,:],cpgs,n_top_cpgs, add_top_negative)
        return new_shapley_data
Converts existing shap data based on continuous variable predictions into categorical variable.

        Parameters
        ----------
        original_class_name : type
            Regression results were split into ClassName_pos and ClassName_neg, what is the ClassName?
        outcome_col : type
            Feed in from pheno sheet one the column to bin samples on.
        add_top_negative : type
            Looking to include negative SHAPs?

        Returns
        -------
        ShapleyData
            With new class labels, built from regression results.

        
Converts existing shap data based on continuous variable predictions into categorical variable.
Parameters

original_class_name : type
Regression results were split into ClassName_pos and ClassName_neg, what is the ClassName.
outcome_col : type
Feed in from pheno sheet one the column to bin samples on.

Returns

ShapleyData
With new class labels, built from regression results.
Converts existing shap data based on continuous variable predictions into categorical variable . Parameters original_class_name : type Regression results were split into ClassName_pos and ClassName_neg what is the ClassName . outcome_col : type Feed in from pheno sheet one the column to bin samples on . Returns ShapleyData With new class labels built from regression results .
def return_binned_shapley_data(self, original_class_name, outcome_col, add_top_negative=False):
        class_names = outcome_col.unique()
        new_shapley_data = ShapleyData()
        new_shapley_data.shapley_values['overall']=self.shapley_data.shapley_values['overall']
        cpgs = new_shapley_data.shapley_values['overall'].index.values
        new_shapley_data.top_cpgs['overall']=self.shapley_data.top_cpgs['overall']
        n_top_cpgs = new_shapley_data.top_cpgs['overall'].shape[0]
        regression_classes = self.shapley_data.shapley_values['by_class'].keys()
        for regression_class in regression_classes:
            print(regression_class,original_class_name)
            if regression_class.startswith(original_class_name):
                shap_df = self.shapley_data.shapley_values['by_class'][regression_class]
                print(shap_df)
                for class_name in class_names:
                    print(class_name)
                    print(outcome_col[outcome_col==class_name])
                    idx = outcome_col[outcome_col==class_name].index.values
                    new_shapley_data.add_class(class_name,shap_df.loc[idx,:],cpgs,n_top_cpgs, add_top_negative)
        return new_shapley_data
def return_binned_shapley_data ( self , original_class_name , outcome_col , add_top_negative = False ) : class_names = outcome_col . unique ( ) new_shapley_data = ShapleyData ( ) new_shapley_data . shapley_values [ 'overall' ] = self . shapley_data . shapley_values [ 'overall' ] cpgs = new_shapley_data . shapley_values [ 'overall' ] . index . values new_shapley_data . top_cpgs [ 'overall' ] = self . shapley_data . top_cpgs [ 'overall' ] n_top_cpgs = new_shapley_data . top_cpgs [ 'overall' ] . shape [ 0 ] regression_classes = self . shapley_data . shapley_values [ 'by_class' ] . keys ( ) for regression_class in regression_classes : print ( regression_class , original_class_name ) if regression_class . startswith ( original_class_name ) : shap_df = self . shapley_data . shapley_values [ 'by_class' ] [ regression_class ] print ( shap_df ) for class_name in class_names : print ( class_name ) print ( outcome_col [ outcome_col == class_name ] ) idx = outcome_col [ outcome_col == class_name ] . index . values new_shapley_data . add_class ( class_name , shap_df . loc [ idx , : ] , cpgs , n_top_cpgs , add_top_negative ) return new_shapley_data
Converts existing shap data based on continuous variable predictions into categorical variable.
Converts existing shap data based on continuous variable predictions into categorical variable .
"""Converts existing shap data based on continuous variable predictions into categorical variable.

        Parameters
        ----------
        original_class_name : type
            Regression results were split into ClassName_pos and ClassName_neg, what is the ClassName?
        outcome_col : type
            Feed in from pheno sheet one the column to bin samples on.
        add_top_negative : type
            Looking to include negative SHAPs?

        Returns
        -------
        ShapleyData
            With new class labels, built from regression results.

        """ #['by_class'][regression_class]
self
original_class_name
outcome_col
add_top_negative