温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么绘制SNP密度图

发布时间:2022-02-23 11:00:55 来源:亿速云 阅读:418 作者:小新 栏目:开发技术

这篇文章主要为大家展示了“怎么绘制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.cn

source("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密度图”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

snp
AI