cogent3
  • Install
  • Gallery
  • Docs
  • GitHub
  • Site
    Posting Bugs Citation Support History Projects License
  • Installation
    • Minimal installation
    • Install with graphing tools
    • Install with developer tools
    • Installing the development version
    • Installing using conda
      • Manual creation of the conda environment
  • Documentation
    • The apps
      • Overview
        • Warning – apps are alpha!
        • Overview of using apps
          • Define the apps
          • Using apps like functions
          • Composing a multi-step process from several apps
          • Applying a process to multiple data records
          • Other important features
            • You can track progress
            • You can do parallel computation
            • You can log the settings and data analysed
            • All of the above
        • Specifying data for analysis
          • A read only data store
          • Data store “members”
          • Showing the last few members
          • Filtering a data store for specific members
          • Looping over a data store
          • Making a writeable data store
          • TinyDB data stores are special
            • Interrogating run logs
        • Tracking records that could not be processed
          • The NotCompleted object
          • NotCompleted FALSE type
          • NotCompleted ERROR type
          • Composed functions propagate NotCompleted results
        • What apps are there?
      • The progressive_align App
        • Using a nucleotide model
          • Nucleotide alignment with default settings
          • Specify a different distance measure for estimating the guide tree
          • Providing a guide tree
          • Specifying the substitution model
          • Alignment settings and file provenance are recorded in the info attribute
        • Using a codon model
          • Codon alignment with default settings
          • Specify a different distance measure for estimating the guide tree
          • Providing a guide tree
          • Specifying the gap parameters
          • Specifying the substitution model and parameters
          • Alignment settings and file provenance are recorded in the info attribute
        • Using a protein model
          • Protein alignment with default settings
          • Specify a different distance measure for estimating the guide tree
          • Alignment settings and file provenance are recorded in the info attribute
      • The model App
        • Apply a non-stationary nucleotide model to an alignment with 3 sequences
          • model_result
          • Fitting a separate nucleotide model to each codon position
        • Apply a non-stationary nucleotide model to an alignment with a tree
          • Specify the tree via a tree instance
          • Specify the tree via a path.
          • Apply the model to an alignment
        • Specifying a non-stationary model with time-heterogeneous parameters
          • Specify a distinct rate matrix for the great apes
        • Extracting maximum likelihood estimates from a model_result
          • Create and apply tabulate_stats app
          • Edge parameters
          • Global parameters
          • Motif parameters
        • Reconstructing ancestral states
          • Define the ancestral_states app
        • Applying a discrete-time, non-stationary nucleotide model
          • Get a tree with branch lengths as paralinear
          • Getting parameter estimates
        • Applying a time-reversible nucleotide model
          • Using the GTR model
        • Applying GNC, a non-stationary codon model
          • We can obtain the tree with branch lengths as ENS
        • Applying a time-reversible codon model
          • Using the conditional nucleotide form codon model
      • The hypothesis App
        • Testing a hypothesis – non-stationary or time-reversible
          • hypothesis_result has attributes and keys
            • Accessing the test statistics
            • The null hypothesis
            • The alternate hypothesis
          • Saving hypothesis results
      • The natsel Apps
        • natsel_neutral – a test for selective neutrality
        • natsel_timehet – a test of branch heterogeneity
        • natsel_sitehet – a test of site heterogeneity
          • Getting the individual site posterior probabilities
        • natsel_zhang – a branch-site test
          • Getting the posterior probabilities of site-class membership
          • Getting all the statistics in tabular form
      • The user_function Apps
        • Custom composable apps
          • A simple example
          • Renaming sequences
          • A user function for with a different output type
    • Cookbook
      • Manipulating biological data
        • Sequences and Alignments
          • Loading an alignment from a file
            • Loading aligned sequences
            • Loading unaligned sequences
            • Specifying the file format
          • Specifying the sequence molecular type
          • Making an alignment from standard python objects
            • From a dict of strings
            • From a series of strings
            • Stripping label characters on loading
          • Making a sequence collection from standard python objects
          • Loading sequences using format parsers
            • Loading FASTA sequences from an open file or list of lines
            • Handling overloaded FASTA sequence labels
          • Sequence Collections and Alignments
            • What’s the difference between Alignment and ArrayAlignment?
            • Basic Collection objects
            • Adding new sequences to an existing collection or alignment
            • The elements of a collection or alignment
            • Alignments
            • Slicing an alignment
            • Computing alignment statistics
          • Sequence
            • DNA and RNA sequences
          • Protein sequences
            • Creating a ProteinSequence with a name
            • Converting a DNA sequence string to protein sequence string
            • Loading protein sequences from a Phylip file
          • Annotations
          • Annotations with coordinates
            • Automated introduction from reading genbank files
            • Customising annotation construction from reading a genbank file
            • Creating directly on a sequence
            • Via
            • Adding as a series or item-wise
            • Taking the union of annotations
            • Getting annotation coordinates
            • Annotations have shadows
            • Adding to a sequence member of an alignment
            • Adding to an alignment
            • Slicing sequences and alignments by annotations
            • Slicing by pseudo-feature or feature series
            • Slice series must not be overlapping
            • You can slice an annotation itself
            • Sequence vs Alignment slicing
            • Copying annotations
            • Querying
            • Querying produces objects only valid for their source
            • Querying for absent annotation
            • Querying features that span gaps in alignments
            • as_one_span unifies features with discontinuous alignment coordinates
            • Behaviour of annotations on nucleic acid sequences
            • Masking annotated regions
            • Masking annotated regions on alignments
            • You can take mask of the shadow
            • What features of a certain type are available?
            • Getting all features of a type, or everything but that type
            • Getting sequence features when you have an alignment object
            • Annotation display on sequences
          • Molecular types
            • Available molecular types
            • Getting a MolType
            • Using a MolType to get ambiguity codes
            • MolType definition of degenerate codes
            • Nucleic acid MolType and complementing
            • Making sequences
            • Verify sequences
            • Making a custom MolType
          • Alphabets
            • Alphabet and MolType
            • Creating tuple alphabets
            • Convert a sequence into integers
            • Convert integers to a sequence
        • Genetic code
          • Available genetic codes
            • Getting a genetic code with get_code()
          • Translate DNA sequences
          • Translate all six frames
          • Find out how many stops in a frame
          • Translate a codon
          • Look up the amino acid corresponding to a single codon
          • Get all the codons for one amino acid
          • Get all the codons for a group of amino acids
          • Converting the CodonAlphabet to codon series
          • Obtaining the codons from a DnaSequence object
          • Translating a DNA sequence with a terminating stop codon
            • By removing the trailing stop codon first
            • By slicing the DnaSequence first
        • Trees
          • Trees
            • Loading a tree from a file and visualizing it with ascii_art()
            • Writing a tree to a file
            • Getting the individual nodes of a tree by name
            • Getting the name of a node (or a tree)
            • The object type of a tree and its nodes is the same
            • Working with the nodes of a tree
            • Getting the path between two tips or edges (connecting edges)
            • Getting the distance between two nodes
            • Getting the last common ancestor (LCA) for two nodes
            • Getting all the ancestors for a node
            • Getting all the children for a node
            • Getting all the distances for a tree
            • Getting the two nodes that are farthest apart
            • Get the nodes within a given distance
            • Rerooting trees
            • Tree representations
            • Tree traversal
            • Selecting subtrees
            • Tree manipulation methods
      • Tabular data
        • Loading a csv file
        • Loading delimited specifying the format
        • Loading delimited data without a header line
          • Using load_delimited()
          • Using FilteringParser
        • Selectively loading parts of a big file
          • Loading a set number of lines from a file
          • Loading only some rows
          • Loading only some columns
          • Load raw data as a list of lists of strings
        • Make a table from header and rows
        • Make a table from a dict
        • Specify the column order when creating from a dict.
        • Create the table with an index
        • Create a table from a pandas.DataFrame
        • Create a table from header and rows
        • Create a table from dict
        • Create a table from a 2D dict
        • Create a table that has complex python objects as elements
        • Create an empty table
        • Adding a new column
        • Add a title and a legend to a table
        • Iterating over table rows
        • How many rows are there?
        • How many columns are there?
        • Iterating over table columns
        • Table slicing using column names
        • Table slicing using indices
        • Changing displayed numerical precision
        • Change digits or column spacing
        • Wrapping tables for display
        • Display the top of a table using head()
        • Display the bottom of a table using tail()
        • Display random rows from a table
        • Change the number of rows displayed by repr()
        • Changing column headings
        • Adding a new column
        • Create a new column from existing ones
        • Get table data as a numpy array
        • Get a table column as a list
        • Get multiple table columns as a list
        • Get the table as a row oriented dict
        • Get the table as a column oriented dict
        • Get the table as a pandas.DataFrame
        • Get a table of counts as a contingency table
        • Appending tables
        • Summing a single column
        • Summing multiple columns or rows - strictly numerical data
        • Summing multiple columns or rows with mixed non-numeric/numeric data
        • Filtering table rows
        • Filtering table columns
        • Standard sorting
        • Reverse sorting
        • Sorting involving multiple columns, one reversed
        • Getting raw data for a single column
        • Getting raw data for multiple columns
        • Getting distinct values
        • Counting occurrences of values
        • Counting unique values
        • Joining or merging tables
        • Transpose a table
        • Specify markdown as the str() format
        • Specify latex as the str() format
        • Get a table as a markdown formatted string
        • Get a table as a latex formatted string
        • Get a table as a restructured text csv-table
        • Get a table as a restructured text grid table
        • Getting a latex format table with to_string()
        • Getting a bedGraph format with to_string()
        • Getting a table as html
        • What formats can be written?
        • Writing a latex formmated file
        • Writing delimited formats
      • Building alignments
        • Using a cogent3 progressive aligner for nucleotides
        • Using a cogent3 progressive aligner for codons
        • Converting gaps from aa-seq alignment to nuc seq alignment
      • Genetic distance calculation
        • Fast pairwise distance estimation
        • Computing genetic distances using the Alignment object
        • Using the distance calculator directly
        • Likelihood based pairwise distance estimation
      • Building phylogenies
        • Building A Phylogenetic Tree From Pairwise Distances
        • Directly via alignment.quick_tree()
          • Using the DistanceMatrix object
          • Explicitly via DistanceMatrix and cogent3.phylo.nj.nj()`
          • Directly from a pairwise distance dict
        • By Least-squares
        • By ML
      • Evolutionary Analysis Using Likelihood
        • Specifying substitution models
          • The available pre-defined substitution models
          • Getting a substitution model with get_model()
          • Rate heterogeneity models
            • For nucleotide
            • For codon
            • For protein
        • Making a likelihood function
          • Providing an alignment to a likelihood function
          • Scoping parameters on trees – time heterogeneous models
          • Specifying a parameter as constant
          • Providing a starting value for a parameter
          • Setting parameter bounds for optimisation
          • Setting an upper bound for branch length
          • Specifying rate heterogeneity functions
          • Specifying Phylo-HMMs
          • Fitting likelihood functions - Choice of optimisers
          • How to check your optimisation was successful
          • Overview of the fitted likelihood function
            • Log likelihood and number of free parameters
            • Aikake Information Criterion
            • Bayesian Information Criterion
            • Getting maximum likelihood estimates
          • Testing Hypotheses - Using Likelihood Ratio Tests
            • Testing Hypotheses - By parametric bootstrapping
          • Determining confidence intervals on MLEs
          • Saving results
          • Reconstructing ancestral sequences
      • Useful Utilities
        • UnionDict – a dict with set like operations and keys as attributes
          • Accessing elements of a UnionDict
          • Updating a UnionDict
          • Accessing a non-existent UnionDict key
        • Using Cogent3’s optimisers for your own functions
        • Miscellaneous functions
          • Force a variable to be iterable
          • Curry a function
          • Test to see if an object is iterable
          • Test to see if an object is a single char
          • Flatten a deeply nested iterable
          • Test to determine if list of tuple
          • Create a case-insensitive iterable
          • Construct a distance matrix lookup function
          • Check class types
          • Delegate to a separate object
          • Wrap a function to hide from a class
          • Construct a constrained container
    • Tutorials
      • Data manipulation
        • Advanced sequence handling
        • Annotating alignments and sequences
        • Map protein alignment gaps to DNA alignment gaps
        • Manipulation of Tree Node Objects
        • An Example of Conditional Tree Node Modifications
      • General data analysis
        • Estimating periodic signals
          • Estimating the periods in a signal
            • For numerical (continuous) data
            • For symbolic data
          • Estimating power for specified period
            • For numerical (continuous) data
            • For symbolic data
          • Measuring statistical significance of periodic signals
            • For numerical (continuous data)
            • For symbolic data
      • Modelling Evolution
        • The simplest script
        • Performing a relative rate test
        • A test of the neutral theory
        • Allowing substitution model parameters to differ between branches
          • Specifying a clade
          • Specifying a stem
          • Specifying clade and stem
          • Alternate arguments for specifying edges
          • Applications of scoped parameters
        • Using codon models
          • Constructing the codon substitution model
          • Standard test of neutrality
          • Rate-heterogeneity model variants
          • Mixing branch and site-heterogeneity
        • Use an empirical protein substitution model
        • Likelihood analysis of multiple loci
        • Simulate an alignment
        • Performing a parametric bootstrap
        • Perform a coevolutionary analysis on biological sequence alignments
        • Analysis of rate heterogeneity
        • Evaluate process heterogeneity using a Hidden Markov Model
          • Model Ho: no rate heterogeneity
          • Model Ha(1): two classes of gamma distributed but independent sites
          • Model Ha(2): fast and slowly evolving sites are auto-correlated
          • A model with patches of kappa
      • Phylogenetic Reconstruction
        • Calculate pairwise distances between sequences
        • Make a neighbor joining tree
        • Make a UPGMA cluster
        • Phylogenetic reconstruction by least squares
          • Look for the single best tree
          • A more rigorous tree space search
          • Assessing the fit for a pre-specified tree topology
          • Using maximum likelihood for measuring tree fit
      • Utilities
        • Parallel computations
          • Parallel computation on a single computer
            • Using app.apply_to()
            • Directly using cogent3.util.parallel.map()
          • Parallel computation on multiple computers
    • API
      • Utility Functions For
        • Loading data from file
          • load_unaligned_seqs
          • load_aligned_seqs
          • load_delimited
          • load_table
          • load_tree
        • Making cogent3 types from standard Python types
          • make_aligned_seqs
          • make_unaligned_seqs
          • make_seq
          • make_table
          • make_tree
        • Getting commonly used cogent3 types
          • get_code
          • get_moltype
        • Displaying cogent3 builtins
          • available_codes
          • available_moltypes
          • available_models
          • available_apps
      • The Major cogent3 Data Types
        • alignment
          • SequenceCollection
          • Alignment
          • ArrayAlignment
        • sequence
          • DnaSequence
          • RnaSequence
          • ProteinSequence
        • genetic_code
          • GeneticCode
        • moltype
          • MolType
        • alphabet
          • Alphabet
        • table
          • Table
          • Columns
          • FilteringParser
        • tree
          • PhyloNode
  • Image Gallery
    • Alignments & Sequences
      • Evaluating coevolution
        • Display coevolution as a heatmap
        • Display coevolution scores as a Violin plot
        • Display coevolution scores as a Boxplot
      • Dotplot
        • Modifying the matching parameters
        • Displaying dotplot for the reverse complement
        • Setting plot attributes
        • All options
      • Dotplot with annotated sequences
        • Reloading from json
        • Removing annotation tracks
      • Counting gaps per sequence
        • Plotting counts of unique gaps
          • Displaying unique gaps as a bar chart
          • Displaying unique gaps as a violin plot
          • Displaying unique gaps as a box plot
      • Information analysis of an alignment
        • Illustrated with a simple example
          • On a sample data set
      • Draw sequence logos
        • Drawing logo for a TFBS
        • Drawing a sequence logo from a multiple sequence alignment
        • Sequence logo of protein alignment
    • Phylogenetic Trees
      • Display a Phylogenetic Tree with a Angular Dendrogram Style
        • With Contemporaneous Tips
      • Display a Phylogenetic Tree with a Circular Dendrogram Style
        • Colouring a set of edges
        • With Contemporaneous Tips
      • Display a Phylogenetic Tree with a Radial Dendrogram Style
        • With Contemporaneous Tips
      • Display a Phylogenetic Tree with a Square Dendrogram Style
        • Changing scale bar placement
        • Colouring a set of edges
        • With Contemporaneous Tips
      • Display a Phylogenetic Tree Showing Bootstrap Support
        • Change the placement of support text
  • Posting Bugs
  • Citation
  • Support
  • Project History
    • cogent3 no longer includes module x, what do I do?
  • Projects using cogent3
  • License
    • Cogent3 License
  • Index

Image Gallery¶

We use Plotly as our backend for visualisation. It provides excellent graph interactivity in Jupyter notebooks.

Alignments & Sequences¶

Evaluating coevolution

Evaluating coevolution¶

Dotplot

Dotplot¶

Dotplot with annotated sequences

Dotplot with annotated sequences¶

Counting gaps per sequence

Counting gaps per sequence¶

Information analysis of an alignment

Information analysis of an alignment¶

Draw sequence logos

Draw sequence logos¶

Phylogenetic Trees¶

Display a Phylogenetic Tree with a Angular Dendrogram Style

Display a Phylogenetic Tree with a Angular Dendrogram Style¶

Display a Phylogenetic Tree with a Circular Dendrogram Style

Display a Phylogenetic Tree with a Circular Dendrogram Style¶

Display a Phylogenetic Tree with a Radial Dendrogram Style

Display a Phylogenetic Tree with a Radial Dendrogram Style¶

Display a Phylogenetic Tree with a Square Dendrogram Style

Display a Phylogenetic Tree with a Square Dendrogram Style¶

Display a Phylogenetic Tree Showing Bootstrap Support

Display a Phylogenetic Tree Showing Bootstrap Support¶

Gallery generated by Sphinx-Gallery

2020-2021, cogent3 Team
Powered by Sphinx 3.5.4 and the Sphinx Docs Theme