Download output/preprocess/Epilepsy/code/TCGA.py from Liu-Hy/GenoTEX: direct link, hf CLI and curl.
- Browser
- Download file 2.05 kB
-
https://huggingface.co/datasets/Liu-Hy/GenoTEX/resolve/main/output/preprocess/Epilepsy/code/TCGA.py
- Command line
-
hf download hf://datasets/Liu-Hy/GenoTEX/output/preprocess/Epilepsy/code/TCGA.py
-
curl -L -o TCGA.py https://huggingface.co/datasets/Liu-Hy/GenoTEX/resolve/main/output/preprocess/Epilepsy/code/TCGA.py
2.05 kB
| # Path Configuration | |
| from tools.preprocess import * | |
| # Processing context | |
| trait = "Epilepsy" | |
| # Input paths | |
| tcga_root_dir = "../DATA/TCGA" | |
| # Output paths | |
| out_data_file = "./output/z3/preprocess/Epilepsy/TCGA.csv" | |
| out_gene_data_file = "./output/z3/preprocess/Epilepsy/gene_data/TCGA.csv" | |
| out_clinical_data_file = "./output/z3/preprocess/Epilepsy/clinical_data/TCGA.csv" | |
| json_path = "./output/z3/preprocess/Epilepsy/cohort_info.json" | |
| # Step 1: Initial Data Loading | |
| import os | |
| # Step 1: Select the most relevant TCGA cohort directory for the trait "Epilepsy" | |
| synonyms = ["epilepsy", "seizure", "seizures", "ictal", "epileptic"] | |
| all_dirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))] | |
| matched_dirs = [d for d in all_dirs if any(s in d.lower() for s in synonyms)] | |
| selected_cohort_dirname = None | |
| if matched_dirs: | |
| # Prefer exact 'epilepsy' match if present; otherwise take the first matched | |
| prioritized = sorted(matched_dirs, key=lambda d: (0 if "epilepsy" in d.lower() else 1, d.lower())) | |
| selected_cohort_dirname = prioritized[0] | |
| if selected_cohort_dirname is None: | |
| print("No suitable TCGA cohort found for the trait 'Epilepsy'. Skipping this trait.") | |
| # Record unusable dataset status | |
| _ = validate_and_save_cohort_info( | |
| is_final=False, | |
| cohort="TCGA", | |
| info_path=json_path, | |
| is_gene_available=False, | |
| is_trait_available=False | |
| ) | |
| clinical_df = None | |
| gene_df = None | |
| else: | |
| # Step 2: Identify clinical and genetic data file paths | |
| cohort_dir = os.path.join(tcga_root_dir, selected_cohort_dirname) | |
| clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir) | |
| # Step 3: Load both files as DataFrames | |
| clinical_df = pd.read_csv(clinical_file_path, sep='\t', index_col=0, low_memory=False, compression='infer') | |
| gene_df = pd.read_csv(genetic_file_path, sep='\t', index_col=0, low_memory=False, compression='infer') | |
| # Step 4: Print column names of the clinical data | |
| print(list(clinical_df.columns)) |