When motile algal cells are exposed to gyrotactic torques, their swimming directions are guided to form radial accumulation, well known as hydrodynamic focusing. The origin of hydrodynamic focusing from the effects of active swimming, ambient flow and particle anisotropy is elucidated in the present study on the pre-asymptotic dispersion of active particles through a vertical pipe. With an extension of the Galerkin method to pipe flows, time-dependent solutions directly from the Smoluchowski equation in the position and orientation space are derived by series expansions of spherical harmonics and Bessel functions. Ballistic and diffusive scaling laws are examined with the predominance of self-propelled swimming, and computation is validated against an explicit benchmark solution and Lagrangian particle simulation. In the limit of extreme shear, the competitive roles of shear dispersion and Brownian rotation are reflected concretely in the pre-asymptotic phase of hydrodynamic focusing. For flows with various shear strengths, a concentration peak in near-wall regions with a smooth transition to hydrodynamic focusing is illustrated with richer phenomena in upwelling and downwelling flows. A newly observed regime through a vertical pipe, named transient effective trapping, is revealed as a transitional mode towards hydrodynamic focusing. The pre-asymptotic approach to hydrodynamic focusing is elaborated intensively through extensive solutions of concentration moments and macroscopic transport coefficients characterised by swimming and flow Péclet numbers. The unique findings for the origin of hydrodynamic focusing could provide insight into related micro-algae reactor technology and contribute to flow control and biomass transfer in confined environments.