|
|
|
from tools.preprocess import * |
|
|
|
|
|
trait = "Esophageal_Cancer" |
|
cohort = "GSE55857" |
|
|
|
|
|
in_trait_dir = "../DATA/GEO/Esophageal_Cancer" |
|
in_cohort_dir = "../DATA/GEO/Esophageal_Cancer/GSE55857" |
|
|
|
|
|
out_data_file = "./output/preprocess/3/Esophageal_Cancer/GSE55857.csv" |
|
out_gene_data_file = "./output/preprocess/3/Esophageal_Cancer/gene_data/GSE55857.csv" |
|
out_clinical_data_file = "./output/preprocess/3/Esophageal_Cancer/clinical_data/GSE55857.csv" |
|
json_path = "./output/preprocess/3/Esophageal_Cancer/cohort_info.json" |
|
|
|
|
|
soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir) |
|
|
|
|
|
background_info, clinical_data = get_background_and_clinical_data(matrix_file_path) |
|
|
|
|
|
unique_values_dict = get_unique_values_by_row(clinical_data) |
|
|
|
|
|
print("Background Information:") |
|
print("-" * 50) |
|
print(background_info) |
|
print("\n") |
|
|
|
|
|
print("Sample Characteristics:") |
|
print("-" * 50) |
|
for row, values in unique_values_dict.items(): |
|
print(f"{row}:") |
|
print(f" {values}") |
|
print() |
|
|
|
|
|
|
|
is_gene_available = False |
|
|
|
|
|
|
|
|
|
|
|
trait_row = 1 |
|
age_row = None |
|
gender_row = None |
|
|
|
|
|
def convert_trait(value): |
|
"""Convert tissue type to binary cancer status""" |
|
if not isinstance(value, str): |
|
return None |
|
value = value.split(": ")[-1].lower().strip() |
|
if "tumor" in value: |
|
return 1 |
|
elif "normal" in value: |
|
return 0 |
|
return None |
|
|
|
def convert_age(value): |
|
"""Convert age value - not used""" |
|
return None |
|
|
|
def convert_gender(value): |
|
"""Convert gender value - not used""" |
|
return None |
|
|
|
|
|
|
|
is_trait_available = trait_row is not None |
|
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) |
|
|
|
|
|
|
|
clinical_features = geo_select_clinical_features(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_results = preview_df(clinical_features) |
|
print("Preview of clinical features:") |
|
print(preview_results) |
|
|
|
|
|
clinical_features.to_csv(out_clinical_data_file) |