基因组重测序数据分析脚本

生成的文件说明:

1.~/Process/fastqc_result 用于存放质量评估的结果
2.~/Process/trim_out 用于存放过滤的结果
3.~/Process/result/depth.txt 将测序深度保存为depth.txt
4.~/Process/result/T_result.txt 将比对结果保存为T_result.txt
5.变异注释生成avinput.variant_function和avinput.exonic_variant_function后缀的两个结果文件保存在~/Process/result

1.安装相关软件及环境的脚本

#!/bin/bash
cd ~
mkdir ~/BioSofts
cd BioSofts
echo "..................................................................................................."
echo "配置java环境......"
sudo mkdir /usr/java
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
sudo tar -zvxf jdk-8u131-linux-x64.tar.gz -C /usr/java/
cd /usr/java
sudo ln -s jdk1.8.0_131 latest
sudo ln -s /usr/java/latest default
sudo chmod 777 /etc/profile
sudo echo 'export JAVA_HOME=/usr/java/latest' >> /etc/profile
sudo echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH' >> /etc/profile
sudo echo 'export CLASSPATH=/usr/java:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile
source /etc/profile
sudo chmod 440 /etc/profile
echo "配置完成!"
echo "..................................................................................................."

echo "..................................................................................................."
echo "创建目录用于安装相关软件......"
cd ~/BioSofts
echo ".................................................................................................."
echo "安装Aspera软件,用于下载大的测序数据文件......"
wget https://download.asperasoft.com/download/sw/connect/3.6.2/aspera-connect-3.6.2.117442-linux-64.tar.gz
tar zvxf aspera-connect-3.6.2.117442-linux-64.tar.gz
bash aspera-connect-3.6.2.117442-linux-64.sh
echo 'export PATH=$PATH:~/.aspera/connect/bin'>>~/.bashrc
source ~/.bashrc
echo "Aspera安装完成!"
echo "..................................................................................................."

echo "..................................................................................................."
echo "下载格式转换工具包sratoolkit......"
wget https://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.9.2/sratoolkit.2.9.2-ubuntu64.tar.gz
tar -zvxf sratoolkit.2.9.2-ubuntu64.tar.gz -C ~/BioSofts/
echo 'export PATH=~/BioSofts/sratoolkit.2.9.2-ubuntu64/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
echo "sratoolkit安装完成!"
echo "..................................................................................................."


echo "..................................................................................................."
echo "安装测序数据质控软件FastQc......"
cd ~/BioSofts
wget http://www.bioinformatics.babraham.ac.uk/projects/fastqc/fastqc_v0.11.7.zip
unzip fastqc_v0.11.7.zip
echo 'export PATH=~/BioSofts/FastQC:$PATH'>>~/.bashrc
source ~/.bashrc
chmod 777 ~/BioSofts/FastQC/fastqc
echo "安装完成!"
echo "..................................................................................................."

echo "..................................................................................................."
echo "安装测序数据的数据过滤软件Trimmomatic......"
wget http://www.usadellab.org/cms/uploads/supplementary/Trimmomatic/Trimmomatic-0.38.zip
unzip Trimmomatic-0.38.zip
echo "安装完成!"
echo "..................................................................................................."

echo "..................................................................................................."
echo "安装比对软件bwa......"
sudo apt install bwa
echo "安装完成!"
echo "..................................................................................................."

echo "..................................................................................................."
echo "安装格式转换软件samtools......"
sudo apt install samtools
echo "安装完成!"
echo "..................................................................................................."

echo "..................................................................................................."
echo "变异基因注释软件Annovar......"
wget http://www.openbioinformatics.org/annovar/download/0wgxR2rIVP/annovar.latest.tar.gz
tar -zvxf annovar.latest.tar.gz
echo 'export PATH=~/BioSofts/annovar:$PATH'>>~/.bashrc
source ~/.bashrc
echo "..................................................................................................."


2.数据下载的脚本

#!/bin/bash 
cd ~
mkdir Seqs
cd Seqs
echo "..................................................................................."
echo "下载达松维尔拟诺卡氏菌亚种(cardiopsis dassonvillei subsp. dassonvillei)的基因组......"
ascp -T -i ~/.aspera/connect/etc/asperaweb_id_dsa.openssh -k 1 -l 200m anonftp@ftp-private.ncbi.nlm.nih.gov:/sra/sra-instant/reads/ByRun/sra/SRR/SRR022/SRR022534/SRR022534.sra ~/Seqs/
echo "下载完成!"
echo "..................................................................................."

echo "..................................................................................."
echo "达松维尔拟诺卡氏菌(Nocardiopsis dassonvillei )参考基因组序列......"
ascp -T -i ~/.aspera/connect/etc/asperaweb_id_dsa.openssh -k 1 -l 200m anonftp@ftp-private.ncbi.nlm.nih.gov:/genomes/all/GCA/001/877/055/GCA_001877055.1_ASM187705v1/GCA_001877055.1_ASM187705v1_genomic.fna.gz ~/Seqs/
echo "下载完成!"
echo ".................................................................................."

echo ".................................................................................."
echo "下载参考基因组的gff文件,用于注释的自定义数据库......"
wget ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/001/877/055/GCA_001877055.1_ASM187705v1/GCA_001877055.1_ASM187705v1_genomic.gff.gz
echo "下载完成!"
echo "..................数据准备完毕...................................................."

3.重测序数据分析脚本

