The DESeq2 paper, page 15 explains the first of the three steps the algorithm uses for finding the dispersion as a function of the mean as follows:
To get a gene-wise dispersion estimate for a gene i, we start by fitting a negative binomial GLM without an LFC prior for the design matrix X to the gene’s count data. This GLM uses a rough method-of-moments estimate of dispersion, based on the within-group variances and means.
I would like to understand this better and I would appreciate more details on this "rough method-of-moments estimate." In principle I can extract this from the code, but that hasn't proved straightforward. Even a clear pointer to exactly where this is carried out in the source code would be a big help.