新浪博客

structure画图--不同K的情况下

2020-08-27 15:04阅读:
第一步:格式转换
vcftols --vcf sample.vcf --plink --out sample
plink --file sample --chr-set 20 --noweb --make-bed --out sample
第二步:Q矩阵和画图
for i in 2 3 4 5 6 7 8 ;do python structure.py -K $i --input sample --output sample --full --seed=100;done
1For i in 2 3 4 5 6 7 8;python distruct.py -K $i --input=sample --title='' --output=$i.structure.svg;done
2http://omicsspeaks.com/strplot2/网页版,但是输入必须是csv格式
3clumpak.t
au.ac.il/CLUMPAK网页版
4R语言:barplot(t(as.matrix(tbl)),col=c('green','red','blue','cyan','yellow'),axes = F,border = NA,space = 0);
5R语言:library(pophelper)

第三步:最佳K值选择
python chooseK.py --input=sample > chooseK.out
但是,问题来了……
在画不同K值的图的时候发现不同K值对应的群体颜色不一致,以及群体的顺序也不样,原因在于画图的时候图层的顺序不一样,导致你即使规定的颜色的顺序画出来的也不一致。
好吧!网上找了很多但都没找到解决办法,看看我是怎么解决的
方法1
R自己画,根据图片的颜色来调整颜色的顺序
tbl = read.table('5.txt');
png(filename='5.png',width=1200,heigh=300)
barplot(t(as.matrix(tbl)),col=c('green','red','blue','cyan','yellow'),axes = F,border = NA,space = 0);
dev.off()
方法二:
excel画,只导入之前需要对Q矩阵根据beast key对群体进行排序,然后调整颜色和大小;

我的更多文章

下载客户端阅读体验更佳

APP专享