Eight hub genes, i.e., CXCL3, CXCL8, CEACAM7, CNTN3, SLC1A1, SLC16A9, SLC4A4, and TIMP1, were related to the prognosis and tumour-infiltrating immune cells of colorectal cancer, and these genes have diagnostic value for ulcerative colitis, colorectal adenoma, and colorectal cancer. Here, SLC4A4 is linked to ulcerative colitis.