Transitional dynamics of cancer stem cells in invasion and metastasis