1吁恍、安裝VMware tools或掛載共享文件夾
2狡赐、下載anaconda
https://repo.anaconda.com/archive/
將下載好的anaconda包放到虛擬機(jī)中
3、在anaconda安裝包路徑下,依次輸入
chmod +x Anaconda3-5.3.0-Linux-x86_64.sh
./Anaconda3-5.3.0-Linux-x86_64.sh
回車*n yes,開始安裝anaconda
4、安裝完成后在目標(biāo)路徑下添加環(huán)境變量
cd /home/maki/anaconda3
sudo vim /etc/profile (這里可能需要先安裝vim : sudo install vim)
按“i”進(jìn)入編輯
在文件最后一行添加:
export PATH="/home/maki/anaconda3/bin:$PATH:"
esc :wq! :q! 退出編輯
更新配置
source ~/.bashrc
5俺孙、添加鏡像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --set show_channel_urls yes
conda config --add channels defaults
conda config --add channels bioconda
conda config --add channels conda-forge
6.1、下載安裝
conda install admixture
6.2缩擂、本地安裝admixture
先將admixture壓縮包放入共享文件夾
進(jìn)入共享文件夾鼠冕,此處為/mnt/hgfs/LinuxShare
解壓縮安裝包
sudo tar -zxv -f admixture_linux-1.3.0.tar.gz -C /usr/local/src
admixture
7、admixture使用
注意這里的snp文件需要先質(zhì)控
plink --bfile xxx --maf 0.05 --geno 0.05 --mind 0.05 --make-bed --out
admixture xxx.bed 3
for K in 1 2 3 4 5; do admixture --cv hapmap3.bed $K | tee log${K}.out; done
grep -h CV *out
8胯盯、R語言作圖
setwd("f:/admixture")
ta3= read.table("hapmap3.3.Q")
barplot(t(as.matrix(ta3)),col = rainbow(3),xlab = "Individual",ylab = "Ancestry",border = NA, main="k=3")
橫向作圖
barplot(t(as.matrix(ta3)),horiz=T,col = topo.colors(3),xlab = "品種占比",ylab = "個(gè)體",border = NA, main="個(gè)體品種純度")
9懈费、python作圖
data_3breed = pd.read_csv(open(r'F:\admixture\7517id_2.3.Q'),sep='\s+',header=None)
data_id = pd.read_csv(open(r'F:\plink\7517id_2.fam'),sep='\s+',header=None)
data_3breed_id = pd.merge(data_id, data_3breed, how='outer',left_index=True,right_index=True)
data_3breed_id['breed']=data_3breed_id['1_x']
data_3breed_id['breed']=data_3breed_id['breed'].astype(str)
data_3breed_id['breed']=data_3breed_id.breed.apply(lambda x : x[:2])
plt.figure(figsize=(40,10),dpi=80)
s1=plt.bar(data_3breed_id['1_x'],data_3breed_id['0_y'],0.8,0,label='LL',color="#F08080")
s2=plt.bar(data_3breed_id['1_x'],data_3breed_id['1_y'],0.8,data_3breed_id['0_y'],label='YY',color="#F0E68C")
s3=plt.bar(data_3breed_id['1_x'],data_3breed_id['2_y'],0.8,(1-data_3breed_id['2_y']),label='DD',color="#3CB371")
plt.xticks(horizontalalignment='left',rotation=-30,fontsize=5)
plt.legend()