Quantum phase transition in a multicomponent Bose-Einstein condensate in optical lattices