python/methylnet/model_interpretability.py
def order_results_by_col(input_csv, test_pkl, col, output_csv, symmetric):
    """Order results that produces some CSV by phenotype column, alphabetical ordering to show maybe that results group together. Plot using pymethyl-visualize."""
    os.makedirs(output_csv[:output_csv.rfind('.')],exist_ok=True)
    df=pd.read_csv(input_csv,index_col=0)
    if os.path.exists(test_pkl):
        test_arr=MethylationArray.from_pickle(test_pkl) # temporary solution
        test_arr_idx=test_arr.pheno.sort_values(col).index.values
        if np.all(np.vectorize(lambda x: x.startswith(col))(df.index.values)):
            test_arr_idx = np.vectorize(lambda x: '{}_{}'.format(col,x))(test_arr_idx)
        test_arr_idx=test_arr_idx[np.isin(test_arr_idx,df.index.values)] # temporary fix
    else:
        test_arr_idx = np.sort(df.index.values)
    df=df.loc[test_arr_idx,test_arr_idx] if symmetric else df[test_arr_idx]
    df.to_csv(output_csv)
Order results that produces some CSV by phenotype column, alphabetical ordering to show maybe that results group together. Plot using pymethyl-visualize.
Order results that produces some CSV by phenotype column, alphabetical ordering to show maybe that results group together. Plot using pymethyl-visualize.
Order results that produces some CSV by phenotype column alphabetical ordering to show maybe that results group together . Plot using pymethyl - visualize .
def order_results_by_col(input_csv, test_pkl, col, output_csv, symmetric):
    os.makedirs(output_csv[:output_csv.rfind('.')],exist_ok=True)
    df=pd.read_csv(input_csv,index_col=0)
    if os.path.exists(test_pkl):
        test_arr=MethylationArray.from_pickle(test_pkl) 
        test_arr_idx=test_arr.pheno.sort_values(col).index.values
        if np.all(np.vectorize(lambda x: x.startswith(col))(df.index.values)):
            test_arr_idx = np.vectorize(lambda x: '{}_{}'.format(col,x))(test_arr_idx)
        test_arr_idx=test_arr_idx[np.isin(test_arr_idx,df.index.values)] 
    else:
        test_arr_idx = np.sort(df.index.values)
    df=df.loc[test_arr_idx,test_arr_idx] if symmetric else df[test_arr_idx]
    df.to_csv(output_csv)
def order_results_by_col ( input_csv , test_pkl , col , output_csv , symmetric ) : os . makedirs ( output_csv [ : output_csv . rfind ( '.' ) ] , exist_ok = True ) df = pd . read_csv ( input_csv , index_col = 0 ) if os . path . exists ( test_pkl ) : test_arr = MethylationArray . from_pickle ( test_pkl ) test_arr_idx = test_arr . pheno . sort_values ( col ) . index . values if np . all ( np . vectorize ( lambda x : x . startswith ( col ) ) ( df . index . values ) ) : test_arr_idx = np . vectorize ( lambda x : '{}_{}' . format ( col , x ) ) ( test_arr_idx ) test_arr_idx = test_arr_idx [ np . isin ( test_arr_idx , df . index . values ) ] else : test_arr_idx = np . sort ( df . index . values ) df = df . loc [ test_arr_idx , test_arr_idx ] if symmetric else df [ test_arr_idx ] df . to_csv ( output_csv )
Order results that produces some CSV by phenotype column, alphabetical ordering to show maybe that results group together.
Order results that produces some CSV by phenotype column alphabetical ordering to show maybe that results group together .
"""Order results that produces some CSV by phenotype column, alphabetical ordering to show maybe that results group together. Plot using pymethyl-visualize.""" # temporary solution # temporary fix
input_csv
test_pkl
col
output_csv
symmetric