# first-distances: Compute first distances or distance from baseline between sequential states¶

#### Docstring:

Usage: qiime longitudinal first-distances [OPTIONS]

Calculates first distances between sequential states for samples collected
from individual subjects sampled repeatedly at two or more states. This
method is similar to the "first differences" method, except that it
requires a distance matrix as input and calculates first differences as
distances between successive states. Outputs a data series of first
distances for each individual subject at each sequential pair of states,
labeled by the SampleID of the second state (e.g., paired distances
between time 0 and time 1 would be labeled by the SampleIDs at time 1).
This file can be used as input to linear mixed effects models or other
longitudinal or diversity methods to compare changes in first distances
across time or among groups of subjects. Also supports distance from
baseline (or other static comparison state) by setting the "baseline"
parameter.

Options:
--i-distance-matrix ARTIFACT PATH DistanceMatrix
Matrix of distances between pairs of
samples.  [required]
Metadata file or artifact viewable as
metadata. This option may be supplied
multiple times to merge metadata. Sample
individual_id_column.  [required]
--p-state-column TEXT           Metadata column containing state (time)
variable information.  [required]
--p-individual-id-column TEXT   Metadata column containing IDs for
individual subjects.  [required]
--p-baseline FLOAT              A value listed in the state_column metadata
column against which all other states should
be compared. Toggles calculation of static
distances instead of first distances (which
are calculated if no value is given for
baseline). If a "baseline" value is
provided, sample distances at each state are
compared against the baseline state, instead
of the previous state. Must be a value
listed in the state_column.  [optional]
--p-replicate-handling [drop|random|error]
Choose how replicate samples are handled. If
replicates are detected, "error" causes
method to fail; "drop" will discard all
replicated samples; "random" chooses one
representative at random from among
replicates.  [default: error]
--o-first-distances ARTIFACT PATH SampleData[FirstDifferences]
Series of first distances.  [required if not
passing --output-dir]
--output-dir DIRECTORY          Output unspecified results to a directory
--cmd-config FILE               Use config file for command options
--verbose                       Display verbose output to stdout and/or
stderr during execution of this action.
[default: False]
--quiet                         Silence output if execution is successful
(silence is golden).  [default: False]
--citations                     Show citations and exit.
--help                          Show this message and exit.

#### Import:

from qiime2.plugins.longitudinal.methods import first_distances


#### Docstring:

Compute first distances or distance from baseline between sequential states

Calculates first distances between sequential states for samples collected
from individual subjects sampled repeatedly at two or more states. This
method is similar to the "first differences" method, except that it
requires a distance matrix as input and calculates first differences as
distances between successive states. Outputs a data series of first
distances for each individual subject at each sequential pair of states,
labeled by the SampleID of the second state (e.g., paired distances between
time 0 and time 1 would be labeled by the SampleIDs at time 1). This file
can be used as input to linear mixed effects models or other longitudinal
or diversity methods to compare changes in first distances across time or
among groups of subjects. Also supports distance from baseline (or other
static comparison state) by setting the "baseline" parameter.

Parameters
----------
distance_matrix : DistanceMatrix
Matrix of distances between pairs of samples.
Sample metadata file containing individual_id_column.
state_column : Str
Metadata column containing state (time) variable information.
individual_id_column : Str
Metadata column containing IDs for individual subjects.
baseline : Float, optional
A value listed in the state_column metadata column against which all
other states should be compared. Toggles calculation of static
distances instead of first distances (which are calculated if no value
is given for baseline). If a "baseline" value is provided, sample
distances at each state are compared against the baseline state,
instead of the previous state. Must be a value listed in the
state_column.
replicate_handling : Str % Choices({'drop', 'error', 'random'}), optional
Choose how replicate samples are handled. If replicates are detected,
"error" causes method to fail; "drop" will discard all replicated
samples; "random" chooses one representative at random from among
replicates.

Returns
-------
first_distances : SampleData[FirstDifferences]
Series of first distances.