Molecular emission from the galactic and extragalactic interstellar medium (ISM) is often used to determine the physical conditions of the dense gas. However, even from spatially resolved regions, the observed molecules do not necessarily arise from a single component. Disentangling multiple gas components is often a degenerate problem in radiative transfer studies. In this paper, we investigate the use of the nonnegative matrix factorization (NMF) approach as a means to recover gas components from a set of blended line intensity maps of molecular transitions that may trace different physical conditions. We run a series of experiments on synthetic data sets designed to replicate conditions in two very different environments: galactic pre-stellar cores and the ISM in high-redshift galaxies. We find that the NMF algorithm often recovers the multiple components resembling those used in the data-generating process, provided that the different components have similar column densities. When NMF fails to recover all the individual components it does however group together the most similarly emitting ones. We further found that initialization and regularisation are key factors in the efficiency of the NMF algorithm.