Retrieve per-analysis translation results from a cohort
Source:R/orthologize-cohort.R
translation_report.RdAfter translate() has translated a Cohort, this returns the
per-analysis TranslationResult objects (including the unmapped features and
mapping statistics) recorded during translation.
Arguments
- cohort
A Cohort produced by
translate().
Value
A named list with from, to, and results (a named list of
TranslationResult objects, one per translated analysis), or NULL if the
cohort has not been translated.
Examples
# A cohort with one gene-level analysis, translated by an in-memory backend.
manifest <- data.frame(
subject_id = "S1", species = "rat", assay = "rna", sample_id = "R1"
)
parsed <- validate_manifest(manifest)
cohort <- cohort_new(
parsed$subject_tbl, parsed$sample_map,
analyses = list(expr = data.frame(gene = c("Tp53", "Myc")))
)
spec <- analysis_spec_new(
name = "expr", assay = "rna", level = "subject",
feature_type = "gene", gene_col = "gene", id_type = "symbol"
)
cohort <- analysis_register(cohort, spec)
to_upper <- function(features, from, to, gene_col, id_type, ...) {
mapped <- features
mapped$ortholog <- toupper(mapped[[gene_col]])
list(mapped = mapped, unmapped = features[0, , drop = FALSE])
}
human <- translate(cohort, to = "human", ortholog_backend = to_upper)
#> ✔ Translated 1 analysis: "expr".
report <- translation_report(human)
report$from
#> [1] "rat"
report$to
#> [1] "human"
translation_stats(report$results$expr)
#> # A tibble: 1 × 8
#> from to backend n_input n_mapped n_unmapped n_multi prop_mapped
#> <chr> <chr> <chr> <int> <int> <int> <int> <dbl>
#> 1 rat human custom 2 2 0 0 1
# NULL for a cohort that has not been translated
translation_report(cohort)
#> NULL