python/methylnet/interpretation_classes.py
def return_shapley_data_by_methylation_status(self, methyl_array, threshold):
        """Return dictionary containing two SHAPley datasets, each split by low/high levels of methylation. Todo: Define this using median methylation value vs 0.5.

        Parameters
        ----------
        methyl_array : type
            MethylationArray instance.

        Returns
        -------
        dictionary
            Contains shapley data by methylation status.

        """
        threshold = {'mean':methyl_array.beta.mean().mean(),'original':0.5}[threshold]
        methylation_shapley_data_dict = {'hyper':copy.deepcopy(self.shapley_data),'hypo':copy.deepcopy(self.shapley_data)}
        for individual in self.list_individuals(return_list=True):
            class_name,individual,top_shap_df=self.view_methylation(individual,methyl_array)
            hyper_df = top_shap_df[top_shap_df['methylation']>=threshold]
            hypo_df = top_shap_df[top_shap_df['methylation']<threshold]
            methylation_shapley_data_dict['hyper'].top_cpgs['by_class'][class_name]['by_individual'][individual]=hyper_df[['cpg','shapley_value']]
            methylation_shapley_data_dict['hypo'].top_cpgs['by_class'][class_name]['by_individual'][individual]=hypo_df[['cpg','shapley_value']]
        for class_name,individuals in self.list_individuals().items():
            top_shap_df=self.extract_class(class_name)
            top_shap_df['methylation']=methyl_array.beta.loc[individuals,self.shapley_data.top_cpgs['by_class'][class_name]['overall']['cpg'].values].mean(axis=0).values
            hyper_df = top_shap_df[top_shap_df['methylation']>=threshold]
            hypo_df = top_shap_df[top_shap_df['methylation']<threshold]
            methylation_shapley_data_dict['hyper'].top_cpgs['by_class'][class_name]['overall']=hyper_df[['cpg','shapley_value']]
            methylation_shapley_data_dict['hypo'].top_cpgs['by_class'][class_name]['overall']=hypo_df[['cpg','shapley_value']]
        return methylation_shapley_data_dict
Return dictionary containing two SHAPley datasets, each split by low/high levels of methylation. Todo: Define this using median methylation value vs 0.5.

        Parameters
        ----------
        methyl_array : type
            MethylationArray instance.

        Returns
        -------
        dictionary
            Contains shapley data by methylation status.

        
Return dictionary containing two SHAPley datasets, each split by low/high levels of methylation. Todo: Define this using median methylation value vs 0.5.
Parameters



Returns

dictionary
Contains shapley data by methylation status.
Return dictionary containing two SHAPley datasets each split by low / high levels of methylation . Todo : Define this using median methylation value vs 0 . 5 . Parameters Returns dictionary Contains shapley data by methylation status .
def return_shapley_data_by_methylation_status(self, methyl_array, threshold):
        threshold = {'mean':methyl_array.beta.mean().mean(),'original':0.5}[threshold]
        methylation_shapley_data_dict = {'hyper':copy.deepcopy(self.shapley_data),'hypo':copy.deepcopy(self.shapley_data)}
        for individual in self.list_individuals(return_list=True):
            class_name,individual,top_shap_df=self.view_methylation(individual,methyl_array)
            hyper_df = top_shap_df[top_shap_df['methylation']>=threshold]
            hypo_df = top_shap_df[top_shap_df['methylation']<threshold]
            methylation_shapley_data_dict['hyper'].top_cpgs['by_class'][class_name]['by_individual'][individual]=hyper_df[['cpg','shapley_value']]
            methylation_shapley_data_dict['hypo'].top_cpgs['by_class'][class_name]['by_individual'][individual]=hypo_df[['cpg','shapley_value']]
        for class_name,individuals in self.list_individuals().items():
            top_shap_df=self.extract_class(class_name)
            top_shap_df['methylation']=methyl_array.beta.loc[individuals,self.shapley_data.top_cpgs['by_class'][class_name]['overall']['cpg'].values].mean(axis=0).values
            hyper_df = top_shap_df[top_shap_df['methylation']>=threshold]
            hypo_df = top_shap_df[top_shap_df['methylation']<threshold]
            methylation_shapley_data_dict['hyper'].top_cpgs['by_class'][class_name]['overall']=hyper_df[['cpg','shapley_value']]
            methylation_shapley_data_dict['hypo'].top_cpgs['by_class'][class_name]['overall']=hypo_df[['cpg','shapley_value']]
        return methylation_shapley_data_dict
def return_shapley_data_by_methylation_status ( self , methyl_array , threshold ) : threshold = { 'mean' : methyl_array . beta . mean ( ) . mean ( ) , 'original' : 0.5 } [ threshold ] methylation_shapley_data_dict = { 'hyper' : copy . deepcopy ( self . shapley_data ) , 'hypo' : copy . deepcopy ( self . shapley_data ) } for individual in self . list_individuals ( return_list = True ) : class_name , individual , top_shap_df = self . view_methylation ( individual , methyl_array ) hyper_df = top_shap_df [ top_shap_df [ 'methylation' ] >= threshold ] hypo_df = top_shap_df [ top_shap_df [ 'methylation' ] < threshold ] methylation_shapley_data_dict [ 'hyper' ] . top_cpgs [ 'by_class' ] [ class_name ] [ 'by_individual' ] [ individual ] = hyper_df [ [ 'cpg' , 'shapley_value' ] ] methylation_shapley_data_dict [ 'hypo' ] . top_cpgs [ 'by_class' ] [ class_name ] [ 'by_individual' ] [ individual ] = hypo_df [ [ 'cpg' , 'shapley_value' ] ] for class_name , individuals in self . list_individuals ( ) . items ( ) : top_shap_df = self . extract_class ( class_name ) top_shap_df [ 'methylation' ] = methyl_array . beta . loc [ individuals , self . shapley_data . top_cpgs [ 'by_class' ] [ class_name ] [ 'overall' ] [ 'cpg' ] . values ] . mean ( axis = 0 ) . values hyper_df = top_shap_df [ top_shap_df [ 'methylation' ] >= threshold ] hypo_df = top_shap_df [ top_shap_df [ 'methylation' ] < threshold ] methylation_shapley_data_dict [ 'hyper' ] . top_cpgs [ 'by_class' ] [ class_name ] [ 'overall' ] = hyper_df [ [ 'cpg' , 'shapley_value' ] ] methylation_shapley_data_dict [ 'hypo' ] . top_cpgs [ 'by_class' ] [ class_name ] [ 'overall' ] = hypo_df [ [ 'cpg' , 'shapley_value' ] ] return methylation_shapley_data_dict
Return dictionary containing two SHAPley datasets, each split by low/high levels of methylation.
Return dictionary containing two SHAPley datasets each split by low / high levels of methylation .
"""Return dictionary containing two SHAPley datasets, each split by low/high levels of methylation. Todo: Define this using median methylation value vs 0.5.

        Parameters
        ----------
        methyl_array : type
            MethylationArray instance.

        Returns
        -------
        dictionary
            Contains shapley data by methylation status.

        """
self
methyl_array
threshold