We develop a novel method DeMixT for the gene expression deconvolution of three compartments in cancer patient samples: tumor, immune and surrounding stromal cells.  In validation studies using mixed cell line and laser-capture microdissection data, DeMixT yielded accurate estimates for both cell proportions and compartment-specific expression profiles. Application to the head and neck cancer data shows DeMixT-based deconvolution provides an important step to link tumor transcriptome data with clinical outcomes.