Today I read a paper in Pubmed(doi: 10.1016/j.omtn.2020.08.030), in this paper, they used many methods and finally they got a matrix, and each row represents a gene, each column represents a sample. The genes were split into two groups,called gene set A and gene set B. Then they used the PCA(Principal component analysis) to give each patient a score, and the formula is as followed: patient score = ∑PC1A−∑PC1B, the PC1A represents the first component of gene set A, and PC1B represents the first component of gene set B. So how can I understand this formula, and if I also have a matrix like this, how to get the score using R language?