In linear regression we can do something like this
$$ y' = resid(y \sim \beta_0 + \beta_1 c1 + \beta_2 c2 ) $$
where $c1, c2$ are covariates, and then fit $y'$ in another model:
$$ y' \sim b_0 + b_1 x_1 $$
The advantage of this approach is when you have a lot of independent variables like $x_1, x_2, \cdots x_n$ (for example, a large number of DNA mutation sites), and they all share the same covariates (e.g. age, sex, weight etc), you can simplify things and reduce computation.
But it looks like this will only work with continous variables, like height, blood pressure, etc, what if I have a binary variable, such as tumor/no-tumor, infected/uninfected etc, is it still possible to do something similar?