python/methylnet/interpretation_classes.py
def extract_class(self, class_name, class_intersect=False, get_shap_values=False):
        """Extract the top cpgs from a class

        Parameters
        ----------
        class_name : type
            Class to extract from?
        class_intersect : type
            Bool to extract from aggregation of SHAP values from individuals of current class, should have been done already.

        Returns
        -------
        DataFrame
            Cpgs and SHAP Values
        """
        if get_shap_values:
            return self.shapley_data.shapley_values['by_class'][class_name].mean(axis=0)
        else:
            if class_intersect:
                shap_dfs=[]
                for individual in self.shapley_data.top_cpgs['by_class'][class_name]['by_individual'].keys():
                    shap_dfs.append(self.shapley_data.top_cpgs['by_class'][class_name]['by_individual'][individual].set_index('cpg'))
                    df=pd.concat([shap_dfs],axis=1,join='inner')
                    df['shapley_value']=df.values.sum(axis=1)
                    df['cpg'] = np.array(list(df.index))
                return df[['cpg','shapley_value']]
            else:
                return self.shapley_data.top_cpgs['by_class'][class_name]['overall']
Extract the top cpgs from a class

        Parameters
        ----------
        class_name : type
            Class to extract from?
        class_intersect : type
            Bool to extract from aggregation of SHAP values from individuals of current class, should have been done already.

        Returns
        -------
        DataFrame
            Cpgs and SHAP Values
        
Extract the top cpgs from a class
Parameters

class_name : type
Class to extract from.
class_intersect : type
Bool to extract from aggregation of SHAP values from individuals of current class, should have been done already.

Returns

DataFrame
Cpgs and SHAP Values
Extract the top cpgs from a class Parameters class_name : type Class to extract from . class_intersect : type Bool to extract from aggregation of SHAP values from individuals of current class should have been done already . Returns DataFrame Cpgs and SHAP Values
def extract_class(self, class_name, class_intersect=False, get_shap_values=False):
        if get_shap_values:
            return self.shapley_data.shapley_values['by_class'][class_name].mean(axis=0)
        else:
            if class_intersect:
                shap_dfs=[]
                for individual in self.shapley_data.top_cpgs['by_class'][class_name]['by_individual'].keys():
                    shap_dfs.append(self.shapley_data.top_cpgs['by_class'][class_name]['by_individual'][individual].set_index('cpg'))
                    df=pd.concat([shap_dfs],axis=1,join='inner')
                    df['shapley_value']=df.values.sum(axis=1)
                    df['cpg'] = np.array(list(df.index))
                return df[['cpg','shapley_value']]
            else:
                return self.shapley_data.top_cpgs['by_class'][class_name]['overall']
def extract_class ( self , class_name , class_intersect = False , get_shap_values = False ) : if get_shap_values : return self . shapley_data . shapley_values [ 'by_class' ] [ class_name ] . mean ( axis = 0 ) else : if class_intersect : shap_dfs = [ ] for individual in self . shapley_data . top_cpgs [ 'by_class' ] [ class_name ] [ 'by_individual' ] . keys ( ) : shap_dfs . append ( self . shapley_data . top_cpgs [ 'by_class' ] [ class_name ] [ 'by_individual' ] [ individual ] . set_index ( 'cpg' ) ) df = pd . concat ( [ shap_dfs ] , axis = 1 , join = 'inner' ) df [ 'shapley_value' ] = df . values . sum ( axis = 1 ) df [ 'cpg' ] = np . array ( list ( df . index ) ) return df [ [ 'cpg' , 'shapley_value' ] ] else : return self . shapley_data . top_cpgs [ 'by_class' ] [ class_name ] [ 'overall' ]
Extract the top cpgs from a class
Parameters
Extract the top cpgs from a class Parameters
"""Extract the top cpgs from a class

        Parameters
        ----------
        class_name : type
            Class to extract from?
        class_intersect : type
            Bool to extract from aggregation of SHAP values from individuals of current class, should have been done already.

        Returns
        -------
        DataFrame
            Cpgs and SHAP Values
        """
self
class_name
class_intersect
get_shap_values