Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- output/preprocess/Anorexia_Nervosa/code/GSE60190.py +180 -0
- output/preprocess/Anorexia_Nervosa/code/TCGA.py +61 -0
- output/preprocess/Anorexia_Nervosa/cohort_info.json +1 -22
- output/preprocess/Anxiety_disorder/clinical_data/GSE60190.csv +4 -0
- output/preprocess/Anxiety_disorder/clinical_data/GSE61672.csv +1 -1
- output/preprocess/Anxiety_disorder/clinical_data/GSE68526.csv +3 -3
- output/preprocess/Anxiety_disorder/code/GSE119995.py +136 -0
- output/preprocess/Anxiety_disorder/code/GSE60190.py +194 -0
- output/preprocess/Anxiety_disorder/code/GSE60491.py +127 -0
- output/preprocess/Anxiety_disorder/code/GSE61672.py +244 -0
- output/preprocess/Anxiety_disorder/code/GSE68526.py +180 -0
- output/preprocess/Anxiety_disorder/code/GSE78104.py +207 -0
- output/preprocess/Anxiety_disorder/code/GSE94119.py +100 -0
- output/preprocess/Anxiety_disorder/code/TCGA.py +52 -0
- output/preprocess/Anxiety_disorder/cohort_info.json +1 -82
- output/preprocess/Arrhythmia/GSE41177.csv +0 -0
- output/preprocess/Arrhythmia/clinical_data/GSE115574.csv +2 -2
- output/preprocess/Arrhythmia/clinical_data/GSE143924.csv +2 -0
- output/preprocess/Arrhythmia/clinical_data/GSE182600.csv +4 -4
- output/preprocess/Arrhythmia/clinical_data/GSE235307.csv +4 -4
- output/preprocess/Arrhythmia/clinical_data/GSE41177.csv +4 -0
- output/preprocess/Arrhythmia/clinical_data/GSE53622.csv +4 -0
- output/preprocess/Arrhythmia/clinical_data/GSE93101.csv +4 -0
- output/preprocess/Arrhythmia/code/GSE115574.py +190 -0
- output/preprocess/Arrhythmia/code/GSE136992.py +123 -0
- output/preprocess/Arrhythmia/code/GSE143924.py +188 -0
- output/preprocess/Arrhythmia/code/GSE182600.py +195 -0
- output/preprocess/Arrhythmia/code/GSE235307.py +236 -0
- output/preprocess/Arrhythmia/code/GSE41177.py +182 -0
- output/preprocess/Arrhythmia/code/GSE47727.py +139 -0
- output/preprocess/Arrhythmia/code/GSE53622.py +309 -0
- output/preprocess/Arrhythmia/code/GSE55231.py +219 -0
- output/preprocess/Arrhythmia/code/GSE93101.py +204 -0
- output/preprocess/Arrhythmia/code/TCGA.py +70 -0
- output/preprocess/Arrhythmia/cohort_info.json +1 -112
- output/preprocess/Arrhythmia/gene_data/GSE53622.csv +0 -1
- output/preprocess/Asthma/GSE270312.csv +0 -0
- output/preprocess/Asthma/clinical_data/GSE123086.csv +4 -0
- output/preprocess/Asthma/clinical_data/GSE123088.csv +4 -4
- output/preprocess/Asthma/clinical_data/GSE182797.csv +1 -2
- output/preprocess/Asthma/clinical_data/GSE182798.csv +1 -2
- output/preprocess/Asthma/clinical_data/GSE270312.csv +1 -1
- output/preprocess/Asthma/code/GSE123086.py +260 -0
- output/preprocess/Asthma/code/GSE123088.py +206 -0
- output/preprocess/Asthma/code/GSE182797.py +189 -0
- output/preprocess/Asthma/code/GSE182798.py +192 -0
- output/preprocess/Asthma/code/GSE184382.py +227 -0
- output/preprocess/Asthma/code/GSE185658.py +190 -0
- output/preprocess/Asthma/code/GSE188424.py +224 -0
- output/preprocess/Asthma/code/GSE205151.py +184 -0
output/preprocess/Anorexia_Nervosa/code/GSE60190.py
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Anorexia_Nervosa"
|
| 6 |
+
cohort = "GSE60190"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Anorexia_Nervosa"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Anorexia_Nervosa/GSE60190"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Anorexia_Nervosa/GSE60190.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Anorexia_Nervosa/gene_data/GSE60190.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Anorexia_Nervosa/clinical_data/GSE60190.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Anorexia_Nervosa/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
# Step 1: Determine gene expression data availability
|
| 40 |
+
is_gene_available = True # Illumina HumanHT-12 v3 microarray indicates gene expression data
|
| 41 |
+
|
| 42 |
+
# Step 2: Variable availability and conversion functions
|
| 43 |
+
|
| 44 |
+
# Trait (Anorexia Nervosa) availability:
|
| 45 |
+
# The dataset provides ED (eating disorder) but does not distinguish AN specifically.
|
| 46 |
+
trait_row = None # Not available at the required specificity (AN vs BN)
|
| 47 |
+
|
| 48 |
+
# Age availability
|
| 49 |
+
age_row = 5 # 'age: <float>'
|
| 50 |
+
def convert_age(x):
|
| 51 |
+
if x is None:
|
| 52 |
+
return None
|
| 53 |
+
try:
|
| 54 |
+
val = x.split(":", 1)[1].strip()
|
| 55 |
+
except Exception:
|
| 56 |
+
val = str(x).strip()
|
| 57 |
+
try:
|
| 58 |
+
v = float(val)
|
| 59 |
+
if 0 <= v < 120:
|
| 60 |
+
return v
|
| 61 |
+
return None
|
| 62 |
+
except Exception:
|
| 63 |
+
return None
|
| 64 |
+
|
| 65 |
+
# Gender availability
|
| 66 |
+
gender_row = 7 # 'Sex: M' / 'Sex: F'
|
| 67 |
+
def convert_gender(x):
|
| 68 |
+
if x is None:
|
| 69 |
+
return None
|
| 70 |
+
try:
|
| 71 |
+
val = x.split(":", 1)[1].strip().lower()
|
| 72 |
+
except Exception:
|
| 73 |
+
val = str(x).strip().lower()
|
| 74 |
+
if val in {"m", "male"}:
|
| 75 |
+
return 1
|
| 76 |
+
if val in {"f", "female"}:
|
| 77 |
+
return 0
|
| 78 |
+
return None
|
| 79 |
+
|
| 80 |
+
# Placeholder for trait conversion (not used because trait_row is None)
|
| 81 |
+
def convert_trait(x):
|
| 82 |
+
return None
|
| 83 |
+
|
| 84 |
+
# Step 3: Initial filtering and save metadata
|
| 85 |
+
is_trait_available = trait_row is not None
|
| 86 |
+
_ = validate_and_save_cohort_info(
|
| 87 |
+
is_final=False,
|
| 88 |
+
cohort=cohort,
|
| 89 |
+
info_path=json_path,
|
| 90 |
+
is_gene_available=is_gene_available,
|
| 91 |
+
is_trait_available=is_trait_available
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
# Step 4: Clinical feature extraction (skip because trait_row is None)
|
| 95 |
+
# If trait_row becomes available in future, the following block can be used:
|
| 96 |
+
if trait_row is not None:
|
| 97 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 98 |
+
clinical_df=clinical_data,
|
| 99 |
+
trait=trait,
|
| 100 |
+
trait_row=trait_row,
|
| 101 |
+
convert_trait=convert_trait,
|
| 102 |
+
age_row=age_row,
|
| 103 |
+
convert_age=convert_age,
|
| 104 |
+
gender_row=gender_row,
|
| 105 |
+
convert_gender=convert_gender
|
| 106 |
+
)
|
| 107 |
+
_ = preview_df(selected_clinical_df)
|
| 108 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 109 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
| 110 |
+
|
| 111 |
+
# Step 3: Gene Data Extraction
|
| 112 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 113 |
+
gene_data = get_genetic_data(matrix_file)
|
| 114 |
+
|
| 115 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 116 |
+
print(gene_data.index[:20])
|
| 117 |
+
|
| 118 |
+
# Step 4: Gene Identifier Review
|
| 119 |
+
requires_gene_mapping = True
|
| 120 |
+
print(f"requires_gene_mapping = {requires_gene_mapping}")
|
| 121 |
+
|
| 122 |
+
# Step 5: Gene Annotation
|
| 123 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 124 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 125 |
+
|
| 126 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 127 |
+
print("Gene annotation preview:")
|
| 128 |
+
print(preview_df(gene_annotation))
|
| 129 |
+
|
| 130 |
+
# Step 6: Gene Identifier Mapping
|
| 131 |
+
# Identify the columns for probe IDs and gene symbols in the annotation
|
| 132 |
+
probe_col = 'ID' # Matches probe IDs like 'ILMN_1343291'
|
| 133 |
+
gene_symbol_col = 'Symbol' # Contains human gene symbols
|
| 134 |
+
|
| 135 |
+
# 2. Build the gene mapping dataframe
|
| 136 |
+
gene_mapping = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=gene_symbol_col)
|
| 137 |
+
|
| 138 |
+
# 3. Apply mapping to convert probe-level data to gene-level expression
|
| 139 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=gene_mapping)
|
| 140 |
+
|
| 141 |
+
# Step 7: Data Normalization and Linking
|
| 142 |
+
import os
|
| 143 |
+
|
| 144 |
+
# 1. Normalize gene symbols and save gene expression data
|
| 145 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 146 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 147 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 148 |
+
|
| 149 |
+
# 2-6. Proceed only if trait data is available; otherwise, skip linking and final validation
|
| 150 |
+
if ('trait_row' in globals()) and (trait_row is not None):
|
| 151 |
+
# Build clinical feature dataframe from clinical_data
|
| 152 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 153 |
+
clinical_df=clinical_data,
|
| 154 |
+
trait=trait,
|
| 155 |
+
trait_row=trait_row,
|
| 156 |
+
convert_trait=convert_trait,
|
| 157 |
+
age_row=age_row,
|
| 158 |
+
convert_age=convert_age,
|
| 159 |
+
gender_row=gender_row,
|
| 160 |
+
convert_gender=convert_gender
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
# Link clinical and genetic data
|
| 164 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 165 |
+
|
| 166 |
+
# Handle missing values
|
| 167 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 168 |
+
|
| 169 |
+
# Assess bias and remove biased demographic features
|
| 170 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 171 |
+
|
| 172 |
+
# Final validation and save cohort info
|
| 173 |
+
is_usable = validate_and_save_cohort_info(
|
| 174 |
+
True, cohort, json_path, True, True, is_trait_biased, unbiased_linked_data
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
# Save linked data if usable
|
| 178 |
+
if is_usable:
|
| 179 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 180 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Anorexia_Nervosa/code/TCGA.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Anorexia_Nervosa"
|
| 6 |
+
|
| 7 |
+
# Input paths
|
| 8 |
+
tcga_root_dir = "../DATA/TCGA"
|
| 9 |
+
|
| 10 |
+
# Output paths
|
| 11 |
+
out_data_file = "./output/z1/preprocess/Anorexia_Nervosa/TCGA.csv"
|
| 12 |
+
out_gene_data_file = "./output/z1/preprocess/Anorexia_Nervosa/gene_data/TCGA.csv"
|
| 13 |
+
out_clinical_data_file = "./output/z1/preprocess/Anorexia_Nervosa/clinical_data/TCGA.csv"
|
| 14 |
+
json_path = "./output/z1/preprocess/Anorexia_Nervosa/cohort_info.json"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# Step 1: Initial Data Loading
|
| 18 |
+
import os
|
| 19 |
+
import pandas as pd
|
| 20 |
+
|
| 21 |
+
# Discover available TCGA cohort directories
|
| 22 |
+
all_entries = os.listdir(tcga_root_dir)
|
| 23 |
+
cohort_dirs = [d for d in all_entries if os.path.isdir(os.path.join(tcga_root_dir, d))]
|
| 24 |
+
|
| 25 |
+
# Define keywords related to the trait to find a relevant cohort (none expected for Anorexia Nervosa in TCGA)
|
| 26 |
+
trait_keywords = {
|
| 27 |
+
"anorexia", "nervosa", "eating", "appetite", "weight", "body_mass", "bmi", "cachexia"
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
# Score directories by presence of any keyword
|
| 31 |
+
def score_dir(name: str) -> int:
|
| 32 |
+
lname = name.lower()
|
| 33 |
+
return sum(1 for kw in trait_keywords if kw in lname)
|
| 34 |
+
|
| 35 |
+
scored = [(d, score_dir(d)) for d in cohort_dirs]
|
| 36 |
+
# Select the best match if any positive score
|
| 37 |
+
scored.sort(key=lambda x: x[1], reverse=True)
|
| 38 |
+
selected_dir = scored[0][0] if scored and scored[0][1] > 0 else None
|
| 39 |
+
|
| 40 |
+
if selected_dir is None:
|
| 41 |
+
# No suitable TCGA cohort for Anorexia Nervosa; mark as unavailable and complete this task
|
| 42 |
+
_ = validate_and_save_cohort_info(
|
| 43 |
+
is_final=False,
|
| 44 |
+
cohort="TCGA",
|
| 45 |
+
info_path=json_path,
|
| 46 |
+
is_gene_available=False,
|
| 47 |
+
is_trait_available=False
|
| 48 |
+
)
|
| 49 |
+
clinical_df = None
|
| 50 |
+
genetic_df = None
|
| 51 |
+
print("No suitable TCGA cohort found for the trait; skipping TCGA for this trait.")
|
| 52 |
+
else:
|
| 53 |
+
cohort_path = os.path.join(tcga_root_dir, selected_dir)
|
| 54 |
+
clinical_fp, genetic_fp = tcga_get_relevant_filepaths(cohort_path)
|
| 55 |
+
|
| 56 |
+
# Load dataframes
|
| 57 |
+
clinical_df = pd.read_csv(clinical_fp, sep='\t', index_col=0, low_memory=False)
|
| 58 |
+
genetic_df = pd.read_csv(genetic_fp, sep='\t', index_col=0, low_memory=False)
|
| 59 |
+
|
| 60 |
+
# Print clinical column names
|
| 61 |
+
print(clinical_df.columns.tolist())
|
output/preprocess/Anorexia_Nervosa/cohort_info.json
CHANGED
|
@@ -1,22 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"GSE60190": {
|
| 3 |
-
"is_usable": false,
|
| 4 |
-
"is_gene_available": true,
|
| 5 |
-
"is_trait_available": true,
|
| 6 |
-
"is_available": true,
|
| 7 |
-
"is_biased": true,
|
| 8 |
-
"has_age": true,
|
| 9 |
-
"has_gender": true,
|
| 10 |
-
"sample_size": 133
|
| 11 |
-
},
|
| 12 |
-
"TCGA": {
|
| 13 |
-
"is_usable": false,
|
| 14 |
-
"is_gene_available": false,
|
| 15 |
-
"is_trait_available": false,
|
| 16 |
-
"is_available": false,
|
| 17 |
-
"is_biased": null,
|
| 18 |
-
"has_age": null,
|
| 19 |
-
"has_gender": null,
|
| 20 |
-
"sample_size": null
|
| 21 |
-
}
|
| 22 |
-
}
|
|
|
|
| 1 |
+
{"GSE60190": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "TCGA": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output/preprocess/Anxiety_disorder/clinical_data/GSE60190.csv
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,GSM1467273,GSM1467274,GSM1467275,GSM1467276,GSM1467277,GSM1467278,GSM1467279,GSM1467280,GSM1467281,GSM1467282,GSM1467283,GSM1467284,GSM1467285,GSM1467286,GSM1467287,GSM1467288,GSM1467289,GSM1467290,GSM1467291,GSM1467292,GSM1467293,GSM1467294,GSM1467295,GSM1467296,GSM1467297,GSM1467298,GSM1467299,GSM1467300,GSM1467301,GSM1467302,GSM1467303,GSM1467304,GSM1467305,GSM1467306,GSM1467307,GSM1467308,GSM1467309,GSM1467310,GSM1467311,GSM1467312,GSM1467313,GSM1467314,GSM1467315,GSM1467316,GSM1467317,GSM1467318,GSM1467319,GSM1467320,GSM1467321,GSM1467322,GSM1467323,GSM1467324,GSM1467325,GSM1467326,GSM1467327,GSM1467328,GSM1467329,GSM1467330,GSM1467331,GSM1467332,GSM1467333,GSM1467334,GSM1467335,GSM1467336,GSM1467337,GSM1467338,GSM1467339,GSM1467340,GSM1467341,GSM1467342,GSM1467343,GSM1467344,GSM1467345,GSM1467346,GSM1467347,GSM1467348,GSM1467349,GSM1467350,GSM1467351,GSM1467352,GSM1467353,GSM1467354,GSM1467355,GSM1467356,GSM1467357,GSM1467358,GSM1467359,GSM1467360,GSM1467361,GSM1467362,GSM1467363,GSM1467364,GSM1467365,GSM1467366,GSM1467367,GSM1467368,GSM1467369,GSM1467370,GSM1467371,GSM1467372,GSM1467373,GSM1467374,GSM1467375,GSM1467376,GSM1467377,GSM1467378,GSM1467379,GSM1467380,GSM1467381,GSM1467382,GSM1467383,GSM1467384,GSM1467385,GSM1467386,GSM1467387,GSM1467388,GSM1467389,GSM1467390,GSM1467391,GSM1467392,GSM1467393,GSM1467394,GSM1467395,GSM1467396,GSM1467397,GSM1467398,GSM1467399,GSM1467400,GSM1467401,GSM1467402,GSM1467403,GSM1467404,GSM1467405
|
| 2 |
+
Anxiety_disorder,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
| 3 |
+
Age,50.421917,27.49863,30.627397,61.167123,32.69589,39.213698,58.605479,49.2,41.041095,51.750684,50.89863,26.745205,29.104109,39.301369,48.978082,57.884931,28.364383,24.041095,19.268493,27.230136,46.605479,23.443835,51.038356,39.663013,46.109589,77.989041,46.967123,63.241095,62.306849,83.641095,42.838356,51.386301,66.715068,51.939726,34.339726,50.109589,18.758904,16.649315,16.353424,42.065753,16.726027,34.465753,34.254794,47.484931,43.756164,49.210958,57.482191,46.561643,49.561643,28.589041,38.410958,30.032876,56.09041,46.915068,49.021917,71.109589,17.235616,16.583561,16.934246,16.8,18.117808,18.660273,16.69589,75.572602,59.260273,55.545205,41.778082,57.454794,45.284931,56.304109,39.654794,55.945205,38.232876,58.109589,40.021917,50.504109,36.550684,45.117808,83.545205,18.786301,48.567123,38.331506,48.101369,18.39452,60.843835,61.372602,52.038356,59.254794,41.567123,50.358904,31.558904,45.701369,44.731506,34.39726,31.613698,54.846575,84.057534,66.79452,53.323287,30.043835,55.435616,45.676712,54.334246,63.558904,45.224657,23.69589,67.865753,16.753424,18.424657,17.09041,16.183561,33.260273,54.424657,45.378082,52.523287,35.273972,22.630136,20.863013,26.531506,24.627397,53.978082,34.961643,18.731506,30.726027,63.471232,54.808219,57.512328,57.610958,44.958904,35.684931,63.0,38.780821,45.978082
|
| 4 |
+
Gender,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0
|
output/preprocess/Anxiety_disorder/clinical_data/GSE61672.csv
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
,GSM1510561,GSM1510562,GSM1510563,GSM1510564,GSM1510565,GSM1510566,GSM1510567,GSM1510568,GSM1510569,GSM1510570,GSM1510571,GSM1510572,GSM1510573,GSM1510574,GSM1510575,GSM1510576,GSM1510577,GSM1510578,GSM1510579,GSM1510580,GSM1510581,GSM1510582,GSM1510583,GSM1510584,GSM1510585,GSM1510586,GSM1510587,GSM1510588,GSM1510589,GSM1510590,GSM1510591,GSM1510592,GSM1510593,GSM1510594,GSM1510595,GSM1510596,GSM1510597,GSM1510598,GSM1510599,GSM1510600,GSM1510601,GSM1510602,GSM1510603,GSM1510604,GSM1510605,GSM1510606,GSM1510607,GSM1510608,GSM1510609,GSM1510610,GSM1510611,GSM1510612,GSM1510613,GSM1510614,GSM1510615,GSM1510616,GSM1510617,GSM1510618,GSM1510619,GSM1510620,GSM1510621,GSM1510622,GSM1510623,GSM1510624,GSM1510625,GSM1510626,GSM1510627,GSM1510628,GSM1510629,GSM1510630,GSM1510631,GSM1510632,GSM1510633,GSM1510634,GSM1510635,GSM1510636,GSM1510637,GSM1510638,GSM1510639,GSM1510640,GSM1510641,GSM1510642,GSM1510643,GSM1510644,GSM1510645,GSM1510646,GSM1510647,GSM1510648,GSM1510649,GSM1510650,GSM1510651,GSM1510652,GSM1510653,GSM1510654,GSM1510655,GSM1510656,GSM1510657,GSM1510658,GSM1510659,GSM1510660,GSM1510661,GSM1510662,GSM1510663,GSM1510664,GSM1510665,GSM1510666,GSM1510667,GSM1510668,GSM1510669,GSM1510670,GSM1510671,GSM1510672,GSM1510673,GSM1510674,GSM1510675,GSM1510676,GSM1510677,GSM1510678,GSM1510679,GSM1510680,GSM1510681,GSM1510682,GSM1510683,GSM1510684,GSM1510685,GSM1510686,GSM1510687,GSM1510688,GSM1510689,GSM1510690,GSM1510691,GSM1510692,GSM1510693,GSM1510694,GSM1510695,GSM1510696,GSM1510697,GSM1510698,GSM1510699,GSM1510700,GSM1510701,GSM1510702,GSM1510703,GSM1510704,GSM1510705,GSM1510706,GSM1510707,GSM1510708,GSM1510709,GSM1510710,GSM1510711,GSM1510712,GSM1510713,GSM1510714,GSM1510715,GSM1510716,GSM1510717,GSM1510718,GSM1510719,GSM1510720,GSM1510721,GSM1510722,GSM1510723,GSM1510724,GSM1510725,GSM1510726,GSM1510727,GSM1510728,GSM1510729,GSM1510730,GSM1510731,GSM1510732,GSM1510733,GSM1510734,GSM1510735,GSM1510736,GSM1510737,GSM1510738,GSM1510739,GSM1510740,GSM1510741,GSM1510742,GSM1510743,GSM1510744,GSM1510745,GSM1510746,GSM1510747,GSM1510748,GSM1510749,GSM1510750,GSM1510751,GSM1510752,GSM1510753,GSM1510754,GSM1510755,GSM1510756,GSM1510757,GSM1510758,GSM1510759,GSM1510760,GSM1510761,GSM1510762,GSM1510763,GSM1510764,GSM1510765,GSM1510766,GSM1510767,GSM1510768,GSM1510769,GSM1510770,GSM1510771,GSM1510772,GSM1510773,GSM1510774,GSM1510775,GSM1510776,GSM1510777,GSM1510778,GSM1510779,GSM1510780,GSM1510781,GSM1510782,GSM1510783,GSM1510784,GSM1510785,GSM1510786,GSM1510787,GSM1510788,GSM1510789,GSM1510790,GSM1510791,GSM1510792,GSM1510793,GSM1510794,GSM1510795,GSM1510796,GSM1510797,GSM1510798,GSM1510799,GSM1510800,GSM1510801,GSM1510802,GSM1510803,GSM1510804,GSM1510805,GSM1510806,GSM1510807,GSM1510808,GSM1510809,GSM1510810,GSM1510811,GSM1510812,GSM1510813,GSM1510814,GSM1510815,GSM1510816,GSM1510817,GSM1510818,GSM1510819,GSM1510820,GSM1510821,GSM1510822,GSM1510823,GSM1510824,GSM1510825,GSM1510826,GSM1510827,GSM1510828,GSM1510829,GSM1510830,GSM1510831,GSM1510832,GSM1510833,GSM1510834,GSM1510835,GSM1510836,GSM1510837,GSM1510838,GSM1510839,GSM1510840,GSM1510841,GSM1510842,GSM1510843,GSM1510844,GSM1510845,GSM1510846,GSM1510847,GSM1510848,GSM1510849,GSM1510850,GSM1510851,GSM1510852,GSM1510853,GSM1510854,GSM1510855,GSM1510856,GSM1510857,GSM1510858,GSM1510859,GSM1510860,GSM1510861,GSM1510862,GSM1510863,GSM1510864,GSM1510865,GSM1510866,GSM1510867,GSM1510868,GSM1510869,GSM1510870,GSM1510871,GSM1510872,GSM1510873,GSM1510874,GSM1510875,GSM1510876,GSM1510877,GSM1510878,GSM1510879,GSM1510880,GSM1510881,GSM1510882,GSM1510883,GSM1510884,GSM1510885,GSM1510886,GSM1510887,GSM1510888,GSM1510889,GSM1510890,GSM1510891,GSM1510892,GSM1510893,GSM1510894,GSM1510895,GSM1510896,GSM1510897,GSM1510898,GSM1510899,GSM1510900,GSM1510901,GSM1510902,GSM1510903,GSM1510904,GSM1510905,GSM1510906,GSM1510907,GSM1510908,GSM1510909,GSM1510910,GSM1510911,GSM1510912,GSM1510913,GSM1510914,GSM1510915,GSM1510916,GSM1510917,GSM1510918,GSM1510919,GSM1510920,GSM1510921,GSM1510922,GSM1510923,GSM1510924,GSM1510925,GSM1510926,GSM1510927,GSM1510928,GSM1510929,GSM1510930,GSM1510931,GSM1510932,GSM1510933,GSM1510934,GSM1510935,GSM1510936,GSM1510937,GSM1510938,GSM1510939,GSM1510940,GSM1510941,GSM1510942,GSM1510943,GSM1510944,GSM1510945,GSM1510946,GSM1510947,GSM1510948,GSM1510949,GSM1510950,GSM1510951,GSM1510952,GSM1510953,GSM1510954,GSM1510955,GSM1510956,GSM1510957,GSM1510958,GSM1510959,GSM1510960,GSM1510961,GSM1510962,GSM1510963,GSM1510964,GSM1510965,GSM1510966,GSM1510967,GSM1510968,GSM1510969,GSM1510970,GSM1510971,GSM1510972,GSM1510973,GSM1510974,GSM1510975,GSM1510976,GSM1510977,GSM1510978,GSM1510979,GSM1510980,GSM1510981,GSM1510982,GSM1510983,GSM1510984,GSM1510985,GSM1510986,GSM1510987,GSM1510988,GSM1510989,GSM1510990,GSM1510991,GSM1510992,GSM1510993,GSM1510994,GSM1510995,GSM1510996,GSM1510997,GSM1510998,GSM1510999,GSM1511000,GSM1511001,GSM1511002,GSM1511003,GSM1511004,GSM1511005,GSM1511006,GSM1511007,GSM1511008,GSM1511009,GSM1511010,GSM1511011,GSM1511012,GSM1511013,GSM1511014,GSM1511015,GSM1511016,GSM1511017,GSM1511018,GSM1511019,GSM1511020,GSM1511021,GSM1511022,GSM1511023,GSM1511024,GSM1511025,GSM1511026,GSM1511027,GSM1511028,GSM1511029,GSM1511030,GSM1511031,GSM1511032,GSM1511033,GSM1511034,GSM1511035,GSM1511036,GSM1511037,GSM1511038,GSM1511039,GSM1511040,GSM1511041,GSM1511042,GSM1511043,GSM1511044,GSM1511045,GSM1511046,GSM1511047,GSM1511048,GSM1511049,GSM1511050,GSM1511051,GSM1511052,GSM1511053,GSM1511054,GSM1511055,GSM1511056,GSM1511057,GSM1511058,GSM1511059,GSM1511060,GSM1511061,GSM1511062,GSM1511063,GSM1511064,GSM1511065,GSM1511066,GSM1511067,GSM1511068,GSM1511069,GSM1511070,GSM1511071,GSM1511072,GSM1511073,GSM1511074,GSM1511075,GSM1511076,GSM1511077,GSM1511078,GSM1511079,GSM1511080,GSM1511081,GSM1511082,GSM1511083,GSM1511084,GSM1511085,GSM1511086,GSM1511087,GSM1511088,GSM1511089,GSM1511090,GSM1511091,GSM1511092,GSM1511093,GSM1511094,GSM1511095,GSM1511096,GSM1511097,GSM1511098,GSM1511099,GSM1511100,GSM1511101,GSM1511102,GSM1511103,GSM1511104,GSM1511105,GSM1511106
|
| 2 |
-
Anxiety_disorder,,0.0,,0.0,1.0,0.0,,,,1.0,,,1.0,,0.0,0.0,1.0,,0.0,0.0,0.0,1.0,,,0.0,,0.0,,0.0,1.0,,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,,0.0,0.0,0.0,0.0,,,0.0,0.0,1.0,,,0.0,1.0,1.0,,1.0,1.0,,1.0,0.0,,,0.0,1.0,,,,,0.0,1.0,1.0,,,0.0,0.0,,,0.0,,,0.0,,,0.0,1.0,0.0,1.0,0.0,,0.0,0.0,,0.0,0.0,,,,0.0,,,,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,,,1.0,,,,0.0,,,1.0,0.0,1.0,,1.0,1.0,,1.0,,,,0.0,1.0,1.0,,1.0,0.0,,,0.0,1.0,1.0,1.0,,,,,1.0,,,,0.0,,,1.0,1.0,,,,0.0,0.0,1.0,,1.0,0.0,,,,0.0,,,0.0,1.0,0.0,,,0.0,1.0,0.0,,,1.0,,1.0,1.0,,0.0,,,,,0.0,1.0,0.0,,1.0,,0.0,1.0,0.0,0.0,,,1.0,0.0,,,1.0,,0.0,0.0,1.0,0.0,0.0,,,0.0,,0.0,1.0,0.0,,,,,1.0,1.0,,1.0,1.0,,1.0,1.0,0.0,1.0,0.0,,1.0,0.0,1.0,,,,1.0,0.0,0.0,,,1.0,1.0,0.0,,1.0,,,,,1.0,0.0,0.0,,,,1.0,,1.0,1.0,0.0,,0.0,0.0,0.0,0.0,,,0.0,,0.0,1.0,,0.0,,1.0,,1.0,0.0,,1.0,1.0,1.0,1.0,0.0,,0.0,0.0,1.0,1.0,0.0,,,0.0,,,0.0,,0.0,0.0,1.0,,,1.0,0.0,,1.0,0.0,,,,1.0,,,,1.0,,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
| 3 |
Age,44.0,59.0,44.0,39.0,64.0,58.0,45.0,37.0,40.0,39.0,57.0,52.0,59.0,57.0,62.0,62.0,55.0,55.0,53.0,47.0,48.0,49.0,35.0,58.0,46.0,54.0,67.0,47.0,51.0,34.0,58.0,58.0,57.0,64.0,55.0,60.0,62.0,41.0,53.0,47.0,44.0,53.0,38.0,54.0,37.0,44.0,73.0,28.0,56.0,34.0,71.0,41.0,51.0,47.0,35.0,45.0,55.0,50.0,50.0,55.0,38.0,57.0,57.0,57.0,48.0,52.0,51.0,42.0,51.0,51.0,65.0,31.0,44.0,50.0,58.0,64.0,49.0,52.0,46.0,53.0,45.0,32.0,50.0,63.0,52.0,54.0,28.0,55.0,59.0,56.0,39.0,46.0,60.0,61.0,45.0,44.0,41.0,56.0,53.0,50.0,56.0,78.0,62.0,47.0,40.0,63.0,55.0,55.0,53.0,34.0,48.0,46.0,58.0,52.0,47.0,62.0,45.0,51.0,38.0,38.0,51.0,59.0,56.0,39.0,29.0,58.0,57.0,45.0,33.0,46.0,35.0,57.0,55.0,66.0,51.0,59.0,61.0,56.0,65.0,37.0,65.0,45.0,45.0,74.0,50.0,39.0,26.0,44.0,49.0,52.0,47.0,37.0,40.0,39.0,40.0,31.0,48.0,59.0,39.0,37.0,59.0,54.0,49.0,57.0,50.0,55.0,50.0,68.0,43.0,67.0,47.0,45.0,56.0,62.0,48.0,39.0,39.0,41.0,63.0,51.0,48.0,50.0,61.0,35.0,50.0,52.0,44.0,45.0,33.0,61.0,58.0,38.0,36.0,50.0,45.0,60.0,55.0,53.0,52.0,47.0,43.0,41.0,47.0,59.0,54.0,52.0,64.0,41.0,46.0,38.0,48.0,43.0,63.0,53.0,60.0,58.0,53.0,52.0,25.0,60.0,27.0,56.0,47.0,40.0,35.0,50.0,56.0,35.0,18.0,52.0,41.0,45.0,54.0,64.0,35.0,48.0,57.0,73.0,46.0,52.0,34.0,19.0,56.0,54.0,46.0,54.0,44.0,19.0,61.0,29.0,48.0,34.0,50.0,39.0,62.0,25.0,18.0,60.0,51.0,58.0,61.0,33.0,50.0,52.0,52.0,59.0,54.0,31.0,60.0,43.0,28.0,34.0,46.0,51.0,43.0,53.0,51.0,48.0,43.0,69.0,48.0,53.0,58.0,57.0,54.0,47.0,60.0,56.0,45.0,35.0,44.0,53.0,43.0,50.0,53.0,69.0,35.0,45.0,57.0,50.0,36.0,33.0,42.0,68.0,57.0,32.0,47.0,54.0,54.0,54.0,41.0,59.0,66.0,29.0,60.0,41.0,53.0,49.0,56.0,59.0,50.0,60.0,53.0,44.0,41.0,56.0,52.0,38.0,47.0,32.0,44.0,39.0,60.0,54.0,50.0,31.0,43.0,58.0,47.0,52.0,44.0,53.0,55.0,38.0,47.0,58.0,30.0,51.0,48.0,54.0,63.0,34.0,36.0,55.0,60.0,53.0,52.0,51.0,36.0,53.0,51.0,55.0,50.0,40.0,43.0,42.0,64.0,71.0,30.0,39.0,60.0,39.0,49.0,56.0,46.0,55.0,34.0,64.0,26.0,59.0,46.0,50.0,20.0,53.0,47.0,46.0,37.0,18.0,37.0,47.0,55.0,41.0,56.0,48.0,51.0,54.0,59.0,53.0,41.0,42.0,42.0,35.0,58.0,41.0,58.0,32.0,31.0,60.0,36.0,78.0,22.0,42.0,35.0,51.0,54.0,39.0,40.0,18.0,47.0,49.0,34.0,49.0,46.0,58.0,44.0,36.0,62.0,59.0,58.0,44.0,52.0,36.0,46.0,51.0,37.0,55.0,63.0,44.0,36.0,51.0,40.0,62.0,41.0,42.0,49.0,63.0,73.0,43.0,49.0,53.0,44.0,30.0,61.0,41.0,41.0,57.0,30.0,50.0,41.0,49.0,37.0,54.0,41.0,37.0,44.0,58.0,39.0,54.0,57.0,36.0,37.0,56.0,37.0,59.0,41.0,48.0,41.0,35.0,52.0,54.0,47.0,57.0,48.0,67.0,55.0,55.0,36.0,55.0,35.0,56.0,48.0,50.0,43.0,59.0,35.0,82.0,51.0,34.0,48.0,58.0,58.0,52.0,59.0,26.0,42.0,55.0,58.0,46.0,44.0,55.0,48.0,50.0,49.0,57.0,30.0,43.0,62.0,42.0,36.0,48.0,38.0,50.0,29.0,53.0,53.0,40.0,36.0,57.0,44.0,41.0,59.0,28.0,35.0,53.0,56.0,44.0,58.0,58.0,57.0,56.0,54.0,59.0,57.0,56.0,56.0,37.0
|
| 4 |
Gender,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
|
|
|
| 1 |
,GSM1510561,GSM1510562,GSM1510563,GSM1510564,GSM1510565,GSM1510566,GSM1510567,GSM1510568,GSM1510569,GSM1510570,GSM1510571,GSM1510572,GSM1510573,GSM1510574,GSM1510575,GSM1510576,GSM1510577,GSM1510578,GSM1510579,GSM1510580,GSM1510581,GSM1510582,GSM1510583,GSM1510584,GSM1510585,GSM1510586,GSM1510587,GSM1510588,GSM1510589,GSM1510590,GSM1510591,GSM1510592,GSM1510593,GSM1510594,GSM1510595,GSM1510596,GSM1510597,GSM1510598,GSM1510599,GSM1510600,GSM1510601,GSM1510602,GSM1510603,GSM1510604,GSM1510605,GSM1510606,GSM1510607,GSM1510608,GSM1510609,GSM1510610,GSM1510611,GSM1510612,GSM1510613,GSM1510614,GSM1510615,GSM1510616,GSM1510617,GSM1510618,GSM1510619,GSM1510620,GSM1510621,GSM1510622,GSM1510623,GSM1510624,GSM1510625,GSM1510626,GSM1510627,GSM1510628,GSM1510629,GSM1510630,GSM1510631,GSM1510632,GSM1510633,GSM1510634,GSM1510635,GSM1510636,GSM1510637,GSM1510638,GSM1510639,GSM1510640,GSM1510641,GSM1510642,GSM1510643,GSM1510644,GSM1510645,GSM1510646,GSM1510647,GSM1510648,GSM1510649,GSM1510650,GSM1510651,GSM1510652,GSM1510653,GSM1510654,GSM1510655,GSM1510656,GSM1510657,GSM1510658,GSM1510659,GSM1510660,GSM1510661,GSM1510662,GSM1510663,GSM1510664,GSM1510665,GSM1510666,GSM1510667,GSM1510668,GSM1510669,GSM1510670,GSM1510671,GSM1510672,GSM1510673,GSM1510674,GSM1510675,GSM1510676,GSM1510677,GSM1510678,GSM1510679,GSM1510680,GSM1510681,GSM1510682,GSM1510683,GSM1510684,GSM1510685,GSM1510686,GSM1510687,GSM1510688,GSM1510689,GSM1510690,GSM1510691,GSM1510692,GSM1510693,GSM1510694,GSM1510695,GSM1510696,GSM1510697,GSM1510698,GSM1510699,GSM1510700,GSM1510701,GSM1510702,GSM1510703,GSM1510704,GSM1510705,GSM1510706,GSM1510707,GSM1510708,GSM1510709,GSM1510710,GSM1510711,GSM1510712,GSM1510713,GSM1510714,GSM1510715,GSM1510716,GSM1510717,GSM1510718,GSM1510719,GSM1510720,GSM1510721,GSM1510722,GSM1510723,GSM1510724,GSM1510725,GSM1510726,GSM1510727,GSM1510728,GSM1510729,GSM1510730,GSM1510731,GSM1510732,GSM1510733,GSM1510734,GSM1510735,GSM1510736,GSM1510737,GSM1510738,GSM1510739,GSM1510740,GSM1510741,GSM1510742,GSM1510743,GSM1510744,GSM1510745,GSM1510746,GSM1510747,GSM1510748,GSM1510749,GSM1510750,GSM1510751,GSM1510752,GSM1510753,GSM1510754,GSM1510755,GSM1510756,GSM1510757,GSM1510758,GSM1510759,GSM1510760,GSM1510761,GSM1510762,GSM1510763,GSM1510764,GSM1510765,GSM1510766,GSM1510767,GSM1510768,GSM1510769,GSM1510770,GSM1510771,GSM1510772,GSM1510773,GSM1510774,GSM1510775,GSM1510776,GSM1510777,GSM1510778,GSM1510779,GSM1510780,GSM1510781,GSM1510782,GSM1510783,GSM1510784,GSM1510785,GSM1510786,GSM1510787,GSM1510788,GSM1510789,GSM1510790,GSM1510791,GSM1510792,GSM1510793,GSM1510794,GSM1510795,GSM1510796,GSM1510797,GSM1510798,GSM1510799,GSM1510800,GSM1510801,GSM1510802,GSM1510803,GSM1510804,GSM1510805,GSM1510806,GSM1510807,GSM1510808,GSM1510809,GSM1510810,GSM1510811,GSM1510812,GSM1510813,GSM1510814,GSM1510815,GSM1510816,GSM1510817,GSM1510818,GSM1510819,GSM1510820,GSM1510821,GSM1510822,GSM1510823,GSM1510824,GSM1510825,GSM1510826,GSM1510827,GSM1510828,GSM1510829,GSM1510830,GSM1510831,GSM1510832,GSM1510833,GSM1510834,GSM1510835,GSM1510836,GSM1510837,GSM1510838,GSM1510839,GSM1510840,GSM1510841,GSM1510842,GSM1510843,GSM1510844,GSM1510845,GSM1510846,GSM1510847,GSM1510848,GSM1510849,GSM1510850,GSM1510851,GSM1510852,GSM1510853,GSM1510854,GSM1510855,GSM1510856,GSM1510857,GSM1510858,GSM1510859,GSM1510860,GSM1510861,GSM1510862,GSM1510863,GSM1510864,GSM1510865,GSM1510866,GSM1510867,GSM1510868,GSM1510869,GSM1510870,GSM1510871,GSM1510872,GSM1510873,GSM1510874,GSM1510875,GSM1510876,GSM1510877,GSM1510878,GSM1510879,GSM1510880,GSM1510881,GSM1510882,GSM1510883,GSM1510884,GSM1510885,GSM1510886,GSM1510887,GSM1510888,GSM1510889,GSM1510890,GSM1510891,GSM1510892,GSM1510893,GSM1510894,GSM1510895,GSM1510896,GSM1510897,GSM1510898,GSM1510899,GSM1510900,GSM1510901,GSM1510902,GSM1510903,GSM1510904,GSM1510905,GSM1510906,GSM1510907,GSM1510908,GSM1510909,GSM1510910,GSM1510911,GSM1510912,GSM1510913,GSM1510914,GSM1510915,GSM1510916,GSM1510917,GSM1510918,GSM1510919,GSM1510920,GSM1510921,GSM1510922,GSM1510923,GSM1510924,GSM1510925,GSM1510926,GSM1510927,GSM1510928,GSM1510929,GSM1510930,GSM1510931,GSM1510932,GSM1510933,GSM1510934,GSM1510935,GSM1510936,GSM1510937,GSM1510938,GSM1510939,GSM1510940,GSM1510941,GSM1510942,GSM1510943,GSM1510944,GSM1510945,GSM1510946,GSM1510947,GSM1510948,GSM1510949,GSM1510950,GSM1510951,GSM1510952,GSM1510953,GSM1510954,GSM1510955,GSM1510956,GSM1510957,GSM1510958,GSM1510959,GSM1510960,GSM1510961,GSM1510962,GSM1510963,GSM1510964,GSM1510965,GSM1510966,GSM1510967,GSM1510968,GSM1510969,GSM1510970,GSM1510971,GSM1510972,GSM1510973,GSM1510974,GSM1510975,GSM1510976,GSM1510977,GSM1510978,GSM1510979,GSM1510980,GSM1510981,GSM1510982,GSM1510983,GSM1510984,GSM1510985,GSM1510986,GSM1510987,GSM1510988,GSM1510989,GSM1510990,GSM1510991,GSM1510992,GSM1510993,GSM1510994,GSM1510995,GSM1510996,GSM1510997,GSM1510998,GSM1510999,GSM1511000,GSM1511001,GSM1511002,GSM1511003,GSM1511004,GSM1511005,GSM1511006,GSM1511007,GSM1511008,GSM1511009,GSM1511010,GSM1511011,GSM1511012,GSM1511013,GSM1511014,GSM1511015,GSM1511016,GSM1511017,GSM1511018,GSM1511019,GSM1511020,GSM1511021,GSM1511022,GSM1511023,GSM1511024,GSM1511025,GSM1511026,GSM1511027,GSM1511028,GSM1511029,GSM1511030,GSM1511031,GSM1511032,GSM1511033,GSM1511034,GSM1511035,GSM1511036,GSM1511037,GSM1511038,GSM1511039,GSM1511040,GSM1511041,GSM1511042,GSM1511043,GSM1511044,GSM1511045,GSM1511046,GSM1511047,GSM1511048,GSM1511049,GSM1511050,GSM1511051,GSM1511052,GSM1511053,GSM1511054,GSM1511055,GSM1511056,GSM1511057,GSM1511058,GSM1511059,GSM1511060,GSM1511061,GSM1511062,GSM1511063,GSM1511064,GSM1511065,GSM1511066,GSM1511067,GSM1511068,GSM1511069,GSM1511070,GSM1511071,GSM1511072,GSM1511073,GSM1511074,GSM1511075,GSM1511076,GSM1511077,GSM1511078,GSM1511079,GSM1511080,GSM1511081,GSM1511082,GSM1511083,GSM1511084,GSM1511085,GSM1511086,GSM1511087,GSM1511088,GSM1511089,GSM1511090,GSM1511091,GSM1511092,GSM1511093,GSM1511094,GSM1511095,GSM1511096,GSM1511097,GSM1511098,GSM1511099,GSM1511100,GSM1511101,GSM1511102,GSM1511103,GSM1511104,GSM1511105,GSM1511106
|
| 2 |
+
Anxiety_disorder,,0.0,,0.0,1.0,0.0,,,,1.0,,,1.0,,0.0,0.0,1.0,,0.0,0.0,0.0,1.0,,,0.0,,0.0,,0.0,1.0,,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,,0.0,0.0,0.0,0.0,,,0.0,0.0,1.0,,,0.0,1.0,1.0,,1.0,1.0,,1.0,0.0,,,0.0,1.0,,,,,0.0,1.0,1.0,,,0.0,0.0,,,0.0,,,0.0,,,0.0,1.0,0.0,1.0,0.0,,0.0,0.0,,0.0,0.0,,,,0.0,,,,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,,,1.0,,,,0.0,,,1.0,0.0,1.0,,1.0,1.0,,1.0,,,,0.0,1.0,1.0,,1.0,0.0,,,0.0,1.0,1.0,1.0,,,,,1.0,,,,0.0,,,1.0,1.0,,,,0.0,0.0,1.0,,1.0,0.0,,,,0.0,,,0.0,1.0,0.0,,,0.0,1.0,0.0,,,1.0,,1.0,1.0,,0.0,,,,,0.0,1.0,0.0,,1.0,,0.0,1.0,0.0,0.0,,,1.0,0.0,,,1.0,,0.0,0.0,1.0,0.0,0.0,,,0.0,,0.0,1.0,0.0,,,,,1.0,1.0,,1.0,1.0,,1.0,1.0,0.0,1.0,0.0,,1.0,0.0,1.0,,,,1.0,0.0,0.0,,,1.0,1.0,0.0,,1.0,,,,,1.0,0.0,0.0,,,,1.0,,1.0,1.0,0.0,,0.0,0.0,0.0,0.0,,,0.0,,0.0,1.0,,0.0,,1.0,,1.0,0.0,,1.0,1.0,1.0,1.0,0.0,,0.0,0.0,1.0,1.0,0.0,,,0.0,,,0.0,,0.0,0.0,1.0,,,1.0,0.0,,1.0,0.0,,,,1.0,,,,1.0,,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,,,,1.0,0.0,0.0,1.0,1.0,,1.0,0.0,,1.0,,0.0,1.0,0.0,0.0,0.0,0.0,1.0,,,1.0,,,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,,0.0,0.0,,1.0,0.0,1.0,,,,,1.0,1.0,0.0,1.0,0.0,0.0,0.0,,0.0,,,,,,1.0,0.0,1.0,1.0,0.0,,,0.0,0.0,1.0,,,0.0,1.0,1.0,,0.0,0.0,0.0,,1.0,0.0,0.0,0.0,,0.0,1.0,1.0,,0.0,0.0,1.0,,,,1.0,0.0,0.0,,0.0,0.0,,0.0,1.0,0.0,,,1.0,0.0,1.0,,1.0,,0.0,,,1.0,1.0,0.0,,0.0,1.0,0.0,1.0,,,0.0,1.0,0.0,0.0,,,1.0,0.0,0.0,0.0,1.0,0.0,1.0,,,,0.0,1.0,,0.0,0.0,1.0,0.0,0.0,,0.0,0.0,0.0,,1.0,1.0,1.0,0.0,0.0,0.0,,,0.0,,,1.0,,,0.0,,1.0,0.0,1.0,,,0.0,0.0,0.0,0.0,1.0,,1.0,,,0.0,0.0,,,1.0,1.0,0.0,,1.0,,1.0,1.0,1.0,,1.0
|
| 3 |
Age,44.0,59.0,44.0,39.0,64.0,58.0,45.0,37.0,40.0,39.0,57.0,52.0,59.0,57.0,62.0,62.0,55.0,55.0,53.0,47.0,48.0,49.0,35.0,58.0,46.0,54.0,67.0,47.0,51.0,34.0,58.0,58.0,57.0,64.0,55.0,60.0,62.0,41.0,53.0,47.0,44.0,53.0,38.0,54.0,37.0,44.0,73.0,28.0,56.0,34.0,71.0,41.0,51.0,47.0,35.0,45.0,55.0,50.0,50.0,55.0,38.0,57.0,57.0,57.0,48.0,52.0,51.0,42.0,51.0,51.0,65.0,31.0,44.0,50.0,58.0,64.0,49.0,52.0,46.0,53.0,45.0,32.0,50.0,63.0,52.0,54.0,28.0,55.0,59.0,56.0,39.0,46.0,60.0,61.0,45.0,44.0,41.0,56.0,53.0,50.0,56.0,78.0,62.0,47.0,40.0,63.0,55.0,55.0,53.0,34.0,48.0,46.0,58.0,52.0,47.0,62.0,45.0,51.0,38.0,38.0,51.0,59.0,56.0,39.0,29.0,58.0,57.0,45.0,33.0,46.0,35.0,57.0,55.0,66.0,51.0,59.0,61.0,56.0,65.0,37.0,65.0,45.0,45.0,74.0,50.0,39.0,26.0,44.0,49.0,52.0,47.0,37.0,40.0,39.0,40.0,31.0,48.0,59.0,39.0,37.0,59.0,54.0,49.0,57.0,50.0,55.0,50.0,68.0,43.0,67.0,47.0,45.0,56.0,62.0,48.0,39.0,39.0,41.0,63.0,51.0,48.0,50.0,61.0,35.0,50.0,52.0,44.0,45.0,33.0,61.0,58.0,38.0,36.0,50.0,45.0,60.0,55.0,53.0,52.0,47.0,43.0,41.0,47.0,59.0,54.0,52.0,64.0,41.0,46.0,38.0,48.0,43.0,63.0,53.0,60.0,58.0,53.0,52.0,25.0,60.0,27.0,56.0,47.0,40.0,35.0,50.0,56.0,35.0,18.0,52.0,41.0,45.0,54.0,64.0,35.0,48.0,57.0,73.0,46.0,52.0,34.0,19.0,56.0,54.0,46.0,54.0,44.0,19.0,61.0,29.0,48.0,34.0,50.0,39.0,62.0,25.0,18.0,60.0,51.0,58.0,61.0,33.0,50.0,52.0,52.0,59.0,54.0,31.0,60.0,43.0,28.0,34.0,46.0,51.0,43.0,53.0,51.0,48.0,43.0,69.0,48.0,53.0,58.0,57.0,54.0,47.0,60.0,56.0,45.0,35.0,44.0,53.0,43.0,50.0,53.0,69.0,35.0,45.0,57.0,50.0,36.0,33.0,42.0,68.0,57.0,32.0,47.0,54.0,54.0,54.0,41.0,59.0,66.0,29.0,60.0,41.0,53.0,49.0,56.0,59.0,50.0,60.0,53.0,44.0,41.0,56.0,52.0,38.0,47.0,32.0,44.0,39.0,60.0,54.0,50.0,31.0,43.0,58.0,47.0,52.0,44.0,53.0,55.0,38.0,47.0,58.0,30.0,51.0,48.0,54.0,63.0,34.0,36.0,55.0,60.0,53.0,52.0,51.0,36.0,53.0,51.0,55.0,50.0,40.0,43.0,42.0,64.0,71.0,30.0,39.0,60.0,39.0,49.0,56.0,46.0,55.0,34.0,64.0,26.0,59.0,46.0,50.0,20.0,53.0,47.0,46.0,37.0,18.0,37.0,47.0,55.0,41.0,56.0,48.0,51.0,54.0,59.0,53.0,41.0,42.0,42.0,35.0,58.0,41.0,58.0,32.0,31.0,60.0,36.0,78.0,22.0,42.0,35.0,51.0,54.0,39.0,40.0,18.0,47.0,49.0,34.0,49.0,46.0,58.0,44.0,36.0,62.0,59.0,58.0,44.0,52.0,36.0,46.0,51.0,37.0,55.0,63.0,44.0,36.0,51.0,40.0,62.0,41.0,42.0,49.0,63.0,73.0,43.0,49.0,53.0,44.0,30.0,61.0,41.0,41.0,57.0,30.0,50.0,41.0,49.0,37.0,54.0,41.0,37.0,44.0,58.0,39.0,54.0,57.0,36.0,37.0,56.0,37.0,59.0,41.0,48.0,41.0,35.0,52.0,54.0,47.0,57.0,48.0,67.0,55.0,55.0,36.0,55.0,35.0,56.0,48.0,50.0,43.0,59.0,35.0,82.0,51.0,34.0,48.0,58.0,58.0,52.0,59.0,26.0,42.0,55.0,58.0,46.0,44.0,55.0,48.0,50.0,49.0,57.0,30.0,43.0,62.0,42.0,36.0,48.0,38.0,50.0,29.0,53.0,53.0,40.0,36.0,57.0,44.0,41.0,59.0,28.0,35.0,53.0,56.0,44.0,58.0,58.0,57.0,56.0,54.0,59.0,57.0,56.0,56.0,37.0
|
| 4 |
Gender,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
output/preprocess/Anxiety_disorder/clinical_data/GSE68526.csv
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
,
|
| 2 |
-
Anxiety_disorder,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
| 3 |
Age,79.0,79.0,76.0,70.0,65.0,64.0,75.0,70.0,66.0,66.0,93.0,69.0,69.0,67.0,77.0,74.0,73.0,80.0,68.0,83.0,64.0,87.0,87.0,83.0,81.0,84.0,55.0,68.0,62.0,58.0,81.0,76.0,84.0,60.0,87.0,56.0,86.0,81.0,60.0,78.0,78.0,75.0,48.0,82.0,76.0,95.0,69.0,62.0,69.0,75.0,87.0,68.0,73.0,84.0,71.0,85.0,76.0,73.0,76.0,70.0,68.0,64.0,69.0,82.0,75.0,73.0,55.0,61.0,82.0,77.0,70.0,75.0,57.0,79.0,65.0,69.0,62.0,71.0,84.0,74.0,56.0,81.0,94.0,61.0,58.0,73.0,79.0,74.0,79.0,71.0,71.0,88.0,64.0,57.0,59.0,73.0,62.0,51.0,82.0,72.0,82.0,77.0,80.0,69.0,84.0,67.0,81.0,91.0,76.0,62.0,68.0,83.0,89.0,85.0,88.0,87.0,81.0,72.0,66.0,71.0,73.0
|
| 4 |
-
Gender,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
|
|
|
| 1 |
+
,GSM1674313,GSM1674314,GSM1674315,GSM1674316,GSM1674317,GSM1674318,GSM1674319,GSM1674320,GSM1674321,GSM1674322,GSM1674323,GSM1674324,GSM1674325,GSM1674326,GSM1674327,GSM1674328,GSM1674329,GSM1674330,GSM1674331,GSM1674332,GSM1674333,GSM1674334,GSM1674335,GSM1674336,GSM1674337,GSM1674338,GSM1674339,GSM1674340,GSM1674341,GSM1674342,GSM1674343,GSM1674344,GSM1674345,GSM1674346,GSM1674347,GSM1674348,GSM1674349,GSM1674350,GSM1674351,GSM1674352,GSM1674353,GSM1674354,GSM1674355,GSM1674356,GSM1674357,GSM1674358,GSM1674359,GSM1674360,GSM1674361,GSM1674362,GSM1674363,GSM1674364,GSM1674365,GSM1674366,GSM1674367,GSM1674368,GSM1674369,GSM1674370,GSM1674371,GSM1674372,GSM1674373,GSM1674374,GSM1674375,GSM1674376,GSM1674377,GSM1674378,GSM1674379,GSM1674380,GSM1674381,GSM1674382,GSM1674383,GSM1674384,GSM1674385,GSM1674386,GSM1674387,GSM1674388,GSM1674389,GSM1674390,GSM1674391,GSM1674392,GSM1674393,GSM1674394,GSM1674395,GSM1674396,GSM1674397,GSM1674398,GSM1674399,GSM1674400,GSM1674401,GSM1674402,GSM1674403,GSM1674404,GSM1674405,GSM1674406,GSM1674407,GSM1674408,GSM1674409,GSM1674410,GSM1674411,GSM1674412,GSM1674413,GSM1674414,GSM1674415,GSM1674416,GSM1674417,GSM1674418,GSM1674419,GSM1674420,GSM1674421,GSM1674422,GSM1674423,GSM1674424,GSM1674425,GSM1674426,GSM1674427,GSM1674428,GSM1674429,GSM1674430,GSM1674431,GSM1674432,GSM1674433
|
| 2 |
+
Anxiety_disorder,1.0,1.0,1.8,1.2,1.4,1.2,1.2,1.0,1.4,1.2,1.8,2.2,1.4,1.8,1.0,1.0,1.0,1.0,1.2,1.0,1.2,1.6,,1.0,1.8,2.8,1.2,2.2,1.8,2.0,,1.6,,1.0,,2.2,1.6,1.4,2.0,1.8,1.0,1.4,,1.4,1.4,1.2,1.0,1.4,1.6,1.0,1.4,1.0,1.4,1.0,1.4,1.2,1.2,1.4,1.0,1.4,,,2.0,1.0,2.4,1.0,,1.2,1.4,,1.6,2.0,1.4,1.0,1.8,2.0,2.0,1.4,3.2,2.0,1.0,1.0,2.6,2.4,,1.0,1.2,1.6,,2.0,1.6,1.4,2.2,1.0,1.4,1.4,1.8,1.0,2.2,1.4,3.2,2.0,2.4,1.0,2.4,1.6,1.0,,1.4,1.0,,1.0,,1.0,1.0,1.0,1.0,1.4,1.8,1.0,1.4
|
| 3 |
Age,79.0,79.0,76.0,70.0,65.0,64.0,75.0,70.0,66.0,66.0,93.0,69.0,69.0,67.0,77.0,74.0,73.0,80.0,68.0,83.0,64.0,87.0,87.0,83.0,81.0,84.0,55.0,68.0,62.0,58.0,81.0,76.0,84.0,60.0,87.0,56.0,86.0,81.0,60.0,78.0,78.0,75.0,48.0,82.0,76.0,95.0,69.0,62.0,69.0,75.0,87.0,68.0,73.0,84.0,71.0,85.0,76.0,73.0,76.0,70.0,68.0,64.0,69.0,82.0,75.0,73.0,55.0,61.0,82.0,77.0,70.0,75.0,57.0,79.0,65.0,69.0,62.0,71.0,84.0,74.0,56.0,81.0,94.0,61.0,58.0,73.0,79.0,74.0,79.0,71.0,71.0,88.0,64.0,57.0,59.0,73.0,62.0,51.0,82.0,72.0,82.0,77.0,80.0,69.0,84.0,67.0,81.0,91.0,76.0,62.0,68.0,83.0,89.0,85.0,88.0,87.0,81.0,72.0,66.0,71.0,73.0
|
| 4 |
+
Gender,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0
|
output/preprocess/Anxiety_disorder/code/GSE119995.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Anxiety_disorder"
|
| 6 |
+
cohort = "GSE119995"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Anxiety_disorder"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Anxiety_disorder/GSE119995"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Anxiety_disorder/GSE119995.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Anxiety_disorder/gene_data/GSE119995.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Anxiety_disorder/clinical_data/GSE119995.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Anxiety_disorder/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
|
| 41 |
+
# 1) Gene expression data availability (plasma mRNA expression -> suitable)
|
| 42 |
+
is_gene_available = True
|
| 43 |
+
|
| 44 |
+
# 2) Variable availability based on provided Sample Characteristics
|
| 45 |
+
# Trait (Anxiety_disorder): all samples are panic disorder patients -> constant -> not usable
|
| 46 |
+
trait_row = None
|
| 47 |
+
|
| 48 |
+
# Age: not present in provided characteristics
|
| 49 |
+
age_row = None
|
| 50 |
+
|
| 51 |
+
# Gender: available
|
| 52 |
+
gender_row = 2
|
| 53 |
+
|
| 54 |
+
# 2.2) Converters
|
| 55 |
+
def _after_colon(val):
|
| 56 |
+
if val is None:
|
| 57 |
+
return None
|
| 58 |
+
if isinstance(val, (int, float)):
|
| 59 |
+
return val
|
| 60 |
+
s = str(val)
|
| 61 |
+
if ':' in s:
|
| 62 |
+
s = s.split(':', 1)[1]
|
| 63 |
+
return s.strip()
|
| 64 |
+
|
| 65 |
+
def convert_trait(x):
|
| 66 |
+
v = _after_colon(x)
|
| 67 |
+
if v is None:
|
| 68 |
+
return None
|
| 69 |
+
sv = str(v).strip().lower()
|
| 70 |
+
# Map common control terms to 0
|
| 71 |
+
control_terms = ['control', 'healthy', 'normal', 'no anxiety', 'no panic', 'non-anxious', 'non anxious']
|
| 72 |
+
if any(term in sv for term in control_terms):
|
| 73 |
+
return 0
|
| 74 |
+
# Map anxiety-related conditions to 1
|
| 75 |
+
case_terms = ['panic disorder', 'panic-disorder', 'pd', 'anxiety', 'anxiety disorder', 'gad', 'phobia', 'agoraphobia']
|
| 76 |
+
if any(term in sv for term in case_terms):
|
| 77 |
+
return 1
|
| 78 |
+
return None
|
| 79 |
+
|
| 80 |
+
def convert_age(x):
|
| 81 |
+
v = _after_colon(x)
|
| 82 |
+
if v is None:
|
| 83 |
+
return None
|
| 84 |
+
sv = str(v).strip().lower()
|
| 85 |
+
if sv in {'na', 'n/a', 'nan', 'none', 'unknown', 'not determined', 'not available', ''}:
|
| 86 |
+
return None
|
| 87 |
+
m = re.search(r'[-+]?\d*\.?\d+', sv)
|
| 88 |
+
if not m:
|
| 89 |
+
return None
|
| 90 |
+
try:
|
| 91 |
+
age = float(m.group())
|
| 92 |
+
if 0 <= age <= 120:
|
| 93 |
+
return age
|
| 94 |
+
except Exception:
|
| 95 |
+
pass
|
| 96 |
+
return None
|
| 97 |
+
|
| 98 |
+
def convert_gender(x):
|
| 99 |
+
v = _after_colon(x)
|
| 100 |
+
if v is None:
|
| 101 |
+
return None
|
| 102 |
+
sv = str(v).strip().lower()
|
| 103 |
+
if sv in {'female', 'f', 'woman', 'women'}:
|
| 104 |
+
return 0
|
| 105 |
+
if sv in {'male', 'm', 'man', 'men'}:
|
| 106 |
+
return 1
|
| 107 |
+
if sv in {'unknown', 'not determined', 'na', 'n/a', ''}:
|
| 108 |
+
return None
|
| 109 |
+
return None
|
| 110 |
+
|
| 111 |
+
# 3) Save initial metadata (trait availability determined by trait_row is None)
|
| 112 |
+
is_trait_available = trait_row is not None
|
| 113 |
+
_ = validate_and_save_cohort_info(
|
| 114 |
+
is_final=False,
|
| 115 |
+
cohort=cohort,
|
| 116 |
+
info_path=json_path,
|
| 117 |
+
is_gene_available=is_gene_available,
|
| 118 |
+
is_trait_available=is_trait_available
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
# 4) Clinical Feature Extraction (skip because trait_row is None)
|
| 122 |
+
# If trait_row were available:
|
| 123 |
+
if trait_row is not None:
|
| 124 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 125 |
+
clinical_df=clinical_data,
|
| 126 |
+
trait=trait,
|
| 127 |
+
trait_row=trait_row,
|
| 128 |
+
convert_trait=convert_trait,
|
| 129 |
+
age_row=age_row,
|
| 130 |
+
convert_age=convert_age,
|
| 131 |
+
gender_row=gender_row,
|
| 132 |
+
convert_gender=convert_gender
|
| 133 |
+
)
|
| 134 |
+
preview = preview_df(selected_clinical_df, n=5)
|
| 135 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 136 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
output/preprocess/Anxiety_disorder/code/GSE60190.py
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Anxiety_disorder"
|
| 6 |
+
cohort = "GSE60190"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Anxiety_disorder"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Anxiety_disorder/GSE60190"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Anxiety_disorder/GSE60190.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Anxiety_disorder/gene_data/GSE60190.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Anxiety_disorder/clinical_data/GSE60190.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Anxiety_disorder/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import pandas as pd
|
| 41 |
+
|
| 42 |
+
# 1) Gene expression data availability
|
| 43 |
+
is_gene_available = True # Illumina HumanHT-12 v3 microarray gene expression platform
|
| 44 |
+
|
| 45 |
+
# 2) Variable availability and conversion functions
|
| 46 |
+
|
| 47 |
+
# Trait: Anxiety_disorder
|
| 48 |
+
# Use key 1 ('ocd': Control, OCD, ED). Map OCD to 1; Control and ED to 0.
|
| 49 |
+
trait_row = 1
|
| 50 |
+
def convert_trait(x):
|
| 51 |
+
if x is None:
|
| 52 |
+
return None
|
| 53 |
+
try:
|
| 54 |
+
val = str(x)
|
| 55 |
+
if ':' in val:
|
| 56 |
+
val = val.split(':', 1)[1]
|
| 57 |
+
val = val.strip().lower()
|
| 58 |
+
except Exception:
|
| 59 |
+
return None
|
| 60 |
+
if val in {'ocd', 'obsessive-compulsive disorder', 'obsessive compulsive disorder'}:
|
| 61 |
+
return 1
|
| 62 |
+
if val in {'control', 'ed', 'eating disorder', 'healthy'}:
|
| 63 |
+
return 0
|
| 64 |
+
# For unexpected categories, return None
|
| 65 |
+
return None
|
| 66 |
+
|
| 67 |
+
# Age: key 5 with continuous values
|
| 68 |
+
age_row = 5
|
| 69 |
+
def convert_age(x):
|
| 70 |
+
if x is None:
|
| 71 |
+
return None
|
| 72 |
+
try:
|
| 73 |
+
val = str(x)
|
| 74 |
+
if ':' in val:
|
| 75 |
+
val = val.split(':', 1)[1]
|
| 76 |
+
val = val.strip()
|
| 77 |
+
if val == '' or val.lower() in {'na', 'nan', 'none', 'unknown'}:
|
| 78 |
+
return None
|
| 79 |
+
return float(val)
|
| 80 |
+
except Exception:
|
| 81 |
+
return None
|
| 82 |
+
|
| 83 |
+
# Gender: key 7 ('Sex: M'/'Sex: F')
|
| 84 |
+
gender_row = 7
|
| 85 |
+
def convert_gender(x):
|
| 86 |
+
if x is None:
|
| 87 |
+
return None
|
| 88 |
+
try:
|
| 89 |
+
val = str(x)
|
| 90 |
+
if ':' in val:
|
| 91 |
+
val = val.split(':', 1)[1]
|
| 92 |
+
val = val.strip().lower()
|
| 93 |
+
except Exception:
|
| 94 |
+
return None
|
| 95 |
+
if val in {'f', 'female', 'woman', 'women'}:
|
| 96 |
+
return 0
|
| 97 |
+
if val in {'m', 'male', 'man', 'men'}:
|
| 98 |
+
return 1
|
| 99 |
+
return None
|
| 100 |
+
|
| 101 |
+
# 3) Initial metadata saving
|
| 102 |
+
is_trait_available = trait_row is not None
|
| 103 |
+
_ = validate_and_save_cohort_info(
|
| 104 |
+
is_final=False,
|
| 105 |
+
cohort=cohort,
|
| 106 |
+
info_path=json_path,
|
| 107 |
+
is_gene_available=is_gene_available,
|
| 108 |
+
is_trait_available=is_trait_available
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
# 4) Clinical feature extraction (only if trait available)
|
| 112 |
+
if trait_row is not None:
|
| 113 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 114 |
+
clinical_df=clinical_data,
|
| 115 |
+
trait=trait,
|
| 116 |
+
trait_row=trait_row,
|
| 117 |
+
convert_trait=convert_trait,
|
| 118 |
+
age_row=age_row,
|
| 119 |
+
convert_age=convert_age,
|
| 120 |
+
gender_row=gender_row,
|
| 121 |
+
convert_gender=convert_gender
|
| 122 |
+
)
|
| 123 |
+
clinical_preview = preview_df(selected_clinical_df, n=5)
|
| 124 |
+
print("Clinical data preview:", clinical_preview)
|
| 125 |
+
|
| 126 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 127 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=True)
|
| 128 |
+
|
| 129 |
+
# Step 3: Gene Data Extraction
|
| 130 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 131 |
+
gene_data = get_genetic_data(matrix_file)
|
| 132 |
+
|
| 133 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 134 |
+
print(gene_data.index[:20])
|
| 135 |
+
|
| 136 |
+
# Step 4: Gene Identifier Review
|
| 137 |
+
requires_gene_mapping = True
|
| 138 |
+
print(f"requires_gene_mapping = {requires_gene_mapping}")
|
| 139 |
+
|
| 140 |
+
# Step 5: Gene Annotation
|
| 141 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 142 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 143 |
+
|
| 144 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 145 |
+
print("Gene annotation preview:")
|
| 146 |
+
print(preview_df(gene_annotation))
|
| 147 |
+
|
| 148 |
+
# Step 6: Gene Identifier Mapping
|
| 149 |
+
# Decide columns for mapping based on annotation preview:
|
| 150 |
+
# - Probe ID column: 'ID' (e.g., ILMN_1343291)
|
| 151 |
+
# - Gene symbol column: 'Symbol' (official HGNC symbols when available)
|
| 152 |
+
|
| 153 |
+
# 1-2) Build mapping dataframe from annotation
|
| 154 |
+
gene_mapping = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Symbol')
|
| 155 |
+
|
| 156 |
+
# 3) Apply mapping to convert probe-level data to gene-level expression
|
| 157 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=gene_mapping)
|
| 158 |
+
|
| 159 |
+
# Step 7: Data Normalization and Linking
|
| 160 |
+
import os
|
| 161 |
+
|
| 162 |
+
# 1. Normalize gene symbols and save gene expression data
|
| 163 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 164 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 165 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 166 |
+
|
| 167 |
+
# 2. Link clinical and genetic data
|
| 168 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 169 |
+
|
| 170 |
+
# 3. Handle missing values
|
| 171 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 172 |
+
|
| 173 |
+
# 4. Assess bias and remove biased demographic features
|
| 174 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 175 |
+
|
| 176 |
+
# 5. Final validation and save cohort info
|
| 177 |
+
is_gene_available = normalized_gene_data.shape[0] > 0
|
| 178 |
+
is_trait_available = (trait in linked_data.columns)
|
| 179 |
+
|
| 180 |
+
is_usable = validate_and_save_cohort_info(
|
| 181 |
+
is_final=True,
|
| 182 |
+
cohort=cohort,
|
| 183 |
+
info_path=json_path,
|
| 184 |
+
is_gene_available=is_gene_available,
|
| 185 |
+
is_trait_available=is_trait_available,
|
| 186 |
+
is_biased=is_trait_biased,
|
| 187 |
+
df=unbiased_linked_data,
|
| 188 |
+
note="INFO: Illumina HumanHT-12 v3 platform; trait defined as OCD vs non-OCD (Control/ED)."
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
# 6. Save linked data if usable
|
| 192 |
+
if is_usable:
|
| 193 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 194 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Anxiety_disorder/code/GSE60491.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Anxiety_disorder"
|
| 6 |
+
cohort = "GSE60491"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Anxiety_disorder"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Anxiety_disorder/GSE60491"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Anxiety_disorder/GSE60491.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Anxiety_disorder/gene_data/GSE60491.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Anxiety_disorder/clinical_data/GSE60491.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Anxiety_disorder/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import pandas as pd
|
| 40 |
+
import numpy as np
|
| 41 |
+
|
| 42 |
+
# 1) Gene expression availability (mRNA expression per background info)
|
| 43 |
+
is_gene_available = True
|
| 44 |
+
|
| 45 |
+
# 2) Variable availability
|
| 46 |
+
# Trait is Anxiety_disorder, but no diagnostic or proxy field is present in the sample characteristics.
|
| 47 |
+
trait_row = None
|
| 48 |
+
|
| 49 |
+
# Age and gender availability based on the provided dictionary
|
| 50 |
+
age_row = 0
|
| 51 |
+
gender_row = 1
|
| 52 |
+
|
| 53 |
+
# 2.2) Conversion functions
|
| 54 |
+
def _extract_value_after_colon(x: str):
|
| 55 |
+
if x is None:
|
| 56 |
+
return None
|
| 57 |
+
if isinstance(x, str):
|
| 58 |
+
parts = x.split(":", 1)
|
| 59 |
+
val = parts[1].strip() if len(parts) > 1 else x.strip()
|
| 60 |
+
return val
|
| 61 |
+
return x
|
| 62 |
+
|
| 63 |
+
def convert_trait(x):
|
| 64 |
+
# No trait available for Anxiety_disorder in this dataset
|
| 65 |
+
return None
|
| 66 |
+
|
| 67 |
+
def convert_age(x):
|
| 68 |
+
v = _extract_value_after_colon(x)
|
| 69 |
+
if v is None:
|
| 70 |
+
return None
|
| 71 |
+
v = v.strip().lower()
|
| 72 |
+
if v in {"na", "n/a", "none", "missing", ""}:
|
| 73 |
+
return None
|
| 74 |
+
try:
|
| 75 |
+
return float(v)
|
| 76 |
+
except Exception:
|
| 77 |
+
return None
|
| 78 |
+
|
| 79 |
+
def convert_gender(x):
|
| 80 |
+
# Row 1 contains 'male: 0/1' where 1=male, 0=female
|
| 81 |
+
v = _extract_value_after_colon(x)
|
| 82 |
+
if v is None:
|
| 83 |
+
return None
|
| 84 |
+
v = str(v).strip().lower()
|
| 85 |
+
if v in {"na", "n/a", "none", "missing", ""}:
|
| 86 |
+
return None
|
| 87 |
+
# Expect numeric 0/1
|
| 88 |
+
try:
|
| 89 |
+
iv = int(float(v))
|
| 90 |
+
if iv == 1:
|
| 91 |
+
return 1 # male
|
| 92 |
+
if iv == 0:
|
| 93 |
+
return 0 # female
|
| 94 |
+
except Exception:
|
| 95 |
+
pass
|
| 96 |
+
# Fallback if textual (not expected here)
|
| 97 |
+
if v in {"male", "m"}:
|
| 98 |
+
return 1
|
| 99 |
+
if v in {"female", "f"}:
|
| 100 |
+
return 0
|
| 101 |
+
return None
|
| 102 |
+
|
| 103 |
+
# 3) Save metadata (initial filtering)
|
| 104 |
+
is_trait_available = trait_row is not None
|
| 105 |
+
_ = validate_and_save_cohort_info(
|
| 106 |
+
is_final=False,
|
| 107 |
+
cohort=cohort,
|
| 108 |
+
info_path=json_path,
|
| 109 |
+
is_gene_available=is_gene_available,
|
| 110 |
+
is_trait_available=is_trait_available
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
# 4) Clinical feature extraction (skip because trait_row is None)
|
| 114 |
+
# If trait_row becomes available in the future, uncomment below:
|
| 115 |
+
# if trait_row is not None:
|
| 116 |
+
# selected_clinical_df = geo_select_clinical_features(
|
| 117 |
+
# clinical_df=clinical_data,
|
| 118 |
+
# trait=trait,
|
| 119 |
+
# trait_row=trait_row,
|
| 120 |
+
# convert_trait=convert_trait,
|
| 121 |
+
# age_row=age_row,
|
| 122 |
+
# convert_age=convert_age,
|
| 123 |
+
# gender_row=gender_row,
|
| 124 |
+
# convert_gender=convert_gender
|
| 125 |
+
# )
|
| 126 |
+
# preview = preview_df(selected_clinical_df)
|
| 127 |
+
# selected_clinical_df.to_csv(out_clinical_data_file, index=True)
|
output/preprocess/Anxiety_disorder/code/GSE61672.py
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Anxiety_disorder"
|
| 6 |
+
cohort = "GSE61672"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Anxiety_disorder"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Anxiety_disorder/GSE61672"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Anxiety_disorder/GSE61672.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Anxiety_disorder/gene_data/GSE61672.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Anxiety_disorder/clinical_data/GSE61672.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Anxiety_disorder/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import re
|
| 41 |
+
import pandas as pd
|
| 42 |
+
|
| 43 |
+
# 1) Gene expression data availability
|
| 44 |
+
is_gene_available = True # Based on series title/summary: blood gene expression profiles
|
| 45 |
+
|
| 46 |
+
# 2) Converters
|
| 47 |
+
def _after_colon(value: str) -> str:
|
| 48 |
+
if value is None:
|
| 49 |
+
return ""
|
| 50 |
+
s = str(value).strip()
|
| 51 |
+
if ":" in s:
|
| 52 |
+
return s.split(":", 1)[1].strip()
|
| 53 |
+
return s
|
| 54 |
+
|
| 55 |
+
def convert_trait(value):
|
| 56 |
+
s = str(value).strip().lower()
|
| 57 |
+
field = s.split(":", 1)[0].strip() if ":" in s else ""
|
| 58 |
+
val = _after_colon(s).lower()
|
| 59 |
+
# Explicitly map "anxiety case/control"
|
| 60 |
+
if ("anxiety" in field) and ("case/control" in field):
|
| 61 |
+
if val in ("case", "1", "yes", "patient"):
|
| 62 |
+
return 1
|
| 63 |
+
if val in ("control", "0", "no", "healthy"):
|
| 64 |
+
return 0
|
| 65 |
+
return None
|
| 66 |
+
return None
|
| 67 |
+
|
| 68 |
+
def convert_age(value):
|
| 69 |
+
val = _after_colon(value)
|
| 70 |
+
m = re.search(r"-?\d+(\.\d+)?", val)
|
| 71 |
+
if m:
|
| 72 |
+
try:
|
| 73 |
+
return float(m.group(0))
|
| 74 |
+
except Exception:
|
| 75 |
+
return None
|
| 76 |
+
return None
|
| 77 |
+
|
| 78 |
+
def convert_gender(value):
|
| 79 |
+
s = str(value).strip().lower()
|
| 80 |
+
field = s.split(":", 1)[0].strip() if ":" in s else ""
|
| 81 |
+
val = _after_colon(s).lower()
|
| 82 |
+
|
| 83 |
+
if "sex" in field or "gender" in field:
|
| 84 |
+
if val in ("f", "female", "woman", "women", "girl"):
|
| 85 |
+
return 0
|
| 86 |
+
if val in ("m", "male", "man", "men", "boy"):
|
| 87 |
+
return 1
|
| 88 |
+
return None
|
| 89 |
+
|
| 90 |
+
# 2.1 Determine the best trait row between candidates 4 and 5, then optionally fill from the other
|
| 91 |
+
candidate_rows = [4, 5]
|
| 92 |
+
candidate_dfs = {}
|
| 93 |
+
non_na_counts = {}
|
| 94 |
+
|
| 95 |
+
for r in candidate_rows:
|
| 96 |
+
# Extract trait only to evaluate coverage
|
| 97 |
+
df_r = geo_select_clinical_features(
|
| 98 |
+
clinical_df=clinical_data,
|
| 99 |
+
trait=trait,
|
| 100 |
+
trait_row=r,
|
| 101 |
+
convert_trait=convert_trait,
|
| 102 |
+
age_row=None,
|
| 103 |
+
convert_age=None,
|
| 104 |
+
gender_row=None,
|
| 105 |
+
convert_gender=None
|
| 106 |
+
)
|
| 107 |
+
candidate_dfs[r] = df_r
|
| 108 |
+
non_na_counts[r] = df_r.loc[trait].notna().sum()
|
| 109 |
+
|
| 110 |
+
# Choose the row with higher non-missing count; if tie, prefer 4 as suggested
|
| 111 |
+
best_trait_row = 4 if non_na_counts.get(4, 0) >= non_na_counts.get(5, 0) else 5
|
| 112 |
+
|
| 113 |
+
# If no trait available at all, mark as unavailable
|
| 114 |
+
trait_row = best_trait_row if max(non_na_counts.values()) > 0 else None
|
| 115 |
+
age_row = 0
|
| 116 |
+
gender_row = 1
|
| 117 |
+
|
| 118 |
+
# 3) Save metadata (initial filtering)
|
| 119 |
+
is_trait_available = trait_row is not None
|
| 120 |
+
_ = validate_and_save_cohort_info(
|
| 121 |
+
is_final=False,
|
| 122 |
+
cohort=cohort,
|
| 123 |
+
info_path=json_path,
|
| 124 |
+
is_gene_available=is_gene_available,
|
| 125 |
+
is_trait_available=is_trait_available
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
# 4) Clinical Feature Extraction (only if trait is available)
|
| 129 |
+
if is_trait_available:
|
| 130 |
+
# Primary extraction with the best trait row including age and gender
|
| 131 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 132 |
+
clinical_df=clinical_data,
|
| 133 |
+
trait=trait,
|
| 134 |
+
trait_row=trait_row,
|
| 135 |
+
convert_trait=convert_trait,
|
| 136 |
+
age_row=age_row,
|
| 137 |
+
convert_age=convert_age,
|
| 138 |
+
gender_row=gender_row,
|
| 139 |
+
convert_gender=convert_gender
|
| 140 |
+
)
|
| 141 |
+
# Fill missing trait values from the alternative row to reduce missingness
|
| 142 |
+
alt_row = 5 if trait_row == 4 else 4
|
| 143 |
+
alt_df = candidate_dfs[alt_row] # already computed trait-only DataFrame
|
| 144 |
+
selected_clinical_df.loc[trait] = selected_clinical_df.loc[trait].fillna(alt_df.loc[trait])
|
| 145 |
+
|
| 146 |
+
# Preview and save
|
| 147 |
+
clinical_preview = preview_df(selected_clinical_df, n=5)
|
| 148 |
+
print(clinical_preview)
|
| 149 |
+
|
| 150 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 151 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
| 152 |
+
|
| 153 |
+
# Step 3: Gene Data Extraction
|
| 154 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 155 |
+
gene_data = get_genetic_data(matrix_file)
|
| 156 |
+
|
| 157 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 158 |
+
print(gene_data.index[:20])
|
| 159 |
+
|
| 160 |
+
# Step 4: Gene Identifier Review
|
| 161 |
+
print("requires_gene_mapping = True")
|
| 162 |
+
|
| 163 |
+
# Step 5: Gene Annotation
|
| 164 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 165 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 166 |
+
|
| 167 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 168 |
+
print("Gene annotation preview:")
|
| 169 |
+
print(preview_df(gene_annotation))
|
| 170 |
+
|
| 171 |
+
# Step 6: Gene Identifier Mapping
|
| 172 |
+
# Decide the identifier and symbol columns from annotation by matching to gene_data index and valid gene symbols
|
| 173 |
+
expr_df = gene_data # keep original probe-level data
|
| 174 |
+
|
| 175 |
+
# Candidate columns
|
| 176 |
+
id_candidates = [c for c in ['ID', 'Probe_Id', 'Array_Address_Id'] if c in gene_annotation.columns]
|
| 177 |
+
symbol_candidates = [c for c in ['Symbol', 'ILMN_Gene', 'Gene Symbol', 'Gene_Symbol'] if c in gene_annotation.columns]
|
| 178 |
+
|
| 179 |
+
# Choose ID column based on maximum overlap with expression probe IDs
|
| 180 |
+
overlap_counts = {}
|
| 181 |
+
for c in id_candidates:
|
| 182 |
+
ids = gene_annotation[c].astype(str).str.strip()
|
| 183 |
+
overlap_counts[c] = ids.isin(expr_df.index).sum()
|
| 184 |
+
id_col = max(overlap_counts, key=overlap_counts.get) if overlap_counts else 'ID'
|
| 185 |
+
|
| 186 |
+
# Choose symbol column based on number of rows with valid human gene symbols
|
| 187 |
+
def valid_symbol_count(series):
|
| 188 |
+
return series.dropna().astype(str).map(lambda s: len(extract_human_gene_symbols(s)) > 0).sum()
|
| 189 |
+
|
| 190 |
+
symbol_scores = {c: valid_symbol_count(gene_annotation[c]) for c in symbol_candidates}
|
| 191 |
+
symbol_col = max(symbol_scores, key=symbol_scores.get) if symbol_scores else 'Symbol'
|
| 192 |
+
|
| 193 |
+
# Build mapping and apply to convert probe-level data to gene-level data
|
| 194 |
+
gene_mapping = get_gene_mapping(gene_annotation, prob_col=id_col, gene_col=symbol_col)
|
| 195 |
+
gene_data = apply_gene_mapping(expression_df=expr_df, mapping_df=gene_mapping)
|
| 196 |
+
|
| 197 |
+
# Step 7: Data Normalization and Linking
|
| 198 |
+
import os
|
| 199 |
+
|
| 200 |
+
# 1. Normalize gene symbols and save gene matrix
|
| 201 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 202 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 203 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 204 |
+
|
| 205 |
+
# 2. Link clinical and genetic data
|
| 206 |
+
linked_data_pre = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 207 |
+
|
| 208 |
+
# 3. Handle missing values
|
| 209 |
+
samples_before = linked_data_pre.shape[0]
|
| 210 |
+
covariate_cols = [trait, 'Age', 'Gender']
|
| 211 |
+
pre_gene_cols = [c for c in linked_data_pre.columns if c not in covariate_cols]
|
| 212 |
+
genes_before = len(pre_gene_cols)
|
| 213 |
+
trait_missing_before = linked_data_pre[trait].isna().sum()
|
| 214 |
+
|
| 215 |
+
linked_data = handle_missing_values(linked_data_pre, trait)
|
| 216 |
+
|
| 217 |
+
samples_after = linked_data.shape[0]
|
| 218 |
+
post_gene_cols = [c for c in linked_data.columns if c not in covariate_cols]
|
| 219 |
+
genes_after = len(post_gene_cols)
|
| 220 |
+
|
| 221 |
+
# 4. Bias check and remove biased demographics
|
| 222 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 223 |
+
|
| 224 |
+
# 5. Final validation and save cohort info
|
| 225 |
+
note = (
|
| 226 |
+
f"INFO: Samples before/after filtering: {samples_before}/{samples_after}; "
|
| 227 |
+
f"Genes before/after filtering: {genes_before}/{genes_after}; "
|
| 228 |
+
f"Missing {trait} before filtering: {trait_missing_before}."
|
| 229 |
+
)
|
| 230 |
+
is_usable = validate_and_save_cohort_info(
|
| 231 |
+
is_final=True,
|
| 232 |
+
cohort=cohort,
|
| 233 |
+
info_path=json_path,
|
| 234 |
+
is_gene_available=True,
|
| 235 |
+
is_trait_available=is_trait_available,
|
| 236 |
+
is_biased=is_trait_biased,
|
| 237 |
+
df=unbiased_linked_data,
|
| 238 |
+
note=note
|
| 239 |
+
)
|
| 240 |
+
|
| 241 |
+
# 6. Save linked data if usable
|
| 242 |
+
if is_usable:
|
| 243 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 244 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Anxiety_disorder/code/GSE68526.py
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Anxiety_disorder"
|
| 6 |
+
cohort = "GSE68526"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Anxiety_disorder"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Anxiety_disorder/GSE68526"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Anxiety_disorder/GSE68526.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Anxiety_disorder/gene_data/GSE68526.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Anxiety_disorder/clinical_data/GSE68526.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Anxiety_disorder/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import pandas as pd
|
| 41 |
+
|
| 42 |
+
# 1) Gene expression data availability based on background info
|
| 43 |
+
is_gene_available = True # Gene expression profiling on peripheral blood RNA
|
| 44 |
+
|
| 45 |
+
# 2) Variable availability and converters
|
| 46 |
+
# - Trait (Anxiety score): key 13 -> 'anxiety: ...' (continuous Beck Anxiety Inventory score)
|
| 47 |
+
# - Age: key 0 -> 'age (yrs): ...'
|
| 48 |
+
# - Gender: key 1 -> 'female: 1/0' (map female=1->0, male=0->1)
|
| 49 |
+
trait_row = 13
|
| 50 |
+
age_row = 0
|
| 51 |
+
gender_row = 1
|
| 52 |
+
|
| 53 |
+
def _after_colon(x: str) -> str:
|
| 54 |
+
if x is None:
|
| 55 |
+
return ''
|
| 56 |
+
parts = str(x).split(':', 1)
|
| 57 |
+
return parts[1].strip() if len(parts) > 1 else str(x).strip()
|
| 58 |
+
|
| 59 |
+
def convert_trait(x):
|
| 60 |
+
# Anxiety score as continuous value; map 'missing' to None
|
| 61 |
+
v = _after_colon(x).lower()
|
| 62 |
+
if v in {'', 'na', 'nan', 'missing', 'none'}:
|
| 63 |
+
return None
|
| 64 |
+
try:
|
| 65 |
+
return float(v)
|
| 66 |
+
except Exception:
|
| 67 |
+
return None
|
| 68 |
+
|
| 69 |
+
def convert_age(x):
|
| 70 |
+
v = _after_colon(x).lower()
|
| 71 |
+
# Fix: check exact equality so valid ages are not dropped
|
| 72 |
+
if v in {'', 'missing', 'na', 'nan', 'none'}:
|
| 73 |
+
return None
|
| 74 |
+
try:
|
| 75 |
+
return float(v)
|
| 76 |
+
except Exception:
|
| 77 |
+
# fallback: extract first number
|
| 78 |
+
import re
|
| 79 |
+
m = re.search(r'[-+]?\d*\.?\d+', v)
|
| 80 |
+
return float(m.group()) if m else None
|
| 81 |
+
|
| 82 |
+
def convert_gender(x):
|
| 83 |
+
# Input is 'female: 1/0' where 1 indicates female
|
| 84 |
+
v = _after_colon(x).strip().lower()
|
| 85 |
+
if v in {'', 'na', 'nan', 'missing', 'none'}:
|
| 86 |
+
return None
|
| 87 |
+
if v in {'1', '0'}:
|
| 88 |
+
return 0 if v == '1' else 1 # female=1->0; male=0->1
|
| 89 |
+
if v in {'female', 'f'}:
|
| 90 |
+
return 0
|
| 91 |
+
if v in {'male', 'm'}:
|
| 92 |
+
return 1
|
| 93 |
+
return None
|
| 94 |
+
|
| 95 |
+
# 3) Save metadata (initial filtering)
|
| 96 |
+
is_trait_available = trait_row is not None
|
| 97 |
+
_ = validate_and_save_cohort_info(
|
| 98 |
+
is_final=False,
|
| 99 |
+
cohort=cohort,
|
| 100 |
+
info_path=json_path,
|
| 101 |
+
is_gene_available=is_gene_available,
|
| 102 |
+
is_trait_available=is_trait_available
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
# 4) Clinical feature extraction (only if trait_row is available)
|
| 106 |
+
if trait_row is not None:
|
| 107 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 108 |
+
clinical_df=clinical_data,
|
| 109 |
+
trait=trait,
|
| 110 |
+
trait_row=trait_row,
|
| 111 |
+
convert_trait=convert_trait,
|
| 112 |
+
age_row=age_row,
|
| 113 |
+
convert_age=convert_age,
|
| 114 |
+
gender_row=gender_row,
|
| 115 |
+
convert_gender=convert_gender
|
| 116 |
+
)
|
| 117 |
+
preview = preview_df(selected_clinical_df)
|
| 118 |
+
print("Clinical features preview:", preview)
|
| 119 |
+
|
| 120 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 121 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=True)
|
| 122 |
+
|
| 123 |
+
# Step 3: Gene Data Extraction
|
| 124 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 125 |
+
gene_data = get_genetic_data(matrix_file)
|
| 126 |
+
|
| 127 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 128 |
+
print(gene_data.index[:20])
|
| 129 |
+
|
| 130 |
+
# Step 4: Gene Identifier Review
|
| 131 |
+
# Based on the observed identifiers (e.g., A1BG, A1CF, A2M, A2ML1, AAAS), these are human gene symbols.
|
| 132 |
+
# Some entries like A2BP1 are older aliases but still gene symbols. Therefore, no mapping is required.
|
| 133 |
+
print("requires_gene_mapping = False")
|
| 134 |
+
|
| 135 |
+
# Step 5: Data Normalization and Linking
|
| 136 |
+
import os
|
| 137 |
+
import pandas as pd
|
| 138 |
+
|
| 139 |
+
# 1. Normalize gene symbols and save
|
| 140 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 141 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 142 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 143 |
+
|
| 144 |
+
# 2. Ensure clinical features are available in scope; load from disk if needed
|
| 145 |
+
if 'selected_clinical_df' not in globals():
|
| 146 |
+
if os.path.exists(out_clinical_data_file):
|
| 147 |
+
selected_clinical_df = pd.read_csv(out_clinical_data_file, index_col=0)
|
| 148 |
+
else:
|
| 149 |
+
raise FileNotFoundError("Clinical features not found in memory or on disk.")
|
| 150 |
+
|
| 151 |
+
# Link clinical and genetic data
|
| 152 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 153 |
+
|
| 154 |
+
# 3. Handle missing values, guarding the presence of the trait column
|
| 155 |
+
if trait not in linked_data.columns:
|
| 156 |
+
raise KeyError(f"Trait column '{trait}' not found in the linked data.")
|
| 157 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 158 |
+
|
| 159 |
+
# 4. Judge bias and remove biased demographic features
|
| 160 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 161 |
+
|
| 162 |
+
# 5. Final validation and save cohort info
|
| 163 |
+
is_gene_available = True
|
| 164 |
+
is_trait_available = trait in unbiased_linked_data.columns
|
| 165 |
+
note = "INFO: Gene symbols normalized via NCBI synonyms; duplicates averaged. Clinical features reused from previous step."
|
| 166 |
+
is_usable = validate_and_save_cohort_info(
|
| 167 |
+
is_final=True,
|
| 168 |
+
cohort=cohort,
|
| 169 |
+
info_path=json_path,
|
| 170 |
+
is_gene_available=is_gene_available,
|
| 171 |
+
is_trait_available=is_trait_available,
|
| 172 |
+
is_biased=is_trait_biased,
|
| 173 |
+
df=unbiased_linked_data,
|
| 174 |
+
note=note
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
# 6. Save linked data if usable
|
| 178 |
+
if is_usable:
|
| 179 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 180 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Anxiety_disorder/code/GSE78104.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Anxiety_disorder"
|
| 6 |
+
cohort = "GSE78104"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Anxiety_disorder"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Anxiety_disorder/GSE78104"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Anxiety_disorder/GSE78104.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Anxiety_disorder/gene_data/GSE78104.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Anxiety_disorder/clinical_data/GSE78104.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Anxiety_disorder/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import re
|
| 41 |
+
|
| 42 |
+
# 1. Gene Expression Data Availability
|
| 43 |
+
is_gene_available = True # mRNA expression profiled by microarray (Agilent lncRNA/mRNA platform)
|
| 44 |
+
|
| 45 |
+
# 2. Variable Availability and Data Type Conversion
|
| 46 |
+
# From Sample Characteristics Dictionary:
|
| 47 |
+
# trait (Anxiety_disorder) inferred from 'disease state' (OCD vs normal control)
|
| 48 |
+
trait_row = 1
|
| 49 |
+
age_row = 3
|
| 50 |
+
gender_row = 2
|
| 51 |
+
|
| 52 |
+
def _after_colon(x: str) -> str:
|
| 53 |
+
if x is None:
|
| 54 |
+
return ""
|
| 55 |
+
parts = str(x).split(":", 1)
|
| 56 |
+
return parts[1].strip() if len(parts) == 2 else str(x).strip()
|
| 57 |
+
|
| 58 |
+
def convert_trait(x):
|
| 59 |
+
# Map OCD to 1 (case), normal/healthy control to 0
|
| 60 |
+
val = _after_colon(x).strip().lower()
|
| 61 |
+
if val in ("ocd", "obsessive-compulsive disorder", "obsessive compulsive disorder"):
|
| 62 |
+
return 1
|
| 63 |
+
if "control" in val:
|
| 64 |
+
return 0
|
| 65 |
+
if val in ("patient", "case"):
|
| 66 |
+
return 1
|
| 67 |
+
if val in ("normal", "healthy"):
|
| 68 |
+
return 0
|
| 69 |
+
return None
|
| 70 |
+
|
| 71 |
+
def convert_age(x):
|
| 72 |
+
# Extract numeric age in years; handles patterns like '18y', '18', '18 years'
|
| 73 |
+
val = _after_colon(x).strip().lower()
|
| 74 |
+
if val in ("na", "n/a", "unknown", ""):
|
| 75 |
+
return None
|
| 76 |
+
m = re.search(r"(\d+(\.\d+)?)", val)
|
| 77 |
+
if m:
|
| 78 |
+
try:
|
| 79 |
+
return float(m.group(1))
|
| 80 |
+
except Exception:
|
| 81 |
+
return None
|
| 82 |
+
return None
|
| 83 |
+
|
| 84 |
+
def convert_gender(x):
|
| 85 |
+
# Female -> 0, Male -> 1
|
| 86 |
+
val = _after_colon(x).strip().lower()
|
| 87 |
+
if val in ("male", "m"):
|
| 88 |
+
return 1
|
| 89 |
+
if val in ("female", "f"):
|
| 90 |
+
return 0
|
| 91 |
+
return None
|
| 92 |
+
|
| 93 |
+
# 3. Save Metadata (initial filtering)
|
| 94 |
+
is_trait_available = trait_row is not None
|
| 95 |
+
_ = validate_and_save_cohort_info(
|
| 96 |
+
is_final=False,
|
| 97 |
+
cohort=cohort,
|
| 98 |
+
info_path=json_path,
|
| 99 |
+
is_gene_available=is_gene_available,
|
| 100 |
+
is_trait_available=is_trait_available
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
# 4. Clinical Feature Extraction
|
| 104 |
+
if trait_row is not None:
|
| 105 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 106 |
+
clinical_df=clinical_data,
|
| 107 |
+
trait=trait,
|
| 108 |
+
trait_row=trait_row,
|
| 109 |
+
convert_trait=convert_trait,
|
| 110 |
+
age_row=age_row,
|
| 111 |
+
convert_age=convert_age,
|
| 112 |
+
gender_row=gender_row,
|
| 113 |
+
convert_gender=convert_gender
|
| 114 |
+
)
|
| 115 |
+
preview = preview_df(selected_clinical_df)
|
| 116 |
+
print(preview)
|
| 117 |
+
|
| 118 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 119 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
| 120 |
+
|
| 121 |
+
# Step 3: Gene Data Extraction
|
| 122 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 123 |
+
gene_data = get_genetic_data(matrix_file)
|
| 124 |
+
|
| 125 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 126 |
+
print(gene_data.index[:20])
|
| 127 |
+
|
| 128 |
+
# Step 4: Gene Identifier Review
|
| 129 |
+
requires_gene_mapping = True
|
| 130 |
+
print(f"requires_gene_mapping = {requires_gene_mapping}")
|
| 131 |
+
|
| 132 |
+
# Step 5: Gene Annotation
|
| 133 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 134 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 135 |
+
|
| 136 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 137 |
+
print("Gene annotation preview:")
|
| 138 |
+
print(preview_df(gene_annotation))
|
| 139 |
+
|
| 140 |
+
# Step 6: Gene Identifier Mapping
|
| 141 |
+
# Determine columns for probe IDs and gene symbols based on annotation preview
|
| 142 |
+
probe_col = 'ID' # Matches probe IDs like 'A_19_P00315459' seen in gene_data index
|
| 143 |
+
gene_symbol_col = 'GeneSymbol'
|
| 144 |
+
|
| 145 |
+
# Build mapping dataframe from annotation
|
| 146 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=gene_symbol_col)
|
| 147 |
+
|
| 148 |
+
# Apply mapping to convert probe-level data to gene-level expression
|
| 149 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
|
| 150 |
+
|
| 151 |
+
# Step 7: Data Normalization and Linking
|
| 152 |
+
import os
|
| 153 |
+
import json
|
| 154 |
+
import pandas as pd
|
| 155 |
+
|
| 156 |
+
# 1. Normalize gene data and save
|
| 157 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 158 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 159 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 160 |
+
|
| 161 |
+
# Ensure clinical dataframe is available; fallback to loading from disk if needed
|
| 162 |
+
try:
|
| 163 |
+
selected_clinical_df
|
| 164 |
+
except NameError:
|
| 165 |
+
selected_clinical_df = pd.read_csv(out_clinical_data_file, index_col=0)
|
| 166 |
+
|
| 167 |
+
# 2. Link the clinical and genetic data
|
| 168 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 169 |
+
|
| 170 |
+
# Determine availability flags with native Python bools
|
| 171 |
+
is_gene_available_final = bool((normalized_gene_data.shape[0] > 0) and (normalized_gene_data.shape[1] > 0))
|
| 172 |
+
is_trait_available_final = bool((trait in linked_data.columns) and (linked_data[trait].notna().sum() > 0))
|
| 173 |
+
|
| 174 |
+
# 3. Handle missing values
|
| 175 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 176 |
+
|
| 177 |
+
# 4. Determine whether the trait and some demographic features are severely biased, and remove biased features.
|
| 178 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 179 |
+
|
| 180 |
+
# 5. Conduct quality check and save the cohort information.
|
| 181 |
+
note = "INFO: Agilent G3 lncRNA/mRNA platform; probe-to-gene mapping via 'GeneSymbol' with synonym normalization."
|
| 182 |
+
|
| 183 |
+
def _finalize_and_save():
|
| 184 |
+
return validate_and_save_cohort_info(
|
| 185 |
+
is_final=True,
|
| 186 |
+
cohort=cohort,
|
| 187 |
+
info_path=json_path,
|
| 188 |
+
is_gene_available=bool(is_gene_available_final),
|
| 189 |
+
is_trait_available=bool(is_trait_available_final),
|
| 190 |
+
is_biased=bool(is_trait_biased),
|
| 191 |
+
df=unbiased_linked_data,
|
| 192 |
+
note=note
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
# Attempt to save; if JSON serialization fails due to non-native bools in existing file, reset and retry once.
|
| 196 |
+
try:
|
| 197 |
+
is_usable = _finalize_and_save()
|
| 198 |
+
except TypeError:
|
| 199 |
+
os.makedirs(os.path.dirname(json_path), exist_ok=True)
|
| 200 |
+
with open(json_path, "w") as f:
|
| 201 |
+
json.dump({}, f)
|
| 202 |
+
is_usable = _finalize_and_save()
|
| 203 |
+
|
| 204 |
+
# 6. If the linked data is usable, save it
|
| 205 |
+
if is_usable:
|
| 206 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 207 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Anxiety_disorder/code/GSE94119.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Anxiety_disorder"
|
| 6 |
+
cohort = "GSE94119"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Anxiety_disorder"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Anxiety_disorder/GSE94119"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Anxiety_disorder/GSE94119.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Anxiety_disorder/gene_data/GSE94119.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Anxiety_disorder/clinical_data/GSE94119.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Anxiety_disorder/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
|
| 41 |
+
# 1. Gene Expression Data Availability
|
| 42 |
+
is_gene_available = True # Illumina HT-12v4 BeadChip microarray indicates mRNA expression data.
|
| 43 |
+
|
| 44 |
+
# 2. Variable Availability and Data Type Conversion
|
| 45 |
+
|
| 46 |
+
# Keys in Sample Characteristics Dictionary
|
| 47 |
+
trait_row = None # No case/control or diagnosis variability available; all are anxiety disorder patients.
|
| 48 |
+
age_row = None # Age not provided.
|
| 49 |
+
gender_row = 0 # Gender is available at key 0.
|
| 50 |
+
|
| 51 |
+
def _extract_after_colon(x: str) -> str:
|
| 52 |
+
if x is None:
|
| 53 |
+
return ""
|
| 54 |
+
parts = str(x).split(":", 1)
|
| 55 |
+
return parts[1].strip() if len(parts) == 2 else str(x).strip()
|
| 56 |
+
|
| 57 |
+
def convert_trait(x):
|
| 58 |
+
# Generic mapping for anxiety-related traits if ever encountered; not used since trait_row is None.
|
| 59 |
+
v = _extract_after_colon(x).lower()
|
| 60 |
+
if v in {"case", "patient", "anxiety", "anxiety disorder", "anxiety_disorder", "panic disorder", "specific phobia"}:
|
| 61 |
+
return 1
|
| 62 |
+
if v in {"control", "healthy", "no", "none"}:
|
| 63 |
+
return 0
|
| 64 |
+
# Heuristics
|
| 65 |
+
if "panic" in v or "phobia" in v:
|
| 66 |
+
return 1
|
| 67 |
+
if "control" in v or "healthy" in v:
|
| 68 |
+
return 0
|
| 69 |
+
return None
|
| 70 |
+
|
| 71 |
+
def convert_age(x):
|
| 72 |
+
v = _extract_after_colon(x)
|
| 73 |
+
m = re.search(r"[-+]?\d*\.?\d+", v)
|
| 74 |
+
if m:
|
| 75 |
+
try:
|
| 76 |
+
return float(m.group())
|
| 77 |
+
except:
|
| 78 |
+
return None
|
| 79 |
+
return None
|
| 80 |
+
|
| 81 |
+
def convert_gender(x):
|
| 82 |
+
v = _extract_after_colon(x).lower()
|
| 83 |
+
if v in {"female", "f", "woman", "women"}:
|
| 84 |
+
return 0
|
| 85 |
+
if v in {"male", "m", "man", "men"}:
|
| 86 |
+
return 1
|
| 87 |
+
return None
|
| 88 |
+
|
| 89 |
+
# 3. Save Metadata (initial filtering)
|
| 90 |
+
is_trait_available = trait_row is not None
|
| 91 |
+
_ = validate_and_save_cohort_info(
|
| 92 |
+
is_final=False,
|
| 93 |
+
cohort=cohort,
|
| 94 |
+
info_path=json_path,
|
| 95 |
+
is_gene_available=is_gene_available,
|
| 96 |
+
is_trait_available=is_trait_available
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
# 4. Clinical Feature Extraction
|
| 100 |
+
# Skipped because trait_row is None (no usable clinical trait data for association)
|
output/preprocess/Anxiety_disorder/code/TCGA.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Anxiety_disorder"
|
| 6 |
+
|
| 7 |
+
# Input paths
|
| 8 |
+
tcga_root_dir = "../DATA/TCGA"
|
| 9 |
+
|
| 10 |
+
# Output paths
|
| 11 |
+
out_data_file = "./output/z1/preprocess/Anxiety_disorder/TCGA.csv"
|
| 12 |
+
out_gene_data_file = "./output/z1/preprocess/Anxiety_disorder/gene_data/TCGA.csv"
|
| 13 |
+
out_clinical_data_file = "./output/z1/preprocess/Anxiety_disorder/clinical_data/TCGA.csv"
|
| 14 |
+
json_path = "./output/z1/preprocess/Anxiety_disorder/cohort_info.json"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# Step 1: Initial Data Loading
|
| 18 |
+
import os
|
| 19 |
+
import pandas as pd
|
| 20 |
+
|
| 21 |
+
# Step 1: Select the most relevant TCGA cohort for Anxiety_disorder (likely none in TCGA cancer cohorts)
|
| 22 |
+
subdirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))]
|
| 23 |
+
trait_lower = trait.lower()
|
| 24 |
+
|
| 25 |
+
# Basic keyword matching for anxiety-related terms
|
| 26 |
+
keywords = ['anxiety', 'anxiet', 'panic', 'gad', 'generalized_anxiety', 'psychi', 'mental']
|
| 27 |
+
candidates = [d for d in subdirs if any(k in d.lower() for k in keywords)]
|
| 28 |
+
|
| 29 |
+
if not candidates:
|
| 30 |
+
# No suitable cohort found; record and skip this trait for TCGA
|
| 31 |
+
validate_and_save_cohort_info(
|
| 32 |
+
is_final=False,
|
| 33 |
+
cohort='TCGA',
|
| 34 |
+
info_path=json_path,
|
| 35 |
+
is_gene_available=False,
|
| 36 |
+
is_trait_available=False
|
| 37 |
+
)
|
| 38 |
+
print("No TCGA cohort relevant to Anxiety_disorder was found. Skipping TCGA for this trait.")
|
| 39 |
+
else:
|
| 40 |
+
# If multiple, select the most specific (use longest name as a simple proxy for specificity)
|
| 41 |
+
selected_dir = sorted(candidates, key=len, reverse=True)[0]
|
| 42 |
+
selected_dir_path = os.path.join(tcga_root_dir, selected_dir)
|
| 43 |
+
|
| 44 |
+
# Step 2: Identify clinical and genetic file paths
|
| 45 |
+
clinical_path, genetic_path = tcga_get_relevant_filepaths(selected_dir_path)
|
| 46 |
+
|
| 47 |
+
# Step 3: Load both files
|
| 48 |
+
clinical_df = pd.read_csv(clinical_path, sep='\t', index_col=0, low_memory=False)
|
| 49 |
+
genetic_df = pd.read_csv(genetic_path, sep='\t', index_col=0, low_memory=False)
|
| 50 |
+
|
| 51 |
+
# Step 4: Print clinical column names
|
| 52 |
+
print(clinical_df.columns.tolist())
|
output/preprocess/Anxiety_disorder/cohort_info.json
CHANGED
|
@@ -1,82 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"GSE94119": {
|
| 3 |
-
"is_usable": false,
|
| 4 |
-
"is_gene_available": true,
|
| 5 |
-
"is_trait_available": false,
|
| 6 |
-
"is_available": false,
|
| 7 |
-
"is_biased": null,
|
| 8 |
-
"has_age": null,
|
| 9 |
-
"has_gender": null,
|
| 10 |
-
"sample_size": null
|
| 11 |
-
},
|
| 12 |
-
"GSE78104": {
|
| 13 |
-
"is_usable": true,
|
| 14 |
-
"is_gene_available": true,
|
| 15 |
-
"is_trait_available": true,
|
| 16 |
-
"is_available": true,
|
| 17 |
-
"is_biased": false,
|
| 18 |
-
"has_age": true,
|
| 19 |
-
"has_gender": true,
|
| 20 |
-
"sample_size": 60
|
| 21 |
-
},
|
| 22 |
-
"GSE68526": {
|
| 23 |
-
"is_usable": false,
|
| 24 |
-
"is_gene_available": true,
|
| 25 |
-
"is_trait_available": false,
|
| 26 |
-
"is_available": false,
|
| 27 |
-
"is_biased": null,
|
| 28 |
-
"has_age": null,
|
| 29 |
-
"has_gender": null,
|
| 30 |
-
"sample_size": null
|
| 31 |
-
},
|
| 32 |
-
"GSE61672": {
|
| 33 |
-
"is_usable": true,
|
| 34 |
-
"is_gene_available": true,
|
| 35 |
-
"is_trait_available": true,
|
| 36 |
-
"is_available": true,
|
| 37 |
-
"is_biased": false,
|
| 38 |
-
"has_age": true,
|
| 39 |
-
"has_gender": true,
|
| 40 |
-
"sample_size": 195
|
| 41 |
-
},
|
| 42 |
-
"GSE60491": {
|
| 43 |
-
"is_usable": false,
|
| 44 |
-
"is_gene_available": false,
|
| 45 |
-
"is_trait_available": false,
|
| 46 |
-
"is_available": false,
|
| 47 |
-
"is_biased": null,
|
| 48 |
-
"has_age": null,
|
| 49 |
-
"has_gender": null,
|
| 50 |
-
"sample_size": null
|
| 51 |
-
},
|
| 52 |
-
"GSE60190": {
|
| 53 |
-
"is_usable": false,
|
| 54 |
-
"is_gene_available": true,
|
| 55 |
-
"is_trait_available": false,
|
| 56 |
-
"is_available": false,
|
| 57 |
-
"is_biased": null,
|
| 58 |
-
"has_age": null,
|
| 59 |
-
"has_gender": null,
|
| 60 |
-
"sample_size": null
|
| 61 |
-
},
|
| 62 |
-
"GSE119995": {
|
| 63 |
-
"is_usable": true,
|
| 64 |
-
"is_gene_available": true,
|
| 65 |
-
"is_trait_available": true,
|
| 66 |
-
"is_available": true,
|
| 67 |
-
"is_biased": false,
|
| 68 |
-
"has_age": false,
|
| 69 |
-
"has_gender": true,
|
| 70 |
-
"sample_size": 72
|
| 71 |
-
},
|
| 72 |
-
"TCGA": {
|
| 73 |
-
"is_usable": false,
|
| 74 |
-
"is_gene_available": true,
|
| 75 |
-
"is_trait_available": false,
|
| 76 |
-
"is_available": false,
|
| 77 |
-
"is_biased": null,
|
| 78 |
-
"has_age": null,
|
| 79 |
-
"has_gender": null,
|
| 80 |
-
"sample_size": null
|
| 81 |
-
}
|
| 82 |
-
}
|
|
|
|
| 1 |
+
{"GSE94119": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE78104": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": true, "has_gender": true, "sample_size": 60, "note": "INFO: Agilent G3 lncRNA/mRNA platform; probe-to-gene mapping via 'GeneSymbol' with synonym normalization."}, "GSE68526": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": true, "has_gender": true, "sample_size": 107, "note": "INFO: Gene symbols normalized via NCBI synonyms; duplicates averaged. Clinical features reused from previous step."}, "GSE61672": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": true, "has_gender": true, "sample_size": 336, "note": "INFO: Samples before/after filtering: 546/336; Genes before/after filtering: 9086/9086; Missing Anxiety_disorder before filtering: 210."}, "GSE60491": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE60190": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": true, "has_gender": true, "sample_size": 133, "note": "INFO: Illumina HumanHT-12 v3 platform; trait defined as OCD vs non-OCD (Control/ED)."}, "GSE119995": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "TCGA": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output/preprocess/Arrhythmia/GSE41177.csv
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
output/preprocess/Arrhythmia/clinical_data/GSE115574.csv
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
1.0,
|
|
|
|
| 1 |
+
,GSM3182680,GSM3182681,GSM3182682,GSM3182683,GSM3182684,GSM3182685,GSM3182686,GSM3182687,GSM3182688,GSM3182689,GSM3182690,GSM3182691,GSM3182692,GSM3182693,GSM3182694,GSM3182695,GSM3182696,GSM3182697,GSM3182698,GSM3182699,GSM3182700,GSM3182701,GSM3182702,GSM3182703,GSM3182704,GSM3182705,GSM3182706,GSM3182707,GSM3182708,GSM3182709,GSM3182710,GSM3182711,GSM3182712,GSM3182713,GSM3182714,GSM3182715,GSM3182716,GSM3182717,GSM3182718,GSM3182719,GSM3182720,GSM3182721,GSM3182722,GSM3182723,GSM3182724,GSM3182725,GSM3182726,GSM3182727,GSM3182728,GSM3182729,GSM3182730,GSM3182731,GSM3182732,GSM3182733,GSM3182734,GSM3182735,GSM3182736,GSM3182737,GSM3182738
|
| 2 |
+
Arrhythmia,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
output/preprocess/Arrhythmia/clinical_data/GSE143924.csv
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,GSM4276706,GSM4276707,GSM4276708,GSM4276709,GSM4276710,GSM4276711,GSM4276712,GSM4276713,GSM4276714,GSM4276715,GSM4276716,GSM4276717,GSM4276718,GSM4276719,GSM4276720,GSM4276721,GSM4276722,GSM4276723,GSM4276724,GSM4276725,GSM4276726,GSM4276727,GSM4276728,GSM4276729,GSM4276730,GSM4276731,GSM4276732,GSM4276733,GSM4276734,GSM4276735
|
| 2 |
+
Arrhythmia,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
output/preprocess/Arrhythmia/clinical_data/GSE182600.csv
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
GSM5532093,GSM5532094,GSM5532095,GSM5532096,GSM5532097,GSM5532098,GSM5532099,GSM5532100,GSM5532101,GSM5532102,GSM5532103,GSM5532104,GSM5532105,GSM5532106,GSM5532107,GSM5532108,GSM5532109,GSM5532110,GSM5532111,GSM5532112,GSM5532113,GSM5532114,GSM5532115,GSM5532116,GSM5532117,GSM5532118,GSM5532119,GSM5532120,GSM5532121,GSM5532122,GSM5532123,GSM5532124,GSM5532125,GSM5532126,GSM5532127,GSM5532128,GSM5532129,GSM5532130,GSM5532131,GSM5532132,GSM5532133,GSM5532134,GSM5532135,GSM5532136,GSM5532137,GSM5532138,GSM5532139,GSM5532140,GSM5532141,GSM5532142,GSM5532143,GSM5532144,GSM5532145,GSM5532146,GSM5532147,GSM5532148,GSM5532149,GSM5532150,GSM5532151,GSM5532152,GSM5532153,GSM5532154,GSM5532155,GSM5532156,GSM5532157,GSM5532158,GSM5532159,GSM5532160,GSM5532161,GSM5532162,GSM5532163,GSM5532164,GSM5532165,GSM5532166,GSM5532167,GSM5532168,GSM5532169,GSM5532170
|
| 2 |
-
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0
|
| 3 |
-
33.4,51.2,51.9,47.8,41.5,67.3,52.8,16.1,78.9,53.2,70.9,59.9,21.9,45.2,52.4,32.3,52.8,55.8,47.0,55.8,57.3,31.7,49.3,66.1,55.9,49.1,63.0,21.0,53.6,50.1,37.4,71.5,56.5,33.4,51.2,51.9,47.8,41.5,67.3,52.8,78.9,53.2,70.9,59.9,21.9,45.2,52.4,32.3,55.8,47.0,55.8,57.3,31.7,49.3,66.1,55.9,49.1,63.0,21.0,53.6,50.1,37.4,71.5,56.5,33.4,51.2,51.9,47.8,52.8,53.2,21.9,55.8,47.0,49.3,66.1,53.6,50.1,56.5
|
| 4 |
-
0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0
|
|
|
|
| 1 |
+
,GSM5532093,GSM5532094,GSM5532095,GSM5532096,GSM5532097,GSM5532098,GSM5532099,GSM5532100,GSM5532101,GSM5532102,GSM5532103,GSM5532104,GSM5532105,GSM5532106,GSM5532107,GSM5532108,GSM5532109,GSM5532110,GSM5532111,GSM5532112,GSM5532113,GSM5532114,GSM5532115,GSM5532116,GSM5532117,GSM5532118,GSM5532119,GSM5532120,GSM5532121,GSM5532122,GSM5532123,GSM5532124,GSM5532125,GSM5532126,GSM5532127,GSM5532128,GSM5532129,GSM5532130,GSM5532131,GSM5532132,GSM5532133,GSM5532134,GSM5532135,GSM5532136,GSM5532137,GSM5532138,GSM5532139,GSM5532140,GSM5532141,GSM5532142,GSM5532143,GSM5532144,GSM5532145,GSM5532146,GSM5532147,GSM5532148,GSM5532149,GSM5532150,GSM5532151,GSM5532152,GSM5532153,GSM5532154,GSM5532155,GSM5532156,GSM5532157,GSM5532158,GSM5532159,GSM5532160,GSM5532161,GSM5532162,GSM5532163,GSM5532164,GSM5532165,GSM5532166,GSM5532167,GSM5532168,GSM5532169,GSM5532170
|
| 2 |
+
Arrhythmia,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0
|
| 3 |
+
Age,33.4,51.2,51.9,47.8,41.5,67.3,52.8,16.1,78.9,53.2,70.9,59.9,21.9,45.2,52.4,32.3,52.8,55.8,47.0,55.8,57.3,31.7,49.3,66.1,55.9,49.1,63.0,21.0,53.6,50.1,37.4,71.5,56.5,33.4,51.2,51.9,47.8,41.5,67.3,52.8,78.9,53.2,70.9,59.9,21.9,45.2,52.4,32.3,55.8,47.0,55.8,57.3,31.7,49.3,66.1,55.9,49.1,63.0,21.0,53.6,50.1,37.4,71.5,56.5,33.4,51.2,51.9,47.8,52.8,53.2,21.9,55.8,47.0,49.3,66.1,53.6,50.1,56.5
|
| 4 |
+
Gender,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0
|
output/preprocess/Arrhythmia/clinical_data/GSE235307.csv
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
| 1 |
+
GSM7498589,GSM7498590,GSM7498591,GSM7498592,GSM7498593,GSM7498594,GSM7498595,GSM7498596,GSM7498597,GSM7498598,GSM7498599,GSM7498600,GSM7498601,GSM7498602,GSM7498603,GSM7498604,GSM7498605,GSM7498606,GSM7498607,GSM7498608,GSM7498609,GSM7498610,GSM7498611,GSM7498612,GSM7498613,GSM7498614,GSM7498615,GSM7498616,GSM7498617,GSM7498618,GSM7498619,GSM7498620,GSM7498621,GSM7498622,GSM7498623,GSM7498624,GSM7498625,GSM7498626,GSM7498627,GSM7498628,GSM7498629,GSM7498630,GSM7498631,GSM7498632,GSM7498633,GSM7498634,GSM7498635,GSM7498636,GSM7498637,GSM7498638,GSM7498639,GSM7498640,GSM7498641,GSM7498642,GSM7498643,GSM7498644,GSM7498645,GSM7498646,GSM7498647,GSM7498648,GSM7498649,GSM7498650,GSM7498651,GSM7498652,GSM7498653,GSM7498654,GSM7498655,GSM7498656,GSM7498657,GSM7498658,GSM7498659,GSM7498660,GSM7498661,GSM7498662,GSM7498663,GSM7498664,GSM7498665,GSM7498666,GSM7498667,GSM7498668,GSM7498669,GSM7498670,GSM7498671,GSM7498672,GSM7498673,GSM7498674,GSM7498675,GSM7498676,GSM7498677,GSM7498678,GSM7498679,GSM7498680,GSM7498681,GSM7498682,GSM7498683,GSM7498684,GSM7498685,GSM7498686,GSM7498687,GSM7498688,GSM7498689,GSM7498690,GSM7498691,GSM7498692,GSM7498693,GSM7498694,GSM7498695,GSM7498696,GSM7498697,GSM7498698,GSM7498699,GSM7498700,GSM7498701,GSM7498702,GSM7498703,GSM7498704,GSM7498705,GSM7498706,GSM7498707
|
| 2 |
+
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0
|
| 3 |
+
63.0,60.0,60.0,72.0,63.0,66.0,70.0,64.0,63.0,61.0,70.0,64.0,63.0,44.0,54.0,44.0,50.0,79.0,63.0,63.0,64.0,60.0,51.0,55.0,55.0,67.0,52.0,70.0,54.0,54.0,73.0,54.0,76.0,76.0,43.0,64.0,64.0,68.0,43.0,54.0,72.0,51.0,68.0,50.0,78.0,69.0,64.0,54.0,54.0,57.0,55.0,60.0,59.0,54.0,54.0,54.0,54.0,53.0,52.0,68.0,72.0,70.0,65.0,64.0,56.0,56.0,63.0,57.0,63.0,68.0,66.0,74.0,38.0,56.0,57.0,71.0,78.0,51.0,50.0,37.0,37.0,70.0,72.0,73.0,69.0,69.0,63.0,62.0,59.0,67.0,76.0,63.0,55.0,57.0,53.0,59.0,77.0,54.0,64.0,75.0,75.0,72.0,58.0,75.0,78.0,58.0,64.0,63.0,61.0,60.0,59.0,68.0,77.0,57.0,62.0,66.0,57.0,65.0,59.0
|
| 4 |
+
1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0
|
output/preprocess/Arrhythmia/clinical_data/GSE41177.csv
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GSM1005418,GSM1005419,GSM1005420,GSM1005421,GSM1005422,GSM1005423,GSM1005424,GSM1005425,GSM1005426,GSM1005427,GSM1005428,GSM1005429,GSM1005430,GSM1005431,GSM1005432,GSM1005433,GSM1005434,GSM1005435,GSM1005436,GSM1005437,GSM1005438,GSM1005439,GSM1005440,GSM1005441,GSM1005442,GSM1005443,GSM1005444,GSM1005445,GSM1006245,GSM1006246,GSM1006247,GSM1006248,GSM1006249,GSM1006250,GSM1006251,GSM1006252,GSM1006253,GSM1006254
|
| 2 |
+
0.0,0.0,0.0,0.0,0.0,0.0,10.0,10.0,110.0,110.0,15.0,15.0,1.0,1.0,72.0,72.0,102.0,102.0,48.0,48.0,10.0,10.0,1.0,1.0,100.0,100.0,1.0,1.0,73.0,73.0,14.0,14.0,150.0,150.0,78.0,78.0,1.0,1.0
|
| 3 |
+
62.0,62.0,43.0,43.0,55.0,55.0,65.0,65.0,65.0,65.0,61.0,61.0,64.0,64.0,47.0,47.0,60.0,60.0,71.0,71.0,32.0,32.0,59.0,59.0,56.0,56.0,51.0,51.0,59.0,59.0,32.0,32.0,43.0,43.0,66.0,66.0,36.0,36.0
|
| 4 |
+
0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0
|
output/preprocess/Arrhythmia/clinical_data/GSE53622.csv
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,GSM1296956,GSM1296957,GSM1296958,GSM1296959,GSM1296960,GSM1296961,GSM1296962,GSM1296963,GSM1296964,GSM1296965,GSM1296966,GSM1296967,GSM1296968,GSM1296969,GSM1296970,GSM1296971,GSM1296972,GSM1296973,GSM1296974,GSM1296975,GSM1296976,GSM1296977,GSM1296978,GSM1296979,GSM1296980,GSM1296981,GSM1296982,GSM1296983,GSM1296984,GSM1296985,GSM1296986,GSM1296987,GSM1296988,GSM1296989,GSM1296990,GSM1296991,GSM1296992,GSM1296993,GSM1296994,GSM1296995,GSM1296996,GSM1296997,GSM1296998,GSM1296999,GSM1297000,GSM1297001,GSM1297002,GSM1297003,GSM1297004,GSM1297005,GSM1297006,GSM1297007,GSM1297008,GSM1297009,GSM1297010,GSM1297011,GSM1297012,GSM1297013,GSM1297014,GSM1297015,GSM1297016,GSM1297017,GSM1297018,GSM1297019,GSM1297020,GSM1297021,GSM1297022,GSM1297023,GSM1297024,GSM1297025,GSM1297026,GSM1297027,GSM1297028,GSM1297029,GSM1297030,GSM1297031,GSM1297032,GSM1297033,GSM1297034,GSM1297035,GSM1297036,GSM1297037,GSM1297038,GSM1297039,GSM1297040,GSM1297041,GSM1297042,GSM1297043,GSM1297044,GSM1297045,GSM1297046,GSM1297047,GSM1297048,GSM1297049,GSM1297050,GSM1297051,GSM1297052,GSM1297053,GSM1297054,GSM1297055,GSM1297056,GSM1297057,GSM1297058,GSM1297059,GSM1297060,GSM1297061,GSM1297062,GSM1297063,GSM1297064,GSM1297065,GSM1297066,GSM1297067,GSM1297068,GSM1297069,GSM1297070,GSM1297071,GSM1297072,GSM1297073,GSM1297074,GSM1297075
|
| 2 |
+
Arrhythmia,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0
|
| 3 |
+
Age,66.4602739726027,66.4602739726027,64.013698630137,64.013698630137,50.9123287671233,50.9123287671233,46.3287671232877,46.3287671232877,53.9972602739726,53.9972602739726,67.8438356164384,67.8438356164384,64.8794520547945,64.8794520547945,45.2219178082192,45.2219178082192,54.4794520547945,54.4794520547945,56.2328767123288,56.2328767123288,57.0986301369863,57.0986301369863,44.6630136986301,44.6630136986301,43.7698630136986,43.7698630136986,67.2739726027397,67.2739726027397,68.2904109589041,68.2904109589041,60.5068493150685,60.5068493150685,48.4027397260274,48.4027397260274,54.2931506849315,54.2931506849315,51.9890410958904,51.9890410958904,58.3205479452055,58.3205479452055,66.2712328767123,66.2712328767123,72.241095890411,72.241095890411,64.7506849315069,64.7506849315069,54.5753424657534,54.5753424657534,62.4383561643836,62.4383561643836,66.1479452054794,66.1479452054794,53.7424657534247,53.7424657534247,56.9643835616438,56.9643835616438,71.9150684931507,71.9150684931507,53.5643835616438,53.5643835616438,61.2739726027397,61.2739726027397,66.4602739726027,66.4602739726027,62.1205479452055,62.1205479452055,59.6520547945205,59.6520547945205,65.4493150684931,65.4493150684931,51.7369863013699,51.7369863013699,58.6356164383562,58.6356164383562,75.5095890410959,75.5095890410959,71.1835616438356,71.1835616438356,55.9890410958904,55.9890410958904,56.0849315068493,56.0849315068493,56.0,56.0,81.0,81.0,51.0,51.0,57.3945205479452,57.3945205479452,50.9424657534247,50.9424657534247,80.9506849315069,80.9506849315069,63.7178082191781,63.7178082191781,62.8986301369863,62.8986301369863,62.8438356164384,62.8438356164384,68.5178082191781,68.5178082191781,39.5397260273973,39.5397260273973,68.0849315068493,68.0849315068493,66.9178082191781,66.9178082191781,47.5506849315069,47.5506849315069,46.0328767123288,46.0328767123288,59.972602739726,59.972602739726,63.6602739726027,63.6602739726027,78.8876712328767,78.8876712328767,61.3315068493151,61.3315068493151
|
| 4 |
+
Gender,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
output/preprocess/Arrhythmia/clinical_data/GSE93101.csv
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,GSM2443799,GSM2443800,GSM2443801,GSM2443802,GSM2443803,GSM2443804,GSM2443805,GSM2443806,GSM2443807,GSM2443808,GSM2443809,GSM2443810,GSM2443811,GSM2443812,GSM2443813,GSM2443814,GSM2443815,GSM2443816,GSM2443817,GSM2443818,GSM2443819,GSM2443820,GSM2443821,GSM2443822,GSM2443823,GSM2443824,GSM2443825,GSM2443826,GSM2443827,GSM2443828,GSM2443829,GSM2443830,GSM2443831
|
| 2 |
+
Arrhythmia,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
| 3 |
+
Age,33.4,51.2,51.9,47.8,41.5,67.3,52.8,16.1,78.9,53.2,70.9,59.9,21.9,45.2,52.4,32.3,52.8,55.8,47.0,55.8,57.3,31.7,49.3,66.1,55.9,49.1,63.0,21.0,53.6,50.1,37.4,71.5,56.5
|
| 4 |
+
Gender,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0
|
output/preprocess/Arrhythmia/code/GSE115574.py
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
cohort = "GSE115574"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Arrhythmia"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Arrhythmia/GSE115574"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/GSE115574.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/GSE115574.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/GSE115574.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import re
|
| 41 |
+
|
| 42 |
+
# 1) Gene expression data availability
|
| 43 |
+
is_gene_available = True # Affymetrix human gene expression microarrays (mRNA), not miRNA-only or methylation-only.
|
| 44 |
+
|
| 45 |
+
# 2) Variable availability and converters
|
| 46 |
+
|
| 47 |
+
# Trait (Arrhythmia) is represented by disease state: AFib vs sinus rhythm at row 0.
|
| 48 |
+
trait_row = 0
|
| 49 |
+
|
| 50 |
+
# Age and gender are not provided in the sample characteristics shown.
|
| 51 |
+
age_row = None
|
| 52 |
+
gender_row = None
|
| 53 |
+
|
| 54 |
+
def _extract_value(x):
|
| 55 |
+
if x is None:
|
| 56 |
+
return None
|
| 57 |
+
# Handle potential NaNs
|
| 58 |
+
try:
|
| 59 |
+
import pandas as pd
|
| 60 |
+
if pd.isna(x):
|
| 61 |
+
return None
|
| 62 |
+
except Exception:
|
| 63 |
+
pass
|
| 64 |
+
# Extract substring after the first colon if present
|
| 65 |
+
s = str(x)
|
| 66 |
+
parts = s.split(":", 1)
|
| 67 |
+
val = parts[1] if len(parts) == 2 else parts[0]
|
| 68 |
+
return val.strip().lower()
|
| 69 |
+
|
| 70 |
+
def convert_trait(x):
|
| 71 |
+
"""
|
| 72 |
+
Map Arrhythmia status: AF/AFib -> 1; Sinus rhythm (SR) -> 0; otherwise None.
|
| 73 |
+
"""
|
| 74 |
+
val = _extract_value(x)
|
| 75 |
+
if val is None:
|
| 76 |
+
return None
|
| 77 |
+
|
| 78 |
+
# Positive for arrhythmia if 'atrial fibrillation' or 'afib' or ' af ' as a word
|
| 79 |
+
if ("atrial fibrillation" in val) or re.search(r"\bafib\b", val) or re.search(r"\baf\b", val):
|
| 80 |
+
return 1
|
| 81 |
+
# Negative if 'sinus rhythm' or ' sr ' as a word
|
| 82 |
+
if ("sinus rhythm" in val) or re.search(r"\bsr\b", val):
|
| 83 |
+
return 0
|
| 84 |
+
|
| 85 |
+
return None
|
| 86 |
+
|
| 87 |
+
# Define but not used since rows are unavailable
|
| 88 |
+
def convert_age(x):
|
| 89 |
+
return None
|
| 90 |
+
|
| 91 |
+
def convert_gender(x):
|
| 92 |
+
return None
|
| 93 |
+
|
| 94 |
+
# 3) Save metadata (initial filtering)
|
| 95 |
+
is_trait_available = trait_row is not None
|
| 96 |
+
_ = validate_and_save_cohort_info(
|
| 97 |
+
is_final=False,
|
| 98 |
+
cohort=cohort,
|
| 99 |
+
info_path=json_path,
|
| 100 |
+
is_gene_available=is_gene_available,
|
| 101 |
+
is_trait_available=is_trait_available
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
# 4) Clinical feature extraction (only if clinical data is available)
|
| 105 |
+
if trait_row is not None:
|
| 106 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 107 |
+
clinical_df=clinical_data,
|
| 108 |
+
trait=trait,
|
| 109 |
+
trait_row=trait_row,
|
| 110 |
+
convert_trait=convert_trait,
|
| 111 |
+
age_row=age_row,
|
| 112 |
+
convert_age=None,
|
| 113 |
+
gender_row=gender_row,
|
| 114 |
+
convert_gender=None
|
| 115 |
+
)
|
| 116 |
+
# Preview and save
|
| 117 |
+
preview = preview_df(selected_clinical_df)
|
| 118 |
+
print(preview)
|
| 119 |
+
|
| 120 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 121 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
| 122 |
+
|
| 123 |
+
# Step 3: Gene Data Extraction
|
| 124 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 125 |
+
gene_data = get_genetic_data(matrix_file)
|
| 126 |
+
|
| 127 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 128 |
+
print(gene_data.index[:20])
|
| 129 |
+
|
| 130 |
+
# Step 4: Gene Identifier Review
|
| 131 |
+
print("requires_gene_mapping = True")
|
| 132 |
+
|
| 133 |
+
# Step 5: Gene Annotation
|
| 134 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 135 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 136 |
+
|
| 137 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 138 |
+
print("Gene annotation preview:")
|
| 139 |
+
print(preview_df(gene_annotation))
|
| 140 |
+
|
| 141 |
+
# Step 6: Gene Identifier Mapping
|
| 142 |
+
# Identify the appropriate columns for probe IDs and gene symbols based on the annotation preview
|
| 143 |
+
probe_col = 'ID'
|
| 144 |
+
gene_symbol_col = 'Gene Symbol'
|
| 145 |
+
|
| 146 |
+
# Build mapping dataframe
|
| 147 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=gene_symbol_col)
|
| 148 |
+
|
| 149 |
+
# Apply mapping to convert probe-level data to gene-level expression
|
| 150 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
| 151 |
+
|
| 152 |
+
# Optionally save the gene-level data for later steps
|
| 153 |
+
import os
|
| 154 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 155 |
+
gene_data.to_csv(out_gene_data_file)
|
| 156 |
+
|
| 157 |
+
# Step 7: Data Normalization and Linking
|
| 158 |
+
import os
|
| 159 |
+
|
| 160 |
+
# 1. Normalize gene symbols and save
|
| 161 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 162 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 163 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 164 |
+
|
| 165 |
+
# 2. Link clinical and genetic data
|
| 166 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 167 |
+
|
| 168 |
+
# 3. Handle missing values
|
| 169 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 170 |
+
|
| 171 |
+
# 4. Check bias and remove biased demographic features
|
| 172 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 173 |
+
|
| 174 |
+
# 5. Final validation and metadata saving
|
| 175 |
+
note = "INFO: Trait from disease state (AFib=1 vs SR=0); Age and Gender unavailable in sample characteristics."
|
| 176 |
+
is_usable = validate_and_save_cohort_info(
|
| 177 |
+
is_final=True,
|
| 178 |
+
cohort=cohort,
|
| 179 |
+
info_path=json_path,
|
| 180 |
+
is_gene_available=True,
|
| 181 |
+
is_trait_available=True,
|
| 182 |
+
is_biased=is_trait_biased,
|
| 183 |
+
df=unbiased_linked_data,
|
| 184 |
+
note=note
|
| 185 |
+
)
|
| 186 |
+
|
| 187 |
+
# 6. Save linked data if usable
|
| 188 |
+
if is_usable:
|
| 189 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 190 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Arrhythmia/code/GSE136992.py
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
cohort = "GSE136992"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Arrhythmia"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Arrhythmia/GSE136992"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/GSE136992.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/GSE136992.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/GSE136992.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
import math
|
| 41 |
+
|
| 42 |
+
# 1) Gene expression data availability
|
| 43 |
+
# Background indicates "mRNA expression ... Illumina whole genome gene expression DASL HT assay" -> gene data available.
|
| 44 |
+
is_gene_available = True
|
| 45 |
+
|
| 46 |
+
# 2) Variable availability and conversion functions
|
| 47 |
+
|
| 48 |
+
# Trait (Arrhythmia): Not available in this dataset; "condition" is Infection vs Control and does not indicate arrhythmia.
|
| 49 |
+
trait_row = None
|
| 50 |
+
|
| 51 |
+
# Age: Available at row 2 (values like "age: 0.5 weeks", etc.)
|
| 52 |
+
age_row = 2
|
| 53 |
+
|
| 54 |
+
# Gender: Available at row 3 ("gender: male/female")
|
| 55 |
+
gender_row = 3
|
| 56 |
+
|
| 57 |
+
def convert_trait(x):
|
| 58 |
+
# Trait not available; return None for any input
|
| 59 |
+
return None
|
| 60 |
+
|
| 61 |
+
def _extract_value_after_colon(x):
|
| 62 |
+
if x is None:
|
| 63 |
+
return None
|
| 64 |
+
s = str(x)
|
| 65 |
+
if ':' in s:
|
| 66 |
+
return s.split(':', 1)[1].strip()
|
| 67 |
+
return s.strip()
|
| 68 |
+
|
| 69 |
+
def convert_age(x):
|
| 70 |
+
"""
|
| 71 |
+
Convert age string like 'age: 12 weeks' into a float number of weeks.
|
| 72 |
+
Unknown or unparsable values -> None.
|
| 73 |
+
"""
|
| 74 |
+
val = _extract_value_after_colon(x)
|
| 75 |
+
if val is None:
|
| 76 |
+
return None
|
| 77 |
+
v = val.lower().strip()
|
| 78 |
+
# Accept numbers possibly with unit; default unit weeks if not specified
|
| 79 |
+
# Handle common units
|
| 80 |
+
m = re.match(r'^([0-9]*\.?[0-9]+)\s*(week|weeks|wk|wks|day|days|d|month|months|mo|year|years|yr|yrs)?$', v)
|
| 81 |
+
if not m:
|
| 82 |
+
return None
|
| 83 |
+
num = float(m.group(1))
|
| 84 |
+
unit = m.group(2) if m.group(2) else 'weeks'
|
| 85 |
+
unit = unit.lower()
|
| 86 |
+
# Convert all to weeks
|
| 87 |
+
if unit in ['week', 'weeks', 'wk', 'wks']:
|
| 88 |
+
weeks = num
|
| 89 |
+
elif unit in ['day', 'days', 'd']:
|
| 90 |
+
weeks = num / 7.0
|
| 91 |
+
elif unit in ['month', 'months', 'mo']:
|
| 92 |
+
weeks = num * (365.25 / 12.0) / 7.0
|
| 93 |
+
elif unit in ['year', 'years', 'yr', 'yrs']:
|
| 94 |
+
weeks = num * 52.17857 # approx
|
| 95 |
+
else:
|
| 96 |
+
weeks = num # default to weeks
|
| 97 |
+
return weeks
|
| 98 |
+
|
| 99 |
+
def convert_gender(x):
|
| 100 |
+
"""
|
| 101 |
+
Convert gender to binary: female -> 0, male -> 1; unknown -> None.
|
| 102 |
+
"""
|
| 103 |
+
val = _extract_value_after_colon(x)
|
| 104 |
+
if val is None:
|
| 105 |
+
return None
|
| 106 |
+
g = val.strip().lower()
|
| 107 |
+
if g in ['female', 'f']:
|
| 108 |
+
return 0
|
| 109 |
+
if g in ['male', 'm']:
|
| 110 |
+
return 1
|
| 111 |
+
return None
|
| 112 |
+
|
| 113 |
+
# 3) Save metadata with initial filtering
|
| 114 |
+
is_trait_available = trait_row is not None
|
| 115 |
+
_ = validate_and_save_cohort_info(
|
| 116 |
+
is_final=False,
|
| 117 |
+
cohort=cohort,
|
| 118 |
+
info_path=json_path,
|
| 119 |
+
is_gene_available=is_gene_available,
|
| 120 |
+
is_trait_available=is_trait_available
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
# 4) Clinical feature extraction: skipped because trait_row is None
|
output/preprocess/Arrhythmia/code/GSE143924.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
cohort = "GSE143924"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Arrhythmia"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Arrhythmia/GSE143924"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/GSE143924.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/GSE143924.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/GSE143924.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import re
|
| 41 |
+
import pandas as pd
|
| 42 |
+
|
| 43 |
+
# 1. Gene expression availability
|
| 44 |
+
is_gene_available = True # Transcriptome (gene expression) analysis is explicitly stated in background.
|
| 45 |
+
|
| 46 |
+
# 2. Variable availability keys inferred from Sample Characteristics Dictionary
|
| 47 |
+
trait_row = 1 # patient diagnosis: sinus rhythm after surgery vs postoperative atrial fibrillation (POAF)
|
| 48 |
+
age_row = None # Not present in provided characteristics
|
| 49 |
+
gender_row = None # Not present in provided characteristics
|
| 50 |
+
|
| 51 |
+
# 2.2 Conversion functions
|
| 52 |
+
def _after_colon(value):
|
| 53 |
+
if value is None:
|
| 54 |
+
return None
|
| 55 |
+
s = str(value)
|
| 56 |
+
parts = s.split(":", 1)
|
| 57 |
+
s = parts[1] if len(parts) > 1 else parts[0]
|
| 58 |
+
return s.strip()
|
| 59 |
+
|
| 60 |
+
def convert_trait(value):
|
| 61 |
+
"""
|
| 62 |
+
Map arrhythmia status (AF/POAF) to binary:
|
| 63 |
+
- 1: any mention of atrial fibrillation, fibrillation, AF, or POAF
|
| 64 |
+
- 0: sinus rhythm / non-POAF / no AF
|
| 65 |
+
"""
|
| 66 |
+
v = _after_colon(value)
|
| 67 |
+
if v is None or v == "":
|
| 68 |
+
return None
|
| 69 |
+
s = v.lower()
|
| 70 |
+
|
| 71 |
+
# Positive (arrhythmia present)
|
| 72 |
+
if any(k in s for k in ["atrial fibrillation", "fibrillation", "poaf", "af "]):
|
| 73 |
+
return 1
|
| 74 |
+
# Negative (no arrhythmia)
|
| 75 |
+
if "sinus rhythm" in s or "non-poaf" in s or "no atrial fibrillation" in s or s == "sr":
|
| 76 |
+
return 0
|
| 77 |
+
|
| 78 |
+
# Heuristic: 'poaf' abbreviation or 'af' at end/beginning
|
| 79 |
+
if re.search(r"\b(poaf|af)\b", s):
|
| 80 |
+
return 1
|
| 81 |
+
|
| 82 |
+
return None
|
| 83 |
+
|
| 84 |
+
def convert_age(value):
|
| 85 |
+
"""
|
| 86 |
+
Convert age text to continuous float (years). Extract first number found.
|
| 87 |
+
"""
|
| 88 |
+
v = _after_colon(value)
|
| 89 |
+
if v is None or v == "":
|
| 90 |
+
return None
|
| 91 |
+
m = re.search(r"(\d+(\.\d+)?)", v)
|
| 92 |
+
if not m:
|
| 93 |
+
return None
|
| 94 |
+
try:
|
| 95 |
+
return float(m.group(1))
|
| 96 |
+
except Exception:
|
| 97 |
+
return None
|
| 98 |
+
|
| 99 |
+
def convert_gender(value):
|
| 100 |
+
"""
|
| 101 |
+
Convert gender to binary: female->0, male->1.
|
| 102 |
+
"""
|
| 103 |
+
v = _after_colon(value)
|
| 104 |
+
if v is None or v == "":
|
| 105 |
+
return None
|
| 106 |
+
s = v.strip().lower()
|
| 107 |
+
if s in ["male", "m"]:
|
| 108 |
+
return 1
|
| 109 |
+
if s in ["female", "f"]:
|
| 110 |
+
return 0
|
| 111 |
+
return None
|
| 112 |
+
|
| 113 |
+
# 3. Save metadata (initial filtering)
|
| 114 |
+
is_trait_available = trait_row is not None
|
| 115 |
+
_ = validate_and_save_cohort_info(
|
| 116 |
+
is_final=False,
|
| 117 |
+
cohort=cohort,
|
| 118 |
+
info_path=json_path,
|
| 119 |
+
is_gene_available=is_gene_available,
|
| 120 |
+
is_trait_available=is_trait_available
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
# 4. Clinical feature extraction (only if trait is available)
|
| 124 |
+
if trait_row is not None:
|
| 125 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 126 |
+
clinical_df=clinical_data,
|
| 127 |
+
trait=trait,
|
| 128 |
+
trait_row=trait_row,
|
| 129 |
+
convert_trait=convert_trait,
|
| 130 |
+
age_row=age_row,
|
| 131 |
+
convert_age=convert_age,
|
| 132 |
+
gender_row=gender_row,
|
| 133 |
+
convert_gender=convert_gender
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
# Preview and save
|
| 137 |
+
preview = preview_df(selected_clinical_df)
|
| 138 |
+
print("Preview of selected clinical features:", preview)
|
| 139 |
+
|
| 140 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 141 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=True)
|
| 142 |
+
|
| 143 |
+
# Step 3: Gene Data Extraction
|
| 144 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 145 |
+
gene_data = get_genetic_data(matrix_file)
|
| 146 |
+
|
| 147 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 148 |
+
print(gene_data.index[:20])
|
| 149 |
+
|
| 150 |
+
# Step 4: Gene Identifier Review
|
| 151 |
+
# Based on inspection of identifiers like "AACS", "AADAC", "ABCA1", "ABCB1", which are HGNC human gene symbols,
|
| 152 |
+
# mapping is not required.
|
| 153 |
+
print("requires_gene_mapping = False")
|
| 154 |
+
|
| 155 |
+
# Step 5: Data Normalization and Linking
|
| 156 |
+
import os
|
| 157 |
+
|
| 158 |
+
# 1. Normalize gene symbols and save gene data
|
| 159 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 160 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 161 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 162 |
+
|
| 163 |
+
# 2. Link clinical and genetic data
|
| 164 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 165 |
+
|
| 166 |
+
# 3. Handle missing values
|
| 167 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 168 |
+
|
| 169 |
+
# 4. Bias evaluation (trait required; drop biased demographics)
|
| 170 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 171 |
+
|
| 172 |
+
# 5. Final validation and save cohort info
|
| 173 |
+
note = "INFO: Balanced POAF vs SR (15/15); no age/gender available."
|
| 174 |
+
is_usable = validate_and_save_cohort_info(
|
| 175 |
+
is_final=True,
|
| 176 |
+
cohort=cohort,
|
| 177 |
+
info_path=json_path,
|
| 178 |
+
is_gene_available=True,
|
| 179 |
+
is_trait_available=True,
|
| 180 |
+
is_biased=is_trait_biased,
|
| 181 |
+
df=unbiased_linked_data,
|
| 182 |
+
note=note
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
# 6. Save linked data if usable
|
| 186 |
+
if is_usable:
|
| 187 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 188 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Arrhythmia/code/GSE182600.py
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
cohort = "GSE182600"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Arrhythmia"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Arrhythmia/GSE182600"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/GSE182600.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/GSE182600.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/GSE182600.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import math
|
| 41 |
+
import pandas as pd
|
| 42 |
+
|
| 43 |
+
# 1) Gene expression data availability (based on background description)
|
| 44 |
+
is_gene_available = True # Transcriptomic profiling / genome-wide gene expression
|
| 45 |
+
|
| 46 |
+
# 2) Variable availability based on the provided sample characteristics dictionary
|
| 47 |
+
trait_row = 0 # 'disease state: ... includes Arrhythmia'
|
| 48 |
+
age_row = 1 # 'age: <float>'
|
| 49 |
+
gender_row = 2 # 'gender: M/F'
|
| 50 |
+
|
| 51 |
+
# 2.2) Conversion helpers
|
| 52 |
+
def _after_colon(x):
|
| 53 |
+
if x is None or (isinstance(x, float) and math.isnan(x)):
|
| 54 |
+
return None
|
| 55 |
+
s = str(x)
|
| 56 |
+
if ':' in s:
|
| 57 |
+
s = s.split(':', 1)[1]
|
| 58 |
+
return s.strip()
|
| 59 |
+
|
| 60 |
+
def convert_trait(x):
|
| 61 |
+
v = _after_colon(x)
|
| 62 |
+
if v is None or v == '':
|
| 63 |
+
return None
|
| 64 |
+
v_low = v.lower()
|
| 65 |
+
# 1 for Arrhythmia, 0 for other disease states
|
| 66 |
+
if 'arrhythmia' == v_low:
|
| 67 |
+
return 1
|
| 68 |
+
# If clearly another disease state, map to 0
|
| 69 |
+
other_states = [
|
| 70 |
+
'acute myocardial infarction', 'acute myocarditis', 'congestive heart failure',
|
| 71 |
+
'dilated cardiomyopathy', 'dilated cardiomyopathy, dcmp', 'aortic dissection'
|
| 72 |
+
]
|
| 73 |
+
if v_low in other_states:
|
| 74 |
+
return 0
|
| 75 |
+
# Default: if it contains arrhythmia substring
|
| 76 |
+
if 'arrhythmia' in v_low:
|
| 77 |
+
return 1
|
| 78 |
+
return 0 # Treat other known disease states as 0
|
| 79 |
+
|
| 80 |
+
def convert_age(x):
|
| 81 |
+
v = _after_colon(x)
|
| 82 |
+
if v is None or v == '':
|
| 83 |
+
return None
|
| 84 |
+
try:
|
| 85 |
+
age = float(v)
|
| 86 |
+
if 0 < age < 120:
|
| 87 |
+
return age
|
| 88 |
+
return None
|
| 89 |
+
except Exception:
|
| 90 |
+
return None
|
| 91 |
+
|
| 92 |
+
def convert_gender(x):
|
| 93 |
+
v = _after_colon(x)
|
| 94 |
+
if v is None or v == '':
|
| 95 |
+
return None
|
| 96 |
+
v_low = v.strip().lower()
|
| 97 |
+
if v_low in ['m', 'male', 'man']:
|
| 98 |
+
return 1
|
| 99 |
+
if v_low in ['f', 'female', 'woman']:
|
| 100 |
+
return 0
|
| 101 |
+
return None
|
| 102 |
+
|
| 103 |
+
# 3) Save initial metadata
|
| 104 |
+
is_trait_available = trait_row is not None
|
| 105 |
+
_ = validate_and_save_cohort_info(
|
| 106 |
+
is_final=False,
|
| 107 |
+
cohort=cohort,
|
| 108 |
+
info_path=json_path,
|
| 109 |
+
is_gene_available=is_gene_available,
|
| 110 |
+
is_trait_available=is_trait_available
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
# 4) Clinical feature extraction, preview, and save
|
| 114 |
+
if trait_row is not None:
|
| 115 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 116 |
+
clinical_df=clinical_data,
|
| 117 |
+
trait=trait,
|
| 118 |
+
trait_row=trait_row,
|
| 119 |
+
convert_trait=convert_trait,
|
| 120 |
+
age_row=age_row,
|
| 121 |
+
convert_age=convert_age,
|
| 122 |
+
gender_row=gender_row,
|
| 123 |
+
convert_gender=convert_gender
|
| 124 |
+
)
|
| 125 |
+
preview = preview_df(selected_clinical_df)
|
| 126 |
+
print(preview)
|
| 127 |
+
|
| 128 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 129 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=True)
|
| 130 |
+
|
| 131 |
+
# Step 3: Gene Data Extraction
|
| 132 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 133 |
+
gene_data = get_genetic_data(matrix_file)
|
| 134 |
+
|
| 135 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 136 |
+
print(gene_data.index[:20])
|
| 137 |
+
|
| 138 |
+
# Step 4: Gene Identifier Review
|
| 139 |
+
requires_gene_mapping = True
|
| 140 |
+
print(f"requires_gene_mapping = {requires_gene_mapping}")
|
| 141 |
+
|
| 142 |
+
# Step 5: Gene Annotation
|
| 143 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 144 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 145 |
+
|
| 146 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 147 |
+
print("Gene annotation preview:")
|
| 148 |
+
print(preview_df(gene_annotation))
|
| 149 |
+
|
| 150 |
+
# Step 6: Gene Identifier Mapping
|
| 151 |
+
# Identify the appropriate columns in the annotation for probe IDs and gene symbols
|
| 152 |
+
probe_id_col = 'ID' # Matches probe identifiers like ILMN_1343291
|
| 153 |
+
gene_symbol_col = 'Symbol' # Contains gene symbols
|
| 154 |
+
|
| 155 |
+
# 2) Build mapping dataframe
|
| 156 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_id_col, gene_col=gene_symbol_col)
|
| 157 |
+
|
| 158 |
+
# 3) Apply mapping to convert probe-level data to gene-level expression
|
| 159 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
|
| 160 |
+
|
| 161 |
+
# Step 7: Data Normalization and Linking
|
| 162 |
+
import os
|
| 163 |
+
|
| 164 |
+
# 1. Normalize gene symbols and save gene data
|
| 165 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 166 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 167 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 168 |
+
|
| 169 |
+
# 2. Link clinical and genetic data
|
| 170 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 171 |
+
|
| 172 |
+
# 3. Handle missing values
|
| 173 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 174 |
+
|
| 175 |
+
# 4. Bias check and remove biased demographic features if necessary
|
| 176 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 177 |
+
|
| 178 |
+
# 5. Final validation and save cohort info
|
| 179 |
+
is_gene_available_flag = (normalized_gene_data.shape[0] > 0) and (normalized_gene_data.shape[1] > 0)
|
| 180 |
+
is_trait_available_flag = True # Clinical trait was extracted previously
|
| 181 |
+
is_usable = validate_and_save_cohort_info(
|
| 182 |
+
is_final=True,
|
| 183 |
+
cohort=cohort,
|
| 184 |
+
info_path=json_path,
|
| 185 |
+
is_gene_available=is_gene_available_flag,
|
| 186 |
+
is_trait_available=is_trait_available_flag,
|
| 187 |
+
is_biased=is_trait_biased,
|
| 188 |
+
df=unbiased_linked_data,
|
| 189 |
+
note=""
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
+
# 6. Save linked data if usable
|
| 193 |
+
if is_usable:
|
| 194 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 195 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Arrhythmia/code/GSE235307.py
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
cohort = "GSE235307"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Arrhythmia"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Arrhythmia/GSE235307"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/GSE235307.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/GSE235307.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/GSE235307.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import re
|
| 41 |
+
import pandas as pd
|
| 42 |
+
|
| 43 |
+
# 1) Gene expression availability based on background info
|
| 44 |
+
is_gene_available = True # Series title indicates gene expression profiling (not miRNA/methylation)
|
| 45 |
+
|
| 46 |
+
# 2) Variable availability (from the provided Sample Characteristics Dictionary)
|
| 47 |
+
trait_row = 5 # 'cardiac rhythm after 1 year follow-up: ...'
|
| 48 |
+
age_row = 2 # 'age: ...'
|
| 49 |
+
gender_row = 1 # 'gender: ...'
|
| 50 |
+
|
| 51 |
+
# 2.2) Conversion utilities
|
| 52 |
+
def _after_colon(x):
|
| 53 |
+
if x is None or (isinstance(x, float) and pd.isna(x)):
|
| 54 |
+
return None
|
| 55 |
+
s = str(x)
|
| 56 |
+
if ':' in s:
|
| 57 |
+
s = s.split(':', 1)[1]
|
| 58 |
+
return s.strip()
|
| 59 |
+
|
| 60 |
+
def convert_trait(x):
|
| 61 |
+
"""
|
| 62 |
+
Binary:
|
| 63 |
+
- 1: Atrial fibrillation (AF)
|
| 64 |
+
- 0: Sinus rhythm
|
| 65 |
+
- None: unknown/other
|
| 66 |
+
"""
|
| 67 |
+
v = _after_colon(x)
|
| 68 |
+
if v is None:
|
| 69 |
+
return None
|
| 70 |
+
vl = v.strip().lower()
|
| 71 |
+
if 'atrial fibrillation' in vl or 'a-fib' in vl or (('atrial' in vl) and ('fibrillation' in vl)) or vl == 'af':
|
| 72 |
+
return 1
|
| 73 |
+
if 'sinus' in vl and 'rhythm' in vl:
|
| 74 |
+
return 0
|
| 75 |
+
if vl == 'sr':
|
| 76 |
+
return 0
|
| 77 |
+
return None
|
| 78 |
+
|
| 79 |
+
def convert_age(x):
|
| 80 |
+
"""
|
| 81 |
+
Continuous age in years. Extract first numeric token; return float if valid (0 < age <= 120), else None.
|
| 82 |
+
"""
|
| 83 |
+
v = _after_colon(x)
|
| 84 |
+
if v is None:
|
| 85 |
+
return None
|
| 86 |
+
m = re.search(r'(\d+(\.\d+)?)', v)
|
| 87 |
+
if not m:
|
| 88 |
+
return None
|
| 89 |
+
try:
|
| 90 |
+
age_val = float(m.group(1))
|
| 91 |
+
except Exception:
|
| 92 |
+
return None
|
| 93 |
+
if 0 < age_val <= 120:
|
| 94 |
+
return age_val
|
| 95 |
+
return None
|
| 96 |
+
|
| 97 |
+
def convert_gender(x):
|
| 98 |
+
"""
|
| 99 |
+
Binary gender:
|
| 100 |
+
- 1: Male
|
| 101 |
+
- 0: Female
|
| 102 |
+
- None: unknown/other
|
| 103 |
+
"""
|
| 104 |
+
v = _after_colon(x)
|
| 105 |
+
if v is None:
|
| 106 |
+
return None
|
| 107 |
+
vl = v.strip().lower()
|
| 108 |
+
if vl in ['male', 'm', 'man']:
|
| 109 |
+
return 1
|
| 110 |
+
if vl in ['female', 'f', 'woman', 'women']:
|
| 111 |
+
return 0
|
| 112 |
+
return None
|
| 113 |
+
|
| 114 |
+
# 3) Save metadata via initial filtering
|
| 115 |
+
is_trait_available = trait_row is not None
|
| 116 |
+
_ = validate_and_save_cohort_info(
|
| 117 |
+
is_final=False,
|
| 118 |
+
cohort=cohort,
|
| 119 |
+
info_path=json_path,
|
| 120 |
+
is_gene_available=is_gene_available,
|
| 121 |
+
is_trait_available=is_trait_available
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
# 4) Clinical Feature Extraction (only if clinical data is available)
|
| 125 |
+
if is_trait_available:
|
| 126 |
+
if 'clinical_data' in locals():
|
| 127 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 128 |
+
clinical_df=clinical_data,
|
| 129 |
+
trait=trait,
|
| 130 |
+
trait_row=trait_row,
|
| 131 |
+
convert_trait=convert_trait,
|
| 132 |
+
age_row=age_row,
|
| 133 |
+
convert_age=convert_age,
|
| 134 |
+
gender_row=gender_row,
|
| 135 |
+
convert_gender=convert_gender
|
| 136 |
+
)
|
| 137 |
+
clinical_preview = preview_df(selected_clinical_df)
|
| 138 |
+
print("Clinical preview:", clinical_preview)
|
| 139 |
+
|
| 140 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 141 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
| 142 |
+
else:
|
| 143 |
+
print("WARNING: 'clinical_data' not found in environment. Skipping clinical feature extraction.")
|
| 144 |
+
|
| 145 |
+
# Step 3: Gene Data Extraction
|
| 146 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 147 |
+
gene_data = get_genetic_data(matrix_file)
|
| 148 |
+
|
| 149 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 150 |
+
print(gene_data.index[:20])
|
| 151 |
+
|
| 152 |
+
# Step 4: Gene Identifier Review
|
| 153 |
+
print("requires_gene_mapping = True")
|
| 154 |
+
|
| 155 |
+
# Step 5: Gene Annotation
|
| 156 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 157 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 158 |
+
|
| 159 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 160 |
+
print("Gene annotation preview:")
|
| 161 |
+
print(preview_df(gene_annotation))
|
| 162 |
+
|
| 163 |
+
# Step 6: Gene Identifier Mapping
|
| 164 |
+
# Determine appropriate identifier columns based on overlap with expression data indices
|
| 165 |
+
id_candidates = [col for col in ['ID', 'NAME', 'SPOT_ID'] if col in gene_annotation.columns]
|
| 166 |
+
expr_ids = set(gene_data.index.astype(str))
|
| 167 |
+
|
| 168 |
+
best_id_col = None
|
| 169 |
+
best_overlap = -1
|
| 170 |
+
for col in id_candidates:
|
| 171 |
+
ann_ids = set(gene_annotation[col].astype(str))
|
| 172 |
+
overlap = len(expr_ids & ann_ids)
|
| 173 |
+
if overlap > best_overlap:
|
| 174 |
+
best_overlap = overlap
|
| 175 |
+
best_id_col = col
|
| 176 |
+
|
| 177 |
+
# Fallback to 'ID' if nothing better is found (shouldn't happen given preview)
|
| 178 |
+
if best_id_col is None:
|
| 179 |
+
best_id_col = 'ID'
|
| 180 |
+
|
| 181 |
+
# Gene symbol column
|
| 182 |
+
gene_symbol_col = 'GENE_SYMBOL'
|
| 183 |
+
|
| 184 |
+
# Build mapping dataframe
|
| 185 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=best_id_col, gene_col=gene_symbol_col)
|
| 186 |
+
|
| 187 |
+
# Apply mapping to convert probe-level data to gene-level data
|
| 188 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
|
| 189 |
+
|
| 190 |
+
# Step 7: Data Normalization and Linking
|
| 191 |
+
import os
|
| 192 |
+
import pandas as pd
|
| 193 |
+
|
| 194 |
+
# 1. Normalize gene symbols and save gene expression data
|
| 195 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 196 |
+
|
| 197 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 198 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 199 |
+
|
| 200 |
+
# 2. Link clinical and genetic data
|
| 201 |
+
# Use the in-memory clinical dataframe if available; otherwise reload from disk and restore row labels.
|
| 202 |
+
if 'selected_clinical_df' not in locals():
|
| 203 |
+
if os.path.exists(out_clinical_data_file):
|
| 204 |
+
tmp = pd.read_csv(out_clinical_data_file)
|
| 205 |
+
# The saved file had index=False, so restore expected row index if shapes match
|
| 206 |
+
if tmp.shape[0] == 3:
|
| 207 |
+
tmp.index = [trait, 'Age', 'Gender']
|
| 208 |
+
selected_clinical_df = tmp
|
| 209 |
+
else:
|
| 210 |
+
raise RuntimeError("Clinical data not found in memory or on disk.")
|
| 211 |
+
|
| 212 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 213 |
+
|
| 214 |
+
# 3. Handle missing values
|
| 215 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 216 |
+
|
| 217 |
+
# 4. Assess bias and remove biased demographic features
|
| 218 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 219 |
+
|
| 220 |
+
# 5. Final validation and save cohort metadata
|
| 221 |
+
note = f"INFO: Gene symbols normalized using NCBI synonyms. Linked {normalized_gene_data.shape[1]} samples and {normalized_gene_data.shape[0]} genes before QC."
|
| 222 |
+
is_usable = validate_and_save_cohort_info(
|
| 223 |
+
is_final=True,
|
| 224 |
+
cohort=cohort,
|
| 225 |
+
info_path=json_path,
|
| 226 |
+
is_gene_available=True,
|
| 227 |
+
is_trait_available=True,
|
| 228 |
+
is_biased=is_trait_biased,
|
| 229 |
+
df=unbiased_linked_data,
|
| 230 |
+
note=note
|
| 231 |
+
)
|
| 232 |
+
|
| 233 |
+
# 6. Save linked data if usable
|
| 234 |
+
if is_usable:
|
| 235 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 236 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Arrhythmia/code/GSE41177.py
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
cohort = "GSE41177"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Arrhythmia"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Arrhythmia/GSE41177"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/GSE41177.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/GSE41177.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/GSE41177.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
import pandas as pd
|
| 41 |
+
|
| 42 |
+
# 1) Gene expression availability
|
| 43 |
+
is_gene_available = True # Microarray gene expression per background info
|
| 44 |
+
|
| 45 |
+
# 2) Variable availability and converters
|
| 46 |
+
# Sample Characteristics Dictionary indices:
|
| 47 |
+
# 0: organ, 1: gender, 2: age, 3: af duration (months)
|
| 48 |
+
trait_row = 3 # Use AF duration as a continuous arrhythmia-related trait (months)
|
| 49 |
+
age_row = 2
|
| 50 |
+
gender_row = 1
|
| 51 |
+
|
| 52 |
+
def _after_colon(value: str) -> str:
|
| 53 |
+
if value is None or (isinstance(value, float) and pd.isna(value)):
|
| 54 |
+
return ""
|
| 55 |
+
s = str(value)
|
| 56 |
+
parts = s.split(":", 1)
|
| 57 |
+
return parts[1].strip() if len(parts) > 1 else s.strip()
|
| 58 |
+
|
| 59 |
+
def convert_trait(value):
|
| 60 |
+
# Convert AF duration to months (continuous). Examples: '>1M', '0M', '10M', '110M'
|
| 61 |
+
s = _after_colon(value)
|
| 62 |
+
if not s:
|
| 63 |
+
return None
|
| 64 |
+
s = s.strip()
|
| 65 |
+
# Match optional comparator and a number followed by 'M' or 'm'
|
| 66 |
+
m = re.search(r'([<>]=?)?\s*([0-9]+)\s*[mM]\b', s)
|
| 67 |
+
if m:
|
| 68 |
+
sign = m.group(1) or ""
|
| 69 |
+
num = int(m.group(2))
|
| 70 |
+
# Use numeric bound; for '>1M' map to 1 (lower bound) to keep it numeric
|
| 71 |
+
return float(num)
|
| 72 |
+
# Fallback: any digits interpreted as months
|
| 73 |
+
m2 = re.search(r'([0-9]+)', s)
|
| 74 |
+
if m2:
|
| 75 |
+
return float(m2.group(1))
|
| 76 |
+
return None
|
| 77 |
+
|
| 78 |
+
def convert_age(value):
|
| 79 |
+
# Convert 'age: 43Y' to 43 (years, continuous)
|
| 80 |
+
s = _after_colon(value)
|
| 81 |
+
if not s:
|
| 82 |
+
return None
|
| 83 |
+
s = s.strip()
|
| 84 |
+
m = re.search(r'([0-9]+)\s*[yY]?\b', s)
|
| 85 |
+
if m:
|
| 86 |
+
return float(m.group(1))
|
| 87 |
+
return None
|
| 88 |
+
|
| 89 |
+
def convert_gender(value):
|
| 90 |
+
# Binary: female -> 0, male -> 1
|
| 91 |
+
s = _after_colon(value).lower()
|
| 92 |
+
if not s:
|
| 93 |
+
return None
|
| 94 |
+
if "female" in s:
|
| 95 |
+
return 0
|
| 96 |
+
if "male" in s:
|
| 97 |
+
return 1
|
| 98 |
+
return None
|
| 99 |
+
|
| 100 |
+
# 3) Save metadata (initial filtering)
|
| 101 |
+
is_trait_available = trait_row is not None
|
| 102 |
+
_ = validate_and_save_cohort_info(
|
| 103 |
+
is_final=False,
|
| 104 |
+
cohort=cohort,
|
| 105 |
+
info_path=json_path,
|
| 106 |
+
is_gene_available=is_gene_available,
|
| 107 |
+
is_trait_available=is_trait_available
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
# 4) Clinical feature extraction (only if trait data is available)
|
| 111 |
+
if is_trait_available:
|
| 112 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 113 |
+
clinical_df=clinical_data,
|
| 114 |
+
trait=trait,
|
| 115 |
+
trait_row=trait_row,
|
| 116 |
+
convert_trait=convert_trait,
|
| 117 |
+
age_row=age_row,
|
| 118 |
+
convert_age=convert_age,
|
| 119 |
+
gender_row=gender_row,
|
| 120 |
+
convert_gender=convert_gender
|
| 121 |
+
)
|
| 122 |
+
preview = preview_df(selected_clinical_df)
|
| 123 |
+
print(preview)
|
| 124 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
| 125 |
+
|
| 126 |
+
# Step 3: Gene Data Extraction
|
| 127 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 128 |
+
gene_data = get_genetic_data(matrix_file)
|
| 129 |
+
|
| 130 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 131 |
+
print(gene_data.index[:20])
|
| 132 |
+
|
| 133 |
+
# Step 4: Gene Identifier Review
|
| 134 |
+
# Affymetrix probe set IDs like "1007_s_at", "1053_at" indicate non-gene-symbol identifiers.
|
| 135 |
+
requires_gene_mapping = True
|
| 136 |
+
print(f"requires_gene_mapping = {requires_gene_mapping}")
|
| 137 |
+
|
| 138 |
+
# Step 5: Gene Annotation
|
| 139 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 140 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 141 |
+
|
| 142 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 143 |
+
print("Gene annotation preview:")
|
| 144 |
+
print(preview_df(gene_annotation))
|
| 145 |
+
|
| 146 |
+
# Step 6: Gene Identifier Mapping
|
| 147 |
+
# Identify the columns for probe IDs and gene symbols from the annotation preview:
|
| 148 |
+
# Probe IDs: 'ID' (e.g., '1007_s_at'); Gene symbols: 'Gene Symbol'
|
| 149 |
+
|
| 150 |
+
# 1-2) Build mapping dataframe from annotation
|
| 151 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
|
| 152 |
+
|
| 153 |
+
# 3) Apply mapping to convert probe-level data to gene-level expression
|
| 154 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
|
| 155 |
+
|
| 156 |
+
# Step 7: Data Normalization and Linking
|
| 157 |
+
import os
|
| 158 |
+
|
| 159 |
+
# 1. Normalize gene symbols and save gene expression data
|
| 160 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 161 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 162 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 163 |
+
|
| 164 |
+
# 2. Link clinical and genetic data
|
| 165 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 166 |
+
|
| 167 |
+
# 3. Handle missing values
|
| 168 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 169 |
+
|
| 170 |
+
# 4. Assess bias and remove biased demographic features
|
| 171 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 172 |
+
|
| 173 |
+
# 5. Final validation and save cohort info
|
| 174 |
+
note_text = "INFO: Trait is AF duration (months); paired tissue samples (LA-PV junction vs LAA)."
|
| 175 |
+
is_usable = validate_and_save_cohort_info(
|
| 176 |
+
True, cohort, json_path, True, True, is_trait_biased, unbiased_linked_data, note=note_text
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
# 6. Save linked data if usable
|
| 180 |
+
if is_usable:
|
| 181 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 182 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Arrhythmia/code/GSE47727.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
cohort = "GSE47727"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Arrhythmia"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Arrhythmia/GSE47727"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/GSE47727.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/GSE47727.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/GSE47727.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
|
| 41 |
+
# 1) Gene expression data availability
|
| 42 |
+
# Platform: Illumina HumanHT-12 v3.0 gene expression microarray -> gene data available
|
| 43 |
+
is_gene_available = True
|
| 44 |
+
|
| 45 |
+
# 2) Variable availability and conversion functions
|
| 46 |
+
|
| 47 |
+
# Trait (Arrhythmia) availability:
|
| 48 |
+
# Sample characteristics only include age, gender, and tissue; no disease status.
|
| 49 |
+
# Background indicates "control participants" only -> trait not variable (constant/absent).
|
| 50 |
+
trait_row = None # Not available
|
| 51 |
+
|
| 52 |
+
# Age availability
|
| 53 |
+
age_row = 0 # 'age (yrs): ...'
|
| 54 |
+
|
| 55 |
+
# Gender availability
|
| 56 |
+
gender_row = 1 # 'gender: female' / 'gender: male'
|
| 57 |
+
|
| 58 |
+
# Conversion functions
|
| 59 |
+
def convert_trait(x):
|
| 60 |
+
# Generic mapper for Arrhythmia/AF presence; not used here since trait_row is None.
|
| 61 |
+
if x is None:
|
| 62 |
+
return None
|
| 63 |
+
s = str(x)
|
| 64 |
+
if ':' in s:
|
| 65 |
+
s = s.split(':', 1)[1]
|
| 66 |
+
v = s.strip().lower()
|
| 67 |
+
# Positive mappings
|
| 68 |
+
pos_terms = {
|
| 69 |
+
'arrhythmia', 'atrial fibrillation', 'af', 'yes', 'present', 'case', '1', 'true', 'y'
|
| 70 |
+
}
|
| 71 |
+
neg_terms = {
|
| 72 |
+
'no arrhythmia', 'no af', 'none', 'no', 'absent', 'control', '0', 'false', 'n', 'healthy', 'normal'
|
| 73 |
+
}
|
| 74 |
+
if v in pos_terms:
|
| 75 |
+
return 1
|
| 76 |
+
if v in neg_terms:
|
| 77 |
+
return 0
|
| 78 |
+
# Heuristics for strings containing keywords
|
| 79 |
+
if any(k in v for k in ['atrial fibrillation', 'af', 'arrhythmia']):
|
| 80 |
+
# If explicitly negated, map to 0
|
| 81 |
+
if any(k in v for k in ['no ', 'absent', 'without', 'free of']):
|
| 82 |
+
return 0
|
| 83 |
+
return 1
|
| 84 |
+
return None
|
| 85 |
+
|
| 86 |
+
def convert_age(x):
|
| 87 |
+
if x is None:
|
| 88 |
+
return None
|
| 89 |
+
s = str(x)
|
| 90 |
+
if ':' in s:
|
| 91 |
+
s = s.split(':', 1)[1]
|
| 92 |
+
s = s.strip()
|
| 93 |
+
m = re.search(r'(\d+(\.\d+)?)', s)
|
| 94 |
+
if not m:
|
| 95 |
+
return None
|
| 96 |
+
try:
|
| 97 |
+
return float(m.group(1))
|
| 98 |
+
except Exception:
|
| 99 |
+
return None
|
| 100 |
+
|
| 101 |
+
def convert_gender(x):
|
| 102 |
+
if x is None:
|
| 103 |
+
return None
|
| 104 |
+
s = str(x)
|
| 105 |
+
if ':' in s:
|
| 106 |
+
s = s.split(':', 1)[1]
|
| 107 |
+
v = s.strip().lower()
|
| 108 |
+
if v in ['female', 'f', '0']:
|
| 109 |
+
return 0
|
| 110 |
+
if v in ['male', 'm', '1']:
|
| 111 |
+
return 1
|
| 112 |
+
return None
|
| 113 |
+
|
| 114 |
+
# 3) Save metadata (initial filtering)
|
| 115 |
+
is_trait_available = trait_row is not None
|
| 116 |
+
_ = validate_and_save_cohort_info(
|
| 117 |
+
is_final=False,
|
| 118 |
+
cohort=cohort,
|
| 119 |
+
info_path=json_path,
|
| 120 |
+
is_gene_available=is_gene_available,
|
| 121 |
+
is_trait_available=is_trait_available
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
# 4) Clinical feature extraction (skip because trait_row is None)
|
| 125 |
+
# If in future a trait field is identified, uncomment the following block:
|
| 126 |
+
# if trait_row is not None:
|
| 127 |
+
# selected_df = geo_select_clinical_features(
|
| 128 |
+
# clinical_df=clinical_data,
|
| 129 |
+
# trait=trait,
|
| 130 |
+
# trait_row=trait_row,
|
| 131 |
+
# convert_trait=convert_trait,
|
| 132 |
+
# age_row=age_row,
|
| 133 |
+
# convert_age=convert_age,
|
| 134 |
+
# gender_row=gender_row,
|
| 135 |
+
# convert_gender=convert_gender
|
| 136 |
+
# )
|
| 137 |
+
# preview = preview_df(selected_df, n=5)
|
| 138 |
+
# os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 139 |
+
# selected_df.to_csv(out_clinical_data_file)
|
output/preprocess/Arrhythmia/code/GSE53622.py
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
cohort = "GSE53622"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Arrhythmia"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Arrhythmia/GSE53622"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/GSE53622.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/GSE53622.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/GSE53622.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import pandas as pd
|
| 41 |
+
|
| 42 |
+
# 1) Assess gene expression availability (lncRNA microarray is acceptable as gene expression)
|
| 43 |
+
is_gene_available = True
|
| 44 |
+
|
| 45 |
+
# 2) Variable availability
|
| 46 |
+
trait_row = 10 # 'arrhythmia: yes/no'
|
| 47 |
+
age_row = 1 # 'age: float'
|
| 48 |
+
gender_row = 2 # 'Sex: male/female'
|
| 49 |
+
|
| 50 |
+
# 2) Conversion functions
|
| 51 |
+
def _after_colon(x):
|
| 52 |
+
if x is None or (isinstance(x, float) and pd.isna(x)):
|
| 53 |
+
return None
|
| 54 |
+
s = str(x)
|
| 55 |
+
parts = s.split(":", 1)
|
| 56 |
+
val = parts[1] if len(parts) > 1 else parts[0]
|
| 57 |
+
return val.strip()
|
| 58 |
+
|
| 59 |
+
def convert_trait(x):
|
| 60 |
+
v = _after_colon(x)
|
| 61 |
+
if v is None:
|
| 62 |
+
return None
|
| 63 |
+
v_l = v.strip().lower()
|
| 64 |
+
if v_l in {"yes", "y", "1", "true", "present"}:
|
| 65 |
+
return 1
|
| 66 |
+
if v_l in {"no", "n", "0", "false", "absent"}:
|
| 67 |
+
return 0
|
| 68 |
+
return None
|
| 69 |
+
|
| 70 |
+
def convert_age(x):
|
| 71 |
+
v = _after_colon(x)
|
| 72 |
+
if v is None:
|
| 73 |
+
return None
|
| 74 |
+
try:
|
| 75 |
+
age = float(v)
|
| 76 |
+
# basic sanity check for human age
|
| 77 |
+
if 0 <= age <= 120:
|
| 78 |
+
return age
|
| 79 |
+
return None
|
| 80 |
+
except Exception:
|
| 81 |
+
return None
|
| 82 |
+
|
| 83 |
+
def convert_gender(x):
|
| 84 |
+
v = _after_colon(x)
|
| 85 |
+
if v is None:
|
| 86 |
+
return None
|
| 87 |
+
v_l = v.strip().lower()
|
| 88 |
+
if v_l in {"female", "f", "woman", "women"}:
|
| 89 |
+
return 0
|
| 90 |
+
if v_l in {"male", "m", "man", "men"}:
|
| 91 |
+
return 1
|
| 92 |
+
return None
|
| 93 |
+
|
| 94 |
+
# 3) Save initial metadata
|
| 95 |
+
is_trait_available = trait_row is not None
|
| 96 |
+
_ = validate_and_save_cohort_info(
|
| 97 |
+
is_final=False,
|
| 98 |
+
cohort=cohort,
|
| 99 |
+
info_path=json_path,
|
| 100 |
+
is_gene_available=is_gene_available,
|
| 101 |
+
is_trait_available=is_trait_available
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
# 4) Clinical feature extraction (only if clinical trait is available)
|
| 105 |
+
if is_trait_available:
|
| 106 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 107 |
+
clinical_df=clinical_data,
|
| 108 |
+
trait=trait,
|
| 109 |
+
trait_row=trait_row,
|
| 110 |
+
convert_trait=convert_trait,
|
| 111 |
+
age_row=age_row,
|
| 112 |
+
convert_age=convert_age,
|
| 113 |
+
gender_row=gender_row,
|
| 114 |
+
convert_gender=convert_gender
|
| 115 |
+
)
|
| 116 |
+
# Observe preview
|
| 117 |
+
preview = preview_df(selected_clinical_df)
|
| 118 |
+
print(preview)
|
| 119 |
+
|
| 120 |
+
# Save clinical data
|
| 121 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 122 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=True)
|
| 123 |
+
|
| 124 |
+
# Step 3: Gene Data Extraction
|
| 125 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 126 |
+
gene_data = get_genetic_data(matrix_file)
|
| 127 |
+
|
| 128 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 129 |
+
print(gene_data.index[:20])
|
| 130 |
+
|
| 131 |
+
# Step 4: Gene Identifier Review
|
| 132 |
+
print("requires_gene_mapping = True")
|
| 133 |
+
|
| 134 |
+
# Step 5: Gene Annotation
|
| 135 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 136 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 137 |
+
|
| 138 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 139 |
+
print("Gene annotation preview:")
|
| 140 |
+
print(preview_df(gene_annotation))
|
| 141 |
+
|
| 142 |
+
# Step 6: Gene Identifier Mapping
|
| 143 |
+
# Step 6 (revised): Map probe IDs to human gene symbols using platform (GPL) annotation
|
| 144 |
+
|
| 145 |
+
import os
|
| 146 |
+
import pandas as pd
|
| 147 |
+
|
| 148 |
+
def try_mapping_with_annotation(ann_df: pd.DataFrame, expr_df: pd.DataFrame):
|
| 149 |
+
# Identify the probe ID column with maximum overlap to expression index
|
| 150 |
+
id_overlaps = []
|
| 151 |
+
for col in ann_df.columns:
|
| 152 |
+
try:
|
| 153 |
+
overlap = ann_df[col].astype(str).str.strip().isin(expr_df.index).sum()
|
| 154 |
+
id_overlaps.append((col, int(overlap)))
|
| 155 |
+
except Exception:
|
| 156 |
+
continue
|
| 157 |
+
if not id_overlaps:
|
| 158 |
+
return None, None, None
|
| 159 |
+
id_overlaps.sort(key=lambda x: x[1], reverse=True)
|
| 160 |
+
prob_col, prob_overlap = id_overlaps[0]
|
| 161 |
+
if prob_overlap == 0:
|
| 162 |
+
return None, None, None
|
| 163 |
+
|
| 164 |
+
# Identify gene symbol column by content-based detection (max extractable human gene symbols)
|
| 165 |
+
gene_col = None
|
| 166 |
+
max_nonempty = -1
|
| 167 |
+
for col in ann_df.columns:
|
| 168 |
+
if col == prob_col:
|
| 169 |
+
continue
|
| 170 |
+
try:
|
| 171 |
+
extracted = ann_df[col].astype(str).map(extract_human_gene_symbols)
|
| 172 |
+
nonempty = extracted.map(lambda x: len(x) if isinstance(x, list) else 0).gt(0).sum()
|
| 173 |
+
if nonempty > max_nonempty:
|
| 174 |
+
max_nonempty = nonempty
|
| 175 |
+
gene_col = col
|
| 176 |
+
except Exception:
|
| 177 |
+
continue
|
| 178 |
+
|
| 179 |
+
if gene_col is None or max_nonempty <= 0:
|
| 180 |
+
return None, None, None
|
| 181 |
+
|
| 182 |
+
# Build mapping and apply
|
| 183 |
+
mapping_df = get_gene_mapping(ann_df, prob_col=prob_col, gene_col=gene_col)
|
| 184 |
+
mapping_df = mapping_df[mapping_df['ID'].isin(expr_df.index)]
|
| 185 |
+
if len(mapping_df) == 0:
|
| 186 |
+
return None, None, None
|
| 187 |
+
|
| 188 |
+
gene_level_df = apply_gene_mapping(expression_df=expr_df, mapping_df=mapping_df)
|
| 189 |
+
return gene_level_df, prob_col, gene_col
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
# Find candidate GPL SOFT files (prefer within cohort dir, then trait dir)
|
| 193 |
+
candidate_softs = []
|
| 194 |
+
for search_dir in [in_cohort_dir, in_trait_dir]:
|
| 195 |
+
if os.path.isdir(search_dir):
|
| 196 |
+
for fname in os.listdir(search_dir):
|
| 197 |
+
low = fname.lower()
|
| 198 |
+
if ('gpl' in low) and ('soft' in low):
|
| 199 |
+
candidate_softs.append(os.path.join(search_dir, fname))
|
| 200 |
+
|
| 201 |
+
# Ensure uniqueness and stable order
|
| 202 |
+
candidate_softs = list(dict.fromkeys(candidate_softs))
|
| 203 |
+
|
| 204 |
+
mapping_done = False
|
| 205 |
+
used_gpl = None
|
| 206 |
+
used_prob_col = None
|
| 207 |
+
used_gene_col = None
|
| 208 |
+
|
| 209 |
+
# Try GPL annotations first
|
| 210 |
+
for gpl_path in candidate_softs:
|
| 211 |
+
try:
|
| 212 |
+
platform_annotation = get_gene_annotation(gpl_path)
|
| 213 |
+
result = try_mapping_with_annotation(platform_annotation, gene_data)
|
| 214 |
+
if result[0] is not None:
|
| 215 |
+
gene_data, used_prob_col, used_gene_col = result
|
| 216 |
+
used_gpl = gpl_path
|
| 217 |
+
mapping_done = True
|
| 218 |
+
print(f"Mapping succeeded with GPL annotation: {os.path.basename(gpl_path)}")
|
| 219 |
+
print(f"Probe ID column: {used_prob_col} | Gene symbol column: {used_gene_col}")
|
| 220 |
+
print(f"Gene-level matrix shape: {gene_data.shape}")
|
| 221 |
+
break
|
| 222 |
+
except Exception as e:
|
| 223 |
+
# Try next GPL if this one fails to parse properly
|
| 224 |
+
print(f"Warning: Failed to use {gpl_path} due to error: {e}")
|
| 225 |
+
|
| 226 |
+
# Fallback: attempt with the previously loaded SOFT (may be series-level; often insufficient)
|
| 227 |
+
if not mapping_done:
|
| 228 |
+
try:
|
| 229 |
+
ann_series = gene_annotation.copy()
|
| 230 |
+
result = try_mapping_with_annotation(ann_series, gene_data)
|
| 231 |
+
if result[0] is not None:
|
| 232 |
+
gene_data, used_prob_col, used_gene_col = result
|
| 233 |
+
mapping_done = True
|
| 234 |
+
print("Mapping succeeded using the previously loaded SOFT annotation (non-GPL).")
|
| 235 |
+
print(f"Probe ID column: {used_prob_col} | Gene symbol column: {used_gene_col}")
|
| 236 |
+
print(f"Gene-level matrix shape: {gene_data.shape}")
|
| 237 |
+
except Exception as e:
|
| 238 |
+
print(f"Warning: Fallback mapping with series SOFT failed due to error: {e}")
|
| 239 |
+
|
| 240 |
+
if not mapping_done:
|
| 241 |
+
raise RuntimeError("Probe-to-gene mapping failed: no suitable GPL annotation found or no valid mapping could be derived.")
|
| 242 |
+
|
| 243 |
+
# Step 7: Data Normalization and Linking
|
| 244 |
+
import os
|
| 245 |
+
|
| 246 |
+
# 1. Normalize gene symbols and save gene matrix
|
| 247 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 248 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 249 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 250 |
+
|
| 251 |
+
# 2. Link clinical and genetic data on sample IDs
|
| 252 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 253 |
+
|
| 254 |
+
# 3. Handle missing values
|
| 255 |
+
is_gene_available_final = (normalized_gene_data.shape[0] > 0)
|
| 256 |
+
if is_gene_available_final:
|
| 257 |
+
processed_linked = handle_missing_values(linked_data, trait)
|
| 258 |
+
else:
|
| 259 |
+
# Avoid dropping all samples when there are no gene columns
|
| 260 |
+
df = linked_data.copy()
|
| 261 |
+
# Drop samples with missing trait
|
| 262 |
+
df = df.dropna(subset=[trait])
|
| 263 |
+
# Impute Age with mean if present
|
| 264 |
+
if 'Age' in df.columns:
|
| 265 |
+
df['Age'] = df['Age'].astype(float)
|
| 266 |
+
df['Age'] = df['Age'].fillna(df['Age'].mean())
|
| 267 |
+
# Impute Gender with mode if present
|
| 268 |
+
if 'Gender' in df.columns:
|
| 269 |
+
mode_result = df['Gender'].mode()
|
| 270 |
+
if len(mode_result) > 0:
|
| 271 |
+
df['Gender'] = df['Gender'].fillna(mode_result[0])
|
| 272 |
+
else:
|
| 273 |
+
df = df.drop(columns=['Gender'])
|
| 274 |
+
processed_linked = df
|
| 275 |
+
|
| 276 |
+
# 4. Bias check and drop biased demographic features
|
| 277 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(processed_linked, trait)
|
| 278 |
+
|
| 279 |
+
# 5. Final validation and save cohort info
|
| 280 |
+
is_trait_available_final = (trait in selected_clinical_df.index) and (not selected_clinical_df.loc[trait].isna().all())
|
| 281 |
+
|
| 282 |
+
note = ""
|
| 283 |
+
if not is_gene_available_final:
|
| 284 |
+
used_gene_col_str = globals().get("used_gene_col", None)
|
| 285 |
+
used_prob_col_str = globals().get("used_prob_col", None)
|
| 286 |
+
used_gpl_str = os.path.basename(globals().get("used_gpl", "")) if globals().get("used_gpl", None) else "non-GPL SOFT"
|
| 287 |
+
details = []
|
| 288 |
+
if used_prob_col_str:
|
| 289 |
+
details.append(f"probe column '{used_prob_col_str}'")
|
| 290 |
+
if used_gene_col_str:
|
| 291 |
+
details.append(f"gene column '{used_gene_col_str}'")
|
| 292 |
+
detail_str = ", ".join(details) if details else "unknown columns"
|
| 293 |
+
note = f"WARNING: Gene mapping likely failed (gene matrix empty after normalization). Previous mapping used {detail_str} from {used_gpl_str}."
|
| 294 |
+
|
| 295 |
+
is_usable = validate_and_save_cohort_info(
|
| 296 |
+
is_final=True,
|
| 297 |
+
cohort=cohort,
|
| 298 |
+
info_path=json_path,
|
| 299 |
+
is_gene_available=is_gene_available_final,
|
| 300 |
+
is_trait_available=is_trait_available_final,
|
| 301 |
+
is_biased=is_trait_biased,
|
| 302 |
+
df=unbiased_linked_data,
|
| 303 |
+
note=note
|
| 304 |
+
)
|
| 305 |
+
|
| 306 |
+
# 6. Save linked data if usable
|
| 307 |
+
if is_usable:
|
| 308 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 309 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Arrhythmia/code/GSE55231.py
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
cohort = "GSE55231"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Arrhythmia"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Arrhythmia/GSE55231"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/GSE55231.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/GSE55231.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/GSE55231.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
|
| 41 |
+
# 1) Gene expression data availability
|
| 42 |
+
is_gene_available = True # Illumina Human HT12 v4 expression profiling (mRNA), not miRNA/methylation
|
| 43 |
+
|
| 44 |
+
# 2) Variable availability and data type conversion
|
| 45 |
+
|
| 46 |
+
# Availability (from Sample Characteristics Dictionary)
|
| 47 |
+
trait_row = None # No arrhythmia-related phenotype available; donors are non-diseased, no case/control info
|
| 48 |
+
age_row = 2 # 'age: <number>'
|
| 49 |
+
gender_row = 0 # 'gender: male/female'
|
| 50 |
+
|
| 51 |
+
# Converters
|
| 52 |
+
def _after_colon(value):
|
| 53 |
+
if value is None:
|
| 54 |
+
return None
|
| 55 |
+
parts = str(value).split(":", 1)
|
| 56 |
+
return parts[1].strip() if len(parts) > 1 else str(value).strip()
|
| 57 |
+
|
| 58 |
+
def convert_trait(x):
|
| 59 |
+
"""
|
| 60 |
+
Binary: 1 = arrhythmia present, 0 = no arrhythmia.
|
| 61 |
+
Heuristics to map a wide range of arrhythmia-related terms if present.
|
| 62 |
+
Unknown/irrelevant values -> None.
|
| 63 |
+
"""
|
| 64 |
+
v = _after_colon(x)
|
| 65 |
+
if v is None or v == "":
|
| 66 |
+
return None
|
| 67 |
+
s = v.lower()
|
| 68 |
+
|
| 69 |
+
# Explicit negatives
|
| 70 |
+
neg_markers = ["no arrhythmia", "arrhythmia: no", "absence of arrhythmia", "no history of arrhythmia",
|
| 71 |
+
"control", "healthy", "non-diseased", "normal"]
|
| 72 |
+
if any(m in s for m in neg_markers):
|
| 73 |
+
return 0
|
| 74 |
+
|
| 75 |
+
# Explicit positives
|
| 76 |
+
pos_terms = [
|
| 77 |
+
"arrhythmia", "atrial fibrillation", "af", "atrial flutter", "ventricular tachycardia", "vt",
|
| 78 |
+
"ventricular fibrillation", "vf", "svt", "supraventricular tachycardia", "long qt", "brugada",
|
| 79 |
+
"wpw", "wolff-parkinson-white"
|
| 80 |
+
]
|
| 81 |
+
if any(term in s for term in pos_terms):
|
| 82 |
+
# If explicitly says 'no', treat as negative (safeguard)
|
| 83 |
+
if "no " in s or "absent" in s:
|
| 84 |
+
return 0
|
| 85 |
+
return 1
|
| 86 |
+
|
| 87 |
+
# Generic yes/no patterns
|
| 88 |
+
if re.search(r"\byes\b|\bpresent\b|\bcase\b|\bpatient\b", s):
|
| 89 |
+
return 1
|
| 90 |
+
if re.search(r"\bno\b|\babsent\b|\bcontrol\b|\bhealthy\b|\bnon-diseased\b|\bnormal\b", s):
|
| 91 |
+
return 0
|
| 92 |
+
|
| 93 |
+
return None
|
| 94 |
+
|
| 95 |
+
def convert_age(x):
|
| 96 |
+
"""
|
| 97 |
+
Continuous age in years (float). Extracts first numeric token after colon.
|
| 98 |
+
"""
|
| 99 |
+
v = _after_colon(x)
|
| 100 |
+
if v is None or v == "":
|
| 101 |
+
return None
|
| 102 |
+
# Find first number (integer or float)
|
| 103 |
+
m = re.search(r"[-+]?\d*\.?\d+", v)
|
| 104 |
+
if not m:
|
| 105 |
+
return None
|
| 106 |
+
try:
|
| 107 |
+
return float(m.group())
|
| 108 |
+
except Exception:
|
| 109 |
+
return None
|
| 110 |
+
|
| 111 |
+
def convert_gender(x):
|
| 112 |
+
"""
|
| 113 |
+
Binary: female = 0, male = 1
|
| 114 |
+
"""
|
| 115 |
+
v = _after_colon(x)
|
| 116 |
+
if v is None or v == "":
|
| 117 |
+
return None
|
| 118 |
+
s = v.strip().lower()
|
| 119 |
+
if s in ["female", "f", "woman", "girl"]:
|
| 120 |
+
return 0
|
| 121 |
+
if s in ["male", "m", "man", "boy"]:
|
| 122 |
+
return 1
|
| 123 |
+
return None
|
| 124 |
+
|
| 125 |
+
# 3) Save metadata (initial filtering)
|
| 126 |
+
is_trait_available = trait_row is not None
|
| 127 |
+
_ = validate_and_save_cohort_info(
|
| 128 |
+
is_final=False,
|
| 129 |
+
cohort=cohort,
|
| 130 |
+
info_path=json_path,
|
| 131 |
+
is_gene_available=is_gene_available,
|
| 132 |
+
is_trait_available=is_trait_available
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
# 4) Clinical Feature Extraction
|
| 136 |
+
# Skipped because trait_row is None (no clinical trait data available for Arrhythmia in this cohort)
|
| 137 |
+
|
| 138 |
+
# Step 3: Gene Data Extraction
|
| 139 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 140 |
+
gene_data = get_genetic_data(matrix_file)
|
| 141 |
+
|
| 142 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 143 |
+
print(gene_data.index[:20])
|
| 144 |
+
|
| 145 |
+
# Step 4: Gene Identifier Review
|
| 146 |
+
requires_gene_mapping = True
|
| 147 |
+
print(f"requires_gene_mapping = {requires_gene_mapping}")
|
| 148 |
+
|
| 149 |
+
# Step 5: Gene Annotation
|
| 150 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 151 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 152 |
+
|
| 153 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 154 |
+
print("Gene annotation preview:")
|
| 155 |
+
print(preview_df(gene_annotation))
|
| 156 |
+
|
| 157 |
+
# Step 6: Gene Identifier Mapping
|
| 158 |
+
# Identify the appropriate columns for mapping: probe IDs and gene symbols
|
| 159 |
+
probe_id_col = 'ID'
|
| 160 |
+
gene_symbol_col = 'Symbol'
|
| 161 |
+
|
| 162 |
+
# Create the mapping dataframe from the annotation
|
| 163 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_id_col, gene_col=gene_symbol_col)
|
| 164 |
+
|
| 165 |
+
# Apply the mapping to convert probe-level data to gene-level data
|
| 166 |
+
probe_data = gene_data # backup the probe-level data
|
| 167 |
+
gene_data = apply_gene_mapping(probe_data, mapping_df)
|
| 168 |
+
|
| 169 |
+
# Step 7: Data Normalization and Linking
|
| 170 |
+
import os
|
| 171 |
+
import pandas as pd
|
| 172 |
+
|
| 173 |
+
# 1. Normalize gene symbols, drop unrecognized, aggregate duplicates, and save
|
| 174 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 175 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 176 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 177 |
+
|
| 178 |
+
# 2-6. Proceed with linking and downstream steps only if clinical data (selected_clinical_data) exists
|
| 179 |
+
if 'selected_clinical_data' in globals() and isinstance(selected_clinical_data, pd.DataFrame):
|
| 180 |
+
# 2. Link clinical and genetic data
|
| 181 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_data, normalized_gene_data)
|
| 182 |
+
|
| 183 |
+
# 3. Handle missing values
|
| 184 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 185 |
+
|
| 186 |
+
# 4. Bias evaluation and removal of biased covariates
|
| 187 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 188 |
+
|
| 189 |
+
# 5. Final validation and save cohort info
|
| 190 |
+
is_usable = validate_and_save_cohort_info(
|
| 191 |
+
is_final=True,
|
| 192 |
+
cohort=cohort,
|
| 193 |
+
info_path=json_path,
|
| 194 |
+
is_gene_available=True,
|
| 195 |
+
is_trait_available=True,
|
| 196 |
+
is_biased=is_trait_biased,
|
| 197 |
+
df=unbiased_linked_data,
|
| 198 |
+
note="INFO: Trait and covariates processed; gene symbols normalized."
|
| 199 |
+
)
|
| 200 |
+
|
| 201 |
+
# 6. Save linked data only if usable
|
| 202 |
+
if is_usable:
|
| 203 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 204 |
+
unbiased_linked_data.to_csv(out_data_file)
|
| 205 |
+
else:
|
| 206 |
+
# No clinical trait data available; skip linking and downstream steps
|
| 207 |
+
linked_data = None
|
| 208 |
+
# Use a non-empty placeholder (samples x genes) to avoid false 'abnormality' override
|
| 209 |
+
placeholder_df = normalized_gene_data.T
|
| 210 |
+
_ = validate_and_save_cohort_info(
|
| 211 |
+
is_final=True,
|
| 212 |
+
cohort=cohort,
|
| 213 |
+
info_path=json_path,
|
| 214 |
+
is_gene_available=True,
|
| 215 |
+
is_trait_available=False,
|
| 216 |
+
is_biased=False,
|
| 217 |
+
df=placeholder_df,
|
| 218 |
+
note="INFO: No trait data available; only gene-level expression normalized and saved."
|
| 219 |
+
)
|
output/preprocess/Arrhythmia/code/GSE93101.py
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
cohort = "GSE93101"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Arrhythmia"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Arrhythmia/GSE93101"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/GSE93101.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/GSE93101.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/GSE93101.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import math
|
| 41 |
+
|
| 42 |
+
# 1) Gene expression availability
|
| 43 |
+
is_gene_available = True # Transcriptome data per background info
|
| 44 |
+
|
| 45 |
+
# 2) Variable availability (rows identified from the provided sample characteristics)
|
| 46 |
+
trait_row = 0 # 'course' field indicates underlying condition; includes 'Arrhythmia'
|
| 47 |
+
age_row = 1 # 'age'
|
| 48 |
+
gender_row = 2 # 'gender'
|
| 49 |
+
|
| 50 |
+
# 2.2) Conversion functions
|
| 51 |
+
def _extract_value(x):
|
| 52 |
+
if x is None:
|
| 53 |
+
return None
|
| 54 |
+
s = str(x).strip()
|
| 55 |
+
if ':' in s:
|
| 56 |
+
s = s.split(':', 1)[1].strip()
|
| 57 |
+
return s if s != '' else None
|
| 58 |
+
|
| 59 |
+
def convert_trait(x):
|
| 60 |
+
v = _extract_value(x)
|
| 61 |
+
if v is None:
|
| 62 |
+
return None
|
| 63 |
+
vl = v.lower()
|
| 64 |
+
if 'arrhythmia' in vl:
|
| 65 |
+
return 1
|
| 66 |
+
# Known non-arrhythmia etiologies -> negative class
|
| 67 |
+
if any(k in vl for k in ['myocardial infarction', 'myocarditis', 'dilated cardiomyopathy', 'congestive heart failure', 'aortic dissection', 'dcmp']):
|
| 68 |
+
return 0
|
| 69 |
+
# Default: if it's a non-empty course but not arrhythmia, treat as 0
|
| 70 |
+
return 0
|
| 71 |
+
|
| 72 |
+
def convert_age(x):
|
| 73 |
+
v = _extract_value(x)
|
| 74 |
+
if v is None:
|
| 75 |
+
return None
|
| 76 |
+
try:
|
| 77 |
+
val = float(v)
|
| 78 |
+
# Basic plausibility filter
|
| 79 |
+
if 0 <= val <= 120:
|
| 80 |
+
return val
|
| 81 |
+
return None
|
| 82 |
+
except Exception:
|
| 83 |
+
return None
|
| 84 |
+
|
| 85 |
+
def convert_gender(x):
|
| 86 |
+
v = _extract_value(x)
|
| 87 |
+
if v is None:
|
| 88 |
+
return None
|
| 89 |
+
vl = v.lower()
|
| 90 |
+
if vl in ['f', 'female', 'woman', 'girl']:
|
| 91 |
+
return 0
|
| 92 |
+
if vl in ['m', 'male', 'man', 'boy']:
|
| 93 |
+
return 1
|
| 94 |
+
return None
|
| 95 |
+
|
| 96 |
+
# 3) Initial filtering metadata
|
| 97 |
+
is_trait_available = trait_row is not None
|
| 98 |
+
_ = validate_and_save_cohort_info(
|
| 99 |
+
is_final=False,
|
| 100 |
+
cohort=cohort,
|
| 101 |
+
info_path=json_path,
|
| 102 |
+
is_gene_available=is_gene_available,
|
| 103 |
+
is_trait_available=is_trait_available
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
# 4) Clinical feature extraction (only if trait is available)
|
| 107 |
+
if trait_row is not None:
|
| 108 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 109 |
+
clinical_df=clinical_data,
|
| 110 |
+
trait=trait,
|
| 111 |
+
trait_row=trait_row,
|
| 112 |
+
convert_trait=convert_trait,
|
| 113 |
+
age_row=age_row,
|
| 114 |
+
convert_age=convert_age,
|
| 115 |
+
gender_row=gender_row,
|
| 116 |
+
convert_gender=convert_gender
|
| 117 |
+
)
|
| 118 |
+
clinical_preview = preview_df(selected_clinical_df)
|
| 119 |
+
|
| 120 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 121 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
| 122 |
+
|
| 123 |
+
# Step 3: Gene Data Extraction
|
| 124 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 125 |
+
gene_data = get_genetic_data(matrix_file)
|
| 126 |
+
|
| 127 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 128 |
+
print(gene_data.index[:20])
|
| 129 |
+
|
| 130 |
+
# Step 4: Gene Identifier Review
|
| 131 |
+
requires_gene_mapping = True
|
| 132 |
+
print(f"requires_gene_mapping = {requires_gene_mapping}")
|
| 133 |
+
|
| 134 |
+
# Step 5: Gene Annotation
|
| 135 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 136 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 137 |
+
|
| 138 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 139 |
+
print("Gene annotation preview:")
|
| 140 |
+
print(preview_df(gene_annotation))
|
| 141 |
+
|
| 142 |
+
# Step 6: Gene Identifier Mapping
|
| 143 |
+
# Identify the appropriate columns for probe IDs and gene symbols in the annotation data
|
| 144 |
+
id_col = 'ID' # Matches probe identifiers like ILMN_#######
|
| 145 |
+
symbol_col = 'Symbol' # Gene symbols
|
| 146 |
+
|
| 147 |
+
# Optional: filter out control probes if 'Species' column is present
|
| 148 |
+
anno_for_map = gene_annotation
|
| 149 |
+
if 'Species' in anno_for_map.columns:
|
| 150 |
+
anno_for_map = anno_for_map[anno_for_map['Species'].astype(str).str.lower() != 'ilmn controls'.lower()]
|
| 151 |
+
|
| 152 |
+
# Build mapping dataframe (probe ID -> symbol)
|
| 153 |
+
mapping_df = get_gene_mapping(anno_for_map, prob_col=id_col, gene_col=symbol_col)
|
| 154 |
+
|
| 155 |
+
# Apply mapping to convert probe-level data to gene-level data
|
| 156 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
|
| 157 |
+
|
| 158 |
+
# Step 7: Data Normalization and Linking
|
| 159 |
+
import os
|
| 160 |
+
|
| 161 |
+
# 1. Normalize gene symbols and save
|
| 162 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 163 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 164 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 165 |
+
|
| 166 |
+
# 2. Link clinical and genetic data
|
| 167 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 168 |
+
|
| 169 |
+
# 3. Handle missing values
|
| 170 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 171 |
+
|
| 172 |
+
# 4. Assess bias and remove biased demographic features
|
| 173 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 174 |
+
|
| 175 |
+
# Fallbacks for metadata flags if not present
|
| 176 |
+
try:
|
| 177 |
+
is_gene_available
|
| 178 |
+
except NameError:
|
| 179 |
+
is_gene_available = True if isinstance(normalized_gene_data, pd.DataFrame) and normalized_gene_data.shape[0] > 0 else False
|
| 180 |
+
|
| 181 |
+
try:
|
| 182 |
+
is_trait_available
|
| 183 |
+
except NameError:
|
| 184 |
+
is_trait_available = True if 'selected_clinical_df' in locals() else False
|
| 185 |
+
|
| 186 |
+
# Optional note about dataset
|
| 187 |
+
note = "INFO: ECMO cardiogenic shock cohort; trait derived from 'course' field (Arrhythmia vs. other etiologies)."
|
| 188 |
+
|
| 189 |
+
# 5. Final validation and save cohort info
|
| 190 |
+
is_usable = validate_and_save_cohort_info(
|
| 191 |
+
is_final=True,
|
| 192 |
+
cohort=cohort,
|
| 193 |
+
info_path=json_path,
|
| 194 |
+
is_gene_available=is_gene_available,
|
| 195 |
+
is_trait_available=is_trait_available,
|
| 196 |
+
is_biased=is_trait_biased,
|
| 197 |
+
df=unbiased_linked_data,
|
| 198 |
+
note=note
|
| 199 |
+
)
|
| 200 |
+
|
| 201 |
+
# 6. Save linked data if usable
|
| 202 |
+
if is_usable:
|
| 203 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 204 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Arrhythmia/code/TCGA.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Arrhythmia"
|
| 6 |
+
|
| 7 |
+
# Input paths
|
| 8 |
+
tcga_root_dir = "../DATA/TCGA"
|
| 9 |
+
|
| 10 |
+
# Output paths
|
| 11 |
+
out_data_file = "./output/z1/preprocess/Arrhythmia/TCGA.csv"
|
| 12 |
+
out_gene_data_file = "./output/z1/preprocess/Arrhythmia/gene_data/TCGA.csv"
|
| 13 |
+
out_clinical_data_file = "./output/z1/preprocess/Arrhythmia/clinical_data/TCGA.csv"
|
| 14 |
+
json_path = "./output/z1/preprocess/Arrhythmia/cohort_info.json"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# Step 1: Initial Data Loading
|
| 18 |
+
import os
|
| 19 |
+
import pandas as pd
|
| 20 |
+
|
| 21 |
+
# Discover available TCGA subdirectories
|
| 22 |
+
available_subdirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))]
|
| 23 |
+
|
| 24 |
+
# Attempt to find a cohort relevant to Arrhythmia (cardiac rhythm disorders)
|
| 25 |
+
keywords_specific = [
|
| 26 |
+
'arrhythmia', 'atrial_fibrillation', 'brugada', 'long_qt', 'ventricular_tachycardia',
|
| 27 |
+
'supraventricular', 'cardiac_conduction', 'torsades', 'wolff', 'wolff-parkinson-white'
|
| 28 |
+
]
|
| 29 |
+
keywords_general = ['cardiac', 'cardio', 'heart', 'myocard']
|
| 30 |
+
|
| 31 |
+
def find_best_cohort(subdirs, specific_kw, general_kw):
|
| 32 |
+
scored = []
|
| 33 |
+
for sd in subdirs:
|
| 34 |
+
sdl = sd.lower()
|
| 35 |
+
score = 0
|
| 36 |
+
if any(k in sdl for k in specific_kw):
|
| 37 |
+
score += 2
|
| 38 |
+
if any(k in sdl for k in general_kw):
|
| 39 |
+
score += 1
|
| 40 |
+
if score > 0:
|
| 41 |
+
scored.append((score, sd))
|
| 42 |
+
if not scored:
|
| 43 |
+
return None
|
| 44 |
+
scored.sort(reverse=True) # highest score first
|
| 45 |
+
return scored[0][1]
|
| 46 |
+
|
| 47 |
+
selected_subdir = find_best_cohort(available_subdirs, keywords_specific, keywords_general)
|
| 48 |
+
|
| 49 |
+
if selected_subdir is None:
|
| 50 |
+
print(f"No suitable TCGA cohort directory found for trait '{trait}'. Skipping this trait.")
|
| 51 |
+
# Record metadata for skipping
|
| 52 |
+
validate_and_save_cohort_info(
|
| 53 |
+
is_final=False,
|
| 54 |
+
cohort="TCGA",
|
| 55 |
+
info_path=json_path,
|
| 56 |
+
is_gene_available=False,
|
| 57 |
+
is_trait_available=False
|
| 58 |
+
)
|
| 59 |
+
else:
|
| 60 |
+
cohort_dir = os.path.join(tcga_root_dir, selected_subdir)
|
| 61 |
+
clinical_path, genetic_path = tcga_get_relevant_filepaths(cohort_dir)
|
| 62 |
+
|
| 63 |
+
# Load files
|
| 64 |
+
clinical_df = pd.read_csv(clinical_path, sep='\t', index_col=0, low_memory=False)
|
| 65 |
+
genetic_df = pd.read_csv(genetic_path, sep='\t', index_col=0, low_memory=False)
|
| 66 |
+
|
| 67 |
+
# Print clinical column names for inspection
|
| 68 |
+
print(f"Selected cohort directory: {selected_subdir}")
|
| 69 |
+
print("Clinical data columns:")
|
| 70 |
+
print(list(clinical_df.columns))
|
output/preprocess/Arrhythmia/cohort_info.json
CHANGED
|
@@ -1,112 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"GSE93101": {
|
| 3 |
-
"is_usable": false,
|
| 4 |
-
"is_gene_available": true,
|
| 5 |
-
"is_trait_available": true,
|
| 6 |
-
"is_available": true,
|
| 7 |
-
"is_biased": true,
|
| 8 |
-
"has_age": true,
|
| 9 |
-
"has_gender": true,
|
| 10 |
-
"sample_size": 33
|
| 11 |
-
},
|
| 12 |
-
"GSE55231": {
|
| 13 |
-
"is_usable": false,
|
| 14 |
-
"is_gene_available": false,
|
| 15 |
-
"is_trait_available": false,
|
| 16 |
-
"is_available": false,
|
| 17 |
-
"is_biased": null,
|
| 18 |
-
"has_age": null,
|
| 19 |
-
"has_gender": null,
|
| 20 |
-
"sample_size": null
|
| 21 |
-
},
|
| 22 |
-
"GSE53622": {
|
| 23 |
-
"is_usable": false,
|
| 24 |
-
"is_gene_available": false,
|
| 25 |
-
"is_trait_available": true,
|
| 26 |
-
"is_available": false,
|
| 27 |
-
"is_biased": null,
|
| 28 |
-
"has_age": null,
|
| 29 |
-
"has_gender": null,
|
| 30 |
-
"sample_size": null
|
| 31 |
-
},
|
| 32 |
-
"GSE47727": {
|
| 33 |
-
"is_usable": false,
|
| 34 |
-
"is_gene_available": true,
|
| 35 |
-
"is_trait_available": true,
|
| 36 |
-
"is_available": true,
|
| 37 |
-
"is_biased": true,
|
| 38 |
-
"has_age": true,
|
| 39 |
-
"has_gender": true,
|
| 40 |
-
"sample_size": 122
|
| 41 |
-
},
|
| 42 |
-
"GSE41177": {
|
| 43 |
-
"is_usable": true,
|
| 44 |
-
"is_gene_available": true,
|
| 45 |
-
"is_trait_available": true,
|
| 46 |
-
"is_available": true,
|
| 47 |
-
"is_biased": false,
|
| 48 |
-
"has_age": true,
|
| 49 |
-
"has_gender": true,
|
| 50 |
-
"sample_size": 38
|
| 51 |
-
},
|
| 52 |
-
"GSE235307": {
|
| 53 |
-
"is_usable": true,
|
| 54 |
-
"is_gene_available": true,
|
| 55 |
-
"is_trait_available": true,
|
| 56 |
-
"is_available": true,
|
| 57 |
-
"is_biased": false,
|
| 58 |
-
"has_age": true,
|
| 59 |
-
"has_gender": false,
|
| 60 |
-
"sample_size": 119
|
| 61 |
-
},
|
| 62 |
-
"GSE182600": {
|
| 63 |
-
"is_usable": true,
|
| 64 |
-
"is_gene_available": true,
|
| 65 |
-
"is_trait_available": true,
|
| 66 |
-
"is_available": true,
|
| 67 |
-
"is_biased": false,
|
| 68 |
-
"has_age": true,
|
| 69 |
-
"has_gender": true,
|
| 70 |
-
"sample_size": 78
|
| 71 |
-
},
|
| 72 |
-
"GSE143924": {
|
| 73 |
-
"is_usable": true,
|
| 74 |
-
"is_gene_available": true,
|
| 75 |
-
"is_trait_available": true,
|
| 76 |
-
"is_available": true,
|
| 77 |
-
"is_biased": false,
|
| 78 |
-
"has_age": false,
|
| 79 |
-
"has_gender": false,
|
| 80 |
-
"sample_size": 30
|
| 81 |
-
},
|
| 82 |
-
"GSE136992": {
|
| 83 |
-
"is_usable": true,
|
| 84 |
-
"is_gene_available": true,
|
| 85 |
-
"is_trait_available": true,
|
| 86 |
-
"is_available": true,
|
| 87 |
-
"is_biased": false,
|
| 88 |
-
"has_age": true,
|
| 89 |
-
"has_gender": true,
|
| 90 |
-
"sample_size": 60
|
| 91 |
-
},
|
| 92 |
-
"GSE115574": {
|
| 93 |
-
"is_usable": true,
|
| 94 |
-
"is_gene_available": true,
|
| 95 |
-
"is_trait_available": true,
|
| 96 |
-
"is_available": true,
|
| 97 |
-
"is_biased": false,
|
| 98 |
-
"has_age": false,
|
| 99 |
-
"has_gender": false,
|
| 100 |
-
"sample_size": 59
|
| 101 |
-
},
|
| 102 |
-
"TCGA": {
|
| 103 |
-
"is_usable": true,
|
| 104 |
-
"is_gene_available": true,
|
| 105 |
-
"is_trait_available": true,
|
| 106 |
-
"is_available": true,
|
| 107 |
-
"is_biased": false,
|
| 108 |
-
"has_age": true,
|
| 109 |
-
"has_gender": true,
|
| 110 |
-
"sample_size": 553
|
| 111 |
-
}
|
| 112 |
-
}
|
|
|
|
| 1 |
+
{"GSE93101": {"is_usable": false, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": true, "has_age": true, "has_gender": true, "sample_size": 33, "note": "INFO: ECMO cardiogenic shock cohort; trait derived from 'course' field (Arrhythmia vs. other etiologies)."}, "GSE55231": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": "INFO: No trait data available; only gene-level expression normalized and saved."}, "GSE53622": {"is_usable": false, "is_gene_available": false, "is_trait_available": true, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": "WARNING: Gene mapping likely failed (gene matrix empty after normalization). Previous mapping used probe column 'ID', gene column 'Control Type' from non-GPL SOFT."}, "GSE47727": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE41177": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": true, "has_gender": true, "sample_size": 38, "note": "INFO: Trait is AF duration (months); paired tissue samples (LA-PV junction vs LAA)."}, "GSE235307": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": true, "has_gender": true, "sample_size": 119, "note": "INFO: Gene symbols normalized using NCBI synonyms. Linked 119 samples and 19847 genes before QC."}, "GSE182600": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": true, "has_gender": true, "sample_size": 78, "note": ""}, "GSE143924": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": false, "has_gender": false, "sample_size": 30, "note": "INFO: Balanced POAF vs SR (15/15); no age/gender available."}, "GSE136992": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE115574": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": false, "has_gender": false, "sample_size": 59, "note": "INFO: Trait from disease state (AFib=1 vs SR=0); Age and Gender unavailable in sample characteristics."}, "TCGA": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output/preprocess/Arrhythmia/gene_data/GSE53622.csv
CHANGED
|
@@ -1,2 +1 @@
|
|
| 1 |
Gene,GSM1296956,GSM1296957,GSM1296958,GSM1296959,GSM1296960,GSM1296961,GSM1296962,GSM1296963,GSM1296964,GSM1296965,GSM1296966,GSM1296967,GSM1296968,GSM1296969,GSM1296970,GSM1296971,GSM1296972,GSM1296973,GSM1296974,GSM1296975,GSM1296976,GSM1296977,GSM1296978,GSM1296979,GSM1296980,GSM1296981,GSM1296982,GSM1296983,GSM1296984,GSM1296985,GSM1296986,GSM1296987,GSM1296988,GSM1296989,GSM1296990,GSM1296991,GSM1296992,GSM1296993,GSM1296994,GSM1296995,GSM1296996,GSM1296997,GSM1296998,GSM1296999,GSM1297000,GSM1297001,GSM1297002,GSM1297003,GSM1297004,GSM1297005,GSM1297006,GSM1297007,GSM1297008,GSM1297009,GSM1297010,GSM1297011,GSM1297012,GSM1297013,GSM1297014,GSM1297015,GSM1297016,GSM1297017,GSM1297018,GSM1297019,GSM1297020,GSM1297021,GSM1297022,GSM1297023,GSM1297024,GSM1297025,GSM1297026,GSM1297027,GSM1297028,GSM1297029,GSM1297030,GSM1297031,GSM1297032,GSM1297033,GSM1297034,GSM1297035,GSM1297036,GSM1297037,GSM1297038,GSM1297039,GSM1297040,GSM1297041,GSM1297042,GSM1297043,GSM1297044,GSM1297045,GSM1297046,GSM1297047,GSM1297048,GSM1297049,GSM1297050,GSM1297051,GSM1297052,GSM1297053,GSM1297054,GSM1297055,GSM1297056,GSM1297057,GSM1297058,GSM1297059,GSM1297060,GSM1297061,GSM1297062,GSM1297063,GSM1297064,GSM1297065,GSM1297066,GSM1297067,GSM1297068,GSM1297069,GSM1297070,GSM1297071,GSM1297072,GSM1297073,GSM1297074,GSM1297075
|
| 2 |
-
CYP2D7,8.079096,8.139438,9.026626,8.791721,8.473965,8.342405,9.739359,7.9230347,8.583124,8.02764,8.788752,8.261488,9.436542,8.793202,8.7394085,8.246852,8.832868,8.059782,9.033502,8.699034,8.6981735,8.912555,9.671825,9.04456,8.546082,8.485996,8.531118,7.918057,8.615377,8.59308,8.368535,8.339417,8.049576,8.49325,8.829485,7.7764406,9.171941,8.380742,8.910029,8.761705,9.288424,8.152321,8.996962,8.421651,9.306223,8.427002,9.186377,9.067205,9.29377,7.674825,8.886724,8.288611,8.391205,8.328333,9.4850645,8.638261,8.818429,8.208845,8.661726,8.337332,8.728982,9.014844,9.993892,9.300717,8.882419,9.034479,9.13243,8.48914,10.105189,8.870117,9.026258,8.353404,9.018257,9.150945,8.951023,8.625228,9.165361,9.344513,9.973912,9.161152,10.080526,9.153526,8.81058,8.382329,9.047473,8.5763,8.87176,8.508767,8.644913,8.179255,8.425197,8.379519,9.144303,9.500169,9.029782,8.204135,8.694639,8.394274,9.329949,9.138085,8.912275,8.730211,9.467376,9.151735,9.105803,8.961231,9.132017,8.702591,8.70009,8.58842,9.246985,8.295102,8.890052,8.258354,8.630826,9.123106,9.033117,8.654027,8.588141,8.872706
|
|
|
|
| 1 |
Gene,GSM1296956,GSM1296957,GSM1296958,GSM1296959,GSM1296960,GSM1296961,GSM1296962,GSM1296963,GSM1296964,GSM1296965,GSM1296966,GSM1296967,GSM1296968,GSM1296969,GSM1296970,GSM1296971,GSM1296972,GSM1296973,GSM1296974,GSM1296975,GSM1296976,GSM1296977,GSM1296978,GSM1296979,GSM1296980,GSM1296981,GSM1296982,GSM1296983,GSM1296984,GSM1296985,GSM1296986,GSM1296987,GSM1296988,GSM1296989,GSM1296990,GSM1296991,GSM1296992,GSM1296993,GSM1296994,GSM1296995,GSM1296996,GSM1296997,GSM1296998,GSM1296999,GSM1297000,GSM1297001,GSM1297002,GSM1297003,GSM1297004,GSM1297005,GSM1297006,GSM1297007,GSM1297008,GSM1297009,GSM1297010,GSM1297011,GSM1297012,GSM1297013,GSM1297014,GSM1297015,GSM1297016,GSM1297017,GSM1297018,GSM1297019,GSM1297020,GSM1297021,GSM1297022,GSM1297023,GSM1297024,GSM1297025,GSM1297026,GSM1297027,GSM1297028,GSM1297029,GSM1297030,GSM1297031,GSM1297032,GSM1297033,GSM1297034,GSM1297035,GSM1297036,GSM1297037,GSM1297038,GSM1297039,GSM1297040,GSM1297041,GSM1297042,GSM1297043,GSM1297044,GSM1297045,GSM1297046,GSM1297047,GSM1297048,GSM1297049,GSM1297050,GSM1297051,GSM1297052,GSM1297053,GSM1297054,GSM1297055,GSM1297056,GSM1297057,GSM1297058,GSM1297059,GSM1297060,GSM1297061,GSM1297062,GSM1297063,GSM1297064,GSM1297065,GSM1297066,GSM1297067,GSM1297068,GSM1297069,GSM1297070,GSM1297071,GSM1297072,GSM1297073,GSM1297074,GSM1297075
|
|
|
output/preprocess/Asthma/GSE270312.csv
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
output/preprocess/Asthma/clinical_data/GSE123086.csv
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049
|
| 2 |
+
Asthma,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
| 3 |
+
Age,56.0,,20.0,51.0,37.0,61.0,,31.0,56.0,41.0,61.0,,80.0,53.0,61.0,73.0,60.0,76.0,77.0,74.0,69.0,77.0,81.0,70.0,82.0,69.0,82.0,67.0,67.0,78.0,67.0,74.0,,51.0,72.0,66.0,80.0,36.0,67.0,31.0,31.0,45.0,56.0,65.0,53.0,48.0,50.0,76.0,,24.0,42.0,76.0,22.0,,23.0,34.0,43.0,47.0,24.0,55.0,48.0,58.0,30.0,28.0,41.0,63.0,55.0,55.0,67.0,47.0,46.0,49.0,23.0,68.0,39.0,24.0,36.0,58.0,38.0,27.0,67.0,61.0,69.0,63.0,60.0,17.0,10.0,9.0,13.0,10.0,13.0,15.0,12.0,13.0,81.0,94.0,51.0,40.0,,97.0,23.0,93.0,58.0,28.0,54.0,15.0,8.0,11.0,12.0,8.0,14.0,8.0,10.0,14.0,13.0,40.0,52.0,42.0,29.0,43.0,41.0,54.0,42.0,49.0,45.0,56.0,64.0,71.0,48.0,20.0,53.0,32.0,26.0,28.0,47.0,24.0,48.0,,19.0,41.0,38.0,,15.0,12.0,13.0,,11.0,,16.0,11.0,,35.0,26.0,39.0,46.0,42.0,20.0,69.0,69.0,47.0,47.0,56.0,54.0,53.0,50.0,22.0
|
| 4 |
+
Gender,1.0,,0.0,0.0,1.0,1.0,,1.0,0.0,0.0,0.0,,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,,0.0,0.0,1.0,1.0,,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,0.0,0.0,0.0,,0.0,1.0,0.0,,1.0,,1.0,1.0,,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0
|
output/preprocess/Asthma/clinical_data/GSE123088.csv
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
-
1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,,,,,,,,,,,,,
|
| 3 |
-
56.0,,20.0,51.0,37.0,61.0,31.0,41.0,80.0,53.0,73.0,60.0,76.0,77.0,74.0,69.0,81.0,70.0,82.0,67.0,78.0,72.0,66.0,36.0,45.0,65.0,48.0,50.0,24.0,42.0
|
| 4 |
-
1.0,,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
|
|
|
| 1 |
+
,GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049,GSM3495050,GSM3495051,GSM3495052,GSM3495053,GSM3495054,GSM3495055,GSM3495056,GSM3495057,GSM3495058,GSM3495059,GSM3495060,GSM3495061,GSM3495062,GSM3495063,GSM3495064,GSM3495065,GSM3495066,GSM3495067,GSM3495068,GSM3495069,GSM3495070,GSM3495071,GSM3495072,GSM3495073,GSM3495074,GSM3495075,GSM3495076,GSM3495077,GSM3495078,GSM3495079,GSM3495080,GSM3495081,GSM3495082,GSM3495083,GSM3495084,GSM3495085,GSM3495086,GSM3495087
|
| 2 |
+
Asthma,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.0,0.0,,,0.0,,0.0,,,0.0,,0.0,0.0,,,0.0,,,,,,0.0,0.0,0.0,,,,,,0.0,,,,,0.0,0.0
|
| 3 |
+
Age,56.0,,20.0,51.0,37.0,61.0,,31.0,56.0,41.0,61.0,,80.0,53.0,61.0,73.0,60.0,76.0,77.0,74.0,69.0,77.0,81.0,70.0,82.0,69.0,82.0,67.0,67.0,78.0,67.0,74.0,,51.0,72.0,66.0,80.0,36.0,67.0,31.0,31.0,45.0,56.0,65.0,53.0,48.0,50.0,76.0,,24.0,42.0,76.0,22.0,,23.0,34.0,43.0,47.0,24.0,55.0,48.0,58.0,30.0,28.0,41.0,63.0,55.0,55.0,67.0,47.0,46.0,49.0,23.0,68.0,39.0,24.0,36.0,58.0,38.0,27.0,67.0,61.0,69.0,63.0,60.0,17.0,10.0,9.0,13.0,10.0,13.0,15.0,12.0,13.0,81.0,94.0,51.0,40.0,,97.0,23.0,93.0,58.0,28.0,54.0,15.0,8.0,11.0,12.0,8.0,14.0,8.0,10.0,14.0,13.0,40.0,52.0,42.0,29.0,43.0,41.0,54.0,42.0,49.0,45.0,56.0,64.0,71.0,48.0,20.0,53.0,32.0,26.0,28.0,47.0,24.0,48.0,,19.0,41.0,38.0,,15.0,12.0,13.0,,11.0,,16.0,11.0,,35.0,26.0,39.0,46.0,42.0,20.0,69.0,69.0,47.0,47.0,56.0,54.0,53.0,50.0,22.0,62.0,74.0,57.0,47.0,70.0,50.0,52.0,43.0,57.0,53.0,70.0,41.0,61.0,39.0,58.0,55.0,63.0,60.0,43.0,68.0,67.0,50.0,67.0,51.0,59.0,44.0,35.0,83.0,78.0,88.0,41.0,60.0,72.0,53.0,73.0,56.0,38.0,53.0
|
| 4 |
+
Gender,1.0,,0.0,0.0,1.0,1.0,,1.0,0.0,0.0,0.0,,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,,0.0,0.0,1.0,1.0,,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,0.0,0.0,0.0,,0.0,1.0,0.0,,1.0,,1.0,1.0,,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
output/preprocess/Asthma/clinical_data/GSE182797.csv
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
,GSM5537157,GSM5537158,GSM5537159,GSM5537160,GSM5537161,GSM5537162,GSM5537163,GSM5537164,GSM5537165,GSM5537166,GSM5537167,GSM5537168,GSM5537169,GSM5537170,GSM5537171,GSM5537172,GSM5537173,GSM5537174,GSM5537175,GSM5537176,GSM5537177,GSM5537178,GSM5537179,GSM5537180,GSM5537181,GSM5537182,GSM5537183,GSM5537184,GSM5537185,GSM5537186,GSM5537187,GSM5537188,GSM5537189,GSM5537190,GSM5537191,GSM5537192,GSM5537193,GSM5537194,GSM5537195,GSM5537196,GSM5537197,GSM5537198,GSM5537199,GSM5537200,GSM5537201,GSM5537202,GSM5537203,GSM5537204,GSM5537205,GSM5537206,GSM5537207,GSM5537208,GSM5537209,GSM5537210,GSM5537211,GSM5537212,GSM5537213,GSM5537214,GSM5537215,GSM5537216,GSM5537217,GSM5537218,GSM5537219,GSM5537220,GSM5537221,GSM5537222,GSM5537223,GSM5537224,GSM5537225,GSM5537226,GSM5537227,GSM5537228,GSM5537229,GSM5537230,GSM5537231,GSM5537232,GSM5537233,GSM5537234,GSM5537235,GSM5537236
|
| 2 |
-
Asthma,0.0,0.0,0.0,1.0,1.0,,0.0,1.0,1.0,,1.0,0.0,1.0,1.0,1.0,,0.0,1.0,1.0,1.0,1.0,0.0,,1.0,1.0,,0.0,1.0,1.0,1.0,0.0,,0.0,1.0,1.0,1.0,1.0,1.0,1.0,,0.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,,0.0,0.0,,1.0,,1.0,0.0,1.0,1.0,1.0,,,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,,0.0,1.0,0.0,,0.0,1.0,1.0,1.0,0.0
|
| 3 |
Age,38.33,38.08,48.83,33.42,46.08,45.58,28.0,30.83,39.25,60.17,52.75,25.75,60.67,64.67,54.83,57.67,47.0,47.5,24.25,47.67,47.58,18.42,41.33,24.5,47.08,47.5,41.17,48.83,47.17,59.83,42.58,56.67,37.5,58.58,24.75,52.75,55.33,56.17,52.75,40.67,19.17,42.5,57.08,40.58,40.67,55.75,43.17,59.58,56.25,46.42,47.08,51.75,53.5,52.58,52.25,45.58,52.67,50.5,60.08,44.67,57.58,53.17,51.33,46.17,26.58,60.17,54.67,57.75,28.42,33.08,50.33,37.83,44.25,58.83,48.25,43.08,41.17,51.75,53.58,41.5
|
| 4 |
-
Gender,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
|
|
|
| 1 |
,GSM5537157,GSM5537158,GSM5537159,GSM5537160,GSM5537161,GSM5537162,GSM5537163,GSM5537164,GSM5537165,GSM5537166,GSM5537167,GSM5537168,GSM5537169,GSM5537170,GSM5537171,GSM5537172,GSM5537173,GSM5537174,GSM5537175,GSM5537176,GSM5537177,GSM5537178,GSM5537179,GSM5537180,GSM5537181,GSM5537182,GSM5537183,GSM5537184,GSM5537185,GSM5537186,GSM5537187,GSM5537188,GSM5537189,GSM5537190,GSM5537191,GSM5537192,GSM5537193,GSM5537194,GSM5537195,GSM5537196,GSM5537197,GSM5537198,GSM5537199,GSM5537200,GSM5537201,GSM5537202,GSM5537203,GSM5537204,GSM5537205,GSM5537206,GSM5537207,GSM5537208,GSM5537209,GSM5537210,GSM5537211,GSM5537212,GSM5537213,GSM5537214,GSM5537215,GSM5537216,GSM5537217,GSM5537218,GSM5537219,GSM5537220,GSM5537221,GSM5537222,GSM5537223,GSM5537224,GSM5537225,GSM5537226,GSM5537227,GSM5537228,GSM5537229,GSM5537230,GSM5537231,GSM5537232,GSM5537233,GSM5537234,GSM5537235,GSM5537236
|
| 2 |
+
Asthma,0.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0
|
| 3 |
Age,38.33,38.08,48.83,33.42,46.08,45.58,28.0,30.83,39.25,60.17,52.75,25.75,60.67,64.67,54.83,57.67,47.0,47.5,24.25,47.67,47.58,18.42,41.33,24.5,47.08,47.5,41.17,48.83,47.17,59.83,42.58,56.67,37.5,58.58,24.75,52.75,55.33,56.17,52.75,40.67,19.17,42.5,57.08,40.58,40.67,55.75,43.17,59.58,56.25,46.42,47.08,51.75,53.5,52.58,52.25,45.58,52.67,50.5,60.08,44.67,57.58,53.17,51.33,46.17,26.58,60.17,54.67,57.75,28.42,33.08,50.33,37.83,44.25,58.83,48.25,43.08,41.17,51.75,53.58,41.5
|
|
|
output/preprocess/Asthma/clinical_data/GSE182798.csv
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
,GSM5530417,GSM5530418,GSM5530419,GSM5530420,GSM5530421,GSM5530422,GSM5530423,GSM5530424,GSM5530425,GSM5530426,GSM5530427,GSM5530428,GSM5530429,GSM5530430,GSM5530431,GSM5530432,GSM5530433,GSM5530434,GSM5530435,GSM5530436,GSM5530437,GSM5530438,GSM5530439,GSM5530440,GSM5530441,GSM5530442,GSM5530443,GSM5530444,GSM5530445,GSM5530446,GSM5530447,GSM5530448,GSM5530449,GSM5530450,GSM5530451,GSM5530452,GSM5530453,GSM5530454,GSM5530455,GSM5530456,GSM5530457,GSM5530458,GSM5530459,GSM5530460,GSM5530461,GSM5530462,GSM5530463,GSM5530464,GSM5530465,GSM5530466,GSM5530467,GSM5530468,GSM5530469,GSM5530470,GSM5530471,GSM5530472,GSM5530473,GSM5530474,GSM5530475,GSM5530476,GSM5530477,GSM5530478,GSM5530479,GSM5530480,GSM5530481,GSM5530482,GSM5530483,GSM5530484,GSM5530485,GSM5530486,GSM5530487,GSM5530488,GSM5530489,GSM5530490,GSM5530491,GSM5530492,GSM5530493,GSM5530494,GSM5530495,GSM5530496,GSM5530497,GSM5530498,GSM5530499,GSM5530500,GSM5530501,GSM5530502,GSM5530503,GSM5530504,GSM5530505,GSM5530506,GSM5530507,GSM5530508,GSM5530509,GSM5530510,GSM5530511,GSM5530512,GSM5530513,GSM5530514,GSM5530515,GSM5530516,GSM5530517,GSM5530518,GSM5537157,GSM5537158,GSM5537159,GSM5537160,GSM5537161,GSM5537162,GSM5537163,GSM5537164,GSM5537165,GSM5537166,GSM5537167,GSM5537168,GSM5537169,GSM5537170,GSM5537171,GSM5537172,GSM5537173,GSM5537174,GSM5537175,GSM5537176,GSM5537177,GSM5537178,GSM5537179,GSM5537180,GSM5537181,GSM5537182,GSM5537183,GSM5537184,GSM5537185,GSM5537186,GSM5537187,GSM5537188,GSM5537189,GSM5537190,GSM5537191,GSM5537192,GSM5537193,GSM5537194,GSM5537195,GSM5537196,GSM5537197,GSM5537198,GSM5537199,GSM5537200,GSM5537201,GSM5537202,GSM5537203,GSM5537204,GSM5537205,GSM5537206,GSM5537207,GSM5537208,GSM5537209,GSM5537210,GSM5537211,GSM5537212,GSM5537213,GSM5537214,GSM5537215,GSM5537216,GSM5537217,GSM5537218,GSM5537219,GSM5537220,GSM5537221,GSM5537222,GSM5537223,GSM5537224,GSM5537225,GSM5537226,GSM5537227,GSM5537228,GSM5537229,GSM5537230,GSM5537231,GSM5537232,GSM5537233,GSM5537234,GSM5537235,GSM5537236
|
| 2 |
-
Asthma,1.0,1.0,,0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,,1.0,1.0,0.0,0.0,1.0,1.0,,,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,,1.0,1.0,0.0,1.0,1.0,,1.0,1.0,0.0,1.0,1.0,1.0,,0.0,0.0,1.0,1.0,0.0,1.0,1.0,,0.0,0.0,1.0,1.0,,0.0,,0.0,0.0,1.0,1.0,1.0,,,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,,1.0,0.0,1.0,1.0,,0.0,0.0,,1.0,1.0,0.0,0.0,1.0,,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,,0.0,1.0,1.0,,1.0,0.0,1.0,1.0,1.0,,0.0,1.0,1.0,1.0,1.0,0.0,,1.0,1.0,,0.0,1.0,1.0,1.0,0.0,,0.0,1.0,1.0,1.0,1.0,1.0,1.0,,0.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,,0.0,0.0,,1.0,,1.0,0.0,1.0,1.0,1.0,,,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,,0.0,1.0,0.0,,0.0,1.0,1.0,1.0,0.0
|
| 3 |
Age,33.42,46.08,45.58,28.0,25.75,59.83,41.17,47.58,50.75,42.58,52.75,51.75,18.42,47.0,38.33,58.58,56.17,52.75,40.67,47.5,54.67,48.83,25.75,64.67,54.83,57.67,39.17,38.08,28.42,40.75,43.17,43.08,48.83,58.83,26.58,42.5,48.25,39.25,55.33,47.0,55.75,47.08,47.5,53.58,60.17,40.58,50.5,46.17,51.33,56.67,37.5,48.83,38.08,52.58,52.67,59.58,56.25,46.42,47.08,52.67,60.08,44.67,57.58,26.58,53.5,58.83,41.5,47.17,51.25,33.08,50.33,60.17,19.17,40.67,24.25,43.08,51.75,41.17,30.83,40.58,42.58,52.75,43.17,24.75,51.75,24.5,44.5,53.17,38.08,37.83,41.33,47.67,57.75,37.5,41.5,44.25,53.58,45.58,19.17,18.42,57.08,60.67,38.33,38.08,48.83,33.42,46.08,45.58,28.0,30.83,39.25,60.17,52.75,25.75,60.67,64.67,54.83,57.67,47.0,47.5,24.25,47.67,47.58,18.42,41.33,24.5,47.08,47.5,41.17,48.83,47.17,59.83,42.58,56.67,37.5,58.58,24.75,52.75,55.33,56.17,52.75,40.67,19.17,42.5,57.08,40.58,40.67,55.75,43.17,59.58,56.25,46.42,47.08,51.75,53.5,52.58,52.25,45.58,52.67,50.5,60.08,44.67,57.58,53.17,51.33,46.17,26.58,60.17,54.67,57.75,28.42,33.08,50.33,37.83,44.25,58.83,48.25,43.08,41.17,51.75,53.58,41.5
|
| 4 |
-
Gender,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
|
|
|
| 1 |
,GSM5530417,GSM5530418,GSM5530419,GSM5530420,GSM5530421,GSM5530422,GSM5530423,GSM5530424,GSM5530425,GSM5530426,GSM5530427,GSM5530428,GSM5530429,GSM5530430,GSM5530431,GSM5530432,GSM5530433,GSM5530434,GSM5530435,GSM5530436,GSM5530437,GSM5530438,GSM5530439,GSM5530440,GSM5530441,GSM5530442,GSM5530443,GSM5530444,GSM5530445,GSM5530446,GSM5530447,GSM5530448,GSM5530449,GSM5530450,GSM5530451,GSM5530452,GSM5530453,GSM5530454,GSM5530455,GSM5530456,GSM5530457,GSM5530458,GSM5530459,GSM5530460,GSM5530461,GSM5530462,GSM5530463,GSM5530464,GSM5530465,GSM5530466,GSM5530467,GSM5530468,GSM5530469,GSM5530470,GSM5530471,GSM5530472,GSM5530473,GSM5530474,GSM5530475,GSM5530476,GSM5530477,GSM5530478,GSM5530479,GSM5530480,GSM5530481,GSM5530482,GSM5530483,GSM5530484,GSM5530485,GSM5530486,GSM5530487,GSM5530488,GSM5530489,GSM5530490,GSM5530491,GSM5530492,GSM5530493,GSM5530494,GSM5530495,GSM5530496,GSM5530497,GSM5530498,GSM5530499,GSM5530500,GSM5530501,GSM5530502,GSM5530503,GSM5530504,GSM5530505,GSM5530506,GSM5530507,GSM5530508,GSM5530509,GSM5530510,GSM5530511,GSM5530512,GSM5530513,GSM5530514,GSM5530515,GSM5530516,GSM5530517,GSM5530518,GSM5537157,GSM5537158,GSM5537159,GSM5537160,GSM5537161,GSM5537162,GSM5537163,GSM5537164,GSM5537165,GSM5537166,GSM5537167,GSM5537168,GSM5537169,GSM5537170,GSM5537171,GSM5537172,GSM5537173,GSM5537174,GSM5537175,GSM5537176,GSM5537177,GSM5537178,GSM5537179,GSM5537180,GSM5537181,GSM5537182,GSM5537183,GSM5537184,GSM5537185,GSM5537186,GSM5537187,GSM5537188,GSM5537189,GSM5537190,GSM5537191,GSM5537192,GSM5537193,GSM5537194,GSM5537195,GSM5537196,GSM5537197,GSM5537198,GSM5537199,GSM5537200,GSM5537201,GSM5537202,GSM5537203,GSM5537204,GSM5537205,GSM5537206,GSM5537207,GSM5537208,GSM5537209,GSM5537210,GSM5537211,GSM5537212,GSM5537213,GSM5537214,GSM5537215,GSM5537216,GSM5537217,GSM5537218,GSM5537219,GSM5537220,GSM5537221,GSM5537222,GSM5537223,GSM5537224,GSM5537225,GSM5537226,GSM5537227,GSM5537228,GSM5537229,GSM5537230,GSM5537231,GSM5537232,GSM5537233,GSM5537234,GSM5537235,GSM5537236
|
| 2 |
+
Asthma,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0
|
| 3 |
Age,33.42,46.08,45.58,28.0,25.75,59.83,41.17,47.58,50.75,42.58,52.75,51.75,18.42,47.0,38.33,58.58,56.17,52.75,40.67,47.5,54.67,48.83,25.75,64.67,54.83,57.67,39.17,38.08,28.42,40.75,43.17,43.08,48.83,58.83,26.58,42.5,48.25,39.25,55.33,47.0,55.75,47.08,47.5,53.58,60.17,40.58,50.5,46.17,51.33,56.67,37.5,48.83,38.08,52.58,52.67,59.58,56.25,46.42,47.08,52.67,60.08,44.67,57.58,26.58,53.5,58.83,41.5,47.17,51.25,33.08,50.33,60.17,19.17,40.67,24.25,43.08,51.75,41.17,30.83,40.58,42.58,52.75,43.17,24.75,51.75,24.5,44.5,53.17,38.08,37.83,41.33,47.67,57.75,37.5,41.5,44.25,53.58,45.58,19.17,18.42,57.08,60.67,38.33,38.08,48.83,33.42,46.08,45.58,28.0,30.83,39.25,60.17,52.75,25.75,60.67,64.67,54.83,57.67,47.0,47.5,24.25,47.67,47.58,18.42,41.33,24.5,47.08,47.5,41.17,48.83,47.17,59.83,42.58,56.67,37.5,58.58,24.75,52.75,55.33,56.17,52.75,40.67,19.17,42.5,57.08,40.58,40.67,55.75,43.17,59.58,56.25,46.42,47.08,51.75,53.5,52.58,52.25,45.58,52.67,50.5,60.08,44.67,57.58,53.17,51.33,46.17,26.58,60.17,54.67,57.75,28.42,33.08,50.33,37.83,44.25,58.83,48.25,43.08,41.17,51.75,53.58,41.5
|
|
|
output/preprocess/Asthma/clinical_data/GSE270312.csv
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
,GSM8339381,GSM8339382,GSM8339383,GSM8339384,GSM8339385,GSM8339386,GSM8339387,GSM8339388,GSM8339389,GSM8339390,GSM8339391,GSM8339392,GSM8339393,GSM8339394,GSM8339395,GSM8339396,GSM8339397,GSM8339398,GSM8339399,GSM8339400,GSM8339401,GSM8339402,GSM8339403,GSM8339404,GSM8339405,GSM8339406,GSM8339407,GSM8339408,GSM8339409,GSM8339410,GSM8339411,GSM8339412,GSM8339413,GSM8339414,GSM8339415,GSM8339416,GSM8339417,GSM8339418,GSM8339419,GSM8339420,GSM8339421,GSM8339422,GSM8339423,GSM8339424,GSM8339425,GSM8339426,GSM8339427,GSM8339428,GSM8339429,GSM8339430,GSM8339431,GSM8339432,GSM8339433,GSM8339434,GSM8339435,GSM8339436,GSM8339437,GSM8339438,GSM8339439,GSM8339440,GSM8339441,GSM8339442,GSM8339443,GSM8339444,GSM8339445,GSM8339446,GSM8339447,GSM8339448,GSM8339449,GSM8339450,GSM8339451,GSM8339452,GSM8339453,GSM8339454,GSM8339455,GSM8339456,GSM8339457,GSM8339458,GSM8339459,GSM8339460,GSM8339461,GSM8339462,GSM8339463,GSM8339464,GSM8339465,GSM8339466,GSM8339467,GSM8339468,GSM8339469,GSM8339470
|
| 2 |
Asthma,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0
|
| 3 |
-
Gender,
|
|
|
|
| 1 |
,GSM8339381,GSM8339382,GSM8339383,GSM8339384,GSM8339385,GSM8339386,GSM8339387,GSM8339388,GSM8339389,GSM8339390,GSM8339391,GSM8339392,GSM8339393,GSM8339394,GSM8339395,GSM8339396,GSM8339397,GSM8339398,GSM8339399,GSM8339400,GSM8339401,GSM8339402,GSM8339403,GSM8339404,GSM8339405,GSM8339406,GSM8339407,GSM8339408,GSM8339409,GSM8339410,GSM8339411,GSM8339412,GSM8339413,GSM8339414,GSM8339415,GSM8339416,GSM8339417,GSM8339418,GSM8339419,GSM8339420,GSM8339421,GSM8339422,GSM8339423,GSM8339424,GSM8339425,GSM8339426,GSM8339427,GSM8339428,GSM8339429,GSM8339430,GSM8339431,GSM8339432,GSM8339433,GSM8339434,GSM8339435,GSM8339436,GSM8339437,GSM8339438,GSM8339439,GSM8339440,GSM8339441,GSM8339442,GSM8339443,GSM8339444,GSM8339445,GSM8339446,GSM8339447,GSM8339448,GSM8339449,GSM8339450,GSM8339451,GSM8339452,GSM8339453,GSM8339454,GSM8339455,GSM8339456,GSM8339457,GSM8339458,GSM8339459,GSM8339460,GSM8339461,GSM8339462,GSM8339463,GSM8339464,GSM8339465,GSM8339466,GSM8339467,GSM8339468,GSM8339469,GSM8339470
|
| 2 |
Asthma,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0
|
| 3 |
+
Gender,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0
|
output/preprocess/Asthma/code/GSE123086.py
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Asthma"
|
| 6 |
+
cohort = "GSE123086"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE123086"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Asthma/GSE123086.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Asthma/gene_data/GSE123086.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Asthma/clinical_data/GSE123086.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Asthma/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
|
| 41 |
+
# 1) Gene expression data availability (Agilent microarray gene expression per background)
|
| 42 |
+
is_gene_available = True
|
| 43 |
+
|
| 44 |
+
# 2) Variable availability and conversion functions
|
| 45 |
+
|
| 46 |
+
# Decide rows based on the Sample Characteristics Dictionary in the prompt:
|
| 47 |
+
# - trait_row: primary diagnosis -> row 1
|
| 48 |
+
# - gender_row: contains 'Sex:' (row 2 has Sex plus some diagnosis2; handle non-sex values in converter)
|
| 49 |
+
# - age_row: rows 3/4 show ages; choose row 3 (handle non-age values in converter)
|
| 50 |
+
trait_row = 1
|
| 51 |
+
gender_row = 2
|
| 52 |
+
age_row = 3
|
| 53 |
+
|
| 54 |
+
# Conversion helpers
|
| 55 |
+
def _after_colon(x: str) -> str:
|
| 56 |
+
if x is None:
|
| 57 |
+
return ""
|
| 58 |
+
parts = str(x).split(":", 1)
|
| 59 |
+
return parts[1].strip() if len(parts) > 1 else str(x).strip()
|
| 60 |
+
|
| 61 |
+
def convert_trait(x):
|
| 62 |
+
# Binary: 1 for trait present (Asthma), 0 for all others (including healthy controls and other diseases)
|
| 63 |
+
v = _after_colon(x).strip().lower()
|
| 64 |
+
if not v:
|
| 65 |
+
return None
|
| 66 |
+
# Match trait name robustly
|
| 67 |
+
# We only consider "primary diagnosis" row, but keep a generic check
|
| 68 |
+
if "asthma" in v:
|
| 69 |
+
return 1
|
| 70 |
+
# If it's clearly a known non-trait value (e.g., healthy control or other diseases), map to 0
|
| 71 |
+
non_trait_keywords = [
|
| 72 |
+
"healthy_control", "obesity", "seasonal_allergic_rhinitis", "psoriasis",
|
| 73 |
+
"crohn", "influenza", "ulcerative_colitis", "atherosclerosis",
|
| 74 |
+
"breast_cancer", "type_1_diabetes", "chronic_lymphocytic_leukemia",
|
| 75 |
+
"atopic_eczema", "acute_tonsillitis"
|
| 76 |
+
]
|
| 77 |
+
if any(k in v for k in non_trait_keywords):
|
| 78 |
+
return 0
|
| 79 |
+
return None
|
| 80 |
+
|
| 81 |
+
def convert_age(x):
|
| 82 |
+
# Continuous: extract numeric age in years; invalid entries -> None
|
| 83 |
+
v = _after_colon(x)
|
| 84 |
+
# Some cells in row 3 may contain "Sex: ..." -> return None
|
| 85 |
+
m = re.search(r"(-?\d+(?:\.\d+)?)", v)
|
| 86 |
+
if not m:
|
| 87 |
+
return None
|
| 88 |
+
try:
|
| 89 |
+
age_val = float(m.group(1))
|
| 90 |
+
if 0 <= age_val <= 120:
|
| 91 |
+
return age_val
|
| 92 |
+
return None
|
| 93 |
+
except Exception:
|
| 94 |
+
return None
|
| 95 |
+
|
| 96 |
+
def convert_gender(x):
|
| 97 |
+
# Binary: female->0, male->1; unknown -> None
|
| 98 |
+
v = _after_colon(x).strip().lower()
|
| 99 |
+
if v in ["female", "f"]:
|
| 100 |
+
return 0
|
| 101 |
+
if v in ["male", "m"]:
|
| 102 |
+
return 1
|
| 103 |
+
return None
|
| 104 |
+
|
| 105 |
+
# 3) Save metadata using initial filtering
|
| 106 |
+
is_trait_available = trait_row is not None
|
| 107 |
+
_ = validate_and_save_cohort_info(
|
| 108 |
+
is_final=False,
|
| 109 |
+
cohort=cohort,
|
| 110 |
+
info_path=json_path,
|
| 111 |
+
is_gene_available=is_gene_available,
|
| 112 |
+
is_trait_available=is_trait_available
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
# 4) Clinical feature extraction (only if trait_row is available)
|
| 116 |
+
if trait_row is not None:
|
| 117 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 118 |
+
clinical_df=clinical_data,
|
| 119 |
+
trait=trait,
|
| 120 |
+
trait_row=trait_row,
|
| 121 |
+
convert_trait=convert_trait,
|
| 122 |
+
age_row=age_row,
|
| 123 |
+
convert_age=convert_age,
|
| 124 |
+
gender_row=gender_row,
|
| 125 |
+
convert_gender=convert_gender
|
| 126 |
+
)
|
| 127 |
+
preview = preview_df(selected_clinical_df, n=5)
|
| 128 |
+
print(preview)
|
| 129 |
+
# Save clinical features
|
| 130 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 131 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
| 132 |
+
|
| 133 |
+
# Step 3: Gene Data Extraction
|
| 134 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 135 |
+
gene_data = get_genetic_data(matrix_file)
|
| 136 |
+
|
| 137 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 138 |
+
print(gene_data.index[:20])
|
| 139 |
+
|
| 140 |
+
# Step 4: Gene Identifier Review
|
| 141 |
+
print("requires_gene_mapping = True")
|
| 142 |
+
|
| 143 |
+
# Step 5: Gene Annotation
|
| 144 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 145 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 146 |
+
|
| 147 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 148 |
+
print("Gene annotation preview:")
|
| 149 |
+
print(preview_df(gene_annotation))
|
| 150 |
+
|
| 151 |
+
# Step 6: Gene Identifier Mapping
|
| 152 |
+
import re
|
| 153 |
+
import pandas as pd
|
| 154 |
+
|
| 155 |
+
# Preserve original probe-/ID-level expression
|
| 156 |
+
expr_df = gene_data.copy()
|
| 157 |
+
|
| 158 |
+
def normalize_id_series(s: pd.Series) -> pd.Series:
|
| 159 |
+
s = s.astype(str).str.strip()
|
| 160 |
+
return s.str.replace(r'\.0$', '', regex=True)
|
| 161 |
+
|
| 162 |
+
# 1) Choose ID column from annotation that best matches expression IDs (should be "ID")
|
| 163 |
+
expr_ids = set(expr_df.index.astype(str).str.strip())
|
| 164 |
+
best_id_col = None
|
| 165 |
+
best_overlap = -1
|
| 166 |
+
for col in gene_annotation.columns:
|
| 167 |
+
cand = normalize_id_series(gene_annotation[col])
|
| 168 |
+
overlap = cand.isin(expr_ids).sum()
|
| 169 |
+
if overlap > best_overlap:
|
| 170 |
+
best_overlap = overlap
|
| 171 |
+
best_id_col = col
|
| 172 |
+
|
| 173 |
+
# Prefer explicit 'ID' if reasonable
|
| 174 |
+
if 'ID' in gene_annotation.columns:
|
| 175 |
+
cand = normalize_id_series(gene_annotation['ID'])
|
| 176 |
+
overlap = cand.isin(expr_ids).sum()
|
| 177 |
+
if overlap >= best_overlap * 0.95:
|
| 178 |
+
best_id_col = 'ID'
|
| 179 |
+
|
| 180 |
+
# 2) Use ENTREZ_GENE_ID as the gene identifier since symbol columns are absent
|
| 181 |
+
if 'ENTREZ_GENE_ID' not in gene_annotation.columns:
|
| 182 |
+
raise ValueError("ENTREZ_GENE_ID column not found in annotation; cannot proceed with Entrez mapping.")
|
| 183 |
+
|
| 184 |
+
print(f"Chosen ID column: {best_id_col}")
|
| 185 |
+
print("Chosen Gene column: ENTREZ_GENE_ID (Entrez IDs)")
|
| 186 |
+
|
| 187 |
+
# 3) Build a clean, 1:1 mapping from ID -> Entrez (numeric-only), avoiding token explosion
|
| 188 |
+
annotation_for_map = gene_annotation.loc[:, [best_id_col, 'ENTREZ_GENE_ID']].copy()
|
| 189 |
+
annotation_for_map[best_id_col] = normalize_id_series(annotation_for_map[best_id_col])
|
| 190 |
+
|
| 191 |
+
# Keep only IDs present in expression
|
| 192 |
+
annotation_for_map = annotation_for_map[annotation_for_map[best_id_col].isin(expr_df.index)]
|
| 193 |
+
|
| 194 |
+
# Extract pure numeric Entrez IDs; drop rows without a valid numeric Entrez
|
| 195 |
+
def extract_numeric_entrez(x):
|
| 196 |
+
if pd.isna(x):
|
| 197 |
+
return None
|
| 198 |
+
m = re.search(r'\d+', str(x))
|
| 199 |
+
return m.group(0) if m else None
|
| 200 |
+
|
| 201 |
+
annotation_for_map['Gene'] = annotation_for_map['ENTREZ_GENE_ID'].apply(extract_numeric_entrez)
|
| 202 |
+
annotation_for_map = annotation_for_map.dropna(subset=['Gene'])
|
| 203 |
+
|
| 204 |
+
# Reduce to necessary columns and remove duplicates
|
| 205 |
+
mapping_df = annotation_for_map.loc[:, [best_id_col, 'Gene']].rename(columns={best_id_col: 'ID'})
|
| 206 |
+
mapping_df['ID'] = mapping_df['ID'].astype(str).str.strip()
|
| 207 |
+
mapping_df['Gene'] = mapping_df['Gene'].astype(str).str.strip()
|
| 208 |
+
mapping_df = mapping_df.drop_duplicates(subset=['ID', 'Gene'])
|
| 209 |
+
|
| 210 |
+
# 4) Map expression to Entrez gene IDs (1:1 in this dataset) and aggregate
|
| 211 |
+
mapped = mapping_df.set_index('ID').join(expr_df, how='inner')
|
| 212 |
+
expr_cols = [c for c in mapped.columns if c != 'Gene']
|
| 213 |
+
gene_data = mapped.groupby('Gene')[expr_cols].sum()
|
| 214 |
+
|
| 215 |
+
# 5) Sanity check gene count to catch mapping explosions
|
| 216 |
+
n_genes = gene_data.shape[0]
|
| 217 |
+
n_samples = gene_data.shape[1]
|
| 218 |
+
print(f"Gene-level data shape: {gene_data.shape} (genes x samples)")
|
| 219 |
+
if n_genes < 5000 or n_genes > 80000:
|
| 220 |
+
raise ValueError(f"Implausible gene count after mapping: {n_genes}. Check mapping logic and annotation parsing.")
|
| 221 |
+
|
| 222 |
+
# Step 7: Data Normalization and Linking
|
| 223 |
+
import os
|
| 224 |
+
|
| 225 |
+
# 1. Normalize gene data only if index appears to be gene symbols; otherwise keep Entrez IDs
|
| 226 |
+
idx = gene_data.index.astype(str)
|
| 227 |
+
digit_ratio = idx.str.fullmatch(r'\d+').mean() # proportion of purely numeric IDs
|
| 228 |
+
note = ""
|
| 229 |
+
|
| 230 |
+
if digit_ratio < 0.5:
|
| 231 |
+
# Likely gene symbols: normalize using synonym information
|
| 232 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 233 |
+
note = "INFO: Gene symbols detected; normalized using synonym dictionary."
|
| 234 |
+
else:
|
| 235 |
+
# Likely Entrez IDs: skip normalization
|
| 236 |
+
normalized_gene_data = gene_data.copy()
|
| 237 |
+
note = "INFO: Gene matrix indexed by Entrez Gene IDs; gene symbol normalization skipped."
|
| 238 |
+
|
| 239 |
+
# Ensure output directory exists and save gene data
|
| 240 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 241 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 242 |
+
|
| 243 |
+
# 2. Link the clinical and genetic data
|
| 244 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 245 |
+
|
| 246 |
+
# 3. Handle missing values
|
| 247 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 248 |
+
|
| 249 |
+
# 4. Determine bias and remove biased demographic features
|
| 250 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 251 |
+
|
| 252 |
+
# 5. Final validation and save cohort info
|
| 253 |
+
is_usable = validate_and_save_cohort_info(
|
| 254 |
+
True, cohort, json_path, True, True, is_trait_biased, unbiased_linked_data, note=note
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
# 6. Save linked data if usable
|
| 258 |
+
if is_usable:
|
| 259 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 260 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Asthma/code/GSE123088.py
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Asthma"
|
| 6 |
+
cohort = "GSE123088"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE123088"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Asthma/GSE123088.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Asthma/gene_data/GSE123088.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Asthma/clinical_data/GSE123088.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Asthma/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
import pandas as pd
|
| 41 |
+
|
| 42 |
+
# 1) Gene Expression Data Availability
|
| 43 |
+
# Given the study context (single-cell, CD4+ T cells), it is likely gene expression (not miRNA/methylation).
|
| 44 |
+
is_gene_available = True
|
| 45 |
+
|
| 46 |
+
# 2) Variable Availability and Data Type Conversion
|
| 47 |
+
|
| 48 |
+
# Based on the provided Sample Characteristics Dictionary:
|
| 49 |
+
# - Trait (Asthma): use row 1 "primary diagnosis"
|
| 50 |
+
trait_row = 1
|
| 51 |
+
|
| 52 |
+
# - Age: choose row 3 (mostly age entries; row 4 also has ages but 3 appears broader)
|
| 53 |
+
age_row = 3
|
| 54 |
+
|
| 55 |
+
# - Gender: use row 2 where "Sex" is present
|
| 56 |
+
gender_row = 2
|
| 57 |
+
|
| 58 |
+
def _get_value_after_colon(x: str) -> str:
|
| 59 |
+
if x is None:
|
| 60 |
+
return ''
|
| 61 |
+
s = str(x)
|
| 62 |
+
parts = s.split(':', 1)
|
| 63 |
+
val = parts[1] if len(parts) > 1 else parts[0]
|
| 64 |
+
return val.strip()
|
| 65 |
+
|
| 66 |
+
def convert_trait(x):
|
| 67 |
+
"""
|
| 68 |
+
Binary: 1 = Asthma, 0 = Control/Healthy Control, None = other diseases/unknown.
|
| 69 |
+
"""
|
| 70 |
+
if x is None:
|
| 71 |
+
return None
|
| 72 |
+
val = _get_value_after_colon(x).strip().lower()
|
| 73 |
+
# normalize underscores/spaces
|
| 74 |
+
val_norm = val.replace('-', '_').replace(' ', '_')
|
| 75 |
+
if val_norm == 'asthma':
|
| 76 |
+
return 1
|
| 77 |
+
if val_norm in {'control', 'healthy_control', 'healthy', 'normal'}:
|
| 78 |
+
return 0
|
| 79 |
+
return None
|
| 80 |
+
|
| 81 |
+
def convert_age(x):
|
| 82 |
+
"""
|
| 83 |
+
Continuous age in years. Extract first integer/float found; filter to plausible range 0-120.
|
| 84 |
+
"""
|
| 85 |
+
if x is None:
|
| 86 |
+
return None
|
| 87 |
+
val = _get_value_after_colon(x)
|
| 88 |
+
m = re.search(r'(\d+(?:\.\d+)?)', val)
|
| 89 |
+
if not m:
|
| 90 |
+
return None
|
| 91 |
+
try:
|
| 92 |
+
age = float(m.group(1))
|
| 93 |
+
if 0 <= age <= 120:
|
| 94 |
+
return age
|
| 95 |
+
except Exception:
|
| 96 |
+
pass
|
| 97 |
+
return None
|
| 98 |
+
|
| 99 |
+
def convert_gender(x):
|
| 100 |
+
"""
|
| 101 |
+
Binary: Female=0, Male=1, else None.
|
| 102 |
+
"""
|
| 103 |
+
if x is None:
|
| 104 |
+
return None
|
| 105 |
+
val = _get_value_after_colon(x).strip().lower()
|
| 106 |
+
if val.startswith('female') or val == 'f':
|
| 107 |
+
return 0
|
| 108 |
+
if val.startswith('male') or val == 'm':
|
| 109 |
+
return 1
|
| 110 |
+
return None
|
| 111 |
+
|
| 112 |
+
# 3) Save Metadata (initial filtering)
|
| 113 |
+
is_trait_available = trait_row is not None
|
| 114 |
+
_ = validate_and_save_cohort_info(
|
| 115 |
+
is_final=False,
|
| 116 |
+
cohort=cohort,
|
| 117 |
+
info_path=json_path,
|
| 118 |
+
is_gene_available=is_gene_available,
|
| 119 |
+
is_trait_available=is_trait_available
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
# 4) Clinical Feature Extraction (only if trait available)
|
| 123 |
+
if trait_row is not None:
|
| 124 |
+
selected_clinical = geo_select_clinical_features(
|
| 125 |
+
clinical_df=clinical_data,
|
| 126 |
+
trait=trait,
|
| 127 |
+
trait_row=trait_row,
|
| 128 |
+
convert_trait=convert_trait,
|
| 129 |
+
age_row=age_row,
|
| 130 |
+
convert_age=convert_age,
|
| 131 |
+
gender_row=gender_row,
|
| 132 |
+
convert_gender=convert_gender
|
| 133 |
+
)
|
| 134 |
+
preview = preview_df(selected_clinical)
|
| 135 |
+
print(preview)
|
| 136 |
+
# Save clinical features
|
| 137 |
+
out_dir = os.path.dirname(out_clinical_data_file)
|
| 138 |
+
os.makedirs(out_dir, exist_ok=True)
|
| 139 |
+
selected_clinical.to_csv(out_clinical_data_file)
|
| 140 |
+
|
| 141 |
+
# Step 3: Gene Data Extraction
|
| 142 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 143 |
+
gene_data = get_genetic_data(matrix_file)
|
| 144 |
+
|
| 145 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 146 |
+
print(gene_data.index[:20])
|
| 147 |
+
|
| 148 |
+
# Step 4: Gene Identifier Review
|
| 149 |
+
print("requires_gene_mapping = True")
|
| 150 |
+
|
| 151 |
+
# Step 5: Gene Annotation
|
| 152 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 153 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 154 |
+
|
| 155 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 156 |
+
print("Gene annotation preview:")
|
| 157 |
+
print(preview_df(gene_annotation))
|
| 158 |
+
|
| 159 |
+
# Step 6: Gene Identifier Mapping
|
| 160 |
+
import re
|
| 161 |
+
import pandas as pd
|
| 162 |
+
|
| 163 |
+
# 1) Decide columns for mapping based on previews:
|
| 164 |
+
# - Probe/ID in expression data matches 'ID' in annotation
|
| 165 |
+
# - Gene identifier available in annotation: 'ENTREZ_GENE_ID' (no explicit gene symbol column provided)
|
| 166 |
+
probe_col = 'ID'
|
| 167 |
+
gene_col = 'ENTREZ_GENE_ID'
|
| 168 |
+
|
| 169 |
+
# 2) Get mapping dataframe with the two columns
|
| 170 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=gene_col)
|
| 171 |
+
|
| 172 |
+
# 3) Apply mapping to convert probe-level data to gene-level data
|
| 173 |
+
def apply_mapping_without_symbol_extraction(expression_df: pd.DataFrame, mapping_df: pd.DataFrame) -> pd.DataFrame:
|
| 174 |
+
# Keep only probes present in the expression data
|
| 175 |
+
mapping_df = mapping_df[mapping_df['ID'].isin(expression_df.index)].copy()
|
| 176 |
+
|
| 177 |
+
# Prepare gene lists per probe (handle potential multiple genes per probe)
|
| 178 |
+
def split_genes(val):
|
| 179 |
+
if pd.isna(val):
|
| 180 |
+
return []
|
| 181 |
+
s = str(val).strip()
|
| 182 |
+
if s == '' or s.lower() in {'na', 'nan', 'none'}:
|
| 183 |
+
return []
|
| 184 |
+
# Common delimiters used in GEO annotations
|
| 185 |
+
parts = re.split(r'\s*///\s*|\s*//\s*|\s*[;,|]\s*|\s+\+\s+|\s*/\s*', s)
|
| 186 |
+
return [p for p in parts if p != '']
|
| 187 |
+
|
| 188 |
+
mapping_df['Gene'] = mapping_df['Gene'].apply(split_genes)
|
| 189 |
+
mapping_df['num_genes'] = mapping_df['Gene'].apply(len)
|
| 190 |
+
|
| 191 |
+
# Expand to one row per (probe, gene)
|
| 192 |
+
mapping_df = mapping_df.explode('Gene')
|
| 193 |
+
mapping_df = mapping_df.dropna(subset=['Gene'])
|
| 194 |
+
mapping_df.set_index('ID', inplace=True)
|
| 195 |
+
|
| 196 |
+
# Join with expression and distribute expression across mapped genes
|
| 197 |
+
merged = mapping_df.join(expression_df, how='inner')
|
| 198 |
+
expr_cols = [c for c in merged.columns if c not in ['Gene', 'num_genes']]
|
| 199 |
+
merged[expr_cols] = merged[expr_cols].div(merged['num_genes'].replace(0, 1), axis=0)
|
| 200 |
+
|
| 201 |
+
# Aggregate to gene level
|
| 202 |
+
gene_expression_df = merged.groupby('Gene')[expr_cols].sum()
|
| 203 |
+
return gene_expression_df
|
| 204 |
+
|
| 205 |
+
# Apply the mapping function
|
| 206 |
+
gene_data = apply_mapping_without_symbol_extraction(gene_data, mapping_df)
|
output/preprocess/Asthma/code/GSE182797.py
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Asthma"
|
| 6 |
+
cohort = "GSE182797"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE182797"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Asthma/GSE182797.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Asthma/gene_data/GSE182797.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Asthma/clinical_data/GSE182797.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Asthma/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import os
|
| 40 |
+
import re
|
| 41 |
+
import pandas as pd
|
| 42 |
+
|
| 43 |
+
# 1) Gene expression data availability
|
| 44 |
+
is_gene_available = True # Microarray transcriptome profiling indicates gene expression data
|
| 45 |
+
|
| 46 |
+
# 2) Variable availability
|
| 47 |
+
trait_row = 0 # 'diagnosis' with multiple categories including asthma
|
| 48 |
+
age_row = 2 # 'age' values available and varying
|
| 49 |
+
gender_row = None # Only 'Female' present => constant => not useful
|
| 50 |
+
|
| 51 |
+
# 2.2) Converters
|
| 52 |
+
def _after_colon(x):
|
| 53 |
+
if x is None:
|
| 54 |
+
return None
|
| 55 |
+
if isinstance(x, str):
|
| 56 |
+
parts = x.split(":", 1)
|
| 57 |
+
x = parts[1] if len(parts) > 1 else parts[0]
|
| 58 |
+
return x.strip()
|
| 59 |
+
return x
|
| 60 |
+
|
| 61 |
+
def convert_trait(x):
|
| 62 |
+
v = _after_colon(x)
|
| 63 |
+
if v is None:
|
| 64 |
+
return None
|
| 65 |
+
v_low = str(v).strip().lower()
|
| 66 |
+
# Map presence of asthma to 1, others (healthy, IEI) to 0
|
| 67 |
+
if "asthma" in v_low:
|
| 68 |
+
return 1
|
| 69 |
+
if v_low in {"healthy", "control", "controls"}:
|
| 70 |
+
return 0
|
| 71 |
+
if v_low in {"iei", "idiopathic environmental intolerance"}:
|
| 72 |
+
return 0
|
| 73 |
+
return None
|
| 74 |
+
|
| 75 |
+
def convert_age(x):
|
| 76 |
+
v = _after_colon(x)
|
| 77 |
+
if v is None:
|
| 78 |
+
return None
|
| 79 |
+
v = str(v).strip().lower()
|
| 80 |
+
if v in {"na", "n/a", "nan", "none", ""}:
|
| 81 |
+
return None
|
| 82 |
+
# Extract first float in the string
|
| 83 |
+
m = re.search(r"-?\d+(\.\d+)?", v)
|
| 84 |
+
if not m:
|
| 85 |
+
return None
|
| 86 |
+
try:
|
| 87 |
+
return float(m.group(0))
|
| 88 |
+
except Exception:
|
| 89 |
+
return None
|
| 90 |
+
|
| 91 |
+
def convert_gender(x):
|
| 92 |
+
v = _after_colon(x)
|
| 93 |
+
if v is None:
|
| 94 |
+
return None
|
| 95 |
+
v_low = str(v).strip().lower()
|
| 96 |
+
if v_low in {"female", "f"}:
|
| 97 |
+
return 0
|
| 98 |
+
if v_low in {"male", "m"}:
|
| 99 |
+
return 1
|
| 100 |
+
return None
|
| 101 |
+
|
| 102 |
+
# 3) Save metadata (initial filtering)
|
| 103 |
+
is_trait_available = trait_row is not None
|
| 104 |
+
_ = validate_and_save_cohort_info(
|
| 105 |
+
is_final=False,
|
| 106 |
+
cohort=cohort,
|
| 107 |
+
info_path=json_path,
|
| 108 |
+
is_gene_available=is_gene_available,
|
| 109 |
+
is_trait_available=is_trait_available
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
# 4) Clinical feature extraction (only if trait is available)
|
| 113 |
+
if trait_row is not None:
|
| 114 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 115 |
+
clinical_df=clinical_data,
|
| 116 |
+
trait=trait,
|
| 117 |
+
trait_row=trait_row,
|
| 118 |
+
convert_trait=convert_trait,
|
| 119 |
+
age_row=age_row,
|
| 120 |
+
convert_age=convert_age,
|
| 121 |
+
gender_row=gender_row,
|
| 122 |
+
convert_gender=None
|
| 123 |
+
)
|
| 124 |
+
preview = preview_df(selected_clinical_df)
|
| 125 |
+
print(preview)
|
| 126 |
+
# Save clinical data
|
| 127 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 128 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=True)
|
| 129 |
+
|
| 130 |
+
# Step 3: Gene Data Extraction
|
| 131 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 132 |
+
gene_data = get_genetic_data(matrix_file)
|
| 133 |
+
|
| 134 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 135 |
+
print(gene_data.index[:20])
|
| 136 |
+
|
| 137 |
+
# Step 4: Gene Identifier Review
|
| 138 |
+
print("requires_gene_mapping = True")
|
| 139 |
+
|
| 140 |
+
# Step 5: Gene Annotation
|
| 141 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 142 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 143 |
+
|
| 144 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 145 |
+
print("Gene annotation preview:")
|
| 146 |
+
print(preview_df(gene_annotation))
|
| 147 |
+
|
| 148 |
+
# Step 6: Gene Identifier Mapping
|
| 149 |
+
# 1-2) Decide columns and build mapping dataframe
|
| 150 |
+
# Probe identifiers: 'ID'; Gene symbols: 'GENE_SYMBOL'
|
| 151 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
|
| 152 |
+
|
| 153 |
+
# 3) Apply mapping to convert probe-level data to gene-level expression
|
| 154 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
|
| 155 |
+
|
| 156 |
+
# Step 7: Data Normalization and Linking
|
| 157 |
+
import os
|
| 158 |
+
|
| 159 |
+
# 1. Normalize gene symbols and save
|
| 160 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 161 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 162 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 163 |
+
|
| 164 |
+
# 2. Link clinical and genetic data
|
| 165 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 166 |
+
|
| 167 |
+
# 3. Handle missing values
|
| 168 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 169 |
+
|
| 170 |
+
# 4. Assess bias and remove biased covariates
|
| 171 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 172 |
+
|
| 173 |
+
# 5. Final validation and save cohort info
|
| 174 |
+
note = "INFO: Gender not provided or constant (female only) per series description; excluded as covariate."
|
| 175 |
+
is_usable = validate_and_save_cohort_info(
|
| 176 |
+
is_final=True,
|
| 177 |
+
cohort=cohort,
|
| 178 |
+
info_path=json_path,
|
| 179 |
+
is_gene_available=True,
|
| 180 |
+
is_trait_available=True,
|
| 181 |
+
is_biased=is_trait_biased,
|
| 182 |
+
df=unbiased_linked_data,
|
| 183 |
+
note=note
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
# 6. Save linked data if usable
|
| 187 |
+
if is_usable:
|
| 188 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 189 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Asthma/code/GSE182798.py
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Asthma"
|
| 6 |
+
cohort = "GSE182798"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE182798"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Asthma/GSE182798.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Asthma/gene_data/GSE182798.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Asthma/clinical_data/GSE182798.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Asthma/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
# Step 1: Determine gene expression availability
|
| 40 |
+
is_gene_available = True # "Transcriptomic profiling" indicates gene expression data (not miRNA-only or methylation-only)
|
| 41 |
+
|
| 42 |
+
# Step 2: Determine availability rows based on the provided Sample Characteristics Dictionary
|
| 43 |
+
trait_row = 0 # diagnosis field with values including 'adult-onset asthma', 'healthy', 'IEI'
|
| 44 |
+
age_row = 2 # age field with diverse numeric values
|
| 45 |
+
gender_row = None # only 'Female' observed (constant), considered not available
|
| 46 |
+
|
| 47 |
+
# Step 2.2: Define conversion functions
|
| 48 |
+
def _extract_value(cell):
|
| 49 |
+
if cell is None:
|
| 50 |
+
return None
|
| 51 |
+
try:
|
| 52 |
+
# Extract value after the last colon to be robust to multiple colons
|
| 53 |
+
return str(cell).split(":", 1)[1].strip()
|
| 54 |
+
except Exception:
|
| 55 |
+
return str(cell).strip()
|
| 56 |
+
|
| 57 |
+
def convert_trait(cell):
|
| 58 |
+
v = _extract_value(cell)
|
| 59 |
+
if v is None:
|
| 60 |
+
return None
|
| 61 |
+
vl = v.lower()
|
| 62 |
+
# Map asthma vs non-asthma
|
| 63 |
+
if "asthma" in vl:
|
| 64 |
+
return 1
|
| 65 |
+
if vl in {"healthy", "control", "normal"}:
|
| 66 |
+
return 0
|
| 67 |
+
if "iei" in vl: # Idiopathic Environmental Intolerance is not asthma
|
| 68 |
+
return 0
|
| 69 |
+
return None
|
| 70 |
+
|
| 71 |
+
def convert_age(cell):
|
| 72 |
+
v = _extract_value(cell)
|
| 73 |
+
if v is None:
|
| 74 |
+
return None
|
| 75 |
+
try:
|
| 76 |
+
val = float(v)
|
| 77 |
+
# Filter unreasonable ages
|
| 78 |
+
if 0 <= val < 120:
|
| 79 |
+
return val
|
| 80 |
+
return None
|
| 81 |
+
except Exception:
|
| 82 |
+
return None
|
| 83 |
+
|
| 84 |
+
def convert_gender(cell):
|
| 85 |
+
v = _extract_value(cell)
|
| 86 |
+
if v is None:
|
| 87 |
+
return None
|
| 88 |
+
vl = v.lower()
|
| 89 |
+
if vl in {"female", "f", "woman", "women"}:
|
| 90 |
+
return 0
|
| 91 |
+
if vl in {"male", "m", "man", "men"}:
|
| 92 |
+
return 1
|
| 93 |
+
return None
|
| 94 |
+
|
| 95 |
+
# Step 3: Initial filtering and save metadata
|
| 96 |
+
is_trait_available = trait_row is not None
|
| 97 |
+
_ = validate_and_save_cohort_info(
|
| 98 |
+
is_final=False,
|
| 99 |
+
cohort=cohort,
|
| 100 |
+
info_path=json_path,
|
| 101 |
+
is_gene_available=is_gene_available,
|
| 102 |
+
is_trait_available=is_trait_available
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
# Step 4: Clinical feature extraction (only if trait data is available)
|
| 106 |
+
if trait_row is not None:
|
| 107 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 108 |
+
clinical_df=clinical_data,
|
| 109 |
+
trait=trait,
|
| 110 |
+
trait_row=trait_row,
|
| 111 |
+
convert_trait=convert_trait,
|
| 112 |
+
age_row=age_row,
|
| 113 |
+
convert_age=convert_age,
|
| 114 |
+
gender_row=gender_row,
|
| 115 |
+
convert_gender=None
|
| 116 |
+
)
|
| 117 |
+
preview = preview_df(selected_clinical_df, n=5)
|
| 118 |
+
# Optionally print to observe preview during execution
|
| 119 |
+
print("Preview of selected clinical features:", preview)
|
| 120 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 121 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=True)
|
| 122 |
+
|
| 123 |
+
# Step 3: Gene Data Extraction
|
| 124 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 125 |
+
gene_data = get_genetic_data(matrix_file)
|
| 126 |
+
|
| 127 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 128 |
+
print(gene_data.index[:20])
|
| 129 |
+
|
| 130 |
+
# Step 4: Gene Identifier Review
|
| 131 |
+
requires_gene_mapping = True
|
| 132 |
+
print(f"requires_gene_mapping = {requires_gene_mapping}")
|
| 133 |
+
|
| 134 |
+
# Step 5: Gene Annotation
|
| 135 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 136 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 137 |
+
|
| 138 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 139 |
+
print("Gene annotation preview:")
|
| 140 |
+
print(preview_df(gene_annotation))
|
| 141 |
+
|
| 142 |
+
# Step 6: Gene Identifier Mapping
|
| 143 |
+
# Determine appropriate columns for probe IDs and gene symbols
|
| 144 |
+
candidate_id_cols = [col for col in ['ID', 'SPOT_ID'] if col in gene_annotation.columns]
|
| 145 |
+
symbol_col = 'GENE_SYMBOL' if 'GENE_SYMBOL' in gene_annotation.columns else None
|
| 146 |
+
|
| 147 |
+
# Fallback checks
|
| 148 |
+
if not candidate_id_cols or symbol_col is None:
|
| 149 |
+
raise ValueError("Required columns for mapping not found in gene annotation.")
|
| 150 |
+
|
| 151 |
+
# Select the probe ID column with the highest overlap with expression data indices
|
| 152 |
+
overlaps = {}
|
| 153 |
+
gene_index_set = set(gene_data.index.astype(str))
|
| 154 |
+
for col in candidate_id_cols:
|
| 155 |
+
ann_ids = gene_annotation[col].dropna().astype(str).str.strip()
|
| 156 |
+
overlaps[col] = len(gene_index_set.intersection(set(ann_ids)))
|
| 157 |
+
|
| 158 |
+
id_col = max(overlaps, key=overlaps.get) if overlaps else 'ID'
|
| 159 |
+
|
| 160 |
+
# Build mapping dataframe
|
| 161 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=id_col, gene_col=symbol_col)
|
| 162 |
+
|
| 163 |
+
# Apply mapping to convert probe-level data to gene-level data
|
| 164 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
|
| 165 |
+
|
| 166 |
+
# Step 7: Data Normalization and Linking
|
| 167 |
+
import os
|
| 168 |
+
|
| 169 |
+
# 1. Normalize the obtained gene data and save
|
| 170 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 171 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 172 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 173 |
+
|
| 174 |
+
# 2. Link the clinical and genetic data
|
| 175 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 176 |
+
|
| 177 |
+
# 3. Handle missing values in the linked data
|
| 178 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 179 |
+
|
| 180 |
+
# 4. Determine whether the trait and some demographic features are severely biased, and remove biased features.
|
| 181 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 182 |
+
|
| 183 |
+
# 5. Conduct quality check and save the cohort information.
|
| 184 |
+
note = "INFO: Gender unavailable/constant female; mixed tissues (PBMC and Nasal biopsy) present."
|
| 185 |
+
is_usable = validate_and_save_cohort_info(
|
| 186 |
+
True, cohort, json_path, True, True, is_trait_biased, unbiased_linked_data, note=note
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
# 6. If the linked data is usable, save it as a CSV file to 'out_data_file'.
|
| 190 |
+
if is_usable:
|
| 191 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 192 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Asthma/code/GSE184382.py
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Asthma"
|
| 6 |
+
cohort = "GSE184382"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE184382"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Asthma/GSE184382.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Asthma/gene_data/GSE184382.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Asthma/clinical_data/GSE184382.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Asthma/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
|
| 41 |
+
# 1. Gene Expression Data Availability
|
| 42 |
+
# Background indicates both miR microarray and transcriptome microarray were performed.
|
| 43 |
+
is_gene_available = True
|
| 44 |
+
|
| 45 |
+
# 2. Variable Availability and Data Type Conversion
|
| 46 |
+
|
| 47 |
+
# Based on the provided Sample Characteristics Dictionary:
|
| 48 |
+
# {0: ['season: in season'], 1: ['ait treatment: no', 'ait treatment: yes']}
|
| 49 |
+
# There is no explicit or inferable asthma status, age, or gender field.
|
| 50 |
+
trait_row = None
|
| 51 |
+
age_row = None
|
| 52 |
+
gender_row = None
|
| 53 |
+
|
| 54 |
+
def _after_colon(x):
|
| 55 |
+
if x is None:
|
| 56 |
+
return None
|
| 57 |
+
s = str(x)
|
| 58 |
+
parts = s.split(":", 1)
|
| 59 |
+
val = parts[1] if len(parts) > 1 else parts[0]
|
| 60 |
+
return val.strip()
|
| 61 |
+
|
| 62 |
+
def convert_trait(x):
|
| 63 |
+
# Binary: 1 for asthma, 0 for non-asthma; unknown -> None
|
| 64 |
+
val = _after_colon(x)
|
| 65 |
+
if val is None or val == "":
|
| 66 |
+
return None
|
| 67 |
+
v = val.lower()
|
| 68 |
+
|
| 69 |
+
# Common indicators
|
| 70 |
+
positives = [
|
| 71 |
+
"asthma", "asthmatic", "aa", "with asthma", "asthma: yes", "diagnosis: asthma"
|
| 72 |
+
]
|
| 73 |
+
negatives = [
|
| 74 |
+
"non-asthma", "no asthma", "without asthma", "control", "hc", "healthy",
|
| 75 |
+
"ar", "allergic rhinitis", "asthma: no"
|
| 76 |
+
]
|
| 77 |
+
|
| 78 |
+
# Heuristic mapping
|
| 79 |
+
if any(tok in v for tok in positives):
|
| 80 |
+
return 1
|
| 81 |
+
if any(tok in v for tok in negatives):
|
| 82 |
+
return 0
|
| 83 |
+
return None
|
| 84 |
+
|
| 85 |
+
def convert_age(x):
|
| 86 |
+
# Continuous age in years; unknown -> None
|
| 87 |
+
val = _after_colon(x)
|
| 88 |
+
if val is None or val == "":
|
| 89 |
+
return None
|
| 90 |
+
m = re.search(r'(\d+(?:\.\d+)?)', val)
|
| 91 |
+
if not m:
|
| 92 |
+
return None
|
| 93 |
+
try:
|
| 94 |
+
return float(m.group(1))
|
| 95 |
+
except Exception:
|
| 96 |
+
return None
|
| 97 |
+
|
| 98 |
+
def convert_gender(x):
|
| 99 |
+
# Binary: female -> 0, male -> 1; unknown -> None
|
| 100 |
+
val = _after_colon(x)
|
| 101 |
+
if val is None or val == "":
|
| 102 |
+
return None
|
| 103 |
+
v = val.strip().lower()
|
| 104 |
+
if v in ["male", "m", "man", "boy"]:
|
| 105 |
+
return 1
|
| 106 |
+
if v in ["female", "f", "woman", "girl"]:
|
| 107 |
+
return 0
|
| 108 |
+
return None
|
| 109 |
+
|
| 110 |
+
# 3. Save Metadata (initial filtering)
|
| 111 |
+
is_trait_available = trait_row is not None
|
| 112 |
+
_ = validate_and_save_cohort_info(
|
| 113 |
+
is_final=False,
|
| 114 |
+
cohort=cohort,
|
| 115 |
+
info_path=json_path,
|
| 116 |
+
is_gene_available=is_gene_available,
|
| 117 |
+
is_trait_available=is_trait_available
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
# 4. Clinical Feature Extraction (skip because trait_row is None)
|
| 121 |
+
if trait_row is not None:
|
| 122 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 123 |
+
clinical_df=clinical_data,
|
| 124 |
+
trait=trait,
|
| 125 |
+
trait_row=trait_row,
|
| 126 |
+
convert_trait=convert_trait,
|
| 127 |
+
age_row=age_row,
|
| 128 |
+
convert_age=convert_age,
|
| 129 |
+
gender_row=gender_row,
|
| 130 |
+
convert_gender=convert_gender
|
| 131 |
+
)
|
| 132 |
+
preview = preview_df(selected_clinical_df)
|
| 133 |
+
print(preview)
|
| 134 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 135 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
| 136 |
+
|
| 137 |
+
# Step 3: Gene Data Extraction
|
| 138 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 139 |
+
gene_data = get_genetic_data(matrix_file)
|
| 140 |
+
|
| 141 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 142 |
+
print(gene_data.index[:20])
|
| 143 |
+
|
| 144 |
+
# Step 4: Gene Identifier Review
|
| 145 |
+
# The provided identifiers include Agilent-style probe IDs (e.g., "A_19_P00315452") and other non-gene-symbol entries.
|
| 146 |
+
# These are not standard human gene symbols and require mapping to gene symbols.
|
| 147 |
+
print("requires_gene_mapping = True")
|
| 148 |
+
|
| 149 |
+
# Step 5: Gene Annotation
|
| 150 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 151 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 152 |
+
|
| 153 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 154 |
+
print("Gene annotation preview:")
|
| 155 |
+
print(preview_df(gene_annotation))
|
| 156 |
+
|
| 157 |
+
# Step 6: Gene Identifier Mapping
|
| 158 |
+
# 1-2. Determine the appropriate columns for probe IDs and gene symbols from gene_annotation
|
| 159 |
+
probe_col = 'ID' # Matches the probe identifiers in the gene expression matrix
|
| 160 |
+
gene_symbol_col = 'GENE_SYMBOL' # Contains human gene symbols
|
| 161 |
+
|
| 162 |
+
# Extract mapping dataframe
|
| 163 |
+
gene_mapping = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=gene_symbol_col)
|
| 164 |
+
|
| 165 |
+
# 3. Apply mapping to convert probe-level data to gene-level expression
|
| 166 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=gene_mapping)
|
| 167 |
+
|
| 168 |
+
# Step 7: Data Normalization and Linking
|
| 169 |
+
# 1. Normalize gene symbols and save gene expression data
|
| 170 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 171 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 172 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 173 |
+
|
| 174 |
+
# 2-6. Handle presence/absence of clinical data (trait). In this cohort, trait was unavailable in Step 2.
|
| 175 |
+
clinical_df = None
|
| 176 |
+
has_clinical = False
|
| 177 |
+
|
| 178 |
+
# Try to use in-memory clinical data if it exists; otherwise try to load from disk if any
|
| 179 |
+
if 'selected_clinical_data' in locals():
|
| 180 |
+
clinical_df = selected_clinical_data
|
| 181 |
+
has_clinical = True
|
| 182 |
+
elif os.path.exists(out_clinical_data_file):
|
| 183 |
+
clinical_df = pd.read_csv(out_clinical_data_file, index_col=0)
|
| 184 |
+
has_clinical = True
|
| 185 |
+
|
| 186 |
+
# Determine if trait is available in clinical data
|
| 187 |
+
trait_available = bool(has_clinical and (trait in clinical_df.index))
|
| 188 |
+
|
| 189 |
+
if trait_available:
|
| 190 |
+
# Link clinical and genetic data
|
| 191 |
+
linked_data = geo_link_clinical_genetic_data(clinical_df, normalized_gene_data)
|
| 192 |
+
|
| 193 |
+
# Handle missing values
|
| 194 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 195 |
+
|
| 196 |
+
# Bias checks (remove biased covariates; record trait bias)
|
| 197 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 198 |
+
|
| 199 |
+
# Final validation and save cohort info
|
| 200 |
+
is_usable = validate_and_save_cohort_info(
|
| 201 |
+
is_final=True,
|
| 202 |
+
cohort=cohort,
|
| 203 |
+
info_path=json_path,
|
| 204 |
+
is_gene_available=True,
|
| 205 |
+
is_trait_available=True,
|
| 206 |
+
is_biased=is_trait_biased,
|
| 207 |
+
df=unbiased_linked_data,
|
| 208 |
+
note="INFO: Clinical trait available; completed linking and preprocessing."
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
# Save linked data if usable
|
| 212 |
+
if is_usable:
|
| 213 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 214 |
+
unbiased_linked_data.to_csv(out_data_file)
|
| 215 |
+
|
| 216 |
+
else:
|
| 217 |
+
# Trait/clinical data unavailable: finalize metadata without linking
|
| 218 |
+
_ = validate_and_save_cohort_info(
|
| 219 |
+
is_final=True,
|
| 220 |
+
cohort=cohort,
|
| 221 |
+
info_path=json_path,
|
| 222 |
+
is_gene_available=True,
|
| 223 |
+
is_trait_available=False,
|
| 224 |
+
is_biased=False,
|
| 225 |
+
df=pd.DataFrame(), # empty df to indicate no linked data available
|
| 226 |
+
note="WARNING: Trait/clinical data unavailable for this series; linking and bias analysis skipped. Only normalized gene data saved."
|
| 227 |
+
)
|
output/preprocess/Asthma/code/GSE185658.py
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Asthma"
|
| 6 |
+
cohort = "GSE185658"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE185658"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Asthma/GSE185658.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Asthma/gene_data/GSE185658.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Asthma/clinical_data/GSE185658.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Asthma/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
import os
|
| 41 |
+
from typing import Any
|
| 42 |
+
|
| 43 |
+
# 1. Gene Expression Data Availability
|
| 44 |
+
is_gene_available = True # Affymetrix microarray gene expression per background info
|
| 45 |
+
|
| 46 |
+
# 2. Variable Availability and Data Type Conversion
|
| 47 |
+
|
| 48 |
+
# Based on the sample characteristics:
|
| 49 |
+
# {0: ['time: DAY14', 'time: DAY4'],
|
| 50 |
+
# 1: ['group: AsthmaHDM', 'group: Healthy', 'group: AsthmaHDMNeg'],
|
| 51 |
+
# 2: ['donor: DJ...']}
|
| 52 |
+
trait_row = 1 # 'group' field indicates asthma status (patients vs healthy controls)
|
| 53 |
+
age_row = None
|
| 54 |
+
gender_row = None
|
| 55 |
+
|
| 56 |
+
def _after_colon(value: Any) -> str:
|
| 57 |
+
if value is None:
|
| 58 |
+
return ""
|
| 59 |
+
s = str(value)
|
| 60 |
+
parts = s.split(":", 1)
|
| 61 |
+
v = parts[1] if len(parts) > 1 else parts[0]
|
| 62 |
+
return v.strip()
|
| 63 |
+
|
| 64 |
+
def convert_trait(value):
|
| 65 |
+
v = _after_colon(value).strip().lower()
|
| 66 |
+
# normalize to alphanumerics only to catch variants like "asthma-hdm", "asthma_hdm"
|
| 67 |
+
v_norm = re.sub(r"[^a-z0-9]+", "", v)
|
| 68 |
+
|
| 69 |
+
if v_norm in {"healthy", "control", "ctrl"}:
|
| 70 |
+
return 0
|
| 71 |
+
# Treat both AsthmaHDM and AsthmaHDMNeg as asthma cases
|
| 72 |
+
if v_norm in {"asthma", "asthmahdm", "asthmahdmneg"}:
|
| 73 |
+
return 1
|
| 74 |
+
# Fallback heuristics
|
| 75 |
+
if "asthma" in v_norm:
|
| 76 |
+
return 1
|
| 77 |
+
if "healthy" in v_norm or "control" in v_norm or v_norm == "ctrl":
|
| 78 |
+
return 0
|
| 79 |
+
return None
|
| 80 |
+
|
| 81 |
+
def convert_age(value):
|
| 82 |
+
v = _after_colon(value).lower()
|
| 83 |
+
nums = re.findall(r"[0-9]+(?:\.[0-9]+)?", v)
|
| 84 |
+
if not nums:
|
| 85 |
+
return None
|
| 86 |
+
try:
|
| 87 |
+
age = float(nums[0])
|
| 88 |
+
if age <= 0 or age > 120:
|
| 89 |
+
return None
|
| 90 |
+
return age
|
| 91 |
+
except Exception:
|
| 92 |
+
return None
|
| 93 |
+
|
| 94 |
+
def convert_gender(value):
|
| 95 |
+
v = _after_colon(value).strip().lower()
|
| 96 |
+
if v in {"female", "f", "woman", "girl"}:
|
| 97 |
+
return 0
|
| 98 |
+
if v in {"male", "m", "man", "boy"}:
|
| 99 |
+
return 1
|
| 100 |
+
return None
|
| 101 |
+
|
| 102 |
+
# 3. Save Metadata (initial filtering)
|
| 103 |
+
is_trait_available = trait_row is not None
|
| 104 |
+
_ = validate_and_save_cohort_info(
|
| 105 |
+
is_final=False,
|
| 106 |
+
cohort=cohort,
|
| 107 |
+
info_path=json_path,
|
| 108 |
+
is_gene_available=is_gene_available,
|
| 109 |
+
is_trait_available=is_trait_available
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
# 4. Clinical Feature Extraction (only if clinical data available)
|
| 113 |
+
if trait_row is not None:
|
| 114 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 115 |
+
clinical_df=clinical_data,
|
| 116 |
+
trait=trait,
|
| 117 |
+
trait_row=trait_row,
|
| 118 |
+
convert_trait=convert_trait
|
| 119 |
+
)
|
| 120 |
+
preview = preview_df(selected_clinical_df)
|
| 121 |
+
print(preview)
|
| 122 |
+
# Save
|
| 123 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 124 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
| 125 |
+
|
| 126 |
+
# Step 3: Gene Data Extraction
|
| 127 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 128 |
+
gene_data = get_genetic_data(matrix_file)
|
| 129 |
+
|
| 130 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 131 |
+
print(gene_data.index[:20])
|
| 132 |
+
|
| 133 |
+
# Step 4: Gene Identifier Review
|
| 134 |
+
print("requires_gene_mapping = True")
|
| 135 |
+
|
| 136 |
+
# Step 5: Gene Annotation
|
| 137 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 138 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 139 |
+
|
| 140 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 141 |
+
print("Gene annotation preview:")
|
| 142 |
+
print(preview_df(gene_annotation))
|
| 143 |
+
|
| 144 |
+
# Step 6: Gene Identifier Mapping
|
| 145 |
+
# Determine the appropriate columns for mapping: 'ID' (probe IDs) and 'gene_assignment' (contains gene symbols)
|
| 146 |
+
prob_col = 'ID'
|
| 147 |
+
gene_col = 'gene_assignment'
|
| 148 |
+
|
| 149 |
+
# 1-2. Build the mapping dataframe from the annotation
|
| 150 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=prob_col, gene_col=gene_col)
|
| 151 |
+
|
| 152 |
+
# 3. Apply the mapping to convert probe-level data to gene-level data
|
| 153 |
+
probe_data = gene_data # keep original probe-level data
|
| 154 |
+
gene_data = apply_gene_mapping(probe_data, mapping_df)
|
| 155 |
+
|
| 156 |
+
# Step 7: Data Normalization and Linking
|
| 157 |
+
import os
|
| 158 |
+
|
| 159 |
+
# 1. Normalize gene symbols and save
|
| 160 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 161 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 162 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 163 |
+
|
| 164 |
+
# 2. Link clinical and genetic data
|
| 165 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
| 166 |
+
|
| 167 |
+
# 3. Handle missing values
|
| 168 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 169 |
+
|
| 170 |
+
# 4. Assess bias and drop biased covariates if necessary
|
| 171 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 172 |
+
|
| 173 |
+
# 5. Final quality validation and save cohort info
|
| 174 |
+
note = ("INFO: Trait inferred from 'group' field; Age/Gender not available. "
|
| 175 |
+
"Affymetrix probe data mapped via 'gene_assignment' and normalized with NCBI synonyms.")
|
| 176 |
+
is_usable = validate_and_save_cohort_info(
|
| 177 |
+
is_final=True,
|
| 178 |
+
cohort=cohort,
|
| 179 |
+
info_path=json_path,
|
| 180 |
+
is_gene_available=True,
|
| 181 |
+
is_trait_available=True,
|
| 182 |
+
is_biased=is_trait_biased,
|
| 183 |
+
df=unbiased_linked_data,
|
| 184 |
+
note=note
|
| 185 |
+
)
|
| 186 |
+
|
| 187 |
+
# 6. Save linked data only if usable
|
| 188 |
+
if is_usable:
|
| 189 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 190 |
+
unbiased_linked_data.to_csv(out_data_file)
|
output/preprocess/Asthma/code/GSE188424.py
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Asthma"
|
| 6 |
+
cohort = "GSE188424"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE188424"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Asthma/GSE188424.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Asthma/gene_data/GSE188424.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Asthma/clinical_data/GSE188424.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Asthma/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
import os
|
| 41 |
+
|
| 42 |
+
# 1) Gene expression data availability (from background info: gene expression profiling on human whole blood)
|
| 43 |
+
is_gene_available = True
|
| 44 |
+
|
| 45 |
+
# 2) Variable availability based on the provided Sample Characteristics Dictionary:
|
| 46 |
+
# Only gender is available under key 0; trait (controlled vs uncontrolled asthma) and age are not explicitly available.
|
| 47 |
+
trait_row = None
|
| 48 |
+
age_row = None
|
| 49 |
+
gender_row = 0
|
| 50 |
+
|
| 51 |
+
# 2.2) Data type conversion functions
|
| 52 |
+
def _after_colon(value):
|
| 53 |
+
if value is None:
|
| 54 |
+
return None
|
| 55 |
+
s = str(value)
|
| 56 |
+
parts = s.split(":", 1)
|
| 57 |
+
v = parts[1] if len(parts) > 1 else parts[0]
|
| 58 |
+
return v.strip()
|
| 59 |
+
|
| 60 |
+
def convert_trait(value):
|
| 61 |
+
# Not available in this dataset; return None safely in case of accidental use.
|
| 62 |
+
v = _after_colon(value)
|
| 63 |
+
if v is None:
|
| 64 |
+
return None
|
| 65 |
+
vl = v.lower()
|
| 66 |
+
# Heuristic mapping if ever present:
|
| 67 |
+
# Map controlled (0) vs uncontrolled (1)
|
| 68 |
+
if "uncontrolled" in vl:
|
| 69 |
+
return 1
|
| 70 |
+
if "controlled" in vl:
|
| 71 |
+
return 0
|
| 72 |
+
# If some free-text indicating asthma/no asthma (unlikely in this controlled/uncontrolled study)
|
| 73 |
+
if vl in {"asthma", "case", "patient"}:
|
| 74 |
+
return 1
|
| 75 |
+
if vl in {"control", "healthy", "non-asthma", "no asthma"}:
|
| 76 |
+
return 0
|
| 77 |
+
return None
|
| 78 |
+
|
| 79 |
+
def convert_age(value):
|
| 80 |
+
# Not available in this dataset; robust parser provided for completeness.
|
| 81 |
+
v = _after_colon(value)
|
| 82 |
+
if v is None:
|
| 83 |
+
return None
|
| 84 |
+
m = re.search(r'(\d+(\.\d+)?)', v)
|
| 85 |
+
return float(m.group(1)) if m else None
|
| 86 |
+
|
| 87 |
+
def convert_gender(value):
|
| 88 |
+
v = _after_colon(value)
|
| 89 |
+
if v is None:
|
| 90 |
+
return None
|
| 91 |
+
vl = v.strip().lower()
|
| 92 |
+
if vl in {"male", "m", "man", "boy"}:
|
| 93 |
+
return 1
|
| 94 |
+
if vl in {"female", "f", "woman", "girl"}:
|
| 95 |
+
return 0
|
| 96 |
+
if vl in {"unknown", "na", "n/a", "nan", ""}:
|
| 97 |
+
return None
|
| 98 |
+
return None
|
| 99 |
+
|
| 100 |
+
# 3) Save metadata with initial filtering
|
| 101 |
+
is_trait_available = trait_row is not None
|
| 102 |
+
_ = validate_and_save_cohort_info(
|
| 103 |
+
is_final=False,
|
| 104 |
+
cohort=cohort,
|
| 105 |
+
info_path=json_path,
|
| 106 |
+
is_gene_available=is_gene_available,
|
| 107 |
+
is_trait_available=is_trait_available
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
# 4) Clinical feature extraction (skip because trait_row is None)
|
| 111 |
+
# If trait_row were available, we would extract as below:
|
| 112 |
+
if trait_row is not None:
|
| 113 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 114 |
+
clinical_df=clinical_data,
|
| 115 |
+
trait=trait,
|
| 116 |
+
trait_row=trait_row,
|
| 117 |
+
convert_trait=convert_trait,
|
| 118 |
+
age_row=age_row,
|
| 119 |
+
convert_age=convert_age if age_row is not None else None,
|
| 120 |
+
gender_row=gender_row,
|
| 121 |
+
convert_gender=convert_gender if gender_row is not None else None
|
| 122 |
+
)
|
| 123 |
+
preview = preview_df(selected_clinical_df, n=5)
|
| 124 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 125 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=True)
|
| 126 |
+
|
| 127 |
+
# Step 3: Gene Data Extraction
|
| 128 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 129 |
+
gene_data = get_genetic_data(matrix_file)
|
| 130 |
+
|
| 131 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 132 |
+
print(gene_data.index[:20])
|
| 133 |
+
|
| 134 |
+
# Step 4: Gene Identifier Review
|
| 135 |
+
print("requires_gene_mapping = True")
|
| 136 |
+
|
| 137 |
+
# Step 5: Gene Annotation
|
| 138 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
| 139 |
+
gene_annotation = get_gene_annotation(soft_file)
|
| 140 |
+
|
| 141 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
| 142 |
+
print("Gene annotation preview:")
|
| 143 |
+
print(preview_df(gene_annotation))
|
| 144 |
+
|
| 145 |
+
# Step 6: Gene Identifier Mapping
|
| 146 |
+
# Identify the appropriate columns for probe IDs and gene symbols
|
| 147 |
+
probe_col = 'ID'
|
| 148 |
+
symbol_col = 'Symbol'
|
| 149 |
+
assert probe_col in gene_annotation.columns and symbol_col in gene_annotation.columns
|
| 150 |
+
|
| 151 |
+
# Build mapping dataframe (probe -> gene symbol)
|
| 152 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=symbol_col)
|
| 153 |
+
|
| 154 |
+
# Apply mapping to convert probe-level expression to gene-level expression
|
| 155 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
|
| 156 |
+
|
| 157 |
+
# Step 7: Data Normalization and Linking
|
| 158 |
+
import os
|
| 159 |
+
|
| 160 |
+
# 1) Normalize gene symbols and save gene-level data
|
| 161 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 162 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 163 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 164 |
+
|
| 165 |
+
# Determine trait availability from earlier step
|
| 166 |
+
is_gene_available = True
|
| 167 |
+
is_trait_available = (locals().get('trait_row', None) is not None)
|
| 168 |
+
|
| 169 |
+
if is_trait_available:
|
| 170 |
+
# Ensure clinical features are available; if not, extract them now
|
| 171 |
+
if 'selected_clinical_data' not in globals():
|
| 172 |
+
selected_clinical_data = geo_select_clinical_features(
|
| 173 |
+
clinical_df=clinical_data,
|
| 174 |
+
trait=trait,
|
| 175 |
+
trait_row=trait_row,
|
| 176 |
+
convert_trait=convert_trait,
|
| 177 |
+
age_row=age_row,
|
| 178 |
+
convert_age=convert_age if age_row is not None else None,
|
| 179 |
+
gender_row=gender_row,
|
| 180 |
+
convert_gender=convert_gender if gender_row is not None else None
|
| 181 |
+
)
|
| 182 |
+
|
| 183 |
+
# 2) Link the clinical and genetic data
|
| 184 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_data, normalized_gene_data)
|
| 185 |
+
|
| 186 |
+
# 3) Handle missing values
|
| 187 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 188 |
+
|
| 189 |
+
# 4) Bias checks
|
| 190 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 191 |
+
|
| 192 |
+
# 5) Final validation and save cohort info
|
| 193 |
+
note = "INFO: Clinical trait available; proceeded with linking and QC."
|
| 194 |
+
is_usable = validate_and_save_cohort_info(
|
| 195 |
+
is_final=True,
|
| 196 |
+
cohort=cohort,
|
| 197 |
+
info_path=json_path,
|
| 198 |
+
is_gene_available=is_gene_available,
|
| 199 |
+
is_trait_available=is_trait_available,
|
| 200 |
+
is_biased=is_trait_biased,
|
| 201 |
+
df=unbiased_linked_data,
|
| 202 |
+
note=note
|
| 203 |
+
)
|
| 204 |
+
|
| 205 |
+
# 6) Save linked data only if usable
|
| 206 |
+
if is_usable:
|
| 207 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 208 |
+
unbiased_linked_data.to_csv(out_data_file)
|
| 209 |
+
|
| 210 |
+
else:
|
| 211 |
+
# Trait not available; skip linking and downstream steps
|
| 212 |
+
note = "WARNING: Trait data not available (trait_row is None). Recorded dataset as unavailable for association analysis."
|
| 213 |
+
# Provide a non-empty df with sufficient columns to avoid abnormality override in validation
|
| 214 |
+
dummy_df = normalized_gene_data.T
|
| 215 |
+
_ = validate_and_save_cohort_info(
|
| 216 |
+
is_final=True,
|
| 217 |
+
cohort=cohort,
|
| 218 |
+
info_path=json_path,
|
| 219 |
+
is_gene_available=is_gene_available,
|
| 220 |
+
is_trait_available=False,
|
| 221 |
+
is_biased=False, # placeholder; not used when trait unavailable
|
| 222 |
+
df=dummy_df,
|
| 223 |
+
note=note
|
| 224 |
+
)
|
output/preprocess/Asthma/code/GSE205151.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path Configuration
|
| 2 |
+
from tools.preprocess import *
|
| 3 |
+
|
| 4 |
+
# Processing context
|
| 5 |
+
trait = "Asthma"
|
| 6 |
+
cohort = "GSE205151"
|
| 7 |
+
|
| 8 |
+
# Input paths
|
| 9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
| 10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE205151"
|
| 11 |
+
|
| 12 |
+
# Output paths
|
| 13 |
+
out_data_file = "./output/z1/preprocess/Asthma/GSE205151.csv"
|
| 14 |
+
out_gene_data_file = "./output/z1/preprocess/Asthma/gene_data/GSE205151.csv"
|
| 15 |
+
out_clinical_data_file = "./output/z1/preprocess/Asthma/clinical_data/GSE205151.csv"
|
| 16 |
+
json_path = "./output/z1/preprocess/Asthma/cohort_info.json"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Step 1: Initial Data Loading
|
| 20 |
+
from tools.preprocess import *
|
| 21 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
| 22 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
| 23 |
+
|
| 24 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
| 25 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
| 26 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
| 27 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
| 28 |
+
|
| 29 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
| 30 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
| 31 |
+
|
| 32 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
| 33 |
+
print("Background Information:")
|
| 34 |
+
print(background_info)
|
| 35 |
+
print("Sample Characteristics Dictionary:")
|
| 36 |
+
print(sample_characteristics_dict)
|
| 37 |
+
|
| 38 |
+
# Step 2: Dataset Analysis and Clinical Feature Extraction
|
| 39 |
+
import re
|
| 40 |
+
|
| 41 |
+
# 1) Gene expression availability (Nanostring mRNA -> gene expression data present)
|
| 42 |
+
is_gene_available = True
|
| 43 |
+
|
| 44 |
+
# 2) Variable availability
|
| 45 |
+
# All participants are children with asthma; no per-sample asthma status, age, or gender fields in the sample characteristics.
|
| 46 |
+
trait_row = None
|
| 47 |
+
age_row = None
|
| 48 |
+
gender_row = None
|
| 49 |
+
|
| 50 |
+
# 2.2) Conversion functions (defined but not used since corresponding rows are None)
|
| 51 |
+
|
| 52 |
+
def _after_colon(x):
|
| 53 |
+
if x is None:
|
| 54 |
+
return None
|
| 55 |
+
s = str(x)
|
| 56 |
+
parts = s.split(":", 1)
|
| 57 |
+
val = parts[1] if len(parts) > 1 else parts[0]
|
| 58 |
+
return val.strip()
|
| 59 |
+
|
| 60 |
+
def convert_trait(x):
|
| 61 |
+
v = _after_colon(x)
|
| 62 |
+
if v is None:
|
| 63 |
+
return None
|
| 64 |
+
vlow = v.lower()
|
| 65 |
+
# Map asthma-related labels: case=1, control/healthy=0
|
| 66 |
+
positives = ['asthma', 'status asthmaticus', 'severe asthma', 'critical asthma', 'case', 'patient']
|
| 67 |
+
negatives = ['control', 'healthy', 'non-asthma', 'no asthma']
|
| 68 |
+
if any(p in vlow for p in positives):
|
| 69 |
+
return 1
|
| 70 |
+
if any(n in vlow for n in negatives):
|
| 71 |
+
return 0
|
| 72 |
+
return None
|
| 73 |
+
|
| 74 |
+
def convert_age(x):
|
| 75 |
+
v = _after_colon(x)
|
| 76 |
+
if v is None:
|
| 77 |
+
return None
|
| 78 |
+
# Extract first floating number as age (in years)
|
| 79 |
+
m = re.search(r'(\d+(?:\.\d+)?)', v)
|
| 80 |
+
if m:
|
| 81 |
+
try:
|
| 82 |
+
return float(m.group(1))
|
| 83 |
+
except:
|
| 84 |
+
return None
|
| 85 |
+
return None
|
| 86 |
+
|
| 87 |
+
def convert_gender(x):
|
| 88 |
+
v = _after_colon(x)
|
| 89 |
+
if v is None:
|
| 90 |
+
return None
|
| 91 |
+
vlow = v.lower().strip()
|
| 92 |
+
if vlow in ['male', 'm', 'man', 'boy', '1']:
|
| 93 |
+
return 1
|
| 94 |
+
if vlow in ['female', 'f', 'woman', 'girl', '0']:
|
| 95 |
+
return 0
|
| 96 |
+
return None
|
| 97 |
+
|
| 98 |
+
# 3) Save metadata (initial filtering)
|
| 99 |
+
is_trait_available = trait_row is not None
|
| 100 |
+
_ = validate_and_save_cohort_info(
|
| 101 |
+
is_final=False,
|
| 102 |
+
cohort=cohort,
|
| 103 |
+
info_path=json_path,
|
| 104 |
+
is_gene_available=is_gene_available,
|
| 105 |
+
is_trait_available=is_trait_available
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
# 4) Clinical feature extraction (skip because trait_row is None)
|
| 109 |
+
if trait_row is not None:
|
| 110 |
+
selected_clinical_df = geo_select_clinical_features(
|
| 111 |
+
clinical_df=clinical_data,
|
| 112 |
+
trait=trait,
|
| 113 |
+
trait_row=trait_row,
|
| 114 |
+
convert_trait=convert_trait,
|
| 115 |
+
age_row=age_row,
|
| 116 |
+
convert_age=convert_age,
|
| 117 |
+
gender_row=gender_row,
|
| 118 |
+
convert_gender=convert_gender
|
| 119 |
+
)
|
| 120 |
+
_ = preview_df(selected_clinical_df)
|
| 121 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
| 122 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=True)
|
| 123 |
+
|
| 124 |
+
# Step 3: Gene Data Extraction
|
| 125 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
| 126 |
+
gene_data = get_genetic_data(matrix_file)
|
| 127 |
+
|
| 128 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
| 129 |
+
print(gene_data.index[:20])
|
| 130 |
+
|
| 131 |
+
# Step 4: Gene Identifier Review
|
| 132 |
+
requires_gene_mapping = False
|
| 133 |
+
print(f"requires_gene_mapping = {requires_gene_mapping}")
|
| 134 |
+
|
| 135 |
+
# Step 5: Data Normalization and Linking
|
| 136 |
+
import os
|
| 137 |
+
|
| 138 |
+
# 1. Normalize gene symbols and save normalized gene expression data
|
| 139 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
| 140 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
| 141 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
| 142 |
+
|
| 143 |
+
# Prepare defaults
|
| 144 |
+
linked_data = None
|
| 145 |
+
|
| 146 |
+
# 2–6. Proceed only if clinical features were extracted previously (i.e., trait data available)
|
| 147 |
+
tr = globals().get('trait_row', None)
|
| 148 |
+
scd = globals().get('selected_clinical_data', None)
|
| 149 |
+
|
| 150 |
+
if (tr is not None) and (scd is not None):
|
| 151 |
+
# 2. Link clinical and genetic data
|
| 152 |
+
linked_data = geo_link_clinical_genetic_data(scd, normalized_gene_data)
|
| 153 |
+
|
| 154 |
+
# 3. Handle missing values
|
| 155 |
+
linked_data = handle_missing_values(linked_data, trait)
|
| 156 |
+
|
| 157 |
+
# 4. Determine bias and remove biased demographic features
|
| 158 |
+
is_trait_biased, unbiased_linked_data = judge_and_remove_biased_features(linked_data, trait)
|
| 159 |
+
|
| 160 |
+
# 5. Final validation and save cohort info
|
| 161 |
+
is_usable = validate_and_save_cohort_info(
|
| 162 |
+
is_final=True,
|
| 163 |
+
cohort=cohort,
|
| 164 |
+
info_path=json_path,
|
| 165 |
+
is_gene_available=True,
|
| 166 |
+
is_trait_available=True,
|
| 167 |
+
is_biased=is_trait_biased,
|
| 168 |
+
df=unbiased_linked_data,
|
| 169 |
+
note="INFO: Finalized with available trait; demographic biases removed if present."
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
# 6. Save usable linked data
|
| 173 |
+
if is_usable:
|
| 174 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
| 175 |
+
unbiased_linked_data.to_csv(out_data_file)
|
| 176 |
+
else:
|
| 177 |
+
# Trait data is not available per sample; record metadata so the cohort is marked unusable for association.
|
| 178 |
+
_ = validate_and_save_cohort_info(
|
| 179 |
+
is_final=False,
|
| 180 |
+
cohort=cohort,
|
| 181 |
+
info_path=json_path,
|
| 182 |
+
is_gene_available=True,
|
| 183 |
+
is_trait_available=False
|
| 184 |
+
)
|