| |
| from tools.preprocess import * |
|
|
| |
| trait = "Endometrioid_Cancer" |
| cohort = "GSE94524" |
|
|
| |
| in_trait_dir = "../DATA/GEO/Endometrioid_Cancer" |
| in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE94524" |
|
|
| |
| out_data_file = "./output/z2/preprocess/Endometrioid_Cancer/GSE94524.csv" |
| out_gene_data_file = "./output/z2/preprocess/Endometrioid_Cancer/gene_data/GSE94524.csv" |
| out_clinical_data_file = "./output/z2/preprocess/Endometrioid_Cancer/clinical_data/GSE94524.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""" |
| if value is None: |
| return None |
| return None |
|
|
| def convert_age(value): |
| """Convert age values to continuous""" |
| if value is None: |
| return None |
| return None |
|
|
| def convert_gender(value): |
| """Convert gender values to binary (0=female, 1=male)""" |
| if value is None: |
| return None |
| 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) |
|
|
| |
| |
|
|
| |
| |
| gene_data = get_genetic_data(matrix_file) |
|
|
| |
| print(gene_data.index[:20]) |
|
|
| |
| print("Examining gene identifiers...") |
| print("Sample identifiers:", gene_data.index[:10].tolist()) |
|
|
| |
| |
| |
|
|
| 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 = 'HUGO' |
|
|
| |
| gene_mapping = get_gene_mapping(gene_annotation, prob_col, gene_col) |
|
|
| |
| gene_data = apply_gene_mapping(gene_data, gene_mapping) |
|
|
| |
| gene_data = normalize_gene_symbols_in_index(gene_data) |
|
|
| print(f"Gene expression data shape after mapping: {gene_data.shape}") |
| print(f"Sample gene names: {gene_data.index[:10].tolist()}") |
|
|
| |
| |
| 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) |
|
|
| |
| |
| print("No variable clinical trait data available - dataset not suitable for association studies") |
|
|
| |
| linked_data = pd.DataFrame() |
|
|
| |
| 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=True, |
| df=linked_data, |
| note="INFO: Dataset contains only constant trait values (all endometrioid adenocarcinoma), no variable clinical features for association analysis" |
| ) |
|
|
| |
| print(f"Dataset usability: {is_usable}") |