This function calculates overlap for all sample-pairs in a SummarizedExperiment object.

calculateOverlap(
  x,
  assay.type = assay_name,
  assay_name = "counts",
  detection = 0,
  ...
)

# S4 method for SummarizedExperiment
calculateOverlap(
  x,
  assay.type = assay_name,
  assay_name = "counts",
  detection = 0,
  ...
)

runOverlap(x, ...)

# S4 method for SummarizedExperiment
runOverlap(x, name = "overlap", ...)

Arguments

x

a SummarizedExperiment object containing a tree.

assay.type

A single character value for selecting the assay to calculate the overlap.

assay_name

a single character value for specifying which assay to use for calculation. (Please use assay.type instead. At some point assay_name will be disabled.)

detection

A single numeric value for selecting detection threshold for absence/presence of features. Feature that has abundance under threshold in either of samples, will be discarded when evaluating overlap between samples.

...

Optional arguments not used.

name

A single character value specifying the name of overlap matrix that is stored in reducedDim(x).

Value

calculateOverlap returns sample-by-sample distance matrix. runOverlap returns x that includes overlap matrix in its reducedDim.

Details

These function calculates overlap between all the sample-pairs. Overlap reflects similarity between sample-pairs.

When overlap is calculated using relative abundances, the higher the value the higher the similarity is, When using relative abundances, overlap value 1 means that all the abundances of features are equal between two samples, and 0 means that samples have completely different relative abundances.

Author

Leo Lahti and Tuomas Borman. Contact: microbiome.github.io

Examples

data(esophagus)
tse <- esophagus
tse <- transformAssay(tse, method = "relabundance")
overlap <- calculateOverlap(tse, assay_name = "relabundance")
overlap
#>           B         C
#> C 0.8811552          
#> D 0.9038734 0.8390008

# Store result to reducedDim
tse <- runOverlap(tse, assay.type = "relabundance", name = "overlap_between_samples")
head(reducedDims(tse)$overlap_between_samples)
#>           B         C         D
#> B 0.0000000 0.8811552 0.9038734
#> C 0.8811552 0.0000000 0.8390008
#> D 0.9038734 0.8390008 0.0000000