Estimating Best Solution to Linear Equation I believe this is quite a basic question, but want to make sure I'm doing this properly.
I want to solve the following set of linear equations:
$\text{RNA}_{1}=\text{RNA}_{Tumor}*\beta_{1}+\text{RNA}_{Non\_tumor}*(1-\beta_1)$
$\text{RNA}_{2}=\text{RNA}_{Tumor}*\beta_{2}+\text{RNA}_{Non\_tumor}*(1-\beta_2)$
Where $\beta_1,\beta_2,\text{RNA}_1,\text{RNA}_2$ are known and I would like to solve for $\text{RNA}_{Tumor}$.
My issue is that all of the $\text{RNA}$ variables are very large matrices (37951 variables). Do I just solve the equation for each of the variables individually? If so how would I go about that in R?
To clarify re EdM's question. The $\beta_i$ are estimates of tumor purity provided by the ESTIMATE algorithm. $\text{RNA}_1,\text{RNA}_2$ are spatially distinct samples from a glioblastoma tumor taken at the same time point.
 A: Although it is easy to solve these formulas (see below), think very hard before you use the solution for this application.
You are attempting to estimate the expression of RNA specific to cancer cells in a tumor by taking two samples with different ratios of cancer (C) to normal (N) cells, expressed as the sample tumor purity $\beta = \frac{C}{N+C}$. Your approach assumes that the RNA expression profile within either of the C or the N cells is the same in both tumor samples.
That's a very dangerous assumption.
First, the ESTIMATE method for inferring tumor purity values is based on 2 different type of N cells, stromal and immune, with distinct RNA expression profiles. If the ratio of stromal to immune cells differs between the two samples, then the RNA expression profiles will not be the same in the overall set of N cells in the two tumor samples.
Second, single-cell RNA analysis of glioblastoma (and other tumor types) has shown substantial differences among cancer cells in the same tumor. For example, see this recent paper by Pang et al., in which different RNA expression signatures were associated with the progression from a stem-cell type to an invasive type of cancer cell. That makes it difficult to assume that the RNA expression within the C cells is the same between the 2 samples.
Third, if $C_{\text{RNA}}$ is the RNA in cancer cells, $R_i$ is the mixed (C + N) RNA in sample $i$ and $\beta_i$ is the purity of sample $i$, you can solve your 2 equations for $C_{\text{RNA}}$:*
$$C_{\text{RNA}} = \frac{R_1 - R_2 + \beta_1 R_2 -\beta_2 R_1}{\beta_1 - \beta_2} .$$
If the values of $\beta_1$ and $\beta_2$ are close to each other, however, then the denominator is close to 0 and your estimate of $C_{\text{RNA}}$ could be very imprecise.

*Alternatively, you could use the solve() function in R with numerical values.
