Sequence
A sequence is a musical pattern that is repeated in transposed form.
Melodic vs. Harmonic (a.k.a. Tonal vs. Real)
In a melodic sequence, the literal pattern is repeated.
In a harmonic sequence, the harmonic pattern (e.g., the chord progression) is repeated, but the specific note pattern might change.
In the Bach example, measures 7 and 8 form a musical unit — a pattern — that is repeated in measures 9 and 10, transposed downward by a major second.
Similarly, measures 10 and 11 form a pattern which is then repeated in measures 12 and 13 in measures 14 and 15, also transposed down a major second.
Both are examples of melodic sequences, since the notes themselves are all transposed. Measures 7–10 can also be considered a harmonic sequence, since the harmonic pattern of moving up a perfect fourth (from D to G, then C to F). Measures 11–13 can also be considered a harmonic sequence, since the chord pattern is transposed by fourths, even though the pattern shifts by an augmented fourth, but the transposed repetition moves by a perfect fourth.
Diatonic vs. Chromatic
In a diatonic sequence, it is permitted to make adjustments in the transposed repetitions so that the primary key remains unchanged.
A chromatic sequence is one in which pitches/harmonies from outside the main key can be used when required to keep the interval content of the pattern intact.
In the Bach example, both sequences are diatonic. Notice that the first two notes in the measure 7 pattern are F-D — a minor third. But in the repetition at measure 9, then first two notes are E-C — a major third. In a chromatic sequence, the first two notes of measure 9 would be E-C#, preserving the minor third in the pattern.
Measure 10–13 also comprise a diatonic sequence. For example, the harmony in the pattern moves by an augmented fourth from Bb to E. In a chromatic sequence, the transposed repetition would move from A to D# rather than the diatonic A to D.
Naming
Sequences are identified according to their level of transposition and sometimes root movement. The sequence in the Bach example are both descending second sequences and could also be identified as +4/-5.