Roy's identities for Stone-Geary utility functions
Monir is correct to point out in the comments that $\ln$ is not a linear transformation. It is an increasing transformation, however, and so should not matter as long as

$$ \sum_{i=1}^n p_i \gamma_i &lt; I$$

In any case, your mistake is in the derivatives you find. Here are the correct expressions:

$$\frac{\partial W}{\partial p_i} = -\gamma_i \sum_{j=1}^n \frac{\beta_j}{I - \sum_{k=1}^n p_k \gamma_k} - \frac{\beta_i}{p_i} = -\frac{\gamma_i}{I - \sum_{j=1}^n p_j \gamma_j} - \frac{\beta_i}{p_i} $$

$$ \frac{\partial W}{\partial I} = \sum_{j=1}^n \frac{\beta_j}{I - \sum_{k=1}^n p_k \gamma_k} = \frac{1}{I - \sum_{j=1}^n p_j \gamma_j} $$

Roy's identity then gives you the Marshallian demand you've initially, and correctly, derived.