def _sparse_variance(X, tmp, axis=0):
    """Calculate variance across the specified axis of a sparse matrix"""

    mean_gene = X.mean(axis=axis).A.squeeze()
    tmp.data **= 2
    return tmp.mean(axis=axis).A.squeeze() - mean_gene ** 2