  The low and high-temperature phases of V$_4$O$_7$ have been studied by
\textit{ab initio} calculations. At high temperature, all V atoms are
electronically equivalent and the material is metallic. Charge and orbital
ordering, associated with the distortions in the V pseudo-rutile chains, occur
below the metal-insulator transition. Orbital ordering in the low-temperature
phase, different in V$^{3+}$ and V$^{4+}$ chains, allows to explain the
distortion pattern in the insulating phase of V$_4$O$_7$. The in-chain magnetic
couplings in the low-temperature phase turn out to be antiferromagnetic, but
very different in the various V$^{4+}$ and V$^{3+}$ bonds. The V$^{4+}$ dimers
formed below the transition temperature form spin singlets, but V$^{3+}$ ions,
despite dimerization, apparently participate in magnetic ordering.
