[BioC] Plotting question: how to plot SNP location data?

Lauri.Nikkinen at veripalvelu.fi Lauri.Nikkinen at veripalvelu.fi
Tue Oct 30 13:54:14 CET 2007


Hello,

I would like to plot specific SNPs with their exact locations on a
chromosome. Based on my genotyping results I would like to separate
these SNPs in three different categories: 1, 2 and 3 and use different
colours to represent these categories. The script below generates the
sample data. I can plot these with the image function using the
following:

val <- 1:3
samp <- sample(val, 100, replace=TRUE)
z <- matrix(samp, nrow=20, ncol=4, byrow=TRUE)
SNP <- 1:20
siblings <- 1:4

opar <- par(cex=0.7)
image(SNP, siblings, z, col=c("blue", "red", "black"), axes=FALSE,
ann=FALSE)
axis(1, at=1:20, labels=paste(rep("SNP", 20), 1:20), las=2)
axis(2, at=1:4)
mtext("sibling", 2, line=3)
title(main="Specific SNPs in Chr 1")
par(opar)

In addition to having the data for the above colour matrix, I also have
data including the exact locations of the SNPs on a chromosome (snploc).
I would like to plot the SPNs using the colour codes from above (z) and
include the exact locations of each SNP. Is it possible to do that using
the image-function? Below I have tried to solve the problem using the
basic plot function but I cannot include the colors to that plot. How
would that be possible?

colnames(z) <- c("sib1","sib2","sib3","sib4")
rownames(z) <- paste(rep("SNP", 20), 1:20)
z.t <- t(z)

#snploc$location represents the location of the SNP in the chromosome
snploc <- data.frame(SNP=paste(rep("SNP", 20), 1:20),
location=c(4.2,5.8,6.9,3,8,7,5,4,3.6,4.3,4.6,6.6,5.2,6,9,9.4,12,16,14,12
.3))
snploc$SNP <- factor(snploc$SNP, levels=unique(snploc$SNP))
temp <- as.data.frame(sapply(levels(snploc$SNP), function(x){   z.t[,x]
<- snploc$location[snploc$SNP == x];
 
z.t[,x]
 
}))


temp1 <- as.list(temp)
#Plot the location of the SNP
x11()
for (i in names(temp1)) {
          opar <- par(new=TRUE)
          plot(temp1[[i]], 1:4, pch="|", ann=FALSE, col="blue",
xlim=c(0, 20), ylim=c(1,4), yaxp=c(1,4,3))
          par(opar)
          }
mtext("SNP location", 1, line=3)
mtext("sibling", 2, line=3)
opar <- par(cex=0.7)
axis(3, at=snploc$location, labels=snploc$SNP, las=3)
par(opar)

Originally my z.t data.frame has dimensios 33*4000 so looping through
this data.frame is tedious.

Thanks, 
Lauri

***************************
Lauri Nikkinen
Finnish Red Cross Blood Service
www.bloodservice.fi



More information about the Bioconductor mailing list