###### tags: `hybpiper` `reese` `phylogeny` # Abronia HybSeq Phylogeny [TOC] ## Sequence Data ### February 2021 NovaSeq 38 samples in: `/media/johnsonseq/2021-02-08_novaseq6000_fastq/Abronia` ### June 2021 NovaSeq 24 samples in: `/media/johnsonseq/2021-06-24_novaseq6000_fastq/Abronia` ## Trim Reads with FASTP `cp fastp.sh fastp2.sh` ## HybPiper To improve sequence recovery we made a new Angiosperms353 target file with sequences from Abronia. The new target file is located at: `/scratch/joh97948/Abronia/angiosperms353.abronia.fasta` Make a namelist (run from the reads directory): `ls | cut -f 1 -d '.' | sort -u > ../hybpiper/new_namelist.txt` ```bash= while read name do /opt/apps/Software/HybPiper/reads_first.py --prefix $name --bwa -r ../reads/"$name".R*.paired.fastq -b /scratch/joh97948/Abronia/angiosperms353.abronia.fasta --cpu 50 --timeout 5000 python /opt/apps/Software/HybPiper/intronerate.py --prefix $name python /opt/apps/Software/HybPiper/cleanup.py $name done < new_namelist.txt ``` ### Get seq lengths Run from the `Abronia/hybpiper` directory `python /opt/apps/Software/HybPiper/get_seq_lengths.py /scratch/joh97948/Abronia/angiosperms353.abronia.fasta namelist.txt DNA > abroniaseqlengths.txt` ### Get hybpiper stats Run from the `Abronia/hybpiper` directory: `python /opt/apps/Software/HybPiper/hybpiper_stats.py abroniaseqlengths.txt namelist.txt > hybpipstats.txt` ### Extract supercontig sequences Run from the HybPiper output directory (`Abronia/hybpiper`), unaligned sequences go into the Sequences `python /opt/apps/Software/HybPiper/retrieve_sequences.py /scratch/joh97948/Abronia/angiosperms353.abronia.fasta ../new_namelist.txt --fasta_dir /scratch/sherpric/Abronia/Sequences2 supercontig` ## Phylogeny ### MAFFT Run this from the Sequences directory to remove the gene name from the sample IDs: `parallel sed -i "s/-{}//g" {}_supercontig.fasta :::: genelist.txt` Run this from the Abronia directory: `parallel "mafft --preservecase --maxiterate 1000 --localpair Sequences2/{}_supercontig.fasta > MAFFT2/{}.mafft.fasta" :::: genelist.txt` ### Trimal Run from the Abronia directory: `parallel -j 10 --eta trimal -in MAFFT2/{}.mafft.fasta -out trimal2/{}.trimal.fasta -gt .5 :::: genelist.txt` ### IQTree Run from the Abronia directory: `parallel --eta -j 10 iqtree -s trimal2/{}.trimal.fasta -m MFP -B 1000 :::: genelist.txt ` ### ASTRAL Remove the gene names from the sequence names. Run this from the trimal directory. `parallel sed -i "s/-{}//g" {}.trimal.fasta.treefile :::: ../genelist.txt` Go back to the Abronia directory. Collapse gene trees so that they don't have branches with poor support: `mkdir collapsed` `parallel "nw_ed trimal/{}.trimal.fasta.treefile 'i & b<=30' o > collapsed/{}.collapsed.tre" :::: genelist.txt` Put all of the gene trees into a single file `cat collapsed/*.tre > abronia.genetrees.tre` Run ASTRAL Run from the Abronia directory `java -jar /opt/apps/Software/ASTRAL/Astral/astral.5.6.3.jar -i abronia.genetrees.tre > abronia.astral.tre` Change the names so that the species are listed and not just the accessions: `python /scratch/joh97948/Abronia/treeLabelReplace.py abronia.astral.tre /scratch/joh97948/Abronia/abronia_label_replace.txt > abronia.astral.renamed.tre` Download `abronia.astral.tre` to your computer and open in FigTree to see it! ### PhyParts Reroot all of the gene trees using the Mirabilis outgroup sequences: Make a directory for rerooted trees: `mkdir reroot` The `reroot_trees_mirabilis.py` script will reroot all gene tres based `parallel "python reroot_trees_mirabilis.py collapsed2/{}.collapsed.tre > reroot/{}.rerooted.tre" :::: genelist.txt` Some trees will be empty either because we didn't have sequences or we don't have any outgroup (and therefore cannot re-root the tree). Delete these: `find reroot -size 0 -delete` Also reroot the ASTRAL species tree: `python reroot_trees_mirabilis.py abronia.astral.tre > abronia.astral.rerooted.tre` Run PhyParts to calculate bipartitions on the rooted trees: `mkdir phyparts; cd phyparts` `java -jar /opt/apps/Software/phyparts/target/phyparts-0.0.1-SNAPSHOT-jar-with-dependencies.jar -a 1 -d ../reroot -m ../abronia.astral.rerooted.tre -v` Download the phyparts output and the rerooted astral tree to make the pie charts (the script doesn't really work on a remote computer) `python ~/phyloscripts/phypartspiecharts/phypartspiecharts.py --taxon_subst ../abronia_label_replace.csv abronia.astral.rerooted.tre out 339`