##1.首先在當(dāng)前文件中創(chuàng)建新文件夾F1_test
####因?yàn)槭堑谝淮蟠肍1表示,如果處理第二代后代就用F2表示,F(xiàn)2_test,以此類推
mkdir F1_test
##2.進(jìn)入文件夾
cd F1_test
##3.處理數(shù)據(jù)
sed 's/##contig=<ID=1/##contig=<ID=chr2/' ../offspring_genotypes_renamed.vcf | sed 's/^1\t/chr2\t/' > offspring_genotypes_renamed_chr2.vcf
##4.復(fù)制腳本
cp /home/DL_2/CUTech/comput_2/Tech_No1/group4/yjc/workspace/SCT_data/test/13.119_SCT_ind/01.40_test/1.test/02.genome_modle/05.PCA/test_F/fenzhi2/F2_test/test1/F3_test/test1/F4_test/test1/F5_test/subset_random_28.sh ./
##5.運(yùn)行腳本
./subset_random_28.sh -i offspring_genotypes_renamed_chr2.vcf -o pick_001_080 -r 001-080 -g 4 -e 8 -s 42
### 上面腳本命令的解釋
### 當(dāng)前offspring_genotypes_renamed_chr2.vcf個(gè)體的編號(hào)為001-080,
### 未來(lái)生成的數(shù)據(jù)的個(gè)體編號(hào)會(huì)更新比如下一輪就變成081-160(因?yàn)槊看畏敝澈蟠叶紩?huì)生成80個(gè)個(gè)體),以此遞增
##6.處理親代數(shù)據(jù)
bcftools query -l ../merged1.vcf.gz | shuf -n 12 > keep.txt
###這里你要記得每個(gè)分支要保持相同的keep.txt編號(hào),所以你要記住最開(kāi)始生成的這個(gè)文件的路徑
##在服務(wù)器上輸入pwd可以得到路徑,你需要復(fù)制這個(gè)路徑比如/home/yjc,假如桌面顯示上述路徑,m那么這個(gè)keep.txt文件所在的文件夾就是home下的yjc文件夾中
##所以下次你復(fù)制這個(gè)文件的命令就是cp /home/yjc/keep.txt ./
bcftools view -S keep.txt -Oz -o output.vcf.gz ../merged1.vcf.gz && bcftools index -f output.vcf.gz
##7.合并
bcftools merge output.vcf.gz pick_001_080.vcf.gz -Oz -o merged1.vcf.gz
###同樣上面提到了001_080這個(gè)編號(hào)會(huì)發(fā)生改變,所以隨著不斷的處理數(shù)據(jù),這個(gè)命令要根據(jù)編號(hào)的不同進(jìn)行調(diào)整
##8.查看個(gè)體編號(hào)
bcftools query -l merged1.vcf.gz
###你需要將屏幕上顯示的個(gè)體編號(hào)輸入到我給你提供的文件中的sample_name.id文件中。
###將sample_name.id文件通過(guò)xftp軟件導(dǎo)入服務(wù)器的文件夾,運(yùn)行腳本05_1,將生成的pairing_schemes文件夾導(dǎo)出,查看文件中的all_schemes_summary.txt文件,這就是我們隨機(jī)生成的4組配對(duì)方案(4個(gè)分支的配對(duì)方案已經(jīng)完全生成,當(dāng)處理分支2,3,4的過(guò)程中不要再次重復(fù)步驟8)
###1.新建文件夾
mkdir test1
###2.進(jìn)入文件夾
cd test1
###3.復(fù)制腳本
cp /home/DL_2/CUTech/comput_2/Tech_No1/group4/yjc/liululu/workspace/fenzhi1/F1_test/test1/step* ./
###4.復(fù)制腳本
cp /home/DL_2/CUTech/comput_2/Tech_No1/group4/yjc/liululu/workspace/fenzhi1/F1_test/test1/slim_read.py ./
###5.復(fù)制vcf文件
cp ../merged1.vcf.gz ./
###6.轉(zhuǎn)換數(shù)據(jù)
bcftools query -f '%CHROM\t%POS\t%REF\t%ALT[\t%GT]\n' merged1.vcf.gz > genotypes_raw.txt
###7.生成個(gè)體編號(hào)
bcftools query -l merged1.vcf.gz > sample_ids.txt
###8.運(yùn)行腳本
python slim_read.py
###9.復(fù)制step0腳本
cp /home/DL_2/CUTech/comput_2/Tech_No1/group4/yjc/liululu/workspace/fenzhi3/F1_test/test1/F2_test/test1/F3_test/test1/F4_test/test1/F5_test/test1/step0.py ./
###10.編寫(xiě)1.txt和2.txt
###11.修改slim腳本中的個(gè)體編號(hào)
python step0.py 1.txt 2.txt step1.breeding_simulation.slim updated.slim
###12.運(yùn)行slim腳本
nohup slim updated.slim &
###多次重復(fù)運(yùn)行這個(gè)腳本
cd ..
mkdir -p {test2,test3}
cd test2
cp ../test1/step* ./
cp ../test1/slim_genotypes.txt ./
cp ../test1/updated.slim ./
nohup slim updated.slim &
cd ../test3
cp ../test2/* ./
nohup slim updated.slim &
###這個(gè)過(guò)程需要等待很久,你可以繼續(xù)開(kāi)展分支2,分支3,分支4的工作
###最后, step1.breeding_simulation.slim腳本運(yùn)行結(jié)束后,運(yùn)行腳本
python step2.vcf_ID_modify.py 081 160
###這次生成的后代的編號(hào)就是081-160了,當(dāng)前是第二代,那么第三代就是161-240,以此類推(請(qǐng)明確區(qū)分代數(shù)和分支的區(qū)別)
###統(tǒng)計(jì)后代遺傳多樣性數(shù)據(jù)
python step3.cau_genetic_parameter.py offspring_genotypes_renamed.vcf
統(tǒng)計(jì)下圖的數(shù)據(jù)到excel

image.png