| |
| from tools.preprocess import * |
|
|
| |
| trait = "Endometrioid_Cancer" |
| cohort = "GSE73614" |
|
|
| |
| in_trait_dir = "../DATA/GEO/Endometrioid_Cancer" |
| in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE73614" |
|
|
| |
| out_data_file = "./output/z2/preprocess/Endometrioid_Cancer/GSE73614.csv" |
| out_gene_data_file = "./output/z2/preprocess/Endometrioid_Cancer/gene_data/GSE73614.csv" |
| out_clinical_data_file = "./output/z2/preprocess/Endometrioid_Cancer/clinical_data/GSE73614.csv" |
| json_path = "./output/z2/preprocess/Endometrioid_Cancer/cohort_info.json" |
|
|
|
|
| |
| from tools.preprocess import * |
| |
| soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir) |
|
|
| |
| background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design'] |
| clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1'] |
| background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes) |
|
|
| |
| sample_characteristics_dict = get_unique_values_by_row(clinical_data) |
|
|
| |
| print("Background Information:") |
| print(background_info) |
| print("Sample Characteristics Dictionary:") |
| print(sample_characteristics_dict) |
|
|
| |
| |
| is_gene_available = True |
|
|
| |
|
|
| |
| trait_row = None |
| age_row = None |
| gender_row = None |
|
|
| |
| def convert_trait(value): |
| """Convert trait values to binary (0 for non-endometrioid, 1 for endometrioid)""" |
| if value is None: |
| return None |
| value_str = str(value).lower() |
| if 'endometrioid' in value_str: |
| return 1 |
| else: |
| return 0 |
|
|
| def convert_age(value): |
| """Convert age to continuous values""" |
| if value is None: |
| return None |
| try: |
| if ':' in str(value): |
| age_str = str(value).split(':')[1].strip() |
| else: |
| age_str = str(value).strip() |
| return float(age_str) |
| except (ValueError, IndexError): |
| return None |
|
|
| def convert_gender(value): |
| """Convert gender to binary (0 for female, 1 for male)""" |
| if value is None: |
| return None |
| value_str = str(value).lower() |
| if ':' in value_str: |
| value_str = value_str.split(':')[1].strip() |
| |
| if 'female' in value_str or 'f' == value_str: |
| return 0 |
| elif 'male' in value_str or 'm' == value_str: |
| return 1 |
| else: |
| return None |
|
|
| |
| is_trait_available = trait_row is not None |
| save_cohort_info = 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 |
| ) |
|
|
| |
| |
|
|
| |
| |
| gene_data = get_genetic_data(matrix_file) |
|
|
| |
| print(gene_data.index[:20]) |
|
|
| |
| |
| gene_identifiers_sample = ['A_23_P100001', 'A_23_P100011', 'A_23_P100022', 'A_23_P100056', |
| 'A_23_P100074', 'A_23_P100092', 'A_23_P100103', 'A_23_P100111', |
| 'A_23_P100127', 'A_23_P100133', 'A_23_P100141', 'A_23_P100156', |
| 'A_23_P100177', 'A_23_P100189', 'A_23_P100196', 'A_23_P100203', |
| 'A_23_P100220', 'A_23_P100240', 'A_23_P10025', 'A_23_P100263'] |
|
|
| print("Sample gene identifiers:") |
| for i, identifier in enumerate(gene_identifiers_sample[:5]): |
| print(f" {identifier}") |
|
|
| |
| |
| |
| |
| |
|
|
| print("\nAnalysis: These are Agilent microarray probe IDs (A_23_P prefix)") |
| print("They are not human gene symbols and require mapping to gene symbols.") |
|
|
| requires_gene_mapping = True |
|
|
| |
| |
| gene_annotation = get_gene_annotation(soft_file) |
|
|
| |
| print("Gene annotation preview:") |
| print(preview_df(gene_annotation)) |
|
|
| |
| |
| |
| |
| prob_col = 'ID' |
| gene_col = 'GENE_SYMBOL' |
|
|
| |
| gene_mapping = get_gene_mapping(gene_annotation, prob_col, gene_col) |
|
|
| |
| gene_data = apply_gene_mapping(gene_data, gene_mapping) |
|
|
| print(f"Gene expression data shape after mapping: {gene_data.shape}") |
| print(f"First 5 gene symbols: {list(gene_data.index[:5])}") |
|
|
| |
| import os |
|
|
| |
| normalized_gene_data = normalize_gene_symbols_in_index(gene_data) |
| os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True) |
| normalized_gene_data.to_csv(out_gene_data_file) |
|
|
| |
| empty_clinical_data = pd.DataFrame() |
| linked_data = geo_link_clinical_genetic_data(empty_clinical_data, normalized_gene_data) |
|
|
| |
| os.makedirs(os.path.dirname(json_path), exist_ok=True) |
| is_usable = validate_and_save_cohort_info( |
| is_final=True, |
| cohort=cohort, |
| info_path=json_path, |
| is_gene_available=True, |
| is_trait_available=False, |
| is_biased=False, |
| df=linked_data, |
| note="INFO: Dataset contains gene expression data but no trait information available for analysis" |
| ) |
|
|
| |
| print("Dataset not saved - no trait information available for associational study") |