|
|
|
from tools.preprocess import * |
|
|
|
|
|
trait = "Height" |
|
cohort = "GSE101710" |
|
|
|
|
|
in_trait_dir = "../DATA/GEO/Height" |
|
in_cohort_dir = "../DATA/GEO/Height/GSE101710" |
|
|
|
|
|
out_data_file = "./output/preprocess/3/Height/GSE101710.csv" |
|
out_gene_data_file = "./output/preprocess/3/Height/gene_data/GSE101710.csv" |
|
out_clinical_data_file = "./output/preprocess/3/Height/clinical_data/GSE101710.csv" |
|
json_path = "./output/preprocess/3/Height/cohort_info.json" |
|
|
|
|
|
soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir) |
|
|
|
|
|
background_info, clinical_data = get_background_and_clinical_data(matrix_file_path) |
|
|
|
|
|
unique_values_dict = get_unique_values_by_row(clinical_data) |
|
|
|
|
|
print("Background Information:") |
|
print(background_info) |
|
print("\nSample Characteristics:") |
|
print(json.dumps(unique_values_dict, indent=2)) |
|
|
|
|
|
|
|
is_gene_available = True |
|
|
|
|
|
|
|
trait_row = None |
|
|
|
|
|
age_row = 1 |
|
|
|
def convert_age(value: str) -> float: |
|
|
|
value = value.split(':')[1].strip() |
|
|
|
if value == 'Young': |
|
return 25.5 |
|
elif value == 'Older': |
|
return 70.0 |
|
else: |
|
return None |
|
|
|
|
|
gender_row = None |
|
|
|
def convert_gender(value: str) -> int: |
|
return None |
|
|
|
def convert_trait(value: str) -> float: |
|
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 |
|
) |
|
|
|
|
|
|
|
|
|
genetic_data = get_genetic_data(matrix_file_path) |
|
|
|
|
|
print("First 20 row IDs:") |
|
print(genetic_data.index[:20].tolist()) |
|
|
|
|
|
requires_gene_mapping = True |
|
|
|
gene_metadata = get_gene_annotation(soft_file_path) |
|
|
|
|
|
print("Column names:") |
|
print(gene_metadata.columns.tolist()) |
|
print("\nPreview of first few rows:") |
|
print(json.dumps(preview_df(gene_metadata), indent=2)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
mapping_data = get_gene_mapping(gene_metadata, 'ID', 'Symbol') |
|
|
|
|
|
gene_data = apply_gene_mapping(genetic_data, mapping_data) |
|
|
|
gene_data = normalize_gene_symbols_in_index(gene_data) |
|
gene_data.to_csv(out_gene_data_file) |
|
|
|
|
|
minimal_df = pd.DataFrame({'trait': [None]}) |
|
|
|
|
|
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=minimal_df, |
|
note="Dataset contains gene expression data but no height measurements" |
|
) |