HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
66 stars 30 forks source link

Subset or filter out cells based on UMAP coordinates #380

Closed vmkalbskopf closed 7 months ago

vmkalbskopf commented 7 months ago

Hi there

The UMAP has some small clusters with cells I would like to remove from further analyses, circled in this picture:

clusters_to_remove

Can you point me in the right direction to accomplish this?

SamGG commented 7 months ago

Using the x and ycoordinates of the UMAP, define boxes to exclude those regions. The red region is defined by something like:

in_red = x_umap > 5 & x_umap < 7 & y_umap > 7  & y_umap < 10
in_violet = up_to_you
in_blue = up_to_you
kept = !in_red & !in_violet & !in_blue
# then filter the inital sce object, something like sce_filtered = sce[,kept]

Helena will correct my errors :-) Hope this help.

HelenaLC commented 7 months ago

Agreed, the above should do the job; though I would recommend against filtering based on UMAP coordinates in any case.

SamGG commented 7 months ago

I mainly agree with Helena. Removing these "cells" without understanding what they represent is not scientific, in my opinion. My experience has taught me that it's always useful/important to characterize (even coarsely) what we put in the trash.