This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to bin groups of 20 cells based amount of a metadata value

I have a scRNAseq Seurat object that is virus infected cells. I have a metadata label that is a sum of the total viral transcripts in each cell.

Object$total.virus.count

I want to make groups of 20 cells based on the highest expression of viral transcripts. For example, if I were to sort based on total.virus.count, group 1 would be the first 20 cells. Group 2 would be the second 20 cells, etc... I would like to label these groups of 20 as another metadata column ("VirusGroup" = 1,2,3,4,5) so they can be subsetted and analyzed.

I have no idea how to do this but I tried order function and some dplyr calls but I have no been successful.

Any help would be greatly appreciated!

Thanks

data seurat scrna-seq r

1 answer

I solved it thanks!

It would be useful to post the actual solution since it can help a future visitor to this thread. Please consider editing above comment and post the solution.

Log in to answer this question.