Unnests the hashes (and abundances) list columns of
smash_aggregate()'s result into a long tibble, with one row per sketch
and hash. Every hash is kept in full, as decimal text, so it can be joined
to other tables of hashes: for example, to label the hashes of a strain
(at k = 51) or species (at k = 31) found in reference genomes or
isolates, and then follow them through metagenomes.
Arguments
- data
A data frame from
smash_aggregate().- keep
Columns of
datato carry into the result (besidesample_id,k,scaled,seedandmethod), e.g. subject or date.- min_abundance
Drop hashes seen fewer than this many times, in sketches with abundances. Defaults to 1 (keep all).
Value
A tibble with one row per sketch and hash: sample_id, k,
scaled, seed, method, the keep columns, hash (text) and
abundance (NA for sketches without abundances).
See also
smash_aggregate(), and smash_heatmap() to plot hashes across
samples.
Examples
sketches <- smash_aggregate(smash_example("signatures"),
metadata = smash_example("runs"), k = 51)
hashes <- smash_hashes(sketches, keep = "host_subject_id")
hashes
#> # A tibble: 148,485 × 8
#> sample_id k scaled seed method host_subject_id hash abundance
#> <chr> <dbl> <dbl> <dbl> <chr> <chr> <chr> <dbl>
#> 1 SRR41520862 51 10000 42 abund GOL_019 196397122172 11
#> 2 SRR41520862 51 10000 42 abund GOL_019 334189847742 2
#> 3 SRR41520862 51 10000 42 abund GOL_019 975247846319 2
#> 4 SRR41520862 51 10000 42 abund GOL_019 975620253002 3
#> 5 SRR41520862 51 10000 42 abund GOL_019 1201699242587 14
#> 6 SRR41520862 51 10000 42 abund GOL_019 1293671068588 2
#> 7 SRR41520862 51 10000 42 abund GOL_019 1392706356360 7
#> 8 SRR41520862 51 10000 42 abund GOL_019 1459017142733 2
#> 9 SRR41520862 51 10000 42 abund GOL_019 1506483291264 2
#> 10 SRR41520862 51 10000 42 abund GOL_019 1599676576985 25
#> # ℹ 148,475 more rows
# hashes found in every sample of one subject, and in no other subject
per_subject <- unique(hashes[c("host_subject_id", "sample_id")])
n_samples <- table(per_subject$host_subject_id)
found <- unique(hashes[c("hash", "host_subject_id", "sample_id")])
tab <- table(found$hash, found$host_subject_id)
private <- rownames(tab)[tab[, "GOL_003"] == n_samples["GOL_003"] &
rowSums(tab > 0) == 1]
length(private)
#> [1] 440