Plotting question: how to plot SNP location data?
1
0
Entering edit mode
@laurinikkinenveripalvelufi-2460
Last seen 9.6 years ago
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
SNP SNP • 1.7k views
ADD COMMENT
0
Entering edit mode
Thomas Girke ★ 1.7k
@thomas-girke-993
Last seen 27 days ago
United States
Hi Lauri, I am often using the following featurePlot() function for similar purposes: source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Script s/featureMap.txt") The instructions that are printed to the screen, after the sourcing step, should explain its usage. To color features (SNPs) in different colors, you simply provide under the featurecol argument a vector of numbers or color names. Thomas On Tue 10/30/07 14:54, Lauri.Nikkinen at veripalvelu.fi wrote: > 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,1 4,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 > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Thomas Girke Assistant Professor of Bioinformatics Director, IIGB Bioinformatic Facility Center for Plant Cell Biology (CEPCEB) Institute for Integrative Genome Biology (IIGB) Department of Botany and Plant Sciences 1008 Noel T. Keen Hall University of California Riverside, CA 92521 E-mail: thomas.girke at ucr.edu Website: http://faculty.ucr.edu/~tgirke Ph: 951-827-2469 Fax: 951-827-4437
ADD COMMENT

Login before adding your answer.

Traffic: 659 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6