[R] Plot Principal component analysis

Christos Hatzis christos.hatzis at nuverabio.com
Tue Feb 26 23:04:56 CET 2008


Sorry, it should have been:

col = c("red", "blue")[c(rep(1, 100), rep(2, 15))]

-Christos 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Christos Hatzis
> Sent: Tuesday, February 26, 2008 4:46 PM
> To: 'SNN'; r-help at r-project.org
> Subject: Re: [R] Plot Principal component analysis
> 
> If your samples are in the specified order (i.e. first 100 
> from group A and remaining from group B) you can try the 
> following in your plot call:
> 
> plot(..., col=c("red", "blue")[c(rep(100, 1), rep(15, 2))])
> 
> -Christos 
> 
> > -----Original Message-----
> > From: r-help-bounces at r-project.org
> > [mailto:r-help-bounces at r-project.org] On Behalf Of SNN
> > Sent: Tuesday, February 26, 2008 4:11 PM
> > To: r-help at r-project.org
> > Subject: [R] Plot Principal component analysis
> > 
> > 
> > Hi,
> > 
> > I have matrix of 300,000*115 (snps*individual). I ran the 
> PCA on the 
> > covariance matrix which has a dimention oof 115*115. I have 
> the first 
> > 100 individuals from group A and the rest of
> > 15 individuals from group B. I need to plot the data in two and 3 
> > dimentions with respect to PC1 and PC2 and (in 3D with 
> respect to PC1, 
> > PC2 and PC3). I do not know how to have the plot ploting 
> the first 100 
> > points corresponding to group A in red (for example) and 
> the rest of 
> > the 15 points in Blue? i.e I want the each group in a 
> diffrent color 
> > in the same plot. I appreciate if someone can help.
> > 
> > Thanks,
> > --
> > View this message in context: 
> > http://www.nabble.com/Plot-Principal-component-analysis-tp1570
> > 0123p15700123.html
> > Sent from the R help mailing list archive at Nabble.com.
> > 
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> > 
> >
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>



More information about the R-help mailing list