|
|
|
from tools.preprocess import * |
|
|
|
|
|
trait = "Head_and_Neck_Cancer" |
|
cohort = "GSE151181" |
|
|
|
|
|
in_trait_dir = "../DATA/GEO/Head_and_Neck_Cancer" |
|
in_cohort_dir = "../DATA/GEO/Head_and_Neck_Cancer/GSE151181" |
|
|
|
|
|
out_data_file = "./output/preprocess/3/Head_and_Neck_Cancer/GSE151181.csv" |
|
out_gene_data_file = "./output/preprocess/3/Head_and_Neck_Cancer/gene_data/GSE151181.csv" |
|
out_clinical_data_file = "./output/preprocess/3/Head_and_Neck_Cancer/clinical_data/GSE151181.csv" |
|
json_path = "./output/preprocess/3/Head_and_Neck_Cancer/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("-" * 50) |
|
print(background_info) |
|
print("\n") |
|
|
|
|
|
print("Sample Characteristics:") |
|
print("-" * 50) |
|
for row, values in unique_values_dict.items(): |
|
print(f"{row}:") |
|
print(f" {values}") |
|
print() |
|
|
|
|
|
is_gene_available = True |
|
|
|
|
|
|
|
|
|
trait_row = 4 |
|
|
|
|
|
age_row = None |
|
gender_row = None |
|
|
|
|
|
def convert_trait(x): |
|
"""Convert RAI response status to binary |
|
Refractory (resistant) = 1, Avid (responsive) = 0""" |
|
if not isinstance(x, str): |
|
return None |
|
x = x.split(": ")[-1].strip().lower() |
|
if x == "refractory": |
|
return 1 |
|
elif x == "avid": |
|
return 0 |
|
return None |
|
|
|
def convert_age(x): |
|
"""Placeholder since age not available""" |
|
return None |
|
|
|
def convert_gender(x): |
|
"""Placeholder since gender not available""" |
|
return None |
|
|
|
|
|
is_usable = validate_and_save_cohort_info( |
|
is_final=False, |
|
cohort=cohort, |
|
info_path=json_path, |
|
is_gene_available=is_gene_available, |
|
is_trait_available=trait_row is not None |
|
) |
|
|
|
|
|
if trait_row is not None: |
|
clinical_features = geo_select_clinical_features( |
|
clinical_df=clinical_data, |
|
trait=trait, |
|
trait_row=trait_row, |
|
convert_trait=convert_trait, |
|
age_row=age_row, |
|
convert_age=convert_age, |
|
gender_row=gender_row, |
|
convert_gender=convert_gender |
|
) |
|
|
|
|
|
preview = preview_df(clinical_features) |
|
print("Preview of extracted clinical features:") |
|
print(preview) |
|
|
|
|
|
clinical_features.to_csv(out_clinical_data_file) |
|
|
|
genetic_data = get_genetic_data(matrix_file_path) |
|
|
|
|
|
print("First 20 probe IDs:") |
|
print(genetic_data.index[:20]) |
|
probe_ids = ['23064070', '23064071', '23064072', '23064073', '23064074'] |
|
|
|
|
|
requires_gene_mapping = True |
|
|
|
files = os.listdir(in_cohort_dir) |
|
print("All files in directory:") |
|
for f in files: |
|
print(f) |
|
print() |
|
|
|
|
|
subseries_files = [f for f in files if 'series' in f.lower()] |
|
gene_annotation = None |
|
|
|
for file in subseries_files: |
|
file_path = os.path.join(in_cohort_dir, file) |
|
temp_annot = get_gene_annotation(file_path) |
|
|
|
|
|
if 'GENE_SYMBOL' in temp_annot.columns and \ |
|
any(not str(x).startswith('hsa-miR') for x in temp_annot['GENE_SYMBOL'].dropna()): |
|
gene_annotation = temp_annot |
|
break |
|
|
|
if gene_annotation is not None: |
|
|
|
preview_dict = preview_df(gene_annotation, n=20) |
|
print("Column names and preview values:") |
|
for col, values in preview_dict.items(): |
|
print(f"\n{col}:") |
|
print(values) |
|
else: |
|
print("No gene annotation data found in any file. This dataset may only contain miRNA data.") |