align_plot_aa: Plot amino acid alignments

View source: R/align_plot_aa.R

align_plot_aaR Documentation

Plot amino acid alignments

Description

This function takes in an alignment of amino acid sequences in a matrix format and returns a plot of that alignment.

Usage

align_plot_aa(
  alignMat,
  aa_colours = NULL,
  other_colours = NULL,
  gap_colour = NA,
  border_colour = NA,
  pos_vec = NULL,
  show_residues = TRUE,
  residue_size = 3,
  show_legend = FALSE
)

Arguments

alignMat

Matrix: the DNA alignments. Rows are the taxa, columns are the base positions, and cells contain the values. Values should be one of the 20 amino acids in single letter form (e.g., 'A', 'V'), '?', '-'.

aa_colours

Character: named vector of colour values for nucleotides. For example, c('K'='blue', 'D'='red'...). You need a colour assigned to each amino acid. Default is NA, which will produce automated colours based on whether an amino acid is small non-polar, hydrophobic, polar, negatively charged, or positively charged.

other_colours

Character: named vector colour values for '?'. For example, c('?'='black'). Default is NA, which will produce automated colours.

gap_colour

Chracter: named vector colour for gaps. For examples, c('-'='white'). Default is NA, which will produce automated colours.

border_colour

Character: single value, the colour of borders around base positions. Default is NA, no assigned border colour.

pos_vec

Integer: a vector of base positions to plot, subsets alignment. Default is NULL, which will plot all bases.

show_residues

Logical: whether the values of residues should be plotted. Default is TRUE.

residue_size

Numeric: the text size used for amino acid residues. Default is 3.

show_legend

Logical: whether a legend should be plotted. Default is FALSE.

Examples

library(genomalicious)

# Create a link to raw external datasets in genomalicious
genomaliciousExtData <- paste0(find.package('genomalicious'), '/extdata')

# Path to the demo FASTA file
fasta <- paste0(genomaliciousExtData, '/data_COI_aa.fasta')

# Multi sequence alignmnet of demo COI data.
aln <- align_many_genes_aa(fasta, gene.names='COI')

# Plot base positions from 200:210
align_plot_aa(as.matrix(aln$COI$align), pos_vec=200:210)

# Default colours, no text, and borders
align_plot_aa(
   as.matrix(aln$COI$align),
   aa_colours=c(
    # Small non-polar
    'G'='#F8C641','A'='#F8C641','S'='#F8C641','T'='#F8C641',
    # Hydrophobic
    'C'='grey80','V'='grey80','I'='grey80','L'='grey80','P'='grey80','F'='grey80','Y'='grey80','M'='grey80','W'='grey80',
    # Polar
    'N'='#08c7e0','Q'='#08c7e0','H'='#08c7e0',
    # Negatively charged
    'D'='#ce0073','E'='#ce0073',
    # Positively charged
    'K'='#59A3FF','R'='#59A3FF'
    ),
   border_colour='grey20',
   pos_vec=200:210,
   show_residues=FALSE
)


j-a-thia/genomalicious documentation built on Oct. 19, 2024, 7:51 p.m.