Isoscalar and isovector pairing in a formalism of quartets