-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMATseq.py
More file actions
707 lines (593 loc) · 22.7 KB
/
MATseq.py
File metadata and controls
707 lines (593 loc) · 22.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
#!/usr/bin/env python
"""MAT-seq pipeline orchestration script."""
import sys
from pathlib import Path
import argparse
import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler
sys.path.insert(0, str(Path(__file__).parent))
random_state = 138
from src import (
# Configuration
CUSTOM_PALETTE_9,
SUBSET_PALETTES,
SUBSET_CLASS_ORDERS,
DESEQ2_CONFIG,
TRAINING_LIGANDS,
ADDITIONAL_LIGANDS,
BACTERIAL_LIGANDS,
FEATURE_SELECTION_CONFIG,
MODEL_FACTORY_CONFIG,
MODEL_TRAINING_CONFIG,
# Preprocessing
merge_counts,
extract_subset,
normalize_rpm,
load_tlr_data,
# Feature engineering
create_feature_pipeline,
# Model training
ModelFactory,
ModelTrainer,
# Evaluation
make_score,
get_confusion_matrix,
# Visualization
plot_pca_pandas,
plot_tlr_hek_blue,
# DESeq2 analysis
AnalysisPipeline,
# Feature analysis
FeatureSelectionAnalyzer,
VennDiagramGenerator,
# GO term analysis
create_fs_de_go_table,
# Prediction and comparison
ModelPredictor,
)
from src.cache import PipelineCache
class MATseqPipeline:
"""Complete MAT-seq analysis pipeline with caching."""
def __init__(self, cache_dir: Path = None, force_recompute: bool = False):
"""Initialize pipeline with caching.
Args:
cache_dir: Directory for cached intermediate files.
force_recompute: Skip cache and recompute all steps.
"""
self.cache = PipelineCache(cache_dir)
self.force_recompute = force_recompute
self.results_dir = Path.cwd() / "results"
self.results_dir.mkdir(exist_ok=True, parents=True)
def run_snakemake_preprocessing(
self,
fastq_dir: Path = None,
genome_dir: Path = None,
dry_run: bool = False,
) -> bool:
"""Run Snakemake preprocessing pipeline to generate featurecounts.
Args:
fastq_dir: Override FASTQ input directory (default: from config.json).
genome_dir: Override genome reference directory (required).
dry_run: If True, only validate Snakemake without running.
Returns:
True if successful, False otherwise.
"""
import subprocess
import json
snakemake_dir = Path.cwd() / "pipeline"
config_path = Path.cwd() / "config.json"
with open(config_path) as f:
config = json.load(f)
snakemake_config = config.get("snakemake", {})
if fastq_dir is None:
fastq_dir = snakemake_config.get("sample_dir", "")
if fastq_dir:
fastq_dir = Path(fastq_dir).expanduser()
if genome_dir is None:
genome_dir = snakemake_config.get("genome_dir", "")
if genome_dir:
genome_dir = Path(genome_dir).expanduser()
if not genome_dir or not Path(genome_dir).exists():
print("Error: genome_dir is required and must exist")
print(f"Current value: '{genome_dir}'")
print("Set via --genome-dir or in config.json snakemake.genome_dir")
return False
if not fastq_dir or not Path(fastq_dir).exists():
print("Error: sample_dir (FASTQ directory) is required and must exist")
print(f"Current value: '{fastq_dir}'")
print("Set via --fastq-dir or in config.json snakemake.sample_dir")
return False
snakefile = snakemake_dir / "0_MATseq.smk"
if not snakefile.exists():
print(f"Error: Snakemake pipeline not found at {snakefile}")
return False
print("\n--- RUNNING SNAKEMAKE PREPROCESSING ---")
print(f"Pipeline directory: {snakemake_dir}")
print(f"FASTQ directory: {fastq_dir}")
print(f"Genome directory: {genome_dir}")
work_dir = Path(
snakemake_config.get("work_dir", "~/MATseq/pipeline/results")
).expanduser()
threads = snakemake_config.get("threads", 42)
cmd = [
"poetry",
"run",
"snakemake",
"--use-conda",
"--cores",
str(threads),
"--snakefile",
str(snakefile),
"--directory",
str(work_dir),
"--config",
f"SampleDir={fastq_dir}",
f"GenomeDir={genome_dir}",
"--latency-wait",
"60",
]
if dry_run:
cmd.append("--dry-run")
print("Dry run mode: validating pipeline...")
try:
result = subprocess.run(
cmd,
cwd=str(Path.cwd()),
capture_output=False,
)
if result.returncode == 0:
print("Snakemake preprocessing completed successfully")
return True
else:
print(f"Snakemake preprocessing failed with code {result.returncode}")
return False
except FileNotFoundError:
print(
"Error: poetry or snakemake not found. Install with: poetry add snakemake"
)
return False
except Exception as e:
print(f"Error running Snakemake: {e}")
return False
def run_preprocessing(self) -> pd.DataFrame:
"""Load and preprocess count data.
Returns:
Merged count matrix.
"""
def _merge():
print("Merging featurecounts files...")
df = merge_counts()
print(f"Merged data shape: {df.shape}")
return df
return self.cache.cached_call(
_merge,
name="merged_counts",
force_recompute=self.force_recompute,
)
def run_venn_feature_selection_multiple_times(
self, X: pd.DataFrame, y: pd.Series, de_genes: set, n_runs: int = 1000
) -> tuple:
"""Run feature selection multiple times to see which genes are more prevalent.
Args:
X: Feature matrix.
y: Target labels.
n_runs: Number of selection runs.
de_genes: Set of differentially expressed genes for frequency table.
Returns:
Tuple of (analyzer, fs_genes_set).
"""
def _venn_selection():
print(f"Running feature selection {n_runs} times...")
analyzer = FeatureSelectionAnalyzer()
analyzer.run_multiple_selections(
X=X,
y=y,
n_runs=n_runs,
)
analyzer.create_gene_frequency_table(de_genes=de_genes)
all_fs_genes = set()
for gene_set in analyzer.feature_sets:
all_fs_genes.update(gene_set)
return analyzer, all_fs_genes
cache_key = f"venn_feature_selection_{n_runs}"
cached = self.cache.get(cache_key)
if cached is not None and not self.force_recompute:
analyzer, all_fs_genes = cached
else:
analyzer, all_fs_genes = _venn_selection()
self.cache.set(cache_key, (analyzer, all_fs_genes))
return analyzer, all_fs_genes
def run_venn_analysis(self, de_genes: set, fs_genes: set) -> VennDiagramGenerator:
"""Generate Venn diagrams for gene set comparisons.
Args:
de_genes: Set of differentially expressed genes.
fs_genes: Set of feature-selected genes.
Returns:
VennDiagramGenerator instance.
"""
venn_gen = VennDiagramGenerator()
venn_gen.plot_venn(
de_genes,
fs_genes,
output_filename="venn_de_vs_fs.png",
)
return venn_gen
def extract_and_run_pca_before_pipeline(
self, df: pd.DataFrame, subset_name: str
) -> tuple[pd.DataFrame, pd.Series]:
"""Process a data subset.
Args:
df: Full count matrix.
subset_name: Name of subset.
Returns:
Tuple of (features_df, labels_series).
"""
print(f"\nProcessing {subset_name} subset...")
subset_data = extract_subset(df, name=subset_name)
X = subset_data.drop(columns="label")
y = subset_data["label"]
# Concat and standardization here is only for PCA plotting
print(f"Creating PCA plots for {subset_name}...")
if subset_name != "training":
training_data = extract_subset(df, name="training")
X = pd.concat([X, training_data.drop(columns="label")])
y = pd.concat([y, training_data["label"]])
X_rpm = normalize_rpm(X.copy())
ss = StandardScaler()
ss.fit(X_rpm)
ss.set_output(transform="pandas")
X_scaled = ss.transform(X_rpm)
palette = SUBSET_PALETTES.get(subset_name, CUSTOM_PALETTE_9)
hue_order = SUBSET_CLASS_ORDERS.get(subset_name)
common_kwargs = dict(
X=X_scaled,
labels=y,
palette=palette,
hue_order=hue_order,
)
for with_names, suffix in [
(False, ""),
(True, "_labeled"),
]:
plot_pca_pandas(
name=f"{subset_name}_selected{suffix}",
with_sample_names=with_names,
output_filename=f"{subset_name}_pca{suffix}.png",
**common_kwargs,
)
return subset_data.drop(columns="label"), subset_data["label"]
def run_feature_selection(
self, X: pd.DataFrame, y: pd.Series, subset_name: str
) -> tuple[object, pd.DataFrame]:
"""Run feature selection pipeline.
Args:
X: Feature matrix.
y: Labels.
subset_name: Name of subset.
Returns:
Tuple of (pipeline, selected_features_df).
"""
def _feature_select():
print(f"Running feature selection for {subset_name}...")
pipe = create_feature_pipeline(
**FEATURE_SELECTION_CONFIG, random_state=random_state
).set_output(transform="pandas")
X_selected = pipe.fit_transform(X, y)
feature_names = pipe[:-1].get_feature_names_out()
X_fs = pd.DataFrame(X_selected, columns=feature_names, index=X.index)
return pipe, X_fs
cache_key = f"feature_selection_{subset_name}"
cached = self.cache.get(cache_key)
if cached is not None and not self.force_recompute:
pipe, X_selected = cached
else:
pipe, X_selected = _feature_select()
self.cache.set(cache_key, (pipe, X_selected))
palette = SUBSET_PALETTES.get(subset_name, CUSTOM_PALETTE_9)
hue_order = SUBSET_CLASS_ORDERS.get(subset_name)
common_kwargs = dict(
X=X_selected,
labels=y,
palette=palette,
hue_order=hue_order,
)
for with_names, suffix in [
(False, ""),
(True, "_labeled"),
]:
plot_pca_pandas(
name=f"{subset_name}_selected{suffix}",
with_sample_names=with_names,
output_filename=f"{subset_name}_pca_selected{suffix}.png",
**common_kwargs,
)
return pipe, X_selected
def train_models(
self, X: pd.DataFrame, y: pd.Series, subset_name: str
) -> ModelTrainer: #! Implement
"""Train classification models.
Args:
X: Feature matrix (feature-selected).
y: Labels.
subset_name: Name of subset.
Returns:
Trained ModelTrainer instance.
"""
def _train():
models = ModelFactory.create_models(**MODEL_FACTORY_CONFIG)
trainer = ModelTrainer(X, y, models=models, **MODEL_TRAINING_CONFIG)
trainer.train_all_models()
return trainer
cache_key = f"trained_models_{subset_name}"
cached = self.cache.get(cache_key)
if cached is not None and not self.force_recompute:
trainer = cached
else:
trainer = _train()
self.cache.set(
cache_key,
trainer,
)
return trainer
def run_pipeline(self):
print("=" * 80)
print("MAT-seq Analysis Pipeline")
print("=" * 80)
# Step 1: Preprocessing
print("\n--- STEP 1: DATA PREPROCESSING ---")
df = self.run_preprocessing()
# Step 2: DESeq2 Analysis (on training subset)
print(
"\n--- STEP 2: DESeq2 DIFFERENTIAL EXPRESSION ANALYSIS ON TRAINING SUBSET ---"
)
X_train, y_train = self.extract_and_run_pca_before_pipeline(df, "training")
deseq2_pipeline_training = AnalysisPipeline(
raw_counts=X_train,
sample_labels=y_train,
padj_threshold=DESEQ2_CONFIG.get("padj_threshold", 0.05),
log2fc_threshold=DESEQ2_CONFIG.get("log2fc_threshold", 2),
n_cpus=DESEQ2_CONFIG.get("n_cpus", 42),
cache=self.cache,
force_recompute=self.force_recompute,
)
deseq2_pipeline_training.run_analysis(
TRAINING_LIGANDS, negative_control="negative_control"
)
# Step 3: Venn Diagram of Feature Selection Analysis (on training subset)
print(
"\n--- STEP 3: GENERATING VENN DIAGRAM OF POST-FEATURE SELECTION AND DIFFERENTIALLY EXPRESSED GENES IN TRAINING SUBSET ---"
)
de_genes = deseq2_pipeline_training.get_de_genes()
fs_analyzer, fs_genes = self.run_venn_feature_selection_multiple_times(
X_train, y_train, n_runs=1000, de_genes=de_genes
)
venn_gen = VennDiagramGenerator()
venn_gen.plot_venn(
de_genes,
fs_genes,
output_filename="venn_de_vs_fs.png",
)
goeaobj, geneid_symbol_mapper = deseq2_pipeline_training.get_go_objects()
create_fs_de_go_table(
de_genes=de_genes,
fs_genes=fs_genes,
goeaobj=goeaobj,
geneid_symbol_mapper=geneid_symbol_mapper,
)
# Step 4: Model Training
print("\n--- STEP 4: MODEL TRAINING ---")
pipe, X_fs = self.run_feature_selection(
X_train,
y_train,
"training",
)
trainer = self.train_models(X_fs, y_train, "training")
models_dir = self.results_dir / "models"
trainer.save_models(models_dir)
print("\n--- EVALUATING MODELS ---")
eval_dir = self.results_dir / "model_evaluation"
# Evaluation 1: Full feature set
print("Evaluation on full feature set (X_train)...")
trainer.evaluate(X_train, y_train, eval_dir=eval_dir, cv=5, eval_name="full")
# Evaluation 2: Feature-selected genes
print("Evaluation on feature-selected genes (X_fs)...")
trainer.evaluate(X_fs, y_train, eval_dir=eval_dir, cv=5, eval_name="fs")
# Evaluation 3: X_train subsetted to genes in X_fs ∪ de_genes
fs_gene_names = set(X_fs.columns)
union_genes = list(fs_gene_names | de_genes)
X_fs_de = X_train[union_genes]
print(f"Evaluation on FS ∪ DE genes ({len(union_genes)} genes)...")
trainer.evaluate(X_fs_de, y_train, eval_dir=eval_dir, cv=5, eval_name="fs_de")
print("Model evaluation complete. Results saved to results/model_evaluation")
# Step 5: DESeq2 Analysis (on other ligands and bacterial subsets)
print(
"\n--- STEP 5: DESeq2 DIFFERENTIAL EXPRESSION ANALYSIS ON REMAINING LIGANDS ---"
)
X_other_ligands, y_other_ligands = self.extract_and_run_pca_before_pipeline(
df, "other_ligands"
)
deseq2_pipeline_other_ligand = AnalysisPipeline(
raw_counts=X_other_ligands,
sample_labels=y_other_ligands,
padj_threshold=DESEQ2_CONFIG.get("padj_threshold", 0.05),
log2fc_threshold=DESEQ2_CONFIG.get("log2fc_threshold", 2),
n_cpus=DESEQ2_CONFIG.get("n_cpus", 42),
cache=self.cache,
force_recompute=self.force_recompute,
)
deseq2_pipeline_other_ligand.run_analysis(
ADDITIONAL_LIGANDS, negative_control="negative_control"
)
X_bacterial, y_bacterial = self.extract_and_run_pca_before_pipeline(
df, "bacterial"
)
deseq2_pipeline_bacterial = AnalysisPipeline(
raw_counts=X_bacterial,
sample_labels=y_bacterial,
padj_threshold=DESEQ2_CONFIG.get("padj_threshold", 0.05),
log2fc_threshold=DESEQ2_CONFIG.get("log2fc_threshold", 2),
n_cpus=DESEQ2_CONFIG.get("n_cpus", 42),
cache=self.cache,
force_recompute=self.force_recompute,
)
deseq2_pipeline_bacterial.run_analysis(
BACTERIAL_LIGANDS,
negative_control="negative_control",
)
# Step 6: Predict classes of other ligands
print("\n--- STEP 6: CLASS PREDICTION ON ADDITIONAL AND BACTERIAL LIGANDS ---")
lps_mask_train = y_train == "LPS"
X_train_lps = X_train[lps_mask_train]
y_train_lps = y_train[lps_mask_train]
X_other_with_lps = pd.concat([X_other_ligands, X_train_lps])
y_other_with_lps = pd.concat([y_other_ligands, y_train_lps])
X_bacterial_with_lps = pd.concat([X_bacterial, X_train_lps])
y_bacterial_with_lps = pd.concat([y_bacterial, y_train_lps])
predictor = ModelPredictor(trainer)
predictions_dir = self.results_dir / "predictions"
X_other_fs = pipe.transform(X_other_with_lps)
predictor.predict_samples(
X_other_fs,
sample_names=X_other_with_lps.index.to_numpy(),
y_test=y_other_with_lps,
)
predictor.save_predictions(predictions_dir / "other_ligands")
predictor.create_probability_heatmaps(
predictions_dir / "other_ligands",
subset="other_ligands",
)
X_bacterial_fs = pipe.transform(X_bacterial_with_lps)
predictor.predict_samples(
X_bacterial_fs,
sample_names=X_bacterial_with_lps.index.to_numpy(),
y_test=y_bacterial_with_lps,
)
predictor.save_predictions(predictions_dir / "bacterial")
predictor.create_probability_heatmaps(
predictions_dir / "bacterial",
subset="bacterial",
)
# Step 7: TLR HEK visualization
print("\n--- STEP 7: TLR HEK BLUE VISUALIZATION ---")
tlr_data_dir = Path(__file__).parent / "data" / "supplementary_data"
tlr2_df, tlr4_df, flapa_data = load_tlr_data(data_dir=tlr_data_dir)
plot_tlr_hek_blue(
tlr2_df,
tlr4_df,
flapa_data,
output_filename="tlr_hek_blue.png",
)
# Step 8: Model Training on training_wo_flapa and Prediction on Additional and Bacterial Ligands
print(
"\n--- STEP 8: MODEL TRAINING ON TRAINING_WO_FLAPA AND PREDICTION ON ADDITIONAL AND BACTERIAL LIGANDS ---"
)
X_train_wo_flapa, y_train_wo_flapa = self.extract_and_run_pca_before_pipeline(
df, "training_wo_flapa"
)
pipe_wo_flapa, X_fs_wo_flapa = self.run_feature_selection(
X_train_wo_flapa,
y_train_wo_flapa,
"training_wo_flapa",
)
trainer_wo_flapa = self.train_models(
X_fs_wo_flapa, y_train_wo_flapa, "training_wo_flapa"
)
predictor_wo_flapa = ModelPredictor(trainer_wo_flapa)
predictions_dir_wo_flapa = (
self.results_dir / "predictions" / "training_wo_flapa"
)
X_other_fs_wo_flapa = pipe_wo_flapa.transform(X_other_with_lps)
predictor_wo_flapa.predict_samples(
X_other_fs_wo_flapa,
sample_names=X_other_with_lps.index.to_numpy(),
y_test=y_other_with_lps,
)
predictor_wo_flapa.save_predictions(predictions_dir_wo_flapa / "other_ligands")
predictor_wo_flapa.create_probability_heatmaps(
predictions_dir_wo_flapa / "other_ligands",
subset="other_ligands",
)
X_bacterial_fs_wo_flapa = pipe_wo_flapa.transform(X_bacterial_with_lps)
predictor_wo_flapa.predict_samples(
X_bacterial_fs_wo_flapa,
sample_names=X_bacterial_with_lps.index.to_numpy(),
y_test=y_bacterial_with_lps,
)
predictor_wo_flapa.save_predictions(predictions_dir_wo_flapa / "bacterial")
predictor_wo_flapa.create_probability_heatmaps(
predictions_dir_wo_flapa / "bacterial",
subset="bacterial",
)
print("\n" + "=" * 80)
print("PIPELINE COMPLETED SUCCESSFULLY")
print("=" * 80)
print(f"Results saved to: {self.results_dir.absolute()}")
print(f"Cache saved to: {self.cache.cache_dir.absolute()}")
return {
"feature_selection": pipe,
"feature_analysis": fs_analyzer,
"models": trainer,
"predictor": predictor,
"models_wo_flapa": trainer_wo_flapa,
"predictor_wo_flapa": predictor_wo_flapa,
}
def main():
"""Main entry point."""
parser = argparse.ArgumentParser(
description="MAT-seq analysis pipeline with caching and full analysis"
)
parser.add_argument(
"--force-recompute",
action="store_true",
help="Skip cache and recompute all steps",
)
parser.add_argument(
"--cache-dir",
type=Path,
default=None,
help="Directory for cached files (default: results/cache)",
)
parser.add_argument(
"--run-snakemake",
action="store_true",
help="Run Snakemake preprocessing pipeline first to generate featurecounts",
)
parser.add_argument(
"--fastq-dir",
type=Path,
default=None,
help="Override FASTQ input directory for Snakemake",
)
parser.add_argument(
"--genome-dir",
type=Path,
default=None,
help="Override genome reference directory for Snakemake",
)
parser.add_argument(
"--snakemake-dry-run",
action="store_true",
help="Validate Snakemake pipeline without running (dry run)",
)
args = parser.parse_args()
pipeline = MATseqPipeline(
cache_dir=args.cache_dir, force_recompute=args.force_recompute
)
# Run Snakemake preprocessing if requested
if args.run_snakemake:
print("=" * 80)
print("MAT-seq Analysis Pipeline - WITH SNAKEMAKE PREPROCESSING")
print("=" * 80)
success = pipeline.run_snakemake_preprocessing(
fastq_dir=args.fastq_dir,
genome_dir=args.genome_dir,
dry_run=args.snakemake_dry_run,
)
if not success:
print("Snakemake preprocessing failed. Aborting pipeline.")
return None
results = pipeline.run_pipeline()
return results
if __name__ == "__main__":
main()