This function counts the number of unique features per sample. A grouping structure can be provided to count higher level features from assays, for example counting the number of unique proteins from PSM data.
Arguments
- object
An object of class
QFeatures
.- i
A
numeric()
orcharacter()
vector indicating from which assays therowData
should be taken.- groupBy
A
character(1)
indicating the variable name in therowData
that contains the grouping variable, for instance to count the unique number of peptides or proteins expressed in each samples (column). IfgroupBy
is missing, the number of non zero elements per sample will be stored.- colDataName
A
character(1)
giving the name of the new variable in thecolData
where the number of unique features will be stored. The name cannot already exist in thecolData
.
Examples
data("ft_na")
## Count number of (non-missing) PSMs
ft_na <- countUniqueFeatures(ft_na,
i = "na",
colDataName = "counts")
ft_na$counts
#> [1] 2 3 4
## Count number of unique rowData feature
ft_na <- countUniqueFeatures(ft_na,
i = "na",
groupBy = "Y",
colDataName = "Y_counts")
ft_na$Y_counts
#> [1] 2 2 2