/
sample-info.R
43 lines (39 loc) · 1.57 KB
/
sample-info.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#' Fetch the sample statistics for sets of samples in the warehouse
#'
#' NOTE: this function needs the axe. It has been changed to use the
#' assay_sample_info_table, but the way we handle this with the new unhinged
#' assay needs to change.
#'
#' @export
#' @param x A \code{FacileDataSet} object
#' @param samples a data.frame or tbl_sqlite that has dataset and sample_id
#' columns
#' @param semi use \code{semi_join}? I've found this to be slow sometimes in
#' SQLite for some reason
#' @param assay_name parameter added to keep old API same with new "unhinged"
#' FacileDataSets.
#' @return a tbl_df or tbl_sqlite result from the sample_stats table
#' @family API
fetch_sample_statistics.FacileDataSet <- function(x, samples = NULL,
semi = TRUE,
assay_name = default_assay(x),
...) {
warning("`fetch_sample_statistics` will be removed from FacileData API\n,",
"See Issue #2\n",
"https://github.com/denalitherapeutics/FacileData/issues/2",
immediate. = TRUE)
assert_string(assay_name)
stopifnot(assay_name %in% assay_names(x))
ss <- assay_sample_info_tbl(x) |>
filter(assay == assay_name) |>
set_fds(x)
if (is.null(samples)) {
out <- ss
} else {
# TODO: Need to write unit tests here to exercise what we want to do with
# these results when samples are provided
samples <- assert_sample_subset(samples)
out <- join_samples(ss, samples, semi)
}
set_fds(out, x)
}