|
|
|
from tools.preprocess import * |
|
|
|
|
|
trait = "Testicular_Cancer" |
|
cohort = "GSE42647" |
|
|
|
|
|
in_trait_dir = "../DATA/GEO/Testicular_Cancer" |
|
in_cohort_dir = "../DATA/GEO/Testicular_Cancer/GSE42647" |
|
|
|
|
|
out_data_file = "./output/preprocess/3/Testicular_Cancer/GSE42647.csv" |
|
out_gene_data_file = "./output/preprocess/3/Testicular_Cancer/gene_data/GSE42647.csv" |
|
out_clinical_data_file = "./output/preprocess/3/Testicular_Cancer/clinical_data/GSE42647.csv" |
|
json_path = "./output/preprocess/3/Testicular_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) |
|
|
|
|
|
print("Background Information:") |
|
print(background_info) |
|
print("\nClinical Data Shape:", clinical_data.shape) |
|
print("\nFirst few rows of Clinical Data:") |
|
print(clinical_data.head()) |
|
|
|
print("\nSample Characteristics:") |
|
|
|
unique_values_dict = get_unique_values_by_row(clinical_data) |
|
for row, values in unique_values_dict.items(): |
|
print(f"\n{row}:") |
|
print(values) |
|
|
|
|
|
is_gene_available = True |
|
|
|
|
|
|
|
|
|
|
|
|
|
trait_row = 1 |
|
|
|
|
|
age_row = None |
|
gender_row = None |
|
|
|
|
|
def convert_trait(x): |
|
"""Convert to binary: 1 for testicular cancer""" |
|
value = x.split(": ")[1].lower() |
|
if 'ebryonal carcinoma' in value: |
|
return 1 |
|
return None |
|
|
|
def convert_age(x): |
|
"""Not used since age data unavailable""" |
|
return None |
|
|
|
def convert_gender(x): |
|
"""Not used since gender data unavailable""" |
|
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_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(clinical_features) |
|
print("Preview of clinical features:") |
|
print(preview) |
|
|
|
|
|
clinical_features.to_csv(out_clinical_data_file) |
|
|
|
|
|
|
|
print("ERROR: This dataset (GSE42647) contains methylation data rather than gene expression data.") |
|
print("Gene data extraction stopped as methylation data is not suitable for this analysis.") |
|
print("Please revise Step 2 to correctly set is_gene_available = False") |
|
|
|
is_gene_available = False |
|
|
|
|
|
|
|
trait_row = None |
|
age_row = None |
|
gender_row = None |
|
|
|
|
|
def convert_trait(x): return None |
|
def convert_age(x): return None |
|
def convert_gender(x): return None |
|
|
|
|
|
validate_and_save_cohort_info( |
|
is_final=False, |
|
cohort=cohort, |
|
info_path=json_path, |
|
is_gene_available=is_gene_available, |
|
is_trait_available=(trait_row is not None) |
|
) |
|
|
|
|
|
|