I'm not sure that there is a "correct" way "to model the effect of the expression of gene A on the size of the tumor," as tumor size typically has a lot more to do with the ability to detect a tumor clinically than with gene expression per se. Furthermore, the ability to detect a tumor clinically at a given size has mostly to do with anatomy. It's hard to miss a large tumor on the skin or in the mouth; it's hard to find many tumor types in the abdominal cavity until they are so large as to affect major bodily functions.
Putting that aside for now, either way of dealing with a "control variable" in general might be OK. The way you set up your model:
$$ y = \beta_0 + \beta_1 \text{geneA} + \beta_2 \text{cancerType}$$
effectively allows each cancerType
to have its own intercept independently of the others. In usual modeling, the intercept $\beta_0$ would be the tumor size with geneA
expression of 0 for one reference cancerType
, and $\beta_2$ would be a collection of coefficients representing the differences of each other cancerType
from that reference intercept value. That's typically called "fixed effect" modeling.
Treating cancerType
as a "random effect" also allows each cancerType
to have its own intercept, but the collection of those intercepts is constrained to have a normal distribution with 0 mean. A big advantage is that you only have to estimate an overall intercept and the variance of that normal distribution, instead of separate regression coefficients for each cancerType
. That also helps share information among the cancerTypes
and can overcome problems when there are differences in case numbers among them. But it's not always a good choice if there is just a handful of cancerType
values.
You can find much discussion of pros and cons of these approaches on this site. See this thread for an overview, and this thread for further guidance on choosing. Those link to many other related threads. Note that the terminology can be confusing; just what is meant by "fixed effects" and "random effects" can differ depending on author and context.
Finally, your writing the equation out is an important first step. Think through its implications to see if that captures what you are trying to model. The way you wrote it, the extra influence of geneA
on tumor size y
would be the same for each cancerType
once you take the baseline differences among cancerTypes
into account. Is that what you want? Or do you want the influence of geneA
expression on tumor size to differ among cancerTypes
? If so, you need to incorporate an interaction between geneA
expression and cancerType
in your model. That could in principle be handled with cancerType
either as a "fixed" or a "random" effect, but then the advantage of the lower number of coefficients to estimate with cancerType
treated as a random effect would tend to become overwhelming.