How to create PCA plot function which use data from 2 datasets (R)?

I am creating PCA plot function in R which use data from 2 datasets : RNA data and Phenotype data. RNA data includes ID , sample and value

ID sample1 sample2 sample3 01 3 -2 5 02 4 -3 3 03 2 1 1

and Phenotype data contains sample and factors like age and cell type sample factor1 factor2 factor3 factor4 sample1
sample2 sample3

What I want to create is a custom PCA plot that uses data as a PCA score datapca <-prcomp(scale(data[-1]),center = T,scale = T) contributions<-summary(datapca1)$importance[2,]*100

I want to group it by Phenotype$sample OR Phenotype$factor4 ,how should I create this function by ggplot? Thank you in advance

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.