Count distinct elements for each level of hierarchy and isotope
Source:R/tidyMS_summarize_hierarchy.R
hierarchy_counts.RdE.g. number of proteins, peptides, precursors in the dataset
Examples
bb <- prolfqua::sim_lfq_data_peptide_config()
#> creating sampleName from file_name column
#> completing cases
#> completing cases done
#> setup done
lfq <- LFQData$new(bb$data, bb$config)
x <- hierarchy_counts(lfq$data_long(), lfq$hierarchy_keys(), lfq$isotope_label())
x$protein_Id
#> [1] 10
stopifnot(ncol(x) == length(lfq$hierarchy_keys()) + 1)
# select non existing protein
data0 <- lfq$data_long() |> dplyr::filter(protein_Id == "XYZ")
tmp <- hierarchy_counts(data0, lfq$hierarchy_keys(), lfq$isotope_label())
stopifnot(nrow(tmp) == 0)