Skip to content

Alignment Trimming

Trim alignment sites across many alignments at once. Available trimming methods:

  • Missing data: remove sites whose proportion of missing data (gaps and ?) is above a threshold.
  • Parsimony informative sites: trim using a threshold of parsimony informative sites.

PySEGUL writes the trimmed alignments to the trimmed_alignments directory and a trimming summary to trimming_summary.csv.

Install PySEGUL using pip if you haven’t done it yet

Terminal window
pip install pysegul

Create a new Python script, import the library, and write python code.

import pysegul
def trim_alignments():
input_dir = 'tests/align-data'
input_format = 'nexus'
datatype = 'dna'
output_format = 'fasta'
output_dir = 'tests/output'
trim = pysegul.AlignmentTrimming(
input_format,
datatype,
output_dir,
output_format,
)
trim.input_dir = input_dir
# Or use a list of files:
# trim.input_files = ['tests/align-data/locus1.nex']
# Remove sites with more than 50% missing data
trim.missing_data(0.5)
# Or trim using parsimony informative sites
# trim.parsimony_inf(1)

This material is based upon work supported by the National Science Foundation under grant numbers: DEB-1754393 and DEB-2244754. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.