Mycobacterium tuberculosis (Mtb) bacilli are the causative agent of tuberculosis (TB), a major killer of mankind. Although it is widely accepted that local interactions between Mtb and the immune system in the tuberculous granuloma determine whether the outcome of infection is controlled or disseminated, these have been poorly studied due to methodological constraints. We have recently used a spatial transcriptomic technique, in situ sequencing (ISS), to define the spatial distribution of immune transcripts in TB mouse lungs. To further contribute to the understanding of the immune microenvironments of Mtb and their local diversity, we here present two complementary automated bacteria-guided analysis pipelines. These position 33 ISS-identified immune transcripts in relation to single bacteria and bacteria clusters. The analysis was applied on new ISS data from lung sections of Mtb-infected C57BL/6 and C3HeB/FeJ mice. In lungs from C57BL/6 mice early and late post infection, transcripts that define inflammatory macrophages were enriched at subcellular distances to bacteria, indicating the activation of infected macrophages. In contrast, expression patterns associated to antigen presentation were enriched in non-infected cells at 12 weeks post infection. T-cell transcripts were evenly distributed in the tissue. In Mtb-infected C3HeB/FeJ mice, transcripts characterizing activated macrophages localized in apposition to small bacteria clusters, but not in organized granulomas. Despite differences in the susceptibility to Mtb, the transcript patterns found around small bacteria clusters of C3HeB/FeJ and C57BL/6 mice were similar. Altogether, the presented tools allow us to characterize in depth the immune cell populations and their activation that interact with Mtb in the infected lung.