matrix

package
v0.0.0-...-b418612 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2024 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package matrix provides a matrix of taxon specimens and character observations.

Index

Constants

View Source
const NotApplicable = "<na>"

Character states without data.

View Source
const Unknown = "<unknown>"

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field string

Field is used to define additional information fields of an observation.

const (
	Reference Field = "reference"
	ImageLink Field = "image"
	Comments  Field = "comments"
)

Additional observation fields.

type Matrix

type Matrix struct {
	// contains filtered or unexported fields
}

A Matrix is a phylogenetic data matrix, a collection of taxa and their character states.

func New

func New() *Matrix

New creates a new empty matrix.

func (*Matrix) Add

func (m *Matrix) Add(taxon, spec, char, state string)

Add adds a new observation (i.e., a character state) to the matrix for a given taxon specimen, and character.

func (*Matrix) Chars

func (m *Matrix) Chars() []string

Chars returns the characters in the matrix.

func (*Matrix) Obs

func (m *Matrix) Obs(spec, char string) []string

Obs returns the states assigned for character in a specimen.

func (*Matrix) ReadTSV

func (m *Matrix) ReadTSV(r io.Reader) error

ReadTSV reads a set of specimen observations from a TSV file.

The TSV file must contains the following fields:

  • taxon, the taxonomic name of the taxon
  • specimen, the ID of the particular specimen observed
  • character, the name of the observed character
  • state, the observed character state

Additional fields are:

  • reference, an ID of a bibliographic reference
  • image, a path to an image of the observation
  • comments, simple comments about the observation

Here is an example file:

# character observations
taxon	specimen	character	state	reference	image	comments
Ascaphidae	ascaphidae:kluge69	tail muscle	present	kluge1969
Ascaphidae	ascaphidae:kluge69	ribs, fusion	free	kluge1969
Discoglossidae	discoglossidae:kluge69	tail muscle	absent	kluge1969
Discoglossidae	discoglossidae:kluge69	ribs, fusion	free	kluge1969
Pipidae	pipidae:kluge69	tail muscle	absent	kluge1969
Pipidae	pipidae:kluge69	ribs, fusion	fused in adults	kluge1969

func (*Matrix) Set

func (m *Matrix) Set(spec, char, state, val string, field Field)

Set sets the value of an addition information for an observation.

func (*Matrix) Specimens

func (m *Matrix) Specimens() []string

Specimens returns the specimens in the matrix.

func (*Matrix) States

func (m *Matrix) States(char string) []string

States returns the states of a character in the matrix.

func (*Matrix) TSV

func (m *Matrix) TSV(w io.Writer) error

TSV writes an observation matrix as a TSV file.

func (*Matrix) Val

func (m *Matrix) Val(spec, char, state string, field Field) string

Val returns the value of additional fields for an observation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL