Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why the same number cell and celltype in seurat object lead to different averageExpression() result #9584

Open
seekning opened this issue Dec 29, 2024 · 2 comments

Comments

@seekning
Copy link

Idents(scRNA)="combined_celltype_add.malignant.normal",
exp1=AverageExpression(scRNA)

scRNA_subset=subset(scRNA,combined_celltype_add.malignant.normal%in%c("Malignant_cell","Epithelial_cells"))
Idents(scRNA_subset)="combined_celltype_add.malignant.normal"
exp2=AverageExpression(scRNA_subset)

even the number of epithelial and malignant cell in scRNA and scRNA_subset is the same:
3

result of exp1 and exp2 as follow :
1
2
i wonder that why thethe averageexpression result of "Malignant_cell","Epithelial_cells" in exp2 is different from exp1?i know is simple but the reslut is uncredeble,thank you so much

@samuel-marsh
Copy link
Collaborator

Hi,

Not member of dev team but hopefully can be helpful. I think there are a couple of issues here. First, I want to point out that the cell numbers for the classes you are mentioning are not the same between full and subsetted objects in data that you provided (e.g Epithelial goes from 2924 to 1459). So it would be expected that average expression would change. The other issue is in your code provide in screenshot and use of == vs %in% operators. When subsetting by more than one value you need to use %in% and not == in order to properly subset the data. While you have %in% in the text you pasted the screen shot showing code shows you using ==.

If you subset using %in% you should get the same number of cells and the same values. If that doesn't work please report back.

Thanks,
Sam

@seekning
Copy link
Author

seekning commented Jan 5, 2025

happy new year,my friend,sorry that i didn't see this message these days because of my study.thank you so much and i used %in% instead of ==,you are right my bro.
and i try to find out what led to this result ,maybe it was because of after subset process, the number of row in Grouped matrix has reduced, so this will led to the expression of gene become biger.but it still has some problem:

result of exp1 and exp2 as follow :
image
image

i wonder that why the averageexpression result of "Malignant_cell","Epithelial_cells" in exp2 is different from exp1? in the exp1,these two celltype were 0,but after subset process,malignant_cell is bigger ,but epithelial_cell is still 0,shouldn't it become bigger as well?thank you for your opinnion so much.
yours zhaokun in centralsouth university ,hunnan province,china

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants