python/pymethylprocess/utils.py
def ref_estimate_cell_counts(input_r_object_dir, algorithm, reference, library, output_csv):
    """Reference based cell type estimates."""
    import rpy2.robjects as robjects
    from rpy2.robjects import pandas2ri, numpy2ri

    pandas2ri.activate()
    from pymethylprocess.meffil_functions import est_cell_counts_meffil, est_cell_counts_minfi, est_cell_counts_IDOL
    os.makedirs(output_csv[:output_csv.rfind('/')],exist_ok=True)
    read_r_object = robjects.r('readRDS')
    robjects.r('library({})'.format(algorithm if algorithm != 'IDOL' else 'minfi'))
    if algorithm == 'meffil':
        qc_list = read_r_object(join(input_r_object_dir,'QCObjects.rds'))
        cell_counts = est_cell_counts_meffil(qc_list,reference)
    else:
        rgset = read_r_object(join(input_r_object_dir,'RGSet.rds'))
        if algorithm=='meffil':
            cell_counts = est_cell_counts_minfi(rgset)
        else:
            cell_counts = est_cell_counts_IDOL(rgset,library)

    # find where samples intersect
    pandas2ri.ri2py(robjects.r('as.data.frame')(cell_counts)).to_csv(output_csv)
Reference based cell type estimates.
Reference based cell type estimates.
Reference based cell type estimates .
def ref_estimate_cell_counts(input_r_object_dir, algorithm, reference, library, output_csv):
    import rpy2.robjects as robjects
    from rpy2.robjects import pandas2ri, numpy2ri
    pandas2ri.activate()
    from pymethylprocess.meffil_functions import est_cell_counts_meffil, est_cell_counts_minfi, est_cell_counts_IDOL
    os.makedirs(output_csv[:output_csv.rfind('/')],exist_ok=True)
    read_r_object = robjects.r('readRDS')
    robjects.r('library({})'.format(algorithm if algorithm != 'IDOL' else 'minfi'))
    if algorithm == 'meffil':
        qc_list = read_r_object(join(input_r_object_dir,'QCObjects.rds'))
        cell_counts = est_cell_counts_meffil(qc_list,reference)
    else:
        rgset = read_r_object(join(input_r_object_dir,'RGSet.rds'))
        if algorithm=='meffil':
            cell_counts = est_cell_counts_minfi(rgset)
        else:
            cell_counts = est_cell_counts_IDOL(rgset,library)
    pandas2ri.ri2py(robjects.r('as.data.frame')(cell_counts)).to_csv(output_csv)
def ref_estimate_cell_counts ( input_r_object_dir , algorithm , reference , library , output_csv ) : import rpy2 . robjects as robjects from rpy2 . robjects import pandas2ri , numpy2ri pandas2ri . activate ( ) from pymethylprocess . meffil_functions import est_cell_counts_meffil , est_cell_counts_minfi , est_cell_counts_IDOL os . makedirs ( output_csv [ : output_csv . rfind ( '/' ) ] , exist_ok = True ) read_r_object = robjects . r ( 'readRDS' ) robjects . r ( 'library({})' . format ( algorithm if algorithm != 'IDOL' else 'minfi' ) ) if algorithm == 'meffil' : qc_list = read_r_object ( join ( input_r_object_dir , 'QCObjects.rds' ) ) cell_counts = est_cell_counts_meffil ( qc_list , reference ) else : rgset = read_r_object ( join ( input_r_object_dir , 'RGSet.rds' ) ) if algorithm == 'meffil' : cell_counts = est_cell_counts_minfi ( rgset ) else : cell_counts = est_cell_counts_IDOL ( rgset , library ) pandas2ri . ri2py ( robjects . r ( 'as.data.frame' ) ( cell_counts ) ) . to_csv ( output_csv )
Reference based cell type estimates.
Reference based cell type estimates .
"""Reference based cell type estimates.""" # find where samples intersect
input_r_object_dir
algorithm
reference
library
output_csv