Entering edit mode
10 weeks ago
Info.shi ▴ 30
I plot PCA using below command.
data1 <- data[,apply(data, 2, function(x) all(x > 0))] pca.result <- prcomp(data1,center = TRUE, scale. = TRUE) autoplot(pca.result, label=TRUE)
I want to label all .Non in one color and .Acc in one color.
I tried using ggplot but in that case which file I should retrieve is problem.
Kindly please me code to label the color using autoplot.
You need to hand both the pca.result, and data1 with a column of the identifiers to the plot function. So if your column of .Non and .Acc is called "type", you would say:
The cran docs for how to plot pca might help.
Thank you but I want different color for all .Non (Red) and .Non (Blue).
But this autoplot(pca.result, data = data1, colour = 'type') convert all in one colour.
That would be great if you can suggest me more.
If it's giving them all the same color, then they must all have the same label in the 'type' column. Can you provide a few rows of your data? Here's an example of a few rows of data that would get unique colors for each point type, because there are distinct labels for each type:
What does your label column look like?
Thank you so much.
My matrix file look like as follows.
That's the PCA result. What we need to see is the first few lines of the input data matrix: data1. If the data1 matrix has the same values as in the "Replicate" column of the PCA result, then each dot will get a different color, because each line has a unique value (1.Acc, 2.Acc). If you want to classify them, as Acc or Nom, you night have to create a column for just those values. Ether way, showing the first few lines of data1 would be informative.