# --Dot/Line graphs-- # We might be interested in plotting the first two dimensions of a PCoA or # NMDS plot. Let's do this with data generated in the Costello stool analysis # tutorial. The necessary file is in your folder. nmds<-read.table(file="stool.final.an.thetayc.0.03.lt.nmds.axes", header=T) plot(nmds$axis1, nmds$axis2) # or plot(nmds$axis2~nmds$axis1) # Looking at the group names in the nmds table we see that the first 12 sample # names are from women ("F") and the last 12 are from men ("M"). There are # more elegant ways to do this, but for beginners, this will work... nmds.col<-c(rep("pink", 12), rep("blue", 12)) plot(nmds$axis2~nmds$axis1, col=nmds.col, xlab="Axis 1", ylab="Axis 2") legend(x=0.3, y=0.6, legend=c("Female", "Male"), pch=1, col=c("pink", "blue")) plot(nmds$axis2~nmds$axis1, col=nmds.col, xlab="Axis 1", ylab="Axis 2", pch=18, cex=2) legend(x=0.3, y=0.6, legend=c("Female", "Male"), pch=18, cex=1, col=c("pink", "blue")) # Although these points aren't linked you could connect them... plot(nmds$axis2~nmds$axis1, col=nmds.col, xlab="Axis 1", ylab="Axis 2", pch=18, cex=2, type="b") legend(x=0.3, y=0.6, legend=c("Female", "Male"), pch=18, cex=1, lty=1, col=c("pink", "blue")) # You can also overlay two graphs on top of each other using the points # command. Here we'll put the cumulative number of sequences that have that # sequence length or higher. hist(seq.sum$nbases, col="skyblue", freq=T, xlab="Sequence Length", main="Distribution of Sequence Lengths", ylim=c(0,length(seq.sum$nbases))) points(sort(seq.sum$nbases), length(seq.sum$nbases):1, type="l") box()
Recent Comments