  LineStacker is a new open access and open source tool for stacking of
spectral lines in interferometric data. LineStacker is an ensemble of CASA
tasks, and can stack both 3D cubes or already extracted spectra. The algorithm
is tested on increasingly complex simulated data sets, mimicking Atacama Large
Millimeter/submillimeter Array and Karl G. Jansky Very Large Array observations
of [CII] and CO(3-2) emission lines, from $z\sim7$ and $z\sim4$ galaxies
respectively. We find that the algorithm is very robust, successfully
retrieving the input parameters of the stacked lines in all cases with an
accuracy $\gtrsim90$\%. However, we distinguish some specific situations
showcasing the intrinsic limitations of the method. Mainly that high
uncertainties on the redshifts ($\Delta z > 0.01$) can lead to poor signal to
noise ratio improvement, due to lines being stacked on shifted central
frequencies. Additionally we give an extensive description of the embedded
statistical tools included in LineStacker: mainly bootstrapping, rebinning and
subsampling. Velocity rebinning {is applied on the data before stacking and}
proves necessary when studying line profiles, in order to avoid artificial
spectral features in the stack. Subsampling is useful to sort the stacked
sources, allowing to find a subsample maximizing the searched parameters, while
bootstrapping allows to detect inhomogeneities in the stacked sample.
LineStacker is a useful tool for extracting the most from spectral observations
of various types.
