python/pymethylprocess/PreProcessDataTypes.py
def format_custom(self, basename_col, disease_class_column, include_columns={}):
        """Custom format clinical sheet if user supplied idats.

        Parameters
        ----------
        basename_col
            Column name of sample names.
        disease_class_column
            Disease column of clinical info csv.
        include_columns
            Dictionary specifying other columns to include, and new names to assign them to.
        """
        idats = glob.glob("{}/*.idat".format(self.idat_dir))
        idat_basenames = np.unique(np.vectorize(lambda x: '_'.join(x.split('/')[-1].split('_')[:-1]))(idats))
        idat_count_underscores = np.vectorize(lambda x: x.count('_'))(idat_basenames)
        self.pheno_sheet['Basename'] = self.pheno_sheet[basename_col]
        basename_count_underscores = np.vectorize(lambda x: x.count('_'))(self.pheno_sheet['Basename'])
        min_underscores=min(np.hstack([idat_count_underscores,basename_count_underscores]))
        basic_basename_fn = np.vectorize(lambda x: '_'.join(x.split('_')[-min_underscores-1:]))
        basic_basename=dict(zip(basic_basename_fn(self.pheno_sheet['Basename']),self.pheno_sheet['Basename'].values))
        basic_idat=dict(zip(basic_basename_fn(idat_basenames),idat_basenames))
        complete_mapping={basic_basename[basename]:basic_idat[basename] for basename in basic_basename}
        self.pheno_sheet.loc[:,'Basename']=self.pheno_sheet['Basename'].map(complete_mapping).map(lambda x: self.idat_dir+x)
        self.pheno_sheet['disease'] = self.pheno_sheet[disease_class_column.replace("'",'')]
        self.pheno_sheet = self.pheno_sheet[np.unique(['Basename', 'disease']+list(include_columns.keys()))].rename(columns=include_columns)
Custom format clinical sheet if user supplied idats.

        Parameters
        ----------
        basename_col
            Column name of sample names.
        disease_class_column
            Disease column of clinical info csv.
        include_columns
            Dictionary specifying other columns to include, and new names to assign them to.
        
Custom format clinical sheet if user supplied idats.
Parameters

basename_col
Column name of sample names.
disease_class_column
Disease column of clinical info csv.
include_columns
Dictionary specifying other columns to include, and new names to assign them to.
Custom format clinical sheet if user supplied idats . Parameters basename_col Column name of sample names . disease_class_column Disease column of clinical info csv . include_columns Dictionary specifying other columns to include and new names to assign them to .
def format_custom(self, basename_col, disease_class_column, include_columns={}):
        idats = glob.glob("{}/*.idat".format(self.idat_dir))
        idat_basenames = np.unique(np.vectorize(lambda x: '_'.join(x.split('/')[-1].split('_')[:-1]))(idats))
        idat_count_underscores = np.vectorize(lambda x: x.count('_'))(idat_basenames)
        self.pheno_sheet['Basename'] = self.pheno_sheet[basename_col]
        basename_count_underscores = np.vectorize(lambda x: x.count('_'))(self.pheno_sheet['Basename'])
        min_underscores=min(np.hstack([idat_count_underscores,basename_count_underscores]))
        basic_basename_fn = np.vectorize(lambda x: '_'.join(x.split('_')[-min_underscores-1:]))
        basic_basename=dict(zip(basic_basename_fn(self.pheno_sheet['Basename']),self.pheno_sheet['Basename'].values))
        basic_idat=dict(zip(basic_basename_fn(idat_basenames),idat_basenames))
        complete_mapping={basic_basename[basename]:basic_idat[basename] for basename in basic_basename}
        self.pheno_sheet.loc[:,'Basename']=self.pheno_sheet['Basename'].map(complete_mapping).map(lambda x: self.idat_dir+x)
        self.pheno_sheet['disease'] = self.pheno_sheet[disease_class_column.replace("'",'')]
        self.pheno_sheet = self.pheno_sheet[np.unique(['Basename', 'disease']+list(include_columns.keys()))].rename(columns=include_columns)
def format_custom ( self , basename_col , disease_class_column , include_columns = { } ) : idats = glob . glob ( "{}/*.idat" . format ( self . idat_dir ) ) idat_basenames = np . unique ( np . vectorize ( lambda x : '_' . join ( x . split ( '/' ) [ - 1 ] . split ( '_' ) [ : - 1 ] ) ) ( idats ) ) idat_count_underscores = np . vectorize ( lambda x : x . count ( '_' ) ) ( idat_basenames ) self . pheno_sheet [ 'Basename' ] = self . pheno_sheet [ basename_col ] basename_count_underscores = np . vectorize ( lambda x : x . count ( '_' ) ) ( self . pheno_sheet [ 'Basename' ] ) min_underscores = min ( np . hstack ( [ idat_count_underscores , basename_count_underscores ] ) ) basic_basename_fn = np . vectorize ( lambda x : '_' . join ( x . split ( '_' ) [ - min_underscores - 1 : ] ) ) basic_basename = dict ( zip ( basic_basename_fn ( self . pheno_sheet [ 'Basename' ] ) , self . pheno_sheet [ 'Basename' ] . values ) ) basic_idat = dict ( zip ( basic_basename_fn ( idat_basenames ) , idat_basenames ) ) complete_mapping = { basic_basename [ basename ] : basic_idat [ basename ] for basename in basic_basename } self . pheno_sheet . loc [ : , 'Basename' ] = self . pheno_sheet [ 'Basename' ] . map ( complete_mapping ) . map ( lambda x : self . idat_dir + x ) self . pheno_sheet [ 'disease' ] = self . pheno_sheet [ disease_class_column . replace ( "'" , '' ) ] self . pheno_sheet = self . pheno_sheet [ np . unique ( [ 'Basename' , 'disease' ] + list ( include_columns . keys ( ) ) ) ] . rename ( columns = include_columns )
Custom format clinical sheet if user supplied idats.
Custom format clinical sheet if user supplied idats .
"""Custom format clinical sheet if user supplied idats.

        Parameters
        ----------
        basename_col
            Column name of sample names.
        disease_class_column
            Disease column of clinical info csv.
        include_columns
            Dictionary specifying other columns to include, and new names to assign them to.
        """
self
basename_col
disease_class_column
include_columns