# Path Configuration from tools.preprocess import * # Processing context trait = "Amyotrophic_Lateral_Sclerosis" cohort = "GSE212131" # Input paths in_trait_dir = "../DATA/GEO/Amyotrophic_Lateral_Sclerosis" in_cohort_dir = "../DATA/GEO/Amyotrophic_Lateral_Sclerosis/GSE212131" # Output paths out_data_file = "./output/preprocess/1/Amyotrophic_Lateral_Sclerosis/GSE212131.csv" out_gene_data_file = "./output/preprocess/1/Amyotrophic_Lateral_Sclerosis/gene_data/GSE212131.csv" out_clinical_data_file = "./output/preprocess/1/Amyotrophic_Lateral_Sclerosis/clinical_data/GSE212131.csv" json_path = "./output/preprocess/1/Amyotrophic_Lateral_Sclerosis/cohort_info.json" # STEP 1 from tools.preprocess import * # 1. Identify the paths to the SOFT file and the matrix file soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir) # 2. Read the matrix file to obtain background information and sample characteristics data 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 ) # 3. Obtain the sample characteristics dictionary from the clinical dataframe sample_characteristics_dict = get_unique_values_by_row(clinical_data) # 4. Explicitly print out all the background information and the sample characteristics dictionary print("Background Information:") print(background_info) print("\nSample Characteristics Dictionary:") print(sample_characteristics_dict) # 1) Determine if gene expression data is available is_gene_available = True # Based on the microarray transcriptomic analysis described # 2) Determine variable availability # The sample characteristics dictionary is {0: ['gender: Female', 'gender: Male']} # Only one row (key=0) with gender info is found. # Trait and age are not found (or are constant/uninformative in this dataset). trait_row = None age_row = None gender_row = 0 # "gender: Female" and "gender: Male" => two distinct values => available # 2.2) Data Type Conversions def convert_trait(x: str): # Not used because trait_row is None, but defining for completeness. # This function should extract relevant text after the colon, then convert. return None # Return None since trait is not available. def convert_age(x: str): # Not used because age_row is None, but defining for completeness. # This function should parse integer/float ages. Return None for invalid values. return None # Return None since age is not available. def convert_gender(x: str): # Example: x might be "gender: Male" parts = x.split(":") if len(parts) < 2: return None val = parts[1].strip().lower() if val == 'male': return 1 elif val == 'female': return 0 return None # 3) Initial filtering and saving metadata # Trait data is not available => is_trait_available=False is_trait_available = 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 ) # 4) Clinical feature extraction # Since trait_row is None, we SKIP extracting clinical features.