assembly
, purge_dups
, BUSCO
, hifiasm
, small
This pipeline was developed for mammal genomes and includes some steps that are necessary for assembling these larger (~3Gb) genomes but that may not be needed for smaller genomes.
The first step is to use the HiFiasm software to assemble a genome from the raw PacBio reads. (You'll start with the slurm part at the top, as always). Then, the general structure for assembly of heterozygous genomes is:
hifiasm -o prefix -t numberThreads input.fasta.gz --write-paf --write-ec /dev/null
so the whole script looks something like this
The last line is to translate the HiFiasm results to a fasta assembly, which is what you will want for most downstream processes.
You want to end up with an assembly that is close to the expected genome size and has the largest scaffold N50 and smallest number of scaffolds that you can achieve. Different combinations of parameters (e.g., s, D) can help you optimize the assembly quality.
You should also check the quality of each assembly with busco and assembly_stats and compare their outputs.
First, evaluate with busco using the correct database for your taxon:
Next, evaluate your assembly using assembly_stats, which you can also install using anaconda:
Based on the busco scores and assembly stats for each variation of the assembly, you can choose the best one for use in purge_dups.
This mini-pipeline is based off the suggested pipeline for purge_dups and starts with the genome generated by HiFiasm above.
First, we need to map the raw PacBio HiFi reads to the draft genome from HiFiasm. We will use minimap2 with the map-hifi setting. However, map-hifi is not available as part of the purge_dups conda package, so we will need to install it separately.
Now we can run the mapping step:
This will generate .paf alignment files for each reads file and use those as input for the next step, which will both generate reads statistics and estimate the cutoffs to use when purging:
The pbcstat
step will generate PB.base.cov and PB.stat files. You can use these same input files to test different levels of purging, since they are specific to your initial assembly+reads. (but rename and generate new files if you try different mapping parameters.)
Now we need to look at the histogram of read coverage using the alignment of our reads to our draft genome. It is possible that the automatically generated cutoffs are fine, but it is a good idea to try a few different values and evaluate them.
First, let purge_dups generate the automatic cutoff values:
Now, take a look at the histogram:
Now download this to your computer with scp username@server.org:/location/of/png ./local/folder/
and take a look at it. It should look something like this
There is some guidance on how to set the thresholds for your data here, and you should trust the purge_dups authors' recommendations over mine.
-l1
and -l2
and ultimately decided on a cutoff of 2, although the results were nearly identical (the auto-generated suggestion for lower cutoff was 5).For the middle threshold, you want to look for the valley if you have two peaks. After running some trials and evaluating purged assemblies with BUSCO & assembly-stats (see Step 2), I chose -m15
.
The upper regions of the coverage plot represent repeated regions, but choosing the upper threshold seems less straightforward to me. In many examples presented by users here, the suggested upper threshold was midway on the right tail. The automatic cutoffs for my assembly chose 45. I opted to start with a conservative upper limit of 60 and compare this to lower values (the lower -u values even below 45 produced assemblies with good BUSCO scores and high scaffold N50 values). You should try some different values and then check the busco scores to evaluate the number of complete, single-copy, duplicated, and missing buscos (to make sure you don't purge too much).
You will need to change the cutoffs to some other values to explore the results of different degrees of purging. This just requires flags for lower, middle, and upper cutoffs:
Personally, although super-long filenames are annoying, I want them to include the specific parameters I used because I know I will be creating several different purged assemblies using different cutoff values. So I keep the cutoff values in all filenames, and rename the purged assemblies as soon as they are complete.
Now you will use that split assembly in minimap2, outside of the purge_dups environment if you have HiFi data:
Now that you have determined what the appropriate levels of purging may be (but check the results of multiple cutoff values, because you still won't know for sure!), you can purge the duplicates and junk, and keep the rest. You do so in these two steps:
This will produce two output files: one called purge.fa, which is your purged assembly, and another called hap.fa, which is the removed scaffolds with a tag stating the reason they were removed (OVLP, REPEAT, etc.).
Rename those with your purging parameters (or move them to a folder titled with those parameters) so you can keep track:
You should check each assembly with assemblystats and busco as in Step 2.
My strategy was to use the assembly that had the largest scaffold N50/ smallest number of scaffolds/ smallest genome size that preserved the maximum number of BUSCOs.
Many assemblies are contaminated with bacterial sequences, so we need to get rid of these. If we do it now, it will make scaffolding and annotation easier.
Genome masking means hiding certain regions of the genome, such as repeats. Masking a genome improves the efficacy of the decontamination by emphasizing the regions that contribute the most to the classification (Saini et al. 2016, Caetano-Anolles).
We will both hard-mask (convert all repeat regions to Ns) and soft-mask (make repeat sequences lower-case) because we will need both versions for downstream analyses. Before proceeding, make sure the sequences in your assembly are uppercase.
Next, you can change all lowercase letters in your assembly to Ns using sed:
Explanation: In sequence lines (not starting with โ>โ), replace each instance of lower case bases (a t c or g), including undefined ones (n), to Ns.