The study aims to accurately identify differentially expressed genes (DEGs) and biological pathways in mycobacterial infections through bioinformatics for deeper disease understanding. Differentially expressed genes (DEGs) was explored by Gene Ontology (GO) and Kyoto Encyclopedia of Genes and Genomes (KEGG) pathway enrichment analysis. Unique DEGs were submitted on least absolute shrinkage and selection operator (LASSO) regression analysis. 1,057 DEGs from two GSE datasets were identified, which were closely connected with NTM/ latent TB infection (LTBI)/active TB disease (ATB). It was demonstrated that these DEGs are mainly associated with detoxification processes, and virus and bacterial infections. Moreover, the METTL7B gene was the most informative marker for distinguishing LTBI and ATB with an area under the curve (AUC) of 0.983 (95%CI: 0.964 to 1). The significantly upregulated HBA1/2 genes were the most informative marker for distinguishing between individuals of IGRA-HC/NTM and LTBI (P < 0.001). Moreover, the upregulated HBD gene was also differ between IGRA-HC/NTM and ATB (P < 0.001). We have identified gene signatures associated with Mycobacterium infection in whole blood, which could be significant for understanding the molecular mechanisms and diagnosis of NTM, LTBI, or ATB.