Even in a single-tissue type cancer is often a collection of different diseases, each with its own genetic mechanism. Consequently, a gene may be expressed in some but not all of the tissues in a sample. Differentially expressed genes are commonly detected by methods that test for a shift in location that ignore the possibility of heterogeneous expression. This article proposes a two-sample test statistic designed to detect shifts that occur in only a part of the sample (partial shifts). The statistic is based on the mixing proportion in a nonparametric mixture and minimizes a weighted distance function. The test is shown to be asymptotically distribution free and consistent, and an efficient permutation-based algorithm for estimating the p value is discussed. A simulation study shows that the test is indeed more powerful than the two-sample t test and the Cramér-von Mises test for detecting partial shifts and is competitive for whole-sample shifts. The use of the test is illustrated on real-life cancer datasets, where the test is able to find genes with clear heterogeneous expression associated with reported subtypes of the cancer. © 2008 American Statistical Association.