python/methylnet/interpretation_classes.py
def run_lola(self, all_cpgs=[], lola_db='', cores=8, collections=[],depletion=False):
        """Run LOLA enrichment test.

        Parameters
        ----------
        all_cpgs : type
            CpG universe for LOLA.
        lola_db : type
            Location of LOLA database, can be downloaded using methylnet-interpret. Set to extended or core, and collections correspond to these.
        cores : type
            Number of cores to use.
        collections : type
            LOLA collections to run, leave empty to run all.
        depletion : type
            Set true to look for depleted regions over enriched.

        Returns
        -------
        type
            Description of returned object.

        """
        import rpy2.robjects as robjects
        from rpy2.robjects import pandas2ri
        order_by_max_rnk=robjects.r("function (dt) {dt[order(meanRnk, decreasing=FALSE),]}")
        pandas2ri.activate()
        cpg_locations = pandas2ri.ri2py(robjects.r['as'](robjects.r('getAnnotation(IlluminaHumanMethylation450kanno.ilmn12.hg19)'),'data.frame')).set_index(keys='Name',drop=False)
        all_cpg_regions = robjects.r('makeGRangesFromDataFrame')(pandas2ri.py2ri(cpg_locations if not all_cpgs else cpg_locations.loc[all_cpgs,:]),start_field='pos',end_field='pos',starts_in_df_are_0based=False)
        #robjects.r('load("{}")'.format(lola_rdata))
        lolaDB = self.lola.loadRegionDB(lola_db,collections=(robjects.r('NULL') if not collections else rpy2.robjects.vectors.StrVector(collections)))#
        output_dfs={}
        for k in self.top_cpgs:
            list_cpgs=self.top_cpgs[k].values[:,0]
            cpg_location_subset = cpg_locations.loc[list_cpgs,:]
            location_subset = robjects.r('makeGRangesFromDataFrame')(pandas2ri.py2ri(cpg_location_subset),start_field='pos',end_field='pos',starts_in_df_are_0based=False)
            lola_output=self.lola.runLOLA(location_subset,all_cpg_regions,lolaDB,cores=cores,direction=('depletion' if depletion else 'enrichment'))
            output_dfs['prediction_{}'.format(k)]=pandas2ri.ri2py(robjects.r['as'](order_by_max_rnk(lola_output),'data.frame'))#.iloc[:20,:]
            print(output_dfs['prediction_{}'.format(k)].head())
        return output_dfs
        #https://academic.oup.com/bioinformatics/article/32/4/587/1743969
Run LOLA enrichment test.

        Parameters
        ----------
        all_cpgs : type
            CpG universe for LOLA.
        lola_db : type
            Location of LOLA database, can be downloaded using methylnet-interpret. Set to extended or core, and collections correspond to these.
        cores : type
            Number of cores to use.
        collections : type
            LOLA collections to run, leave empty to run all.
        depletion : type
            Set true to look for depleted regions over enriched.

        Returns
        -------
        type
            Description of returned object.

        
Run LOLA enrichment test.
Parameters

all_cpgs : type
CpG universe for LOLA.
lola_db : type
Location of LOLA database, can be downloaded using methylnet-interpret. Set to extended or core, and collections correspond to these.
cores : type
Number of cores to use.
collections : type
LOLA collections to run, leave empty to run all.
depletion : type
Set true to look for depleted regions over enriched.

Returns

type
Description of returned object.
Run LOLA enrichment test . Parameters all_cpgs : type CpG universe for LOLA . lola_db : type Location of LOLA database can be downloaded using methylnet - interpret . Set to extended or core and collections correspond to these . cores : type Number of cores to use . collections : type LOLA collections to run leave empty to run all . depletion : type Set true to look for depleted regions over enriched . Returns type Description of returned object .
def run_lola(self, all_cpgs=[], lola_db='', cores=8, collections=[],depletion=False):
        import rpy2.robjects as robjects
        from rpy2.robjects import pandas2ri
        order_by_max_rnk=robjects.r("function (dt) {dt[order(meanRnk, decreasing=FALSE),]}")
        pandas2ri.activate()
        cpg_locations = pandas2ri.ri2py(robjects.r['as'](robjects.r('getAnnotation(IlluminaHumanMethylation450kanno.ilmn12.hg19)'),'data.frame')).set_index(keys='Name',drop=False)
        all_cpg_regions = robjects.r('makeGRangesFromDataFrame')(pandas2ri.py2ri(cpg_locations if not all_cpgs else cpg_locations.loc[all_cpgs,:]),start_field='pos',end_field='pos',starts_in_df_are_0based=False)
        lolaDB = self.lola.loadRegionDB(lola_db,collections=(robjects.r('NULL') if not collections else rpy2.robjects.vectors.StrVector(collections)))
        output_dfs={}
        for k in self.top_cpgs:
            list_cpgs=self.top_cpgs[k].values[:,0]
            cpg_location_subset = cpg_locations.loc[list_cpgs,:]
            location_subset = robjects.r('makeGRangesFromDataFrame')(pandas2ri.py2ri(cpg_location_subset),start_field='pos',end_field='pos',starts_in_df_are_0based=False)
            lola_output=self.lola.runLOLA(location_subset,all_cpg_regions,lolaDB,cores=cores,direction=('depletion' if depletion else 'enrichment'))
            output_dfs['prediction_{}'.format(k)]=pandas2ri.ri2py(robjects.r['as'](order_by_max_rnk(lola_output),'data.frame')).iloc[:20,:]
            print(output_dfs['prediction_{}'.format(k)].head())
        return output_dfs
        https://academic.oup.com/bioinformatics/article/32/4/587/1743969
def run_lola ( self , all_cpgs = [ ] , lola_db = '' , cores = 8 , collections = [ ] , depletion = False ) : import rpy2 . robjects as robjects from rpy2 . robjects import pandas2ri order_by_max_rnk = robjects . r ( "function (dt) {dt[order(meanRnk, decreasing=FALSE),]}" ) pandas2ri . activate ( ) cpg_locations = pandas2ri . ri2py ( robjects . r [ 'as' ] ( robjects . r ( 'getAnnotation(IlluminaHumanMethylation450kanno.ilmn12.hg19)' ) , 'data.frame' ) ) . set_index ( keys = 'Name' , drop = False ) all_cpg_regions = robjects . r ( 'makeGRangesFromDataFrame' ) ( pandas2ri . py2ri ( cpg_locations if not all_cpgs else cpg_locations . loc [ all_cpgs , : ] ) , start_field = 'pos' , end_field = 'pos' , starts_in_df_are_0based = False ) lolaDB = self . lola . loadRegionDB ( lola_db , collections = ( robjects . r ( 'NULL' ) if not collections else rpy2 . robjects . vectors . StrVector ( collections ) ) ) output_dfs = { } for k in self . top_cpgs : list_cpgs = self . top_cpgs [ k ] . values [ : , 0 ] cpg_location_subset = cpg_locations . loc [ list_cpgs , : ] location_subset = robjects . r ( 'makeGRangesFromDataFrame' ) ( pandas2ri . py2ri ( cpg_location_subset ) , start_field = 'pos' , end_field = 'pos' , starts_in_df_are_0based = False ) lola_output = self . lola . runLOLA ( location_subset , all_cpg_regions , lolaDB , cores = cores , direction = ( 'depletion' if depletion else 'enrichment' ) ) output_dfs [ 'prediction_{}' . format ( k ) ] = pandas2ri . ri2py ( robjects . r [ 'as' ] ( order_by_max_rnk ( lola_output ) , 'data.frame' ) ) print ( output_dfs [ 'prediction_{}' . format ( k ) ] . head ( ) ) return output_dfs
Run LOLA enrichment test.
Run LOLA enrichment test .
"""Run LOLA enrichment test.

        Parameters
        ----------
        all_cpgs : type
            CpG universe for LOLA.
        lola_db : type
            Location of LOLA database, can be downloaded using methylnet-interpret. Set to extended or core, and collections correspond to these.
        cores : type
            Number of cores to use.
        collections : type
            LOLA collections to run, leave empty to run all.
        depletion : type
            Set true to look for depleted regions over enriched.

        Returns
        -------
        type
            Description of returned object.

        """ #robjects.r('load("{}")'.format(lola_rdata)) # #.iloc[:20,:] #https://academic.oup.com/bioinformatics/article/32/4/587/1743969
self
all_cpgs
lola_db
cores
collections
depletion