Neural Collapse in Deep Linear Networks: From Balanced to Imbalanced Data