% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/manhattan.R
\name{manhattan}
\alias{manhattan}
\title{Compute Manhattan Dissimilarity from a Dense or Sparse Matrix.}
\usage{
manhattan(x, weighted = TRUE, threads = 1)
}
\arguments{
\item{x}{A \link[base]{matrix}, \link[Matrix]{sparseMatrix} or \link[Matrix]{Matrix}.}

\item{weighted}{A boolean value, to use abundances (\code{weighted = TRUE}) or absence/presence (\code{weighted=FALSE}) (default: TRUE).}

\item{threads}{A wholenumber, the number of threads to use in \link[RcppParallel]{setThreadOptions} (default: 1).}
}
\value{
A column x column \link[stats]{dist} object.
}
\description{
Calculates the Manhattan dissimilarity of a Matrix pairwise for each column.
}
\details{
The Manhattan dissimilarity between two samples \eqn{A} and \eqn{B}, each of length \eqn{n}, is defined as:

\eqn{d(A, B) = \sum_{i}^n |A_i - B_i|}

where \eqn{A_i} and \eqn{B_i} are the abundances of the \eqn{i}-th feature in sample \eqn{A} and \eqn{B}, respectively.
When weighted is set to FALSE, counts are replaced by presence/absence data.
}
\examples{
library("OmicFlow")

metadata_file <- system.file("extdata", "metadata.tsv", package = "OmicFlow")
counts_file <- system.file("extdata", "counts.tsv", package = "OmicFlow")
features_file <- system.file("extdata", "features.tsv", package = "OmicFlow")
tree_file <- system.file("extdata", "tree.newick", package = "OmicFlow")

taxa <- metagenomics$new(
    metaData = metadata_file,
    countData = counts_file,
    featureData = features_file,
    treeData = tree_file
)

taxa$feature_subset(Kingdom == "Bacteria")
taxa$scale(method = "tss")

manhattan(taxa$countData)
}
\references{
Deza, M. M., & Deza, E. (2009). Encyclopedia of Distances. Springer Science & Business Media., 313.
}
