Part II · Module 09 · PHYLUCE 1.7.3

Building phylogenomic datasets

Evaluate matrix completeness and select UCE loci according to taxon occupancy. This step converts the broad incomplete alignment set into one or more filtered phylogenomic datasets for downstream tree inference.

Objective

Use the aligned UCE loci from Module 08 to examine the trade-off between the number of retained loci and taxon occupancy, then generate filtered matrices with phyluce_align_get_only_loci_with_min_taxa.

No universal occupancy threshold

A 75%, 90% or 95% matrix is an analytical choice, not a universal quality standard. Higher occupancy reduces missing taxa per locus but usually retains fewer loci. Lower occupancy retains more loci but allows more missing data.

1. Activate PHYLUCE 1.7.3

conda activate phyluce-1.7.3

On Apple Silicon:

conda activate phyluce-1.7.3-x86

Confirm that the filtering program is available:

phyluce_align_get_only_loci_with_min_taxa --help

2. Define the alignment dataset

PROJECT="/path/to/my_UCE_project"

DATASET="$PROJECT/taxon-sets/all"
ALIGNMENTS="$DATASET/mafft-nexus"
LOGS="$DATASET/log"

THREADS=8
N_TAXA=5
ALIGNMENTS
Incomplete locus-by-locus MAFFT alignments produced in Module 08.
N_TAXA
Total number of samples included in the complete taxon set.
THREADS
Number of physical CPU cores available for PHYLUCE.
Replace N_TAXA

N_TAXA=5 is only an example. Use the actual total number of samples in the dataset.

3. Review the completeness summary

If you already generated the summary in Module 08, review its Data matrix completeness summary. Otherwise, run:

phyluce_align_get_align_summary_data \
  --alignments "$ALIGNMENTS" \
  --cores "$THREADS" \
  --log-path "$LOGS"

PHYLUCE reports how many alignments would remain at increasing occupancy levels. A typical section of the output looks conceptually like:

Data matrix completeness summary
Matrix 50%    ...
Matrix 55%    ...
Matrix 60%    ...
Matrix 65%    ...
Matrix 70%    ...
Matrix 75%    ...
Matrix 80%    ...
Matrix 85%    ...
Matrix 90%    ...
Matrix 95%    ...

Use these counts to understand how quickly the number of loci decreases as occupancy becomes more stringent.

4. What does occupancy mean?

A 75% matrix contains only loci represented by at least 75% of the total samples. For example, if a project contains 100 samples, every retained alignment must contain sequence data for at least 75 of those samples.

Important interpretation

Occupancy is evaluated locus by locus. A 75% matrix does not mean that the same 75% of samples are present in every locus, and it does not mean that any particular sample has data for 75% of all loci.

5. Generate a 75% occupancy dataset

ALIGN_75="$DATASET/mafft-nexus-75p"

phyluce_align_get_only_loci_with_min_taxa \
  --alignments "$ALIGNMENTS" \
  --taxa "$N_TAXA" \
  --percent 0.75 \
  --output "$ALIGN_75" \
  --cores "$THREADS" \
  --log-path "$LOGS"
--taxa
Total number of samples in the study.
--percent 0.75
Retains only loci represented by at least 75% of the total samples.
--output
New directory containing only the loci that pass the occupancy filter.

6. Generate a 95% occupancy dataset

A more stringent matrix can be generated independently from the same original incomplete alignments:

ALIGN_95="$DATASET/mafft-nexus-95p"

phyluce_align_get_only_loci_with_min_taxa \
  --alignments "$ALIGNMENTS" \
  --taxa "$N_TAXA" \
  --percent 0.95 \
  --output "$ALIGN_95" \
  --cores "$THREADS" \
  --log-path "$LOGS"

Do not generate the 95% dataset from the 75% directory. Both filtered datasets should be derived independently from the same original alignment set.

7. Compare the retained loci

Count the original and filtered alignments:

echo "Incomplete matrix:"
find "$ALIGNMENTS" -maxdepth 1 -name "*.nexus" | wc -l

echo "75% matrix:"
find "$ALIGN_75" -maxdepth 1 -name "*.nexus" | wc -l

echo "95% matrix:"
find "$ALIGN_95" -maxdepth 1 -name "*.nexus" | wc -l

The expected pattern is:

Incomplete matrix   ≥   75% matrix   ≥   95% matrix

If a stricter dataset unexpectedly contains more loci than a less stringent one, check the input directories and command history before proceeding.

8. Validate the filtered datasets

Run the PHYLUCE summary separately on each filtered directory:

phyluce_align_get_align_summary_data \
  --alignments "$ALIGN_75" \
  --cores "$THREADS" \
  --log-path "$LOGS"

phyluce_align_get_align_summary_data \
  --alignments "$ALIGN_95" \
  --cores "$THREADS" \
  --log-path "$LOGS"

Confirm that the number of taxa per locus is consistent with the selected occupancy threshold and record the number of loci retained in each dataset.

9. Choosing the dataset for downstream analyses

It is often useful to retain more than one occupancy matrix rather than selecting one threshold immediately. Comparing phylogenetic results across matrices can reveal whether major relationships are sensitive to missing-data treatment.

Example strategy

Keep both a moderately complete matrix such as 75% and a stringent matrix such as 95%. Treat these values as examples, not mandatory standards. The appropriate thresholds should reflect the number of samples, locus recovery, missing-data distribution and the objective of the study.

10. Expected directory structure

taxon-sets/
└── all/
    ├── mafft-nexus/
    │   ├── uce-1.nexus
    │   ├── uce-2.nexus
    │   └── ...
    │
    ├── mafft-nexus-75p/
    │   ├── uce-1.nexus
    │   ├── uce-2.nexus
    │   └── ...
    │
    ├── mafft-nexus-95p/
    │   ├── uce-1.nexus
    │   └── ...
    │
    └── log/

11. What comes next?

The filtered locus sets can now follow two complementary phylogenomic routes:

Filtered UCE alignments
│
├── Concatenation
│   └── IQ-TREE
│
└── Individual locus trees
    └── Species-tree inference

Module 10 will prepare a concatenated matrix and infer a maximum-likelihood tree with IQ-TREE. Modules 11 and 12 will retain the loci individually for gene-tree and species-tree analyses.

12. Pre-flight check

✓ The completeness summary was inspected before filtering.
✓ N_TAXA equals the total number of samples in the dataset.
✓ Filtered matrices were generated from the original incomplete alignments.
✓ The number of retained loci decreases or remains equal as occupancy increases.
✓ Filtered datasets were summarized again after selection.
✓ Occupancy thresholds were treated as analytical choices, not universal standards.
✓ Locus-by-locus alignments were preserved for later gene-tree inference.

References and official documentation

PHYLUCE 1.7.3 — Tutorial I: final data matrices

PHYLUCE 1.7.3 — UCE processing for phylogenomics

PHYLUCE v1.7.3 — Official release

Documentation note

The PHYLUCE tutorial commonly demonstrates 75% and 95% complete matrices. These are useful comparison points, but they are examples rather than required thresholds. The command syntax used here follows the PHYLUCE 1.7.3 documentation.

← UCE alignments Next: Concatenated phylogenetic inference →