File size: 4,195 Bytes
13fd1a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Path Configuration
from tools.preprocess import *

# Processing context
trait = "COVID-19"
cohort = "GSE216705"

# Input paths
in_trait_dir = "../DATA/GEO/COVID-19"
in_cohort_dir = "../DATA/GEO/COVID-19/GSE216705"

# Output paths
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"

# Get file paths for SOFT and matrix files
soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)

# Get background info from the soft file since matrix file shows this is a SuperSeries
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)

# Extract unique characteristics values while removing prefixes
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()
        # Group by characteristic type (e.g., tissue, cell type, etc.)
        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 the information
print("Dataset Background Information:")
print(background_info)
print("\nSample Characteristics:")
for characteristic, values in char_values.items():
    print(f"\n{characteristic}:")
    print(list(values))
# 1. Gene Expression Data Availability
# Based on the title mentioning macrophages and GM-CSF, this likely contains gene expression data
is_gene_available = True

# 2. Variable Availability and Data Type Conversion
# Sample characteristics dictionary appears empty, so no clinical data available
trait_row = None
age_row = None  
gender_row = None

def convert_trait(x):
    pass

def convert_age(x):
    pass

def convert_gender(x):
    pass

# 3. Save Metadata 
validate_and_save_cohort_info(is_final=False,
                            cohort=cohort,
                            info_path=json_path,
                            is_gene_available=is_gene_available,
                            is_trait_available=False)

# 4. Clinical Feature Extraction
# Skip since trait_row is None, indicating no clinical data available
# Extract genetic data matrix
genetic_data = get_genetic_data(matrix_file_path)

# Print first few rows with column names to examine data structure
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)

# Verify this is gene expression data and check identifiers
is_gene_available = True

# Save updated metadata
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)
)

# Save gene expression data 
genetic_data.to_csv(out_gene_data_file)
# Row indices appear to be probe IDs (e.g. 10338001) rather than human gene symbols
# These are Illumina probe IDs that need to be mapped to gene symbols
requires_gene_mapping = True
# Extract gene annotation data
gene_metadata = get_gene_annotation(soft_file_path)

# Preview column names and first few values 
preview = preview_df(gene_metadata)
print("\nGene annotation columns and sample values:")
print(preview)

# Update gene availability status since we discovered this is mouse data
is_gene_available = False

# Save updated metadata
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)
)