0

I am trying to create a enterotype plot. I am following http://enterotype.embl.de/enterotypes.html. My question how can i color the factors in s.class. I tried

points(obs.bet$ls[,xax], obs.bet$ls[,yax], col=rainbow(length(unique(design$BF))),cex=1,pch=16)

but the colors are not correct for the factors. And one more question data in this link have used k=3 cluster but i would like to use k=2 but I am getting an error.Looking forward for a reply

Thanks!!

MANOJ GOPI
  • 1,279
  • 10
  • 31
  • 2
    Please make the question reproducible (imagine the link goes dead) and more specific. What packages are being called? What datasets? How are they manipulated before your line of code? What is the expected result? Also, try to keep one question per post. – Roman Luštrik Jan 21 '15 at 13:24
  • Thanks you for the reply. I am working with abundance data at genus level. #The packages been called are clusterSim and ade4 1. After reading the files I am using Jensen-Shannon Distance for clustering the samples `data.dist=dist.JSD(data)` 2. Followed by this using the Partitioning around medoids function to cluster the abundance profiles. `data.cluster=pam.clustering(data.dist, k=3)` ####First Error when k=2 `obs.pca=dudi.pca(data.frame((data)), scannf=F, nf=10)` `obs.bet=bca(obs.pca, fac=as.factor(data.cluster), scannf=F, nf=k-1) `###Second Error if k=2 – user3252863 Jan 21 '15 at 14:35
  • `s.class(obs.bet$ls, fac=as.factor(data.cluster), col=rainbow(k),grid=F,pch=16) points(obs.bet$ls[,xax], obs.bet$ls[,yax], col=rainbow(length(unique(design$Gender))),cex=1,pch=16)` #####Third error/bug not coloring the samples based on factor means $Gender – user3252863 Jan 21 '15 at 14:36
  • 1
    When adding important information, you should edit your original question, not dump the info in comments. – MrFlick Jan 21 '15 at 19:02
  • 1
    Read few tips [in this "thread"](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) about how to share bits of your data in order to make your question reproducible. – Roman Luštrik Jan 22 '15 at 09:12

1 Answers1

0

I had faced the same problem. And I finally get it. Since your best K cluster is 2, you should type

data.cluster=pam.clustering(data.dist, k=2)

before you type BCA plot. Hope it‘s helpful.