#!/bin/bash
cd ~
mkdir Process
cp ~/Seqs/* ~/Process
echo "一、将序列与参考基因组的比对:"
echo "1.数据文件的格式转换"
cd Process
mkdir result
fastq-dump SRR022534.sra

echo "2.质量评估"
mkdir fastqc_result #用于存放质量评估的结果
fastqc SRR022534.fastq
mv *.zip *.html fastqc_result/

echo "3.测序数据的数据过滤"
mkdir trim_out #用于存放过滤的结果
java -jar ~/BioSofts/Trimmomatic-0.38/trimmomatic-0.38.jar SE -phred33 SRR022534.fastq ./trim_out/SRR011534_out.fastq.gz ILLUMINACLIP:/home/lizeguo/BioSofts/Trimmomatic-0.38/adapters/TruSeq2-PE.fa:2:30:10 SLIDINGWINDOW:5:20 LEADING:20 TRAILING:20 MINLEN:75

echo "4.建立参考基因组索引"
gunzip GCA_001877055.1_ASM187705v1_genomic.fna.gz
bwa index GCA_001877055.1_ASM187705v1_genomic.fna

echo "5.测序数据比对到参考基因组得到sam文件"
bwa mem GCA_001877055.1_ASM187705v1_genomic.fna trim_out/SRR011534_out.fastq.gz >bwa_mem_SRR011534.sam

echo "6.sam文件转换为bam文件"
samtools faidx GCA_001877055.1_ASM187705v1_genomic.fna
samtools view -bhS -t GCA_001877055.1_ASM187705v1_genomic.fna.fai -o bwa_mem_SRR011534.bam bwa_mem_SRR011534.sam 

echo "7.为bam文件排序"
samtools sort bwa_mem_SRR011534.bam -o bwa_mem_SRR011534.sorted.bam

echo "8.为bam文件建立索引"
samtools index bwa_mem_SRR011534.sorted.bam

echo "9.测试参考基因组每个位点或一段区域的测序深度"
samtools depth bwa_mem_SRR011534.sorted.bam >result/depth.txt #将测序深度保存为depth.txt

echo "10.统计比对结果"
samtools flagstat bwa_mem_SRR011534.sorted.bam > result/T_result.txt #将比对结果保存为T_result.txt
echo "......................................第一部分完成..............................................."

echo "二、变异位点的检测"
echo "1.去除PCR重复"
samtools rmdup bwa_mem_SRR011534.sorted.bam bwa_mem_SRR011534_nopcr.bam

echo "2.生成bcf文件"
samtools mpileup -gf GCA_001877055.1_ASM187705v1_genomic.fna bwa_mem_SRR011534_nopcr.bam >bwa_mem_SRR011534.bcf

echo "3.基因变异检测,得到bwa_mem_SRR011534.snps.bcf文件"
bcftools call -vm bwa_mem_SRR011534.bcf -o bwa_mem_SRR011534.variants.bcf
bcftools view -v snps,indels bwa_mem_SRR011534.variants.bcf > bwa_mem_SRR011534.snps.vcf

echo "4.变异位点的过滤"
bcftools filter -o bwa_mem_SRR011534.snps.filtered.vcf -i 'QUAL>20 &&DP>5' bwa_mem_SRR011534.snps.vcf
echo ".....................................第二部分完成..............................................."

echo "三、变异基因注释"
echo "1.生成annovar输入文件"
convert2annovar.pl -format vcf4 bwa_mem_SRR011534.snps.vcf > bwa_mem_SRR011534.snps.avinput

echo "2.自定义注释数据库"
gunzip GCA_001877055.1_ASM187705v1_genomic.gff.gz
wget http://hgdownload.soe.ucsc.edu/admin/exe/linux.x86_64/gff3ToGenePred
chmod 777 gff3ToGenePred 
./gff3ToGenePred -useName GCA_001877055.1_ASM187705v1_genomic.gff 7055-genome_refGene.txt
cut -f 12 7055-genome_refGene.txt >column1.txt
cut -f 2-15 7055-genome_refGene.txt >column_else.txt
paste column1.txt column_else.txt >7055-genome_new_refGene.txt
retrieve_seq_from_fasta.pl -format refGene -seqfile GCA_001877055.1_ASM187705v1_genomic.fna -outfile 7055-genome_new_refGeneMrna.fa 7055-genome_new_refGene.txt
cp 7055-genome_new_refGene* ~/BioSofts/annovar/humandb/

echo "3.注释变异基因位点,生成avinput.variant_function和avinput.exonic_variant_function后缀的两个结果文件"
annotate_variation.pl --geneanno --dbtype refGene --buildver 7055-genome_new  bwa_mem_SRR011534.snps.avinput ~/BioSofts/annovar/humandb/
mv *_function result
echo "....................................第三部分完成.............................................."

echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>重测序数据分析完成>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"

4.start.sh

#!/bin/bash

chmod 777 software.sh
chmod 777 process.sh
chmod 777 data_download.sh

echo "说明:本次运行需要以下软件和环境的支持,并且需要将软件加到环境目录下,请确认是否已安装这些软件和环境,如果是请输入1,否请输入0"
echo "Aspera sratoolkit FastQC Trimmomatic bwa samtools Annovar"
read response
if [ $response -eq 1  ] ; then
    echo "开始下载数据"
    exec ./data_download.sh
    echo "开始分析"
    exec ./precess.sh
elif [ $response -eq 0 ] ; then
    echo "开始安装所需要的软件"
    exec ./software.sh
    echo "开始下载数据"
    exec ./data_download.sh
    echo "开始分析"
    exec ./precess.sh
else
    echo "输入有误,退出!"
    exit 1
fi
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,547评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,399评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,428评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,599评论 1 274
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,612评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,577评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,941评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,603评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,852评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,605评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,693评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,375评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,955评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,936评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,172评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,970评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,414评论 2 342

推荐阅读更多精彩内容