Liu-Hy's picture
Add files using upload-large-folder tool
ff3b0fa verified
# Path Configuration
from tools.preprocess import *
# Processing context
trait = "Epilepsy"
cohort = "GSE273630"
# Input paths
in_trait_dir = "../DATA/GEO/Epilepsy"
in_cohort_dir = "../DATA/GEO/Epilepsy/GSE273630"
# Output paths
out_data_file = "./output/preprocess/3/Epilepsy/GSE273630.csv"
out_gene_data_file = "./output/preprocess/3/Epilepsy/gene_data/GSE273630.csv"
out_clinical_data_file = "./output/preprocess/3/Epilepsy/clinical_data/GSE273630.csv"
json_path = "./output/preprocess/3/Epilepsy/cohort_info.json"
# Get paths to the SOFT and matrix files
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
# Get background info and clinical data from matrix file
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
# Get unique values for each feature (row) in clinical data
unique_values_dict = get_unique_values_by_row(clinical_data)
# Print background info
print("=== Dataset Background Information ===")
print(background_info)
print("\n=== Sample Characteristics ===")
print(json.dumps(unique_values_dict, indent=2))
# Review gene expression data availability
is_gene_available = True # Dataset contains dopamine-regulated gene expression data from a Nanostring panel
# Clinical data variables
trait_row = None # No epilepsy trait data, all subjects are explicitly excluded for epilepsy
age_row = None # Age is constant (35-44 years) by design
gender_row = None # Gender is constant (all males) by design
def convert_trait(x):
# Not used since trait data is not available
return None
def convert_age(x):
# Not used since age data is not available
return None
def convert_gender(x):
# Not used since gender data is not available
return None
# Save metadata
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)
# Extract gene expression data from matrix file
genetic_df = get_genetic_data(matrix_file)
# Print DataFrame shape and first 20 row IDs
print("DataFrame shape:", genetic_df.shape)
print("\nFirst 20 row IDs:")
print(genetic_df.index[:20])
print("\nPreview of first few rows and columns:")
print(genetic_df.head().iloc[:, :5])
# The identifiers are already human gene symbols (ABAT, ABL1, ACAA1, etc.)
# These are well-recognized standard HUGO gene symbols, no mapping needed
requires_gene_mapping = False
# 1. Normalize gene symbols and save
genetic_df = normalize_gene_symbols_in_index(genetic_df)
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
genetic_df.to_csv(out_gene_data_file)
# This dataset explicitly excludes epilepsy as shown in background info:
# "Exclusion criteria were ... epilepsy"
note = "Dataset not usable for epilepsy studies as it explicitly excludes epilepsy patients in exclusion criteria"
is_usable = validate_and_save_cohort_info(
is_final=False, # Filtering out at initial stage
cohort=cohort,
info_path=json_path,
is_gene_available=True,
is_trait_available=False,
note=note
)