|
|
|
from tools.preprocess import * |
|
|
|
|
|
trait = "Melanoma" |
|
cohort = "GSE148949" |
|
|
|
|
|
in_trait_dir = "../DATA/GEO/Melanoma" |
|
in_cohort_dir = "../DATA/GEO/Melanoma/GSE148949" |
|
|
|
|
|
out_data_file = "./output/preprocess/3/Melanoma/GSE148949.csv" |
|
out_gene_data_file = "./output/preprocess/3/Melanoma/gene_data/GSE148949.csv" |
|
out_clinical_data_file = "./output/preprocess/3/Melanoma/clinical_data/GSE148949.csv" |
|
json_path = "./output/preprocess/3/Melanoma/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("Dataset Background Information:") |
|
print(background_info) |
|
print("\nSample Characteristics:") |
|
for feature, values in unique_values_dict.items(): |
|
print(f"\n{feature}:") |
|
print(values) |
|
|
|
|
|
|
|
is_gene_available = True |
|
|
|
|
|
|
|
|
|
|
|
trait_row = None |
|
age_row = None |
|
gender_row = None |
|
|
|
|
|
|
|
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("First 20 row IDs:") |
|
print(list(genetic_data.index)[:20]) |
|
|
|
|
|
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) |
|
|
|
|
|
print("\nGene annotation data shape:", gene_metadata.shape) |
|
print("\nGene annotation columns:") |
|
print(gene_metadata.columns) |
|
|
|
|
|
print("\nFirst few rows:") |
|
print(gene_metadata.head()) |
|
|
|
|
|
for col in gene_metadata.columns: |
|
print(f"\nSample values from column '{col}':") |
|
sample_vals = gene_metadata[col].head(10).tolist() |
|
print(sample_vals) |
|
|
|
|
|
probe_col = None |
|
gene_col = None |
|
|
|
for col in gene_metadata.columns: |
|
|
|
sample_vals = set(gene_metadata[col].astype(str).head(100)) |
|
genetic_ids = set(list(genetic_data.index)[:100]) |
|
overlap = sample_vals & genetic_ids |
|
if len(overlap) > 0: |
|
probe_col = col |
|
break |
|
|
|
|
|
print("\nMapping columns found:") |
|
print(f"Probe ID column: {probe_col}") |
|
print(f"Gene Symbol column: {gene_col}") |
|
|
|
gene_data = genetic_data.copy() |
|
|
|
|
|
gene_data = normalize_gene_symbols_in_index(gene_data) |
|
|
|
print("\nFirst 10 rows of processed gene expression data:") |
|
print(gene_data.head(10)) |
|
|
|
gene_data = normalize_gene_symbols_in_index(genetic_data) |
|
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True) |
|
gene_data.to_csv(out_gene_data_file) |
|
|
|
|
|
|
|
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=gene_data, |
|
note="Dataset contains only reference samples from cell lines. No trait data available for analysis." |
|
) |
|
|
|
|