Skip to contents

Returns the genomes detected in one sample as a `gifter_community`, so that [community_traits()], [community_network()] and everything else keep working on a single sample unchanged. Nothing is re-evaluated: the calls are the catalogue's, restricted to the detected genomes.

Usage

sample_community(dataset, sample, detection = 0)

Arguments

dataset

A `gifter_dataset`.

sample

One sample identifier.

detection

Abundance a genome must exceed to be a member of the sample's community. `0` by default, meaning observed at all. A sample in which no genome exceeds it is refused rather than returned empty.

Value

A `gifter_community` of the genomes detected in that sample.

The reference frame does not shrink

The returned community keeps the catalogue's evaluated GIFTs rather than recomputing the union over the detected genomes. For a catalogue whose genomes were evaluated together — the ordinary case — the two are identical. They differ only when genomes were evaluated over different GIFT subsets, and there the recomputed union would give every sample a different `assessable` denominator, which is the sample-level form of the failure the mixed-release refusal in [gifter_community()] exists to prevent. A dataset's reference frame is the catalogue's, and it does not shrink because a sample is small.

Examples

donor <- evaluate_gifts(data.frame(
  gene_id = "g1", namespace = "KO", accession = "K01198"
))
recipient <- evaluate_gifts(data.frame(
  gene_id = "g1", namespace = "KO", accession = "K01805"
))
catalogue <- gifter_community(donor = donor, recipient = recipient)
abundance <- matrix(
  c(0.7, 0.3, 0, 1), nrow = 2,
  dimnames = list(c("donor", "recipient"), c("gut", "soil"))
)
dataset <- gifter_dataset(catalogue, abundance)
sample_community(dataset, "soil")$genome_id
#> [1] "recipient"