|
|
|
from tools.preprocess import * |
|
|
|
|
|
trait = "COVID-19" |
|
cohort = "GSE216705" |
|
|
|
|
|
in_trait_dir = "../DATA/GEO/COVID-19" |
|
in_cohort_dir = "../DATA/GEO/COVID-19/GSE216705" |
|
|
|
|
|
out_data_file = "./output/preprocess/3/COVID-19/GSE216705.csv" |
|
out_gene_data_file = "./output/preprocess/3/COVID-19/gene_data/GSE216705.csv" |
|
out_clinical_data_file = "./output/preprocess/3/COVID-19/clinical_data/GSE216705.csv" |
|
json_path = "./output/preprocess/3/COVID-19/cohort_info.json" |
|
|
|
|
|
soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir) |
|
|
|
|
|
prefixes_background = ['!Series_title', '!Series_summary', '!Series_overall_design'] |
|
prefixes_clinical = ['!Sample_geo_accession', '!Sample_characteristics_ch1'] |
|
background_info, clinical_data = filter_content_by_prefix(soft_file_path, prefixes_background, prefixes_clinical, |
|
source_type='file', return_df_a=False, return_df_b=True) |
|
|
|
|
|
char_values = {} |
|
for col in clinical_data.columns: |
|
if '!Sample_characteristics_ch1' in str(col): |
|
values = clinical_data[col].dropna() |
|
values = values.str.replace('!Sample_characteristics_ch1 = ', '').unique() |
|
|
|
for val in values: |
|
if ':' in val: |
|
key, value = val.split(': ', 1) |
|
if key not in char_values: |
|
char_values[key] = set() |
|
char_values[key].add(value) |
|
|
|
|
|
print("Dataset Background Information:") |
|
print(background_info) |
|
print("\nSample Characteristics:") |
|
for characteristic, values in char_values.items(): |
|
print(f"\n{characteristic}:") |
|
print(list(values)) |
|
|
|
|
|
is_gene_available = True |
|
|
|
|
|
|
|
trait_row = None |
|
age_row = None |
|
gender_row = None |
|
|
|
def convert_trait(x): |
|
pass |
|
|
|
def convert_age(x): |
|
pass |
|
|
|
def convert_gender(x): |
|
pass |
|
|
|
|
|
validate_and_save_cohort_info(is_final=False, |
|
cohort=cohort, |
|
info_path=json_path, |
|
is_gene_available=is_gene_available, |
|
is_trait_available=False) |
|
|
|
|
|
|
|
|
|
genetic_data = get_genetic_data(matrix_file_path) |
|
|
|
|
|
print("Data preview:") |
|
print("\nColumn names:") |
|
print(list(genetic_data.columns)[:5]) |
|
print("\nFirst 5 rows:") |
|
print(genetic_data.head()) |
|
print("\nShape:", genetic_data.shape) |
|
|
|
|
|
is_gene_available = True |
|
|
|
|
|
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) |
|
) |
|
|
|
|
|
genetic_data.to_csv(out_gene_data_file) |
|
|
|
|
|
requires_gene_mapping = True |
|
|
|
gene_metadata = get_gene_annotation(soft_file_path) |
|
|
|
|
|
preview = preview_df(gene_metadata) |
|
print("\nGene annotation columns and sample values:") |
|
print(preview) |
|
|
|
|
|
is_gene_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=(trait_row is not None) |
|
) |