|
|
|
from tools.preprocess import * |
|
|
|
|
|
trait = "LDL_Cholesterol_Levels" |
|
cohort = "GSE34945" |
|
|
|
|
|
in_trait_dir = "../DATA/GEO/LDL_Cholesterol_Levels" |
|
in_cohort_dir = "../DATA/GEO/LDL_Cholesterol_Levels/GSE34945" |
|
|
|
|
|
out_data_file = "./output/preprocess/3/LDL_Cholesterol_Levels/GSE34945.csv" |
|
out_gene_data_file = "./output/preprocess/3/LDL_Cholesterol_Levels/gene_data/GSE34945.csv" |
|
out_clinical_data_file = "./output/preprocess/3/LDL_Cholesterol_Levels/clinical_data/GSE34945.csv" |
|
json_path = "./output/preprocess/3/LDL_Cholesterol_Levels/cohort_info.json" |
|
|
|
|
|
soft_path, matrix_path = geo_get_relevant_filepaths(in_cohort_dir) |
|
|
|
|
|
background_info, clinical_data = get_background_and_clinical_data(matrix_path) |
|
|
|
|
|
sample_chars = get_unique_values_by_row(clinical_data) |
|
|
|
|
|
print("Background Information:") |
|
print(background_info) |
|
print("\nClinical Features Overview:") |
|
print(json.dumps(sample_chars, indent=2)) |
|
|
|
|
|
is_gene_available = False |
|
|
|
|
|
|
|
|
|
trait_row = 2 |
|
|
|
age_row = None |
|
gender_row = None |
|
|
|
|
|
def convert_trait(x): |
|
|
|
if isinstance(x, str) and "percent change in apoc3 levels:" in x: |
|
try: |
|
return float(x.split(":")[1].strip()) |
|
except: |
|
return None |
|
return None |
|
|
|
def convert_age(x): |
|
return None |
|
|
|
def convert_gender(x): |
|
return None |
|
|
|
|
|
|
|
is_trait_available = True if trait_row is not None else False |
|
validate_and_save_cohort_info(is_final=False, cohort=cohort, info_path=json_path, |
|
is_gene_available=is_gene_available, |
|
is_trait_available=is_trait_available) |
|
|
|
|
|
|
|
if trait_row is not None: |
|
selected_clinical_df = geo_select_clinical_features( |
|
clinical_df=clinical_data, |
|
trait=trait, |
|
trait_row=trait_row, |
|
convert_trait=convert_trait, |
|
age_row=age_row, |
|
convert_age=convert_age, |
|
gender_row=gender_row, |
|
convert_gender=convert_gender |
|
) |
|
|
|
|
|
preview = preview_df(selected_clinical_df) |
|
print("Preview of selected clinical features:") |
|
print(preview) |
|
|
|
|
|
selected_clinical_df.to_csv(out_clinical_data_file) |