Which always leads me to the question: how do cells know where they are in the body such that the correct genes are expressed?
This is a vast topic but, In general, cellular signaling molecules transported into the nucleus causes genes to be turned on or off.