def feature_selection(df, labels, n_features, method='chi2'):
        """
        Reduces the number of features in the imput dataframe.
        Ex: labels = gs.meta['biospecimen_sample__sample_type_id'].apply(int).apply(lambda x: 0 if x < 10 else 1)
            chi2_fs(gs.data, labels, 50)

        :param df: The input dataframe
        :param labels: Labels for each row in the df. Type: Pandas.Series
        :param no_features: The desired number of features
        :param method: The feature selection method to be employed. It is set to 'chi2' by default
        To select the features using mutual information, the method value should be set to 'mi'
        To select the features using ANOVA, the method value should be set to 'ANOVA'
        :return: Returns the dataframe with the selected features

        """
        fs_obj = None
        if method == 'chi2':
            fs_obj = chi2
        elif method == 'ANOVA':
            fs_obj = f_classif
        elif method == 'mi':
            fs_obj = mutual_info_classif
        else:
            raise ValueError('The method is not recognized')
    
        fs = SelectKBest(fs_obj, k=n_features)
        fs.fit_transform(df, labels)
        df_reduced = df.loc[:, fs.get_support()]
        return df_reduced