千家信息网

怎么绘制SNP密度图

发表于:2025-11-15 作者:千家信息网编辑
千家信息网最后更新 2025年11月15日,这篇文章主要为大家展示了"怎么绘制SNP密度图",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"怎么绘制SNP密度图"这篇文章吧。脚本运行示例:Rscript
千家信息网最后更新 2025年11月15日怎么绘制SNP密度图

这篇文章主要为大家展示了"怎么绘制SNP密度图",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"怎么绘制SNP密度图"这篇文章吧。

脚本运行示例:

Rscript snp.density.map.R -i snp.vcf -n out -s 1000000 -c "darkgreen,yellow,red"

-i :跟输入文件,格式为vcf文件;

-n :设置输出文件名称前缀,文件输出到当前目录下;

-s :设置窗口大小;

-c :设置颜色梯度,可以设置一到多种颜色,建议设置两种或三种颜色,颜色间以 "," 分隔。

代码如下:

#北京组学生物科技有限公司#email: wangq@biomics.com.cnsource("https://raw.githubusercontent.com/YinLiLin/CMplot/master/R/CMplot.r")library(getopt)#+--------------------# get options#+--------------------spec <- matrix(c(  'help', 'h', 0, "logical", "help",  'binsize', 's', 1, "integer", "the size of bin for SNP_density plot, optional.",  'color', 'c', 1, "character", " the colour for the SNP density, separated by ',', optional.",  'name', 'n', 1, "character", "add a character to the output file name, optional.",  'input', 'i', 1, "character", "vcf input file, forced."), byrow = TRUE, ncol = 5)opt <- getopt(spec)#+--------------------# check options#+--------------------if ( !is.null(opt$help) | is.null(opt$input) ) {  cat(getopt(spec, usage=TRUE))  q(status=1)}if ( is.null(opt$binsize ) )            { opt$binsize = 1e6 }if ( is.null(opt$color ) )              { opt$color = "yellow,red" }if ( is.null(opt$name ) )               { opt$name = "Fig1" }#data(pig60K)data <- read.table(opt$input, comment.char = "#", header = F, blank.lines.skip = T)num <- dim(data)[1]name <- paste("A", 1:num, sep = "")snp <- data.frame(name,data[1],data[2])colnames(snp) = c("SNP","Chromosome","Position")color <- unlist(strsplit( opt$color, split = ","))CMplot(  snp, plot.type="d",  bin.size=opt$binsize, col=color, xlab = "SNP",  file="jpg", dpi=300, memo=opt$name, file.output=TRUE, verbose=TRUE)CMplot(  snp, plot.type="d",  bin.size=opt$binsize, col=color,  file="pdf", memo=opt$name, file.output=TRUE, verbose=TRUE)

以上是"怎么绘制SNP密度图"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

0