python/pymethylprocess/preprocess.py
def combine_methylation_arrays(input_pkls, optional_input_pkl_dir, basename, output_pkl, exclude, outer_join):
    """If split MethylationArrays by subtype for either preprocessing or imputation, can use to recombine data for downstream step."""
    os.makedirs(output_pkl[:output_pkl.rfind('/')],exist_ok=True)
    if optional_input_pkl_dir:
        input_pkls=glob.glob(os.path.join(optional_input_pkl_dir,'*',basename))
        if exclude:
            input_pkls=(np.array(input_pkls)[~np.isin(np.vectorize(lambda x: x.split('/')[-2])(input_pkls),np.array(exclude))]).tolist()
    if len(input_pkls) > 0:
        base_methyl_array=MethylationArray(*extract_pheno_beta_df_from_pickle_dict(pickle.load(open(input_pkls[0],'rb')), ''))
        methyl_arrays_generator = (MethylationArray(*extract_pheno_beta_df_from_pickle_dict(pickle.load(open(input_pkl,'rb')), '')) for input_pkl in input_pkls[1:])
        list_methyl_arrays = MethylationArrays([base_methyl_array])
        combined_methyl_array = list_methyl_arrays.combine(methyl_arrays_generator,outer_join=outer_join)
    else:
        combined_methyl_array=MethylationArray(*extract_pheno_beta_df_from_pickle_dict(pickle.load(open(input_pkls[0],'rb')), ''))
    combined_methyl_array.write_pickle(output_pkl)
If split MethylationArrays by subtype for either preprocessing or imputation, can use to recombine data for downstream step.
If split MethylationArrays by subtype for either preprocessing or imputation, can use to recombine data for downstream step.
If split MethylationArrays by subtype for either preprocessing or imputation can use to recombine data for downstream step .
def combine_methylation_arrays(input_pkls, optional_input_pkl_dir, basename, output_pkl, exclude, outer_join):
    os.makedirs(output_pkl[:output_pkl.rfind('/')],exist_ok=True)
    if optional_input_pkl_dir:
        input_pkls=glob.glob(os.path.join(optional_input_pkl_dir,'*',basename))
        if exclude:
            input_pkls=(np.array(input_pkls)[~np.isin(np.vectorize(lambda x: x.split('/')[-2])(input_pkls),np.array(exclude))]).tolist()
    if len(input_pkls) > 0:
        base_methyl_array=MethylationArray(*extract_pheno_beta_df_from_pickle_dict(pickle.load(open(input_pkls[0],'rb')), ''))
        methyl_arrays_generator = (MethylationArray(*extract_pheno_beta_df_from_pickle_dict(pickle.load(open(input_pkl,'rb')), '')) for input_pkl in input_pkls[1:])
        list_methyl_arrays = MethylationArrays([base_methyl_array])
        combined_methyl_array = list_methyl_arrays.combine(methyl_arrays_generator,outer_join=outer_join)
    else:
        combined_methyl_array=MethylationArray(*extract_pheno_beta_df_from_pickle_dict(pickle.load(open(input_pkls[0],'rb')), ''))
    combined_methyl_array.write_pickle(output_pkl)
def combine_methylation_arrays ( input_pkls , optional_input_pkl_dir , basename , output_pkl , exclude , outer_join ) : os . makedirs ( output_pkl [ : output_pkl . rfind ( '/' ) ] , exist_ok = True ) if optional_input_pkl_dir : input_pkls = glob . glob ( os . path . join ( optional_input_pkl_dir , '*' , basename ) ) if exclude : input_pkls = ( np . array ( input_pkls ) [ ~ np . isin ( np . vectorize ( lambda x : x . split ( '/' ) [ - 2 ] ) ( input_pkls ) , np . array ( exclude ) ) ] ) . tolist ( ) if len ( input_pkls ) > 0 : base_methyl_array = MethylationArray ( * extract_pheno_beta_df_from_pickle_dict ( pickle . load ( open ( input_pkls [ 0 ] , 'rb' ) ) , '' ) ) methyl_arrays_generator = ( MethylationArray ( * extract_pheno_beta_df_from_pickle_dict ( pickle . load ( open ( input_pkl , 'rb' ) ) , '' ) ) for input_pkl in input_pkls [ 1 : ] ) list_methyl_arrays = MethylationArrays ( [ base_methyl_array ] ) combined_methyl_array = list_methyl_arrays . combine ( methyl_arrays_generator , outer_join = outer_join ) else : combined_methyl_array = MethylationArray ( * extract_pheno_beta_df_from_pickle_dict ( pickle . load ( open ( input_pkls [ 0 ] , 'rb' ) ) , '' ) ) combined_methyl_array . write_pickle ( output_pkl )
If split MethylationArrays by subtype for either preprocessing or imputation, can use to recombine data for downstream step.
If split MethylationArrays by subtype for either preprocessing or imputation can use to recombine data for downstream step .
"""If split MethylationArrays by subtype for either preprocessing or imputation, can use to recombine data for downstream step."""
input_pkls
optional_input_pkl_dir
basename
output_pkl
exclude
outer_join