Phenotypic heterogeneity driven by cell-cell signaling: principles of pattern formation and implications for metastasis