# How is PCA applied to (one-hot encoded) DNA sequence data?

I realize some questions have been asked already about one-hot encoding for PCA. The answer seems to be along the lines of 'The PCA will run, but does not necessarily make sense.'

However, I have a question regarding the application of PCA on one-hot encoded sequence data. For example, in this paper, the authors claim to first one-hot encode DNA sequences, and then apply PCA on some resulting matrix. I'm trying to understand this paper (I'm looking to apply a similar strategy for a different kind of sequence), but I don't see to what matrix they actually apply PCA.

The part I don't understand is this: If we one-hot encode using the categories "$$a,t,g,c,\_$$" (as stated in the paper)

a sequence $$\{gaatc\}$$ becomes: $$\begin{bmatrix} 0 & 1 & 1 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 \\ \end{bmatrix}$$

a sequence $$\{aagctt\}$$ becomes: $$\begin{bmatrix} 1 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 1\\ 0 & 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0\\ \end{bmatrix}$$

Meaning every sample is now a matrix. In "normal" PCA every sample is a vector, which we stack together into the matrix of which we determine the coveriance, etc.

So what is being done in case of one-hot encoded sequence data? How are these sample-matrices combined such that we can determine a (useful) covariance matrix?

The paper is incorrect in applying Principal Component Analysis (PCA) to boolean data since PCA implicitly minimizes a squared loss function, which is not always appropriate for not real-valued data. "A Generalization of Principal Components Analysis to the Exponential Family" by Collins et al. goes into detail.

Boolean data would be more appropriately modeled with Multiple Correspondence Analysis (MCA).

• I understand that PCA may not be appropriate for categorical data. However, I am interested in seeing what they actually (mathematically) do here. The results they claim seem at least interesting, if not useful. Commented May 9, 2023 at 7:16
• Your question may be better answered on stats.stackexchange.com. datascience.stackexchange.com tends to focus on correctly applying the most appropriate technique. Commented May 9, 2023 at 14:34
• IMO you jump too quickly to "not appropriate", without understanding what the authors are doing. Commented May 9, 2023 at 14:44

As the title suggests, it seems that they apply the operator to each encoded matrix. Then they use some "post-processing", explained in the "Materials and Methods" section, to make the individual results comparable.

So, they do not combine the sequence matrices at all; they treat each one as an individual dataset.

New contributor
MaxPowers is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.