Closed antagomir closed 4 months ago
On the same go, these functions might have an argument to pick one element per sample at random, if there are multiple dominant features per sample. Warning should be always thrown.
I noticed that whereas addPerSampleDominantFeature(tse)
returns a list with the length of nrow(tse)
but perSampleDominantFeature(tse)
returns a vector with the length of total occurrences of dominant features, sometimes this is larger than nrow(tse)
(when there are multiple dominant features per sample). It could be useful to have a similar output for both cases (e.g. the full list) and then optional argument to shrink this to a vector with a single random instance chosen per sample, if multiple ones exist.
We frequently need to retrieve top features for analysis and visualization purposes.
Often we like to focus on the most dominant features, and treat the rest (more rare) features in an "Other" category.
This can now be done e.g. as follows:
It would be however very handy for practical wrangling if one could just write:
tse <- addPerSampleDominantFeatures(tse, n=5, name="topfeats2", other_name="Other")
and this would achieve the same. Same comment would apply to the
perSampleDominantFeatures
function.This could throw a warning if the dominant feature per sample is not unique.