# B Cell Receptor Phylogenetics Toolkit

## Documentation for package ‘dowser’ version 2.5.1

- DESCRIPTION file
- User guides, package vignettes and other documentation
- Package NEWS
- Package README

## Help Pages

A B C D E F G I M P R S T W

## -- A --

airrClone | S4 class defining a clone in Dowser
airrClone-class | S4 class defining a clone in Dowser

## -- B --

BiopsyTrees | Example Ig lineage trees with biopsy reconstructions.
bootstrapTrees | Deprecated! Please use findSwitches instead.
buildAllClonalGermlines | buildAllClonalGermlines Determines and builds all possible germlines for a clone
buildBeast | Read in a directory from a BEAST run. Runs treeannotator and loganalyser.
buildClonalGermline | 'buildClonalGermline' Determine consensus clone sequence and create germline for clone
buildGermline | 'buildGermline' reconstruct germline segments from alignment data
buildIgphyml | Wrapper to build IgPhyML trees and infer intermediate nodes
buildPhylo | Wrapper for alakazam::buildPhylipLineage
buildPML | Wrapper for phangorn::optim.pml
buildPratchet | Wrapper for phangorn::pratchet
buildRAxML | Wrapper to build RAxML-ng trees and infer intermediate nodes

## -- C --

calcRF | Finds the Robinson-Fould's cluster distance between phylogenies.
checkDivergence | Compare divergence along a tree in terms of mutations (sum of branches) for each tip and reconstructed internal node to its Hamming distance from the germline. Divergence should never be less than Hamming distance. A threshold of -1 is used to represent 1 full mutation difference. The function will throw a warning if any trees cross this threshold
checkNodeDivergences | For each node in nodes list, check that the current divergence is the same as previously reported
collapseNodes | Collapse internal nodes with the same predicted sequence
colorTrees | Get a color palette for a predefined set of trait values
condenseTrees | Condense a set of equally parsimonious node labels into a single tree
correlationTest | Run date randomization test for temporal signal on a set of trees.
createAllGermlines | createAllGermlines Creates all possible germlines for a clone
createGermlines | createGermlines Determine consensus clone sequence and create germline for clone
create_alignment | Takes an airr clone object and returns BEAST2 Alignment xml of the sequences
create_height_prior | Takes an airr clone object and returns BEAST2 XML to set a height prior
create_max_height_prior | Takes an airr clone object and returns BEAST2 XML to set a maximum height prior
create_MRCA_prior_germline | Takes an airr clone object and returns BEAST2 XML for MRCA prior of the germline sequence
create_MRCA_prior_observed | Takes an airr clone object and returns BEAST2 XML for MRCA prior of the observed sequences
create_root_freqs | Takes an airr clone object and returns BEAST2 rootfreqs xml of the germline
create_starting_tree | Takes an airr clone object and tree and returns BEAST2 XML for setting the starting tree
create_traitset | Takes an airr clone object and returns BEAST2 XML for a trait/traitSet from a column

## -- D --

dfToFasta | Write a fasta file of sequences 'readFasta' reads a fasta file
downsampleClone | 'downsampleClone' Down-sample clone to maximum tip/switch ratio
dowser | The dowser package
dowserObjectEquivalent | 'dowserObjectEquivalent' Experimental. Check if two Dowser objects are equivalent

## -- E --

ExampleAirr | Example AIRR database
ExampleAirrTyCHE | Example AIRR database for TyCHE
ExampleClones | Example Ig lineage trees
ExampleDbChangeo | Example Change-O database
ExampleMixedClones | Example Multiple Partition Trees
ExampleMixedDb | Example Change-O database
exportTrees | Exports the phylogenetic trees from the airrClone object

## -- F --

filterCombs | 'filterCombs' Remove sequences likely resulting from oversequencing and PCR error This removes "comb" structures in trees which are flat polytomies with low duplicate counts radiating out from a single node with a much higher duplicate count. Adapted from https://bitbucket.org/kleinstein/projects/src/master/Hoehn2022/isotype_analysis/treesAndSwitches_dowser.R
filterPartialSeqs | 'filterPartialSeqs'
findSwitches | Create a bootstrap distribution for clone sequence alignments, and estimate trees for each bootstrap replicate.
formatClones | Generate an ordered list of airrClone objects for lineage construction

## -- G --

getAllSeqs | Return all tip and internal node sequences
getBootstraps | Creates a bootstrap distribution for clone sequence alignments, and returns estimated trees for each bootstrap replicate as a nested list as a new input tibble column.
getDiffPoint | Recurse up to tree to find most recent node with different state, or the root
getDiffPoints | For each tree, recurse up to tree to find most recent node with a different state, or the root
getDivergence | Get divergence from root of tree for each tip
getGermline | getGermline get germline segment from specified receptor and segment
getHeightsAndLengths | Add height and length columns to a tree@data data frame
getNodeSeq | Return IMGT gapped sequence of specified tree node
getPalette | Get a color palette for a predefined set of trait values. 'Germline' defaults to black unless specified.
getSeq | Deprecated! Use getNodeSeq
getSeqPath | Return all sequences along the tree from the germline to a specified node
getSkylines | Make data frames for Bayesian skyline plots
getSubclones | #' Deprecated! Use resolveLightChains
getSubTaxa | Get the tip labels as part of a clade defined by an internal node
getTimeTrees | Estimate time trees by running BEAST on each clone Applies XML 'template' to each clone
getTimeTreesIterate | Iteratively resume getTimeTrees until convergence, as defined by all parameters (except those in 'ignore' vector) having ESS greater than or equal to the specified ess_cutoff
getTrees | Estimate lineage tree topologies, branch lengths, and internal node states if desired
getTreesAndUCAs | getTreesAndUCAs Construct trees and infer the UCA

## -- I --

installPythonDependencies | installPythonDependencies Checks for and installs the Python dependencies for UCA estimation
IsotypeTrees | Example Ig lineage trees with isotype reconstructions.

## -- M --

makeAirrClone | Generate a airrClone object for lineage construction
makeModelFile | Make a parsimony model file
makeSkyline | get values for Bayesian Skyline plot
mapSubtrees | Get a map of nodes from one
maskCodons | 'maskCodons' Masks codons split by insertions
maskSequences | 'maskSequences' Mask codons split by insertions in V gene

## -- P --

plotMSA | Simple function for plotting multiple sequence alignments input can be either nucleotide or AA and contain ambiguous characters
plotSkylines | Simple function for plotting Bayesian skyline plots
plotTrees | Plot a tree with colored internal node labels using ggtree

## -- R --

readBEAST | Reads in a BEAST output directory
readFasta | Read a fasta file into a list of sequences 'readFasta' reads a fasta file
readIMGT | 'readIMGT' read in IMGT database
readLineages | Read in all trees from a lineages file
readModelFile | Read in a parsimony model file
readTreesJSON | 'readTreesJSON' Experimental. Read trees from JSON/AIRR format from Dowser
reconIgPhyML | Do IgPhyML maximum parsimony reconstruction
rerootTree | Reroot phylogenetic tree to have its germline sequence at a zero-length branch to a node which is the direct ancestor of the tree's UCA. Assigns 'uca' to be the ancestral node to the tree's germline sequence, as 'germid' as the tree's germline sequence ID.
resolveLightChains | Define subgroups within clones based on light chain rearrangements
resolvePolytomies | Resolve polytomies to have the minimum number of single timepoint clades
runCorrelationTest | Run correlationTest, based on https://doi.org/10.1111/2041-210X.12466

## -- S --

sampleCloneMultiGroup | 'sampleCloneMultiGroup' Down-sample clone to specified size with one or multiple groups to sample evenly
sampleClones | 'sampleClones' Down-sample clones to specified size
scaleBranches | Scale branch lengths to represent either mutations or mutations per site.
setNodeDivergences | For each node in nodes list, store the divergence from the UCA
stitchRegions | stitchRegions Similar to stitchVDJ but with segment IDs instead of nucleotides
stitchVDJ | stitchVDJ combines germline gene segments to a single string
stopCodonCheck | Check whether sequences have in-frame premature stop codons (PTCs)

## -- T --

testPS | Performs PS (parsimony score) test on switch data
testSC | Performs SC (switch count) test on switch data
testSP | Performs SP (switch proportion) test on switch data
TimeTrees | Example Ig lineage trees sampled over time.
treesEquivalent | Check whether two tree objects are equivalent
treesToPDF | Simple function for plotting a lot of trees into a pdf

## -- W --

writeCloneSequences | Write the sequences used in tree building to a fasta format. If there are more than one tree in airrClone output the sequence id will be followed by "|clone_id".
writeFasta | 'writeFasta' Write a fasta file of sequences given a named list of sequences
writeLineageFile | Write lineage file for IgPhyML use
writeTreesJSON | 'writeTreesJSON' Experimental. Write trees in AIRR format
write_clones_to_xmls | Wrapper to write multiple clones to XML files
write_clone_to_xml | Takes an airr clone object and template and writes a BEAST2 XML file