Liu-Hy's picture
Add files using upload-large-folder tool
a0747da verified
# Path Configuration
from tools.preprocess import *
# Processing context
trait = "Liver_cirrhosis"
cohort = "GSE66843"
# Input paths
in_trait_dir = "../DATA/GEO/Liver_cirrhosis"
in_cohort_dir = "../DATA/GEO/Liver_cirrhosis/GSE66843"
# Output paths
out_data_file = "./output/preprocess/3/Liver_cirrhosis/GSE66843.csv"
out_gene_data_file = "./output/preprocess/3/Liver_cirrhosis/gene_data/GSE66843.csv"
out_clinical_data_file = "./output/preprocess/3/Liver_cirrhosis/clinical_data/GSE66843.csv"
json_path = "./output/preprocess/3/Liver_cirrhosis/cohort_info.json"
# Step 1: Get file paths
soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)
# Step 2: Extract background info and clinical data from matrix file
background_info, clinical_data = get_background_and_clinical_data(matrix_file_path)
# Step 3: Get dictionary of unique values for each clinical feature
unique_values_dict = get_unique_values_by_row(clinical_data)
# Step 4: Print background info and sample characteristics
print("Dataset Background Information:")
print("-" * 80)
print(background_info)
print("\nSample Characteristics:")
print("-" * 80)
print(json.dumps(unique_values_dict, indent=2))
# 1. Gene Expression Data Availability
# Based on summary and platform information, this appears to be a cell line study
# with potential gene expression data for HCV infection study
is_gene_available = True
# 2. Clinical Feature Analysis
# Looking at characteristics, this is a cell line study without human clinical data
trait_row = None # No trait data for liver cirrhosis
age_row = None # No age data
gender_row = None # No gender data
def convert_trait(x):
# Not needed as trait data unavailable
return None
def convert_age(x):
# Not needed as age data unavailable
return None
def convert_gender(x):
# Not needed as gender data unavailable
return None
# 3. Save initial filtering results
is_trait_available = trait_row is not None
validate_and_save_cohort_info(
is_final=False,
cohort=cohort,
info_path=json_path,
is_gene_available=is_gene_available,
is_trait_available=is_trait_available
)
# 4. Clinical Feature Extraction
# Skip as trait_row is None, indicating no clinical data available
# 1. Extract gene expression data from matrix file
genetic_data = get_genetic_data(matrix_file_path)
# 2. Print first 20 row IDs
print("First 20 gene/probe identifiers:")
print(genetic_data.index[:20])
# These appear to be Illumina probe IDs (starting with ILMN_) rather than standard human gene symbols
# Illumina IDs need to be mapped to gene symbols for downstream analysis
requires_gene_mapping = True
# 1. Extract gene annotation data from SOFT file
gene_annotation = get_gene_annotation(soft_file_path)
# 2. Preview annotation data
print("Column names and first few values in gene annotation data:")
print(preview_df(gene_annotation))
# 1. Observe gene identifiers
# From previous outputs:
# Gene expression data uses identifiers like ILMN_1343291
# In gene annotation, 'ID' column has ILMN_ identifiers, 'Symbol' has gene symbols
# 2. Extract mapping between probe IDs and gene symbols
mapping_data = get_gene_mapping(gene_annotation, 'ID', 'Symbol')
# 3. Apply mapping to convert probe data to gene expression data
gene_data = apply_gene_mapping(genetic_data, mapping_data)
# 1. Normalize gene symbols and save gene data
gene_data = normalize_gene_symbols_in_index(gene_data)
gene_data.to_csv(out_gene_data_file)
# Skip remaining steps since no clinical data is available
# Dataset unusability was already recorded in initial filtering