python/pymethylprocess/MethylationDataTypes.py
def feature_select(self, n_top_cpgs, feature_selection_method='mad', metric='correlation', nn=10):
        """Perform unsupervised feature selection on MethylationArray.

        Parameters
        ----------
        n_top_cpgs
            Number of CpGs to retain.
        feature_selection_method
            Method to perform selection.
        metric
            If considering structural feature selection like SPEC, use this distance metric.
        nn
            Number of nearest neighbors.
        """
        if feature_selection_method=='mad':
            mad_cpgs = self.beta.mad(axis=0).sort_values(ascending=False)
            top_mad_cpgs = np.array(list(mad_cpgs.iloc[:n_top_cpgs].index))
            self.beta = self.beta.loc[:, top_mad_cpgs]
        elif feature_selection_method=='spectral':
            from pynndescent.pynndescent_ import PyNNDescentTransformer
            from skfeature.function.similarity_based.SPEC import spec
            if nn:
                W=PyNNDescentTransformer(n_neighbors=nn,metric=metric).fit_transform(self.beta.values)
                print('W computed...')
                f_weights = spec(self.beta.values,W=W)
                print('weights',f_weights)
            else:
                f_weights = spec(self.beta.values)
            self.beta = self.beta.iloc[:, np.argsort(f_weights)[::-1][:n_top_cpgs]]
Perform unsupervised feature selection on MethylationArray.

        Parameters
        ----------
        n_top_cpgs
            Number of CpGs to retain.
        feature_selection_method
            Method to perform selection.
        metric
            If considering structural feature selection like SPEC, use this distance metric.
        nn
            Number of nearest neighbors.
        
Perform unsupervised feature selection on MethylationArray.
Parameters


Perform unsupervised feature selection on MethylationArray . Parameters
def feature_select(self, n_top_cpgs, feature_selection_method='mad', metric='correlation', nn=10):
        if feature_selection_method=='mad':
            mad_cpgs = self.beta.mad(axis=0).sort_values(ascending=False)
            top_mad_cpgs = np.array(list(mad_cpgs.iloc[:n_top_cpgs].index))
            self.beta = self.beta.loc[:, top_mad_cpgs]
        elif feature_selection_method=='spectral':
            from pynndescent.pynndescent_ import PyNNDescentTransformer
            from skfeature.function.similarity_based.SPEC import spec
            if nn:
                W=PyNNDescentTransformer(n_neighbors=nn,metric=metric).fit_transform(self.beta.values)
                print('W computed...')
                f_weights = spec(self.beta.values,W=W)
                print('weights',f_weights)
            else:
                f_weights = spec(self.beta.values)
            self.beta = self.beta.iloc[:, np.argsort(f_weights)[::-1][:n_top_cpgs]]
def feature_select ( self , n_top_cpgs , feature_selection_method = 'mad' , metric = 'correlation' , nn = 10 ) : if feature_selection_method == 'mad' : mad_cpgs = self . beta . mad ( axis = 0 ) . sort_values ( ascending = False ) top_mad_cpgs = np . array ( list ( mad_cpgs . iloc [ : n_top_cpgs ] . index ) ) self . beta = self . beta . loc [ : , top_mad_cpgs ] elif feature_selection_method == 'spectral' : from pynndescent . pynndescent_ import PyNNDescentTransformer from skfeature . function . similarity_based . SPEC import spec if nn : W = PyNNDescentTransformer ( n_neighbors = nn , metric = metric ) . fit_transform ( self . beta . values ) print ( 'W computed...' ) f_weights = spec ( self . beta . values , W = W ) print ( 'weights' , f_weights ) else : f_weights = spec ( self . beta . values ) self . beta = self . beta . iloc [ : , np . argsort ( f_weights ) [ : : - 1 ] [ : n_top_cpgs ] ]
Perform unsupervised feature selection on MethylationArray.
Perform unsupervised feature selection on MethylationArray .
"""Perform unsupervised feature selection on MethylationArray.

        Parameters
        ----------
        n_top_cpgs
            Number of CpGs to retain.
        feature_selection_method
            Method to perform selection.
        metric
            If considering structural feature selection like SPEC, use this distance metric.
        nn
            Number of nearest neighbors.
        """
self
n_top_cpgs
feature_selection_method
metric
nn