In this code, the HTSFilter package is being used to filter the data (contained in the cds object) to remove genes with relatively low counts across samples using a data-driven filtering threshold. The HTSFilter function returns both the filtered data themselves (contained in filter$filteredData, which will have a number of rows less than or equal to the number of rows in cds) as well as a binary vector (contained in filter$on) of the same length as the number of rows in cds indicating whether a gene was retained after the filtering (1) or not (0). So on.index will just provide the indices of genes retained after filtering -- as you can see, above it is used to fill in the appropriate rows of the res data.frame with the results from the DESeq function nbinomTest.