``` r
# Choose a gene expression PC to visualize (e.g., the most predictable one)
best_feature_ATP_prod_GO_tp4 <- performance_results_ATP_prod_GO_tp4$Feature[which.max(performance_results_ATP_prod_GO_tp4$R2)]

# Extract actual and predicted values for that PC
actual_values_ATP_prod_GO_tp4 <- vsd_energetic_state_GO_tp4[[best_feature_ATP_prod_GO_tp4]]
predicted_values_ATP_prod_GO_tp4 <- predict(models_ATP_prod_GO_tp4[[best_feature_ATP_prod_GO_tp4]], as.matrix(full_pred_counts_tp4), s = "lambda.min")

# Create data frame
prediction_df_ATP_prod_GO_tp4 <- data.frame(
  Actual = actual_values_ATP_prod_GO_tp4,
  Predicted = predicted_values_ATP_prod_GO_tp4
)

# Scatter plot with regression line
ggplot(prediction_df_ATP_prod_GO_tp4, aes(x = Actual, y = lambda.min)) +
  geom_point(color = "blue", alpha = 0.7) +
  geom_smooth(method = "lm", color = "red", se = FALSE) +
  theme_minimal() +
  labs(title = paste("Predicted vs. Actual for", best_feature_ATP_prod_GO_tp4),
       x = "Actual Gene Expression PC",
       y = "Predicted Gene Expression PC") +
  annotate("text", x = min(actual_values_ATP_prod_GO_tp4), y = max(predicted_values_ATP_prod_GO_tp4), 
           label = paste("R² =", round(max(performance_results_ATP_prod_GO_tp4$R2, na.rm=TRUE), 3)), 
           hjust = 0, color = "black", size = 5)
```

```
## `geom_smooth()` using formula = 'y ~ x'
```

![](22.3-Apul-multiomic-machine-learning-byTP_files/figure-gfm/unnamed-chunk-53-1.png)<!-- -->

``` r
## `geom_smooth()` using formula = 'y ~ x'
```