  We present a general method to obtain the exact rate function
$\Psi_{[a,b]}(k)$ controlling the large deviation probability
$\text{Prob}[\mathcal{I}_N[a,b]=kN] \asymp e^{-N\Psi_{[a,b]}(k)}$ that a $N
\times N$ sparse random matrix has $\mathcal{I}_N[a,b]=kN$ eigenvalues inside
the interval $[a,b]$. The method is applied to study the eigenvalue statistics
in two distinct examples: (i) the shifted index number of eigenvalues for an
ensemble of Erd\"os-R\'enyi graphs and (ii) the number of eigenvalues within a
bounded region of the spectrum for the Anderson model on regular random graphs.
A salient feature of the rate function in both cases is that, unlike
rotationally invariant random matrices, it is asymmetric with respect to its
minimum. The asymmetric character depends on the disorder in a way that is
compatible with the distinct eigenvalue statistics corresponding to localized
and delocalized eigenstates. The results also show that the number variance
$\sigma_{N}^{2}$ for the Anderson model on a regular graph scales as
$\sigma_{N}^{2} \propto N$ ($N \gg 1$) for any nonzero disorder, which is
consistent with the absence of level-repulsion in the extended phase. Our
theoretical findings are thoroughly compared to numerical diagonalization in
both cases, showing a reasonable good agreement.
