# masterbashscript.sh - stacks pipeline for Ny. darlingi nextRAD data #!/bin/bash # run all samples through ustacks # includes 19 individuals from Peru and Brazil not in current study for catalog building src=$HOME/projects/Adarlingi/combined_analysis_2018 seqdir=/illumina/darlingi_nextrad_samples logdir=$src/denovo_log stacksdir=$src/denovo_stacks dbdir=/genomes/Adarlingi/ dbname="Adarlingi_bwa" mapdir=$src/population_maps outdir=$stacksdir/populations_corrected_10kloci_p4r0.5_maf0.02het id=1 while read sample do echo "ustacks -f $seqdir/${sample}.fastq.gz -o $stacksdir -i $id --name $sample -M 4 -d -p 1 2> $logdir/${sample}_ustacks.log" >>$$src/scripts/run_ustacks_kate_new_samples.sh let "id+=1" done < kate_new_samples parallel -j 20 --noswap --progress --nice 19 < $src/scripts/run_ustacks_kate_new_samples.sh # build master darlingi catalog using catalog_map of 24 samples echo 'starting cstacks' cstacks -n 4 -P $stacksdir -M $mapdir/catalog_map -p 60 2> $logdir/catalog.log # align catalog to darlingi genome (AdarC3) bwa mem -t 60 $dbdir/$dbname $stacksdir/catalog.fa.gz > $stacksdir/catalog.sam cd $stacksdir cat catalog.sam | parallel "samtools view -b -S {} | samtools sort - {.}; samtools index {.}.bam" rm *.sam # after catalog building and ustacks - match 190 deforestation samples in brazil_deforestation_popmap to catalog echo 'starting sstacks' sstacks -P $stacksdir -M $mapdir/brazil_deforestation_popmap -p 60 2> $logdir/sstacks.log echo 'starting tsv2bam' tsv2bam -P $stacksdir -M $mapdir/brazil_deforestation_popmap -t 60 2> $logdir/tsv2bam.log echo 'starting gstacks' gstacks -P $stacksdir -M $mapdir/brazil_deforestation_popmap -t 60 2> $logdir/gstacks.log stacks-integrate-alignments -P $stacksdir -B $stacksdir/catalog.bam -O $stacksdir # run populations - population map includes only 164 individuals matching to >=100,000 catalog loci, locality is population mkdir $outdir populations -P $stacksdir -M $mapdir/brazil_deforestation_popmap_locality_10kloci -O $outdir \ -r 0.5 -p 4 --vcf --genepop --structure --fstats --hwe --write_single_snp \ --no_hap_exports --min_maf 0.02 --max_obs_het 0.7 -t 20