Context. Near- and mid-infrared observations have revealed the presence of organic refractory materials in the Solar System, in cometary nuclei and on the surface of centaurs, Kuiper-belt and trans-neptunian objects. In these astrophysical environments, organic materials can be formed because of the interaction of frozen volatile compounds with cosmic rays and solar particles, and favoured by thermal processing. The analysis of laboratory analogues of such materials gives information on their properties, complementary to observations. Aims. We present new experiments to contribute to the understanding of the chemical composition of organic refractory materials in space. Methods. We bombard frozen water, methanol and ammonia mixtures with 40 keV H+ and we warmed the by-products up to 300 K. The experiments enabled the production of organic residues that we analysed by means of infrared spectroscopy and by very high resolution mass spectrometry to study their chemical composition and their high molecular diversity, including the presence of hexamethylenetetramine and its derivatives. Results. We find that the accumulated irradiation dose plays a role in determining the composition of the residue. Conclusions. Based on the laboratory doses, we estimate the astrophysical timescales to be short enough to induce an efficient formation of organic refractory materials at the surface of icy bodies in the outer Solar System.