This study leverages the GSE4386 dataset, obtained from atrial tissue samples post-coronary artery bypass graft (CABG) surgery, to investigate the impact of anesthetic agents (sevoflurane and propofol) on gene expression and immune cell infiltration. Hierarchical clustering and box plots were employed for dataset preprocessing, highlighting a significant outlier (sample GSM99282), subsequently removed to ensure data integrity. Differentially expressed genes (DEGs) were identified using volcano plots based on specific log-fold-change and P-value thresholds. Additional analyses included the Friends approach, Spearman's correlation, and gene set enrichment analysis (GSEA), exploring functional annotations and pathways. Heatmaps and bubble plots depicted DEGs, revealing distinct expression patterns between the sevoflurane and propofol groups. Friends analysis identified top genes based on log fold changes, further correlated using Spearman's method. Gene Ontology and Kyoto Encyclopedia of Genes and Genomes enrichment analyses illustrated functional annotations of DEGs, while GSEA highlighted enriched biological categories. Immune cell infiltration analysis showcased varied cellular presence post-CABG. ESTIMATE algorithm scores demonstrated differences in immune, stroma, and estimate scores. Microenvironment Cell Populations-counter (MCPcounter) revealed an increased abundance of cytotoxic lymphocytes in the sevoflurane group, confirmed by a single sample GSEA. CIBERSORT algorithm identified distinct immune cell compositions, highlighting differences in macrophage M0 prevalence between sevoflurane and propofol groups. This comprehensive analysis provides insights into anesthetic-induced gene expression changes and immune cell dynamics in atrial tissue post-CABG surgery. The identified DEGs and immune cell compositions offer potential biomarkers and therapeutic targets for refining anesthetic strategies in cardiac surgeries